Allows setting the event frequency to other than event length (#1349)

This commit is contained in:
Alex van Andel authored and GitHub committed 2021-12-19 12:11:31 +00:00
1 parent 38f762f7b2
commit cbf528c33e
12 files changed
+70 -4

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
schedulingType: true,
minimumBookingNotice: true,
timeZone: true,
slotInterval: true,
users: {
select: {
avatar: true,
+1
View File
@@ -132,6 +132,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
req.body.minimumBookingNotice || req.body.minimumBookingNotice === 0
? parseInt(req.body.minimumBookingNotice, 10)
: undefined,
slotInterval: req.body.slotInterval,
price: req.body.price,
currency: req.body.currency,
};
+50
View File
@@ -275,6 +275,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
periodDaysType: string;
periodDates: { startDate: Date; endDate: Date };
minimumBookingNotice: number;
slotInterval: number | null;
}>({
defaultValues: {
locations: eventType.locations || [],
@@ -512,6 +513,7 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
advancedPayload.periodStartDate = values.periodDates.startDate || undefined;
advancedPayload.periodEndDate = values.periodDates.endDate || undefined;
advancedPayload.minimumBookingNotice = values.minimumBookingNotice;
advancedPayload.slotInterval = values.slotInterval;
// prettier-ignore
advancedPayload.price =
!requirePayment ? undefined :
@@ -849,6 +851,53 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
)}
/>
<div className="items-center block sm:flex">
<div className="mb-4 min-w-48 sm:mb-0">
<label htmlFor="eventName" className="flex text-sm font-medium text-neutral-700">
{t("slot_interval")}
</label>
</div>
<div className="w-full">
<div className="relative mt-1 rounded-sm shadow-sm">
<Controller
name="slotInterval"
control={formMethods.control}
render={() => {
const slotIntervalOptions = [
{
label: t("slot_interval_default"),
value: -1,
},
...[5, 10, 15, 20, 30, 45, 60].map((minutes) => ({
label: minutes + " " + t("minutes"),
value: minutes,
})),
];
return (
<Select
isSearchable={false}
classNamePrefix="react-select"
className="flex-1 block w-full min-w-0 border border-gray-300 rounded-sm react-select-container focus:ring-primary-500 focus:border-primary-500 sm:text-sm"
onChange={(val) => {
formMethods.setValue(
"slotInterval",
val && (val.value || 0) > 0 ? val.value : null
);
}}
defaultValue={
slotIntervalOptions.find(
(option) => option.value === eventType.slotInterval
) || slotIntervalOptions[0]
}
options={slotIntervalOptions}
/>
);
}}
/>
</div>
</div>
</div>
<div className="block sm:flex">
<div className="mb-4 min-w-48 sm:mb-0">
<label
@@ -1324,6 +1373,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
requiresConfirmation: true,
disableGuests: true,
minimumBookingNotice: true,
slotInterval: true,
team: {
select: {
slug: true,
+1
View File
@@ -63,6 +63,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
price: true,
currency: true,
timeZone: true,
slotInterval: true,
},
},
},