Zomars/cal 777 switching off paid mode bug (#1401)
* Adds Form component * Disabling price sets it to 0
This commit is contained in:
		
							parent
							
								
									4cd7a4ce5b
								
							
						
					
					
						commit
						a66610d9c2
					
				
					 1 changed files with 15 additions and 14 deletions
				
			
		|  | @ -46,6 +46,7 @@ import { WorkingHours } from "@lib/types/schedule"; | ||||||
| import { Dialog, DialogContent, DialogTrigger } from "@components/Dialog"; | import { Dialog, DialogContent, DialogTrigger } from "@components/Dialog"; | ||||||
| import Shell from "@components/Shell"; | import Shell from "@components/Shell"; | ||||||
| import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; | import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; | ||||||
|  | import { Form } from "@components/form/fields"; | ||||||
| import CustomInputTypeForm from "@components/pages/eventtypes/CustomInputTypeForm"; | import CustomInputTypeForm from "@components/pages/eventtypes/CustomInputTypeForm"; | ||||||
| import Button from "@components/ui/Button"; | import Button from "@components/ui/Button"; | ||||||
| import { Scheduler } from "@components/ui/Scheduler"; | import { Scheduler } from "@components/ui/Scheduler"; | ||||||
|  | @ -500,8 +501,9 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|         <div className="block mx-auto sm:flex md:max-w-5xl"> |         <div className="block mx-auto sm:flex md:max-w-5xl"> | ||||||
|           <div className="w-full mr-2 sm:w-9/12"> |           <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"> |             <div className="p-4 py-6 -mx-4 bg-white border rounded-sm border-neutral-200 sm:mx-0 sm:px-8"> | ||||||
|               <form |               <Form | ||||||
|                 onSubmit={formMethods.handleSubmit(async (values) => { |                 form={formMethods} | ||||||
|  |                 handleSubmit={async (values) => { | ||||||
|                   const enteredTitle: string = values.title; |                   const enteredTitle: string = values.title; | ||||||
| 
 | 
 | ||||||
|                   const advancedPayload: AdvancedOptions = {}; |                   const advancedPayload: AdvancedOptions = {}; | ||||||
|  | @ -514,12 +516,10 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|                     advancedPayload.periodEndDate = values.periodDates.endDate || undefined; |                     advancedPayload.periodEndDate = values.periodDates.endDate || undefined; | ||||||
|                     advancedPayload.minimumBookingNotice = values.minimumBookingNotice; |                     advancedPayload.minimumBookingNotice = values.minimumBookingNotice; | ||||||
|                     advancedPayload.slotInterval = values.slotInterval; |                     advancedPayload.slotInterval = values.slotInterval; | ||||||
|                     // prettier-ignore
 |                     advancedPayload.price = requirePayment | ||||||
|                     advancedPayload.price = |                       ? Math.round(parseFloat(asStringOrThrow(values.price)) * 100) | ||||||
|                       !requirePayment ? undefined : |                       : 0; | ||||||
|                         values.price ? Math.round(parseFloat(asStringOrThrow(values.price)) * 100) : |                     advancedPayload.currency = currency; | ||||||
|                           /* otherwise */   0; |  | ||||||
|                     advancedPayload.currency = currency; //
 |  | ||||||
|                     advancedPayload.availability = values.scheduler.enteredAvailability || undefined; |                     advancedPayload.availability = values.scheduler.enteredAvailability || undefined; | ||||||
|                     advancedPayload.customInputs = values.customInputs; |                     advancedPayload.customInputs = values.customInputs; | ||||||
|                     advancedPayload.timeZone = values.scheduler.selectedTimezone; |                     advancedPayload.timeZone = values.scheduler.selectedTimezone; | ||||||
|  | @ -544,7 +544,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|                       : {}), |                       : {}), | ||||||
|                   }; |                   }; | ||||||
|                   updateMutation.mutate(payload); |                   updateMutation.mutate(payload); | ||||||
|                 })} |                 }} | ||||||
|                 className="space-y-6"> |                 className="space-y-6"> | ||||||
|                 <div className="space-y-3"> |                 <div className="space-y-3"> | ||||||
|                   <div className="items-center block sm:flex"> |                   <div className="items-center block sm:flex"> | ||||||
|  | @ -1105,7 +1105,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|                   </Button> |                   </Button> | ||||||
|                   <Button type="submit">{t("update")}</Button> |                   <Button type="submit">{t("update")}</Button> | ||||||
|                 </div> |                 </div> | ||||||
|               </form> |               </Form> | ||||||
|             </div> |             </div> | ||||||
|           </div> |           </div> | ||||||
|           <div className="w-full px-2 mt-8 ml-2 sm:w-3/12 sm:mt-0 min-w-[177px] "> |           <div className="w-full px-2 mt-8 ml-2 sm:w-3/12 sm:mt-0 min-w-[177px] "> | ||||||
|  | @ -1176,8 +1176,9 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|                   </div> |                   </div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|               <form |               <Form | ||||||
|                 onSubmit={locationFormMethods.handleSubmit(async (values) => { |                 form={locationFormMethods} | ||||||
|  |                 handleSubmit={async (values) => { | ||||||
|                   const newLocation = values.locationType; |                   const newLocation = values.locationType; | ||||||
| 
 | 
 | ||||||
|                   let details = {}; |                   let details = {}; | ||||||
|  | @ -1200,7 +1201,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|                   } |                   } | ||||||
| 
 | 
 | ||||||
|                   setShowLocationModal(false); |                   setShowLocationModal(false); | ||||||
|                 })}> |                 }}> | ||||||
|                 <Controller |                 <Controller | ||||||
|                   name="locationType" |                   name="locationType" | ||||||
|                   control={locationFormMethods.control} |                   control={locationFormMethods.control} | ||||||
|  | @ -1233,7 +1234,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { | ||||||
|                     {t("cancel")} |                     {t("cancel")} | ||||||
|                   </Button> |                   </Button> | ||||||
|                 </div> |                 </div> | ||||||
|               </form> |               </Form> | ||||||
|             </div> |             </div> | ||||||
|           </DialogContent> |           </DialogContent> | ||||||
|         </Dialog> |         </Dialog> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Omar López
						Omar López