From e7de213c186d1d40b87b569c553b16bff6f4f3c3 Mon Sep 17 00:00:00 2001 From: Dmytro Stanchiev Date: Sat, 16 Aug 2025 11:34:34 -0400 Subject: [PATCH] use button as a file picker --- src/app/page.tsx | 8 ++--- src/components/ics-file-picker.tsx | 58 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/components/ics-file-picker.tsx diff --git a/src/app/page.tsx b/src/app/page.tsx index d406c74..1a1c60b 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -7,6 +7,7 @@ import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from ' import { Input } from '@/components/ui/input' import { Card } from '@/components/ui/card' import { RecurrencePicker } from '@/components/recurrence-picker' +import { IcsFilePicker } from '@/components/ics-file-picker' import { addEvent, deleteEvent, getAllEvents, clearEvents, getDB } from '@/lib/db' import { parseICS, generateICS } from '@/lib/ical' @@ -248,18 +249,13 @@ export default function HomePage() { {/* Control Toolbar */}
+ Import .ics {events.length > 0 && ( <> )} -
{/* Event List */} diff --git a/src/components/ics-file-picker.tsx b/src/components/ics-file-picker.tsx new file mode 100644 index 0000000..f0789f3 --- /dev/null +++ b/src/components/ics-file-picker.tsx @@ -0,0 +1,58 @@ +"use client" + +import type React from "react" + +import { useRef } from "react" +import { Button } from "@/components/ui/button" +import { Calendar } from "lucide-react" + +interface IcsFilePickerProps { + onFileSelect?: (file: File) => void + className?: string + children?: React.ReactNode + variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" + size?: "default" | "sm" | "lg" | "icon" +} + +export function IcsFilePicker({ + onFileSelect, + className, + children, + variant = "default", + size = "default", +}: IcsFilePickerProps) { + const fileInputRef = useRef(null) + + const handleButtonClick = () => { + fileInputRef.current?.click() + } + + const handleFileChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0] + if (file && onFileSelect) { + onFileSelect(file) + } + } + + return ( + <> + + + + ) +} +