fix/update-days-schedule (#1931)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
parent
50c75da5e0
commit
9863178025
1 changed files with 13 additions and 2 deletions
|
@ -178,6 +178,11 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
||||||
const [requirePayment, setRequirePayment] = useState(eventType.price > 0);
|
const [requirePayment, setRequirePayment] = useState(eventType.price > 0);
|
||||||
const [advancedSettingsVisible, setAdvancedSettingsVisible] = useState(false);
|
const [advancedSettingsVisible, setAdvancedSettingsVisible] = useState(false);
|
||||||
|
|
||||||
|
const [availabilityState, setAvailabilityState] = useState<{
|
||||||
|
openingHours: AvailabilityInput[];
|
||||||
|
dateOverrides: AvailabilityInput[];
|
||||||
|
}>({ openingHours: [], dateOverrides: [] });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchTokens = async () => {
|
const fetchTokens = async () => {
|
||||||
// Get a list of most popular ERC20s and ERC777s, combine them into a single list, set as tokensList
|
// 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<typeof getServerSideProps>) => {
|
||||||
form={formMethods}
|
form={formMethods}
|
||||||
handleSubmit={async (values) => {
|
handleSubmit={async (values) => {
|
||||||
const { periodDates, periodCountCalendarDays, smartContractAddress, ...input } = values;
|
const { periodDates, periodCountCalendarDays, smartContractAddress, ...input } = values;
|
||||||
|
|
||||||
updateMutation.mutate({
|
updateMutation.mutate({
|
||||||
...input,
|
...input,
|
||||||
|
availability: availabilityState,
|
||||||
periodStartDate: periodDates.startDate,
|
periodStartDate: periodDates.startDate,
|
||||||
periodEndDate: periodDates.endDate,
|
periodEndDate: periodDates.endDate,
|
||||||
periodCountCalendarDays: periodCountCalendarDays === "1",
|
periodCountCalendarDays: periodCountCalendarDays === "1",
|
||||||
|
@ -1187,10 +1194,14 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
||||||
render={() => (
|
render={() => (
|
||||||
<Scheduler
|
<Scheduler
|
||||||
setAvailability={(val) => {
|
setAvailability={(val) => {
|
||||||
formMethods.setValue("availability", {
|
const schedule = {
|
||||||
openingHours: val.openingHours,
|
openingHours: val.openingHours,
|
||||||
dateOverrides: val.dateOverrides,
|
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) => {
|
setTimeZone={(timeZone) => {
|
||||||
formMethods.setValue("timeZone", timeZone);
|
formMethods.setValue("timeZone", timeZone);
|
||||||
|
|
Loading…
Reference in a new issue