Fixed event-dialog
This commit is contained in:
@@ -73,8 +73,10 @@ const isCalendarEventExternal = (
|
||||
|
||||
export const EventForm: React.FC<{
|
||||
event: ICalendarEvent | Omit<ICalendarEvent, "id">;
|
||||
onSubmit: (data: EventFormValues) => any;
|
||||
}> = ({ event, onSubmit }) => {
|
||||
setForm: React.Dispatch<
|
||||
React.SetStateAction<UseFormReturn<EventFormValues> | undefined>
|
||||
>;
|
||||
}> = ({ event, setForm }) => {
|
||||
const _start = new Date(event.start ?? Date.now());
|
||||
const _end = new Date(event.end ?? Date.now());
|
||||
const form = useForm<EventFormValues>({
|
||||
@@ -91,56 +93,15 @@ export const EventForm: React.FC<{
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setForm(form);
|
||||
}, []);
|
||||
|
||||
const frequency = form.watch("frequency");
|
||||
|
||||
// async function onSubmit(data: EventFormValues) {
|
||||
// try {
|
||||
// const validatedData = eventFormSchema.parse(data);
|
||||
// onSubmitEvent(validatedData);
|
||||
// } catch (error) {
|
||||
// console.error("On submit error : ", error);
|
||||
// }
|
||||
// }
|
||||
|
||||
// useEffect(() => {
|
||||
// try {
|
||||
// const validatedData = eventFormSchema.parse(form);
|
||||
// setEvent((old) => {
|
||||
// const rrule = mapFrequencyToRrule(
|
||||
// validatedData.frequency,
|
||||
// validatedData.frequencyEndDate,
|
||||
// );
|
||||
// const [sHours, sMinutes] = validatedData.startTime.split(":");
|
||||
// validatedData.startDate.setHours(
|
||||
// parseInt(sHours),
|
||||
// parseInt(sMinutes),
|
||||
// );
|
||||
// const [eHours, eMinutes] = validatedData.endTime.split(":");
|
||||
// validatedData.endDate.setHours(
|
||||
// parseInt(eHours),
|
||||
// parseInt(eMinutes),
|
||||
// );
|
||||
// return {
|
||||
// ...old,
|
||||
// start: validatedData.startDate.toISOString(),
|
||||
// end: validatedData.endDate.toISOString(),
|
||||
// title: `${validatedData.title}`,
|
||||
// fullDay: validatedData.fullDay,
|
||||
// rrule: rrule,
|
||||
// isVisible: validatedData.isVisible,
|
||||
// };
|
||||
// });
|
||||
// } catch (e) {
|
||||
// console.log(e);
|
||||
// }
|
||||
// }, [form]);
|
||||
|
||||
return (
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="w-full max-w-md space-y-4"
|
||||
>
|
||||
<form className="w-full max-w-md space-y-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="title"
|
||||
|
||||
Reference in New Issue
Block a user