Skip to content

Commit

Permalink
Zomars/cal 777 switching off paid mode bug (#1401)
Browse files Browse the repository at this point in the history
* Adds Form component

* Disabling price sets it to 0
  • Loading branch information
zomars committed Jan 3, 2022
1 parent 4cd7a4c commit a66610d
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions pages/event-types/[type].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { WorkingHours } from "@lib/types/schedule";
import { Dialog, DialogContent, DialogTrigger } from "@components/Dialog";
import Shell from "@components/Shell";
import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent";
import { Form } from "@components/form/fields";
import CustomInputTypeForm from "@components/pages/eventtypes/CustomInputTypeForm";
import Button from "@components/ui/Button";
import { Scheduler } from "@components/ui/Scheduler";
Expand Down Expand Up @@ -500,8 +501,9 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
<div className="block mx-auto sm:flex md:max-w-5xl">
<div className="w-full mr-2 sm:w-9/12">
<div className="p-4 py-6 -mx-4 bg-white border rounded-sm border-neutral-200 sm:mx-0 sm:px-8">
<form
onSubmit={formMethods.handleSubmit(async (values) => {
<Form
form={formMethods}
handleSubmit={async (values) => {
const enteredTitle: string = values.title;

const advancedPayload: AdvancedOptions = {};
Expand All @@ -514,12 +516,10 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
advancedPayload.periodEndDate = values.periodDates.endDate || undefined;
advancedPayload.minimumBookingNotice = values.minimumBookingNotice;
advancedPayload.slotInterval = values.slotInterval;
// prettier-ignore
advancedPayload.price =
!requirePayment ? undefined :
values.price ? Math.round(parseFloat(asStringOrThrow(values.price)) * 100) :
/* otherwise */ 0;
advancedPayload.currency = currency; //
advancedPayload.price = requirePayment
? Math.round(parseFloat(asStringOrThrow(values.price)) * 100)
: 0;
advancedPayload.currency = currency;
advancedPayload.availability = values.scheduler.enteredAvailability || undefined;
advancedPayload.customInputs = values.customInputs;
advancedPayload.timeZone = values.scheduler.selectedTimezone;
Expand All @@ -544,7 +544,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
: {}),
};
updateMutation.mutate(payload);
})}
}}
className="space-y-6">
<div className="space-y-3">
<div className="items-center block sm:flex">
Expand Down Expand Up @@ -1105,7 +1105,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
</Button>
<Button type="submit">{t("update")}</Button>
</div>
</form>
</Form>
</div>
</div>
<div className="w-full px-2 mt-8 ml-2 sm:w-3/12 sm:mt-0 min-w-[177px] ">
Expand Down Expand Up @@ -1176,8 +1176,9 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
</div>
</div>
</div>
<form
onSubmit={locationFormMethods.handleSubmit(async (values) => {
<Form
form={locationFormMethods}
handleSubmit={async (values) => {
const newLocation = values.locationType;

let details = {};
Expand All @@ -1200,7 +1201,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
}

setShowLocationModal(false);
})}>
}}>
<Controller
name="locationType"
control={locationFormMethods.control}
Expand Down Expand Up @@ -1233,7 +1234,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
{t("cancel")}
</Button>
</div>
</form>
</Form>
</div>
</DialogContent>
</Dialog>
Expand Down

1 comment on commit a66610d

@vercel
Copy link

@vercel vercel bot commented on a66610d Jan 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.