Allow less than 6 bookings and add proper min validation of 2+ (#2921)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/2746/head^2
Hariom Balhara 2022-05-30 21:16:05 +05:30 committed by GitHub
parent e493b16466
commit b22c562719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 18 deletions

View File

@ -324,8 +324,8 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
); );
const [tokensList, setTokensList] = useState<Array<Token>>([]); const [tokensList, setTokensList] = useState<Array<Token>>([]);
const defaultSeats = 2; const defaultSeatsPro = 6;
const defaultSeatsInput = 6; const minSeats = 2;
const [enableSeats, setEnableSeats] = useState(!!eventType.seatsPerTimeSlot); const [enableSeats, setEnableSeats] = useState(!!eventType.seatsPerTimeSlot);
const periodType = const periodType =
@ -1672,7 +1672,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
if (e?.target.checked) { if (e?.target.checked) {
setEnableSeats(true); setEnableSeats(true);
// Want to disable individuals from taking multiple seats // Want to disable individuals from taking multiple seats
formMethods.setValue("seatsPerTimeSlot", defaultSeats); formMethods.setValue("seatsPerTimeSlot", defaultSeatsPro);
formMethods.setValue("disableGuests", true); formMethods.setValue("disableGuests", true);
formMethods.setValue("requiresConfirmation", false); formMethods.setValue("requiresConfirmation", false);
} else { } else {
@ -1731,13 +1731,13 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
<input <input
type="number" type="number"
className="focus:border-primary-500 focus:ring-primary-500 py- block w-20 rounded-sm border-gray-300 [appearance:textfield] ltr:mr-2 rtl:ml-2 sm:text-sm" className="focus:border-primary-500 focus:ring-primary-500 py- block w-20 rounded-sm border-gray-300 [appearance:textfield] ltr:mr-2 rtl:ml-2 sm:text-sm"
placeholder={`${defaultSeatsInput}`} placeholder={`${defaultSeatsPro}`}
min={minSeats}
{...formMethods.register("seatsPerTimeSlot", { {...formMethods.register("seatsPerTimeSlot", {
valueAsNumber: true, valueAsNumber: true,
min: defaultSeatsInput,
})} })}
defaultValue={ defaultValue={
eventType.seatsPerTimeSlot || defaultSeatsInput eventType.seatsPerTimeSlot || defaultSeatsPro
} }
/> />
</div> </div>
@ -1757,22 +1757,14 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
return; return;
} }
if (val.value === -1) { if (val.value === -1) {
formMethods.setValue( formMethods.setValue("seatsPerTimeSlot", minSeats);
"seatsPerTimeSlot",
defaultSeatsInput
);
} else { } else {
formMethods.setValue( formMethods.setValue("seatsPerTimeSlot", val.value);
"seatsPerTimeSlot",
val!.value
);
} }
}} }}
defaultValue={{ defaultValue={{
value: eventType.seatsPerTimeSlot || defaultSeats, value: eventType.seatsPerTimeSlot || minSeats,
label: `${ label: `${eventType.seatsPerTimeSlot || minSeats}`,
eventType.seatsPerTimeSlot || defaultSeats
}`,
}} }}
options={selectSeatsPerTimeSlotOptions} options={selectSeatsPerTimeSlotOptions}
/> />