From 9863178025d9ec63d0202f989a58c953c97f5888 Mon Sep 17 00:00:00 2001 From: alannnc Date: Mon, 21 Feb 2022 12:08:36 -0700 Subject: [PATCH] fix/update-days-schedule (#1931) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Omar López --- apps/web/pages/event-types/[type].tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsx index 42676c17..3fb8c88e 100644 --- a/apps/web/pages/event-types/[type].tsx +++ b/apps/web/pages/event-types/[type].tsx @@ -178,6 +178,11 @@ const EventTypePage = (props: inferSSRProps) => { const [requirePayment, setRequirePayment] = useState(eventType.price > 0); const [advancedSettingsVisible, setAdvancedSettingsVisible] = useState(false); + const [availabilityState, setAvailabilityState] = useState<{ + openingHours: AvailabilityInput[]; + dateOverrides: AvailabilityInput[]; + }>({ openingHours: [], dateOverrides: [] }); + useEffect(() => { const fetchTokens = async () => { // Get a list of most popular ERC20s and ERC777s, combine them into a single list, set as tokensList @@ -671,8 +676,10 @@ const EventTypePage = (props: inferSSRProps) => { form={formMethods} handleSubmit={async (values) => { const { periodDates, periodCountCalendarDays, smartContractAddress, ...input } = values; + updateMutation.mutate({ ...input, + availability: availabilityState, periodStartDate: periodDates.startDate, periodEndDate: periodDates.endDate, periodCountCalendarDays: periodCountCalendarDays === "1", @@ -1187,10 +1194,14 @@ const EventTypePage = (props: inferSSRProps) => { render={() => ( { - formMethods.setValue("availability", { + const schedule = { openingHours: val.openingHours, dateOverrides: val.dateOverrides, - }); + }; + // Updating internal state that would be sent on mutation + setAvailabilityState(schedule); + // Updating form values displayed, but this one doesn't reach form submit scope + formMethods.setValue("availability", schedule); }} setTimeZone={(timeZone) => { formMethods.setValue("timeZone", timeZone);