const { data, isLoading } = useQuery<AddEventFormData>(
["eventDetails"],
() => getEventBySlug(id),
{
enabled: id.length > 0,
}
);
const eventDetailsToEdit = useMemo(() => {
if (isLoading) {
return {};
}
return {
name: data?.name,
tags: data?.tags,
timezone: data?.timezone,
description: data?.description,
locationType: data?.location.location_type,
sections: [],
category: null,
mainImage: undefined,
additionalImages: [],
path: "",
startTime: undefined,
endTime: undefined,
maxTicketsPerOrder: 0,
};
}, [data, isLoading]);
const methods = useForm<AddEventFormData>({
resolver: zodResolver(eventSchema),
// mode: "onChange",
defaultValues: {
name: "",
sections: [],
tags: [],
timezone: null,
description: "",
category: null,
mainImage: undefined,
additionalImages: [],
locationType: "live",
currency: "",
path: "",
startTime: undefined,
endTime: undefined,
maxTicketsPerOrder: 0,
...eventDetailsToEdit,
},
});
const { data, isLoading } = useQuery<AddEventFormData>(
["eventDetails"],
() => getEventBySlug(id),
{
enabled: id.length > 0,
}
);
const eventDetailsToEdit = useMemo(() => {
if (isLoading) {
return {};
}
return {
name: data?.name,
tags: data?.tags,
timezone: data?.timezone,
description: data?.description,
locationType: data?.location.location_type,
sections: [],
category: null,
mainImage: undefined,
additionalImages: [],
path: "",
startTime: undefined,
endTime: undefined,
maxTicketsPerOrder: 0,
};
}, [data, isLoading]);
const methods = useForm<AddEventFormData>({
resolver: zodResolver(eventSchema),
// mode: "onChange",
defaultValues: {
name: "",
sections: [],
tags: [],
timezone: null,
description: "",
category: null,
mainImage: undefined,
additionalImages: [],
locationType: "live",
currency: "",
path: "",
startTime: undefined,
endTime: undefined,
maxTicketsPerOrder: 0,
...eventDetailsToEdit,
},
});