feat: add option to hide duration selector in booking page for multiple durations (#27033)
* feat: add option to hide duration selector in booking page for multiple durations - Add 'hideDurationSelectorInBookingPage' field to event type metadata schema - Add checkbox under Default Duration select in event type settings - Modify Duration component to hide selector when setting is enabled - URL params can still set duration when selector is hidden - Add i18n translation for the new checkbox label - Add e2e tests for the new functionality Co-Authored-By: [email protected] <[email protected]> * fix: rename checkbox label to 'Hide duration selector' Co-Authored-By: [email protected] <[email protected]> * fix: replace text locator with data-testid in E2E test Replace `text=Multiple duration` locator with `page.getByTestId("event-types").locator('a[title="Multiple duration"]')` to follow E2E test best practices. Co-Authored-By: unknown <> * fix: add data-testid to hide duration selector checkbox for E2E tests Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]>
This commit is contained in:
5 files changed
+145
-1
No files matched your search
@@ -93,6 +93,13 @@ export const EventDuration = ({
|
||||
return <>{getDurationFormatted(event.length, t)}</>;
|
||||
|
||||
const durations = event?.metadata?.multipleDuration || [15, 30, 60, 90];
|
||||
const hideDurationSelector = event?.metadata?.hideDurationSelectorInBookingPage;
|
||||
|
||||
// When duration selector is hidden, show only the selected/default duration as text
|
||||
// URL params can still set the duration, but the user cannot change it via UI
|
||||
if (hideDurationSelector) {
|
||||
return <>{getDurationFormatted(selectedDuration || event.length, t)}</>;
|
||||
}
|
||||
|
||||
return selectedDuration ? (
|
||||
<div className="border-default relative mr-5 flex flex-row items-center justify-between rounded-md border">
|
||||
|
||||
@@ -15,7 +15,7 @@ import { slugify } from "@calcom/lib/slugify";
|
||||
import turndown from "@calcom/lib/turndownService";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Editor } from "@calcom/ui/components/editor";
|
||||
import { Label, Select, SettingsToggle, TextAreaField, TextField } from "@calcom/ui/components/form";
|
||||
import { CheckboxField, Label, Select, SettingsToggle, TextAreaField, TextField } from "@calcom/ui/components/form";
|
||||
import { Skeleton } from "@calcom/ui/components/skeleton";
|
||||
import Locations from "@calcom/web/modules/event-types/components/locations/Locations";
|
||||
import { useState } from "react";
|
||||
@@ -276,6 +276,21 @@ export const EventSetupTab = (
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<Controller
|
||||
name="metadata.hideDurationSelectorInBookingPage"
|
||||
control={formMethods.control}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
<CheckboxField
|
||||
data-testid="hide-duration-selector-checkbox"
|
||||
checked={value ?? false}
|
||||
onChange={(e) => onChange(e.target.checked)}
|
||||
description={t("hide_duration_selector_in_booking_page")}
|
||||
disabled={lengthLockedProps.disabled}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<TextField
|
||||
|
||||
Reference in new issue
Block a user