Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 120 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"date-fns": "^3.6.0",
"dotenv": "^16.4.7",
"embla-carousel-react": "^8.3.0",
"groq-sdk": "^1.1.1",
"input-otp": "^1.2.4",
"lucide-react": "^0.469.0",
"next-themes": "^0.3.0",
Expand All @@ -64,6 +65,7 @@
"sonner": "^1.7.1",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
"tesseract.js": "^7.0.0",
"vaul": "^0.9.3",
"zod": "^3.23.8"
},
Expand Down
32 changes: 22 additions & 10 deletions src/components/AddEventDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface AddEventDialogProps {
onOpenChange: (open: boolean) => void;
onSubmit: (event: Omit<Event, "id">) => void;
selectedDate: Date | undefined;
initialData?: Partial<Event>;
}

const CATEGORIES = [
Expand All @@ -23,7 +24,7 @@ const CATEGORIES = [
{ value: "social", label: "Social" },
];

const AddEventDialog = ({ open, onOpenChange, onSubmit, selectedDate }: AddEventDialogProps) => {
const AddEventDialog = ({ open, onOpenChange, onSubmit, selectedDate, initialData }: AddEventDialogProps) => {
const [title, setTitle] = useState("");
const [date, setDate] = useState("");
const [time, setTime] = useState("");
Expand All @@ -32,16 +33,27 @@ const AddEventDialog = ({ open, onOpenChange, onSubmit, selectedDate }: AddEvent
const [recurrence, setRecurrence] = useState("none");

useEffect(() => {
if (selectedDate) {
const localDate = new Date(
selectedDate.getFullYear(),
selectedDate.getMonth(),
selectedDate.getDate()
);
const formattedDate = localDate.toLocaleDateString('en-CA');
setDate(formattedDate);
if (open) {
setTitle(initialData?.title || "");
setTime(initialData?.time || "");
setDescription(initialData?.description || "");
setCategory(initialData?.category || "");
setRecurrence(initialData?.recurrence || "none");

if (initialData?.date) {
setDate(initialData.date);
} else if (selectedDate) {
const localDate = new Date(
selectedDate.getFullYear(),
selectedDate.getMonth(),
selectedDate.getDate()
);
setDate(localDate.toLocaleDateString('en-CA'));
} else {
setDate("");
}
}
}, [selectedDate]);
}, [open, initialData, selectedDate]);

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
Expand Down
Loading
Loading