Scheduling infrastructure for absolutely everyone.
fix: remove alert and disable toggle (#7542)
Udit Takkar48c8b749ceed
diff --git a/apps/web/components/eventtype/RequiresConfirmationController.tsx b/apps/web/components/eventtype/RequiresConfirmationController.tsxindex bc628b9be0a..f2e78a7e1de 100644--- a/apps/web/components/eventtype/RequiresConfirmationController.tsx+++ b/apps/web/components/eventtype/RequiresConfirmationController.tsx@@ -9,7 +9,7 @@ import type z from "zod";import { useLocale } from "@calcom/lib/hooks/useLocale";import type { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";-import { Alert, Input, Label, SettingsToggle } from "@calcom/ui";+import { Input, Label, SettingsToggle } from "@calcom/ui";type RequiresConfirmationControllerProps = {metadata: z.infer<typeof EventTypeMetaDataSchema>;@@ -39,118 +39,116 @@ export default function RequiresConfirmationController({return (<div className="block items-start sm:flex">- <div className={!seatsEnabled ? "w-full" : ""}>- {seatsEnabled ? (- <Alert severity="warning" title="Seats option doesn't support confirmation requirement" />- ) : (- <Controller- name="requiresConfirmation"- control={formMethods.control}- render={() => (- <SettingsToggle- title={t("requires_confirmation")}- description={t("requires_confirmation_description")}- checked={requiresConfirmation}- onCheckedChange={(val) => {- formMethods.setValue("requiresConfirmation", val);- onRequiresConfirmation(val);- }}>- <RadioGroup.Root- defaultValue={- requiresConfirmation- ? requiresConfirmationSetup === undefined- ? "always"- : "notice"- : undefined+ <div className="w-full">+ <Controller+ name="requiresConfirmation"+ control={formMethods.control}+ render={() => (+ <SettingsToggle+ title={t("requires_confirmation")}+ disabled={seatsEnabled}+ tooltip={seatsEnabled ? t("seat_options_doesnt_support_confirmation") : undefined}+ description={t("requires_confirmation_description")}+ checked={requiresConfirmation}+ onCheckedChange={(val) => {+ formMethods.setValue("requiresConfirmation", val);+ onRequiresConfirmation(val);+ }}>+ <RadioGroup.Root+ defaultValue={+ requiresConfirmation+ ? requiresConfirmationSetup === undefined+ ? "always"+ : "notice"+ : undefined+ }+ onValueChange={(val) => {+ if (val === "always") {+ formMethods.setValue("requiresConfirmation", true);+ onRequiresConfirmation(true);+ formMethods.setValue("metadata.requiresConfirmationThreshold", undefined);+ setRequiresConfirmationSetup(undefined);+ } else if (val === "notice") {+ formMethods.setValue("requiresConfirmation", true);+ onRequiresConfirmation(true);+ formMethods.setValue(+ "metadata.requiresConfirmationThreshold",+ requiresConfirmationSetup || defaultRequiresConfirmationSetup+ );}- onValueChange={(val) => {- if (val === "always") {- formMethods.setValue("requiresConfirmation", true);- onRequiresConfirmation(true);- formMethods.setValue("metadata.requiresConfirmationThreshold", undefined);- setRequiresConfirmationSetup(undefined);- } else if (val === "notice") {- formMethods.setValue("requiresConfirmation", true);- onRequiresConfirmation(true);- formMethods.setValue(- "metadata.requiresConfirmationThreshold",- requiresConfirmationSetup || defaultRequiresConfirmationSetup- );- }- }}>- <div className="-ml-2 flex flex-col flex-wrap justify-start gap-y-2 space-y-2">- <div className="flex items-center">- <RadioGroup.Item- id="always"- value="always"- className="min-w-4 flex h-4 w-4 cursor-pointer items-center rounded-full border border-black bg-white focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2">- <RadioGroup.Indicator className="relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full after:bg-black" />- </RadioGroup.Item>- <Label htmlFor="always" className="!m-0 flex items-center">- {t("always_requires_confirmation")}- </Label>- </div>- <div className="flex items-center">- <RadioGroup.Item- id="notice"- value="notice"- className="min-w-4 flex h-4 w-4 cursor-pointer items-center rounded-full border border-black bg-white focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2">- <RadioGroup.Indicator className="relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full after:bg-black" />- </RadioGroup.Item>- <Label htmlFor="notice" className="!m-0 flex items-center">- <Trans- i18nKey="when_booked_with_less_than_notice"- defaults="When booked with less than <time></time> notice"- components={{- time: (- <div className="mx-2 flex">- <Input- type="number"- min={1}- onChange={(evt) => {- const val = Number(evt.target?.value);- setRequiresConfirmationSetup({- unit:- requiresConfirmationSetup?.unit ??- defaultRequiresConfirmationSetup.unit,- time: val,- });- formMethods.setValue("metadata.requiresConfirmationThreshold.time", val);- }}- className="!m-0 block w-16 rounded-md border-gray-300 text-sm [appearance:textfield]"- defaultValue={metadata?.requiresConfirmationThreshold?.time || 30}- />- <select- onChange={(evt) => {- const val = evt.target.value as UnitTypeLongPlural;- setRequiresConfirmationSetup({- time:- requiresConfirmationSetup?.time ??- defaultRequiresConfirmationSetup.time,- unit: val,- });- formMethods.setValue("metadata.requiresConfirmationThreshold.unit", val);- }}- className="ml-2 block h-9 rounded-md border-gray-300 py-2 pl-3 pr-10 text-sm focus:outline-none"- defaultValue={- metadata?.requiresConfirmationThreshold?.unit ||- defaultRequiresConfirmationSetup.unit- }>- <option value="minutes">{t("minute_timeUnit")}</option>- <option value="hours">{t("hour_timeUnit")}</option>- </select>- </div>- ),- }}- />- </Label>- </div>+ }}>+ <div className="-ml-2 flex flex-col flex-wrap justify-start gap-y-2 space-y-2">+ <div className="flex items-center">+ <RadioGroup.Item+ id="always"+ value="always"+ className="min-w-4 flex h-4 w-4 cursor-pointer items-center rounded-full border border-black bg-white focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2">+ <RadioGroup.Indicator className="relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full after:bg-black" />+ </RadioGroup.Item>+ <Label htmlFor="always" className="!m-0 flex items-center">+ {t("always_requires_confirmation")}+ </Label>+ </div>+ <div className="flex items-center">+ <RadioGroup.Item+ id="notice"+ value="notice"+ className="min-w-4 flex h-4 w-4 cursor-pointer items-center rounded-full border border-black bg-white focus:border-2 focus:outline-none ltr:mr-2 rtl:ml-2">+ <RadioGroup.Indicator className="relative flex h-4 w-4 items-center justify-center after:block after:h-2 after:w-2 after:rounded-full after:bg-black" />+ </RadioGroup.Item>+ <Label htmlFor="notice" className="!m-0 flex items-center">+ <Trans+ i18nKey="when_booked_with_less_than_notice"+ defaults="When booked with less than <time></time> notice"+ components={{+ time: (+ <div className="mx-2 flex">+ <Input+ type="number"+ min={1}+ onChange={(evt) => {+ const val = Number(evt.target?.value);+ setRequiresConfirmationSetup({+ unit:+ requiresConfirmationSetup?.unit ??+ defaultRequiresConfirmationSetup.unit,+ time: val,+ });+ formMethods.setValue("metadata.requiresConfirmationThreshold.time", val);+ }}+ className="!m-0 block w-16 rounded-md border-gray-300 text-sm [appearance:textfield]"+ defaultValue={metadata?.requiresConfirmationThreshold?.time || 30}+ />+ <select+ onChange={(evt) => {+ const val = evt.target.value as UnitTypeLongPlural;+ setRequiresConfirmationSetup({+ time:+ requiresConfirmationSetup?.time ??+ defaultRequiresConfirmationSetup.time,+ unit: val,+ });+ formMethods.setValue("metadata.requiresConfirmationThreshold.unit", val);+ }}+ className="ml-2 block h-9 rounded-md border-gray-300 py-2 pl-3 pr-10 text-sm focus:outline-none"+ defaultValue={+ metadata?.requiresConfirmationThreshold?.unit ||+ defaultRequiresConfirmationSetup.unit+ }>+ <option value="minutes">{t("minute_timeUnit")}</option>+ <option value="hours">{t("hour_timeUnit")}</option>+ </select>+ </div>+ ),+ }}+ />+ </Label></div>- </RadioGroup.Root>- </SettingsToggle>- )}- />- )}+ </div>+ </RadioGroup.Root>+ </SettingsToggle>+ )}+ /></div></div>);diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.jsonindex ff4ffc8a34d..bb7503ac047 100644--- a/apps/web/public/static/locales/en/common.json+++ b/apps/web/public/static/locales/en/common.json@@ -110,6 +110,7 @@"hidden_team_owner_message": "You need a pro account to use teams, you are hidden until you upgrade.","link_expires": "p.s. It expires in {{expiresIn}} hours.","upgrade_to_per_seat": "Upgrade to Per-Seat",+ "seat_options_doesnt_support_confirmation":"Seats option doesn't support confirmation requirement","team_upgrade_seats_details": "Of the {{memberCount}} members in your team, {{unpaidCount}} seat(s) are unpaid. At ${{seatPrice}}/month per seat the estimated total cost of your membership is ${{totalCost}}/month.","team_upgrade_banner_description": "Thank you for trialing our new team plan. We noticed your team \"{{teamName}}\" needs to be upgraded.","team_upgrade_banner_action": "Upgrade here",diff --git a/packages/ui/components/form/switch/SettingsToggle.tsx b/packages/ui/components/form/switch/SettingsToggle.tsxindex a18fce67bfd..d4474a412f3 100644--- a/packages/ui/components/form/switch/SettingsToggle.tsx+++ b/packages/ui/components/form/switch/SettingsToggle.tsx@@ -12,6 +12,7 @@ type Props = {disabled?: boolean;onCheckedChange?: (checked: boolean) => void;"data-testid"?: string;+ tooltip?: string;};function SettingsToggle({@@ -21,6 +22,7 @@ function SettingsToggle({title,children,disabled,+ tooltip,...rest}: Props) {const [animateRef] = useAutoAnimate<HTMLDivElement>();@@ -36,9 +38,10 @@ function SettingsToggle({checked={checked}onCheckedChange={onCheckedChange}disabled={disabled}+ tooltip={tooltip}/>- <div className="">+ <div><Label className="text-sm font-semibold leading-none text-black">{title}</Label>{description && <p className="-mt-1.5 text-sm leading-normal text-gray-600">{description}</p>}</div>