Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Default polls to time-based options with a duration picker (#2466)
Luke Vella4cd6c4b19b15
diff --git a/apps/docs/workflow/create.mdx b/apps/docs/workflow/create.mdxindex 1b548cd6c..ef55b986f 100644--- a/apps/docs/workflow/create.mdx+++ b/apps/docs/workflow/create.mdx@@ -21,7 +21,7 @@ on [New Poll](https://app.rallly.co/new).Use the calendar to choose different options for your participants to vote on.<Tabs><Tab title="Month View">- <Frame caption="Use Month View to select dates or create repeating time slots">+ <Frame caption="Use Month View to select dates and set a duration for each option"><img src="/images/workflow/month-view.png" alt="Month View"/></Frame></Tab>@@ -31,6 +31,8 @@ on [New Poll](https://app.rallly.co/new).</Frame></Tab></Tabs>+ **Duration** - Each option defaults to a 1 hour time slot. Use the duration picker above the calendar to change the length (30m, 1h, 1h 30m or 2h), or choose **All day** for participants to vote on whole days without specific times.+**Automatic Time Zone Conversion** - Times are automatically converted to the participant's time zone. This is useful for remote meetings where participants can be in different locations.*If you want to make sure everyone sees the same times regardless of their location, you can disable this feature.*diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex 683829198..bf582e4d0 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -386,6 +386,7 @@"membersSettingsDescription": "Manage space members, invite new users, and control access permissions.","microsoft365": "Microsoft 365","minutesAbbreviation": "min",+ "mixedDurations": "Mixed","mixedOptionsDescription": "You can't have both time and date options in the same poll. Which would you like to keep?","mixedOptionsKeepDates": "Keep date options","mixedOptionsKeepTimes": "Keep time options",@@ -410,6 +411,7 @@"noCalendarsDescription": "No calendars found","noChanges": "No Changes","noDatesSelected": "No dates selected",+ "noDatesSelectedDescription": "Click on a date to add a time slot","noKeepCurrentTimezone": "No, keep the current timezone","noLicenseKey": "No license key found","noLicenseKeyDescription": "This instance doesn’t have a license key yet.",@@ -605,8 +607,6 @@"spaceSettings": "Space Settings","spaceUpdatedError": "Failed to update space","spaceUpdatedSuccess": "Space updated successfully",- "specifyTimes": "Specify times",- "specifyTimesDescription": "Include start and end times for each option","ssoAuthenticationOnly": "Authentication is managed through Single Sign-On (SSO). Password management is not available.","startOfWeek": "Start of week","submit": "Submit",diff --git a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsxindex f207b1069..befaaa113 100644--- a/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx+++ b/apps/web/src/components/forms/poll-options-form/month-calendar/month-calendar.tsx@@ -7,7 +7,7 @@ import {DropdownMenuTrigger,} from "@rallly/ui/dropdown-menu";import { Icon } from "@rallly/ui/icon";-import { Switch } from "@rallly/ui/switch";+import { RadioCards, RadioCardsItem } from "@rallly/ui/radio-pills";import {CalendarIcon,CalendarXIcon,@@ -20,11 +20,18 @@ import {} from "lucide-react";import * as React from "react";import { useFormContext } from "react-hook-form";+import {+ EmptyState,+ EmptyStateDescription,+ EmptyStateIcon,+ EmptyStateTitle,+} from "@/components/empty-state";import type { NewEventData } from "@/components/forms";import { Trans, useTranslation } from "@/i18n/client";import { dayjs } from "@/lib/dayjs";import {expectTimeOption,+ formatDuration,getBrowserTimeZone,getDateProps,removeAllOptionsForDay,@@ -45,10 +52,89 @@ const MonthCalendar: React.FunctionComponent<DateTimePickerProps> = ({onChangeDuration,}) => {const { t } = useTranslation();- const isTimedEvent = options.some((option) => option.type === "timeSlot");+ // Time-based options are the default. With no options yet the selected+ // duration drives the mode (0 = all-day) so the first selection creates the+ // right kind of option; once options exist their type is the source of truth.+ const isTimedEvent =+ options.length > 0+ ? options.some((option) => option.type === "timeSlot")+ : duration !== 0;const form = useFormContext<NewEventData>();+ // Durations currently in use across the timed options. When they all share a+ // single value the radio group selects it; differing values show as "Mixed".+ const optionDurations = options.flatMap((option) =>+ option.type === "timeSlot"+ ? [dayjs(option.end).diff(option.start, "minute")]+ : [],+ );+ const uniformDuration =+ optionDurations.length > 0 &&+ optionDurations.every((d) => d === optionDurations[0])+ ? optionDurations[0]+ : null;+ const isMixed = optionDurations.length > 0 && uniformDuration === null;++ const durationValue = !isTimedEvent+ ? "all-day"+ : isMixed+ ? "mixed"+ : String(uniformDuration ?? duration);++ // Standard presets, plus the current duration if it's a non-standard value+ // (e.g. set by dragging in the week view) so the selection stays visible.+ const durationPresets = [30, 60, 90, 120];+ const durationOptions =+ uniformDuration !== null && !durationPresets.includes(uniformDuration)+ ? [...durationPresets, uniformDuration].sort((a, b) => a - b)+ : durationPresets;++ // Length to use whenever we build a time slot. `duration` is 0 in all-day+ // mode; fall back to an hour so a slot is never zero-length.+ const slotDuration = duration || 60;++ const handleDurationChange = (value: string) => {+ if (value === "mixed") {+ return;+ }++ if (value === "all-day") {+ onChangeDuration(0);+ form.setValue("timeZone", "");+ onChange(+ datepicker.selection.map((date) => ({+ type: "date",+ date: formatDateWithoutTime(date),+ })),+ );+ return;+ }++ const minutes = Number(value);+ onChangeDuration(minutes);+ if (!form.getValues("timeZone")) {+ form.setValue("timeZone", getBrowserTimeZone());+ }+ // Normalize every option to a time slot of the chosen duration, keeping the+ // existing start time (defaulting all-day options to midday).+ onChange(+ options.map<DateTimeOption>((option) => {+ const startDate =+ option.type === "timeSlot"+ ? new Date(option.start)+ : new Date(`${option.date}T12:00:00`);+ return {+ type: "timeSlot",+ start: formatDateWithoutTz(startDate),+ end: formatDateWithoutTz(+ dayjs(startDate).add(minutes, "minutes").toDate(),+ ),+ };+ }),+ );+ };+const optionsByDay = React.useMemo(() => {const res: Record<string,@@ -89,402 +175,400 @@ const MonthCalendar: React.FunctionComponent<DateTimePickerProps> = ({});return (- <div className="overflow-hidden md:flex">- <div className="shrink-0 border-b p-3 sm:p-4 md:w-[380px] md:border-r md:border-b-0">- <div>- <div className="flex w-full flex-col">- <div className="mb-3 flex items-center justify-center space-x-4">- <Button- title={t("previousMonth")}- size="icon"- onClick={datepicker.prev}- >- <ChevronLeftIcon />- </Button>- <div className="grow text-center font-semibold tracking-tight">- {datepicker.label}- </div>- <Button- title={t("nextMonth")}- size="icon"- onClick={datepicker.next}- >- <ChevronRightIcon />- </Button>- </div>- <div className="grid grid-cols-7">- {datepicker.daysOfWeek.map((dayOfWeek) => {- return (- <div- key={dayOfWeek}- className="flex items-center justify-center pb-2 font-medium text-muted-foreground text-sm"- >- {dayOfWeek.substring(0, 2)}- </div>- );- })}- </div>- <div className="grid grow grid-cols-7 overflow-hidden rounded-lg border shadow-xs">- {datepicker.days.map((day, i) => {- return (- <div- // biome-ignore lint/suspicious/noArrayIndexKey: Fix this later- key={i}- className={cn("h-11", {- "border-r": (i + 1) % 7 !== 0,- "border-b": i < datepicker.days.length - 7,- })}- >- <button- type="button"- onClick={() => {- if (- datepicker.selection.some((selectedDate) =>- dayjs(selectedDate).isSame(day.date, "day"),- )- ) {- onChange(removeAllOptionsForDay(options, day.date));- } else {- const selectedDate = dayjs(day.date)- .set("hour", 12)- .toDate();- const newOption: DateTimeOption = !isTimedEvent- ? {- type: "date",- date: formatDateWithoutTime(selectedDate),- }- : {- type: "timeSlot",- start: formatDateWithoutTz(selectedDate),- end: formatDateWithoutTz(- dayjs(selectedDate)- .add(duration, "minutes")- .toDate(),- ),- };-- onChange([...options, newOption]);- onNavigate(selectedDate);- }- if (day.outOfMonth) {- if (i < 6) {- datepicker.prev();- } else {- datepicker.next();- }- }- }}- className={cn(- "group relative flex h-full w-full items-start justify-end rounded-none px-2.5 py-1.5 font-medium text-sm tracking-tight focus:z-10 focus:rounded-sm",- {- "bg-muted text-muted-foreground opacity-50":- day.isPast,- "text-rose-500": day.today && !day.selected,- "bg-muted/50 text-muted-foreground":- day.outOfMonth && !day.isPast,- "text-foreground": day.selected,- },- )}- >- <span- aria-hidden- className={cn(- "absolute inset-1 z-0 rounded-md border",- day.selected- ? "border-accent-border bg-accent shadow-xs group-hover:border-accent-border"- : "border-transparent group-hover:border-accent-border group-active:bg-accent",- )}- />- <span className="z-10">{day.day}</span>- </button>- </div>- );- })}- </div>- <Button className="mt-3" onClick={datepicker.today}>- {t("today")}- </Button>+ <div className="overflow-hidden">+ <div className="border-b">+ <div className="flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:justify-between sm:p-4">+ <div className="font-medium text-sm">+ <Trans i18nKey="durationLabel" defaults="Duration" /></div>+ <RadioCards+ value={durationValue}+ onValueChange={handleDurationChange}+ className="flex-wrap gap-y-2"+ >+ {durationOptions.map((minutes) => (+ <RadioCardsItem key={minutes} value={String(minutes)}>+ {formatDuration(minutes)}+ </RadioCardsItem>+ ))}+ <RadioCardsItem data-testid="all-day-option" value="all-day">+ <Trans i18nKey="allDay" defaults="All day" />+ </RadioCardsItem>+ {isMixed ? (+ <RadioCardsItem value="mixed" disabled>+ <Trans i18nKey="mixedDurations" defaults="Mixed" />+ </RadioCardsItem>+ ) : null}+ </RadioCards></div></div>- <div className="flex grow flex-col">- <div- className={cn("border-b", {- hidden: datepicker.selection.length === 0,- })}- >- <div className="flex items-center space-x-3 p-3 sm:p-4">- <div className="grow">- <div className="font-medium">{t("specifyTimes")}</div>- <div className="text-gray-500 text-sm">- {t("specifyTimesDescription")}+ <div className="md:flex">+ <div className="shrink-0 border-b p-3 sm:p-4 md:w-[380px] md:border-r md:border-b-0">+ <div>+ <div className="flex w-full flex-col">+ <div className="mb-3 flex items-center justify-center space-x-4">+ <Button+ title={t("previousMonth")}+ size="icon"+ onClick={datepicker.prev}+ >+ <ChevronLeftIcon />+ </Button>+ <div className="grow text-center font-semibold tracking-tight">+ {datepicker.label}+ </div>+ <Button+ title={t("nextMonth")}+ size="icon"+ onClick={datepicker.next}+ >+ <ChevronRightIcon />+ </Button></div>- </div>- <div>- <Switch- data-testid="specify-times-switch"- checked={isTimedEvent}- onCheckedChange={(checked) => {- if (checked) {- form.setValue("timeZone", getBrowserTimeZone());- // convert dates to time slots- onChange(- options.map<DateTimeOption>((option) => {- if (option.type === "timeSlot") {- throw new Error(- "Expected option to be a date but received timeSlot",- );- }- const startDate = new Date(`${option.date}T12:00:00`);- const endDate = dayjs(startDate)- .add(duration, "minutes")- .toDate();- return {- type: "timeSlot",- start: formatDateWithoutTz(startDate),- duration: duration,- end: formatDateWithoutTz(endDate),- };- }),- );- } else {- form.setValue("timeZone", "");- onChange(- datepicker.selection.map((date) => ({- type: "date",- date: formatDateWithoutTime(date),- })),- );- }- }}- />- </div>- </div>- </div>- <div className="min-h-0 grow overflow-auto">- {isTimedEvent ? (- <div className="divide-y">- {Object.keys(optionsByDay)- .sort((a, b) => (a > b ? 1 : -1))- .map((dateString) => {- const optionsForDay = optionsByDay[dateString];+ <div className="grid grid-cols-7">+ {datepicker.daysOfWeek.map((dayOfWeek) => {return (<div- key={dateString}- className="space-y-3 p-3 sm:flex sm:items-start sm:space-x-4 sm:space-y-0 sm:p-4"+ key={dayOfWeek}+ className="flex items-center justify-center pb-2 font-medium text-muted-foreground text-sm">- <DateCard- {...getDateProps(new Date(`${dateString}T12:00:00`))}- />- <div className="grow space-y-3">- {optionsForDay.map(({ option, index }) => {- if (option.type === "date") {- throw new Error("Expected timeSlot but got date");- }- const startDate = new Date(option.start);- return (- <div- key={index}- className="flex items-center space-x-3"- >- <TimePicker- value={startDate}- onChange={(newStart) => {- const newEnd = dayjs(newStart).add(- duration,- "minutes",- );-- // replace enter with updated start time- onChange([- ...options.slice(0, index),- {- ...option,- start: formatDateWithoutTz(newStart),- end: formatDateWithoutTz(newEnd.toDate()),- },- ...options.slice(index + 1),- ]);- onNavigate(newStart);- onChangeDuration(- newEnd.diff(newStart, "minutes"),- );- }}- />- <TimePicker- value={new Date(option.end)}- after={startDate}- onChange={(newEnd) => {- onChange([- ...options.slice(0, index),- {- ...option,- end: formatDateWithoutTz(newEnd),- },- ...options.slice(index + 1),- ]);- onNavigate(newEnd);- onChangeDuration(- dayjs(newEnd).diff(startDate, "minutes"),- );- }}- />- <Button- size="icon"- variant="ghost"- onClick={() => {- onChange([- ...options.slice(0, index),- ...options.slice(index + 1),- ]);- }}- >- <XIcon />- </Button>- </div>- );- })}- <div className="flex items-center space-x-2">- <Button- onClick={() => {- const lastOption = expectTimeOption(- optionsForDay[optionsForDay.length - 1].option,- );-- const startTime = dayjs(lastOption.end).isSame(- lastOption.start,- "day",- )- ? // if the end time of the previous option is on the same day as the start time, use the end time- lastOption.end- : // otherwise use the start time- lastOption.start;-- onChange([- ...options,- {+ {dayOfWeek.substring(0, 2)}+ </div>+ );+ })}+ </div>+ <div className="grid grow grid-cols-7 overflow-hidden rounded-lg border shadow-xs">+ {datepicker.days.map((day, i) => {+ return (+ <div+ // biome-ignore lint/suspicious/noArrayIndexKey: Fix this later+ key={i}+ className={cn("h-11", {+ "border-r": (i + 1) % 7 !== 0,+ "border-b": i < datepicker.days.length - 7,+ })}+ >+ <button+ type="button"+ onClick={() => {+ if (+ datepicker.selection.some((selectedDate) =>+ dayjs(selectedDate).isSame(day.date, "day"),+ )+ ) {+ onChange(removeAllOptionsForDay(options, day.date));+ } else {+ const selectedDate = dayjs(day.date)+ .set("hour", 12)+ .toDate();+ const newOption: DateTimeOption = !isTimedEvent+ ? {+ type: "date",+ date: formatDateWithoutTime(selectedDate),+ }+ : {type: "timeSlot",- start: startTime,+ start: formatDateWithoutTz(selectedDate),end: formatDateWithoutTz(- dayjs(new Date(startTime))- .add(duration, "minutes")+ dayjs(selectedDate)+ .add(slotDuration, "minutes").toDate(),),- },- ]);- }}- >- <PlusIcon data-icon="inline-start" />- {t("addTimeOption")}- </Button>- <DropdownMenu>- <DropdownMenuTrigger asChild={true}>- <Button variant="ghost" size="icon">- <MoreVerticalIcon />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start">- <DropdownMenuItem- onClick={() => {- const times = optionsForDay.map(- ({ option }) => {- if (option.type === "date") {- throw new Error(- "Expected timeSlot but got date",- );- }+ };- return {- startTime: option.start.substring(- option.start.indexOf("T"),- ),- endTime: option.end.substring(- option.end.indexOf("T"),- ),- };- },- );- const newOptions: DateTimeOption[] = [];- Object.keys(optionsByDay).forEach(- (dateString) => {- times.forEach((time) => {- const start =- dateString + time.startTime;- newOptions.push({- type: "timeSlot",- start: start,- end: dayjs(start)- .add(duration, "minutes")- .format("YYYY-MM-DDTHH:mm"),- });- });- },- );- onChange(newOptions);- }}- >- <Icon>- <SparklesIcon />- </Icon>- <Trans i18nKey="applyToAllDates" />- </DropdownMenuItem>- <DropdownMenuItem- onClick={() => {- onChange(- removeAllOptionsForDay(- options,- new Date(dateString),- ),- );- }}- >- <Icon>- <CalendarXIcon />- </Icon>- <Trans i18nKey="deleteDate" />- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </div>- </div>+ if (+ options.length === 0 &&+ newOption.type === "timeSlot"+ ) {+ form.setValue("timeZone", getBrowserTimeZone());+ }++ onChange([...options, newOption]);+ onNavigate(selectedDate);+ }+ if (day.outOfMonth) {+ if (i < 6) {+ datepicker.prev();+ } else {+ datepicker.next();+ }+ }+ }}+ className={cn(+ "group relative flex h-full w-full items-start justify-end rounded-none px-2.5 py-1.5 font-medium text-sm tracking-tight focus:z-10 focus:rounded-sm",+ {+ "bg-muted text-muted-foreground opacity-50":+ day.isPast,+ "text-rose-500": day.today && !day.selected,+ "bg-muted/50 text-muted-foreground":+ day.outOfMonth && !day.isPast,+ "text-foreground": day.selected,+ },+ )}+ >+ <span+ aria-hidden+ className={cn(+ "absolute inset-1 z-0 rounded-md border",+ day.selected+ ? "border-accent-border bg-accent shadow-xs group-hover:border-accent-border"+ : "border-transparent group-hover:border-accent-border group-active:bg-accent",+ )}+ />+ <span className="z-10">{day.day}</span>+ </button></div>);})}+ </div>+ <Button className="mt-3" onClick={datepicker.today}>+ {t("today")}+ </Button></div>- ) : datepicker.selection.length ? (- <div className="flex flex-wrap gap-3 p-3 sm:gap-4 sm:p-4">- {datepicker.selection- .sort((a, b) => a.getTime() - b.getTime())- .map((selectedDate, i) => {- return (- <DateCard- // biome-ignore lint/suspicious/noArrayIndexKey: Fix this later- key={i}- {...getDateProps(selectedDate)}- // annotation={- // <CompactButton- // icon={XIcon}- // onClick={() => {- // // TODO (Luke Vella) [2022-03-19]: Find cleaner way to manage this state- // // Quite tedious right now to remove a single element- // onChange(- // removeAllOptionsForDay(options, selectedDate),- // );- // }}- // />- // }+ </div>+ </div>+ <div className="flex grow flex-col">+ <div className="min-h-0 grow overflow-auto">+ {datepicker.selection.length === 0 ? (+ <div className="flex h-full items-center justify-center py-12">+ <EmptyState>+ <EmptyStateIcon>+ <CalendarIcon />+ </EmptyStateIcon>+ <EmptyStateTitle>+ <Trans+ i18nKey="noDatesSelected"+ defaults="No dates selected"/>- );- })}- </div>- ) : (- <div className="flex h-full items-center justify-center py-12">- <div className="text-center text-muted-foreground">- <CalendarIcon className="mb-4 inline-block size-10" />- <div className="text-sm">{t("noDatesSelected")}</div>+ </EmptyStateTitle>+ <EmptyStateDescription>+ <Trans+ i18nKey="noDatesSelectedDescription"+ defaults="Click on a date to add a time slot"+ />+ </EmptyStateDescription>+ </EmptyState></div>- </div>- )}+ ) : isTimedEvent ? (+ <div className="divide-y">+ {Object.keys(optionsByDay)+ .sort((a, b) => (a > b ? 1 : -1))+ .map((dateString) => {+ const optionsForDay = optionsByDay[dateString];+ return (+ <div+ key={dateString}+ className="space-y-3 p-3 sm:flex sm:items-start sm:space-x-4 sm:space-y-0 sm:p-4"+ >+ <DateCard+ {...getDateProps(new Date(`${dateString}T12:00:00`))}+ />+ <div className="grow space-y-3">+ {optionsForDay.map(({ option, index }) => {+ if (option.type === "date") {+ throw new Error("Expected timeSlot but got date");+ }+ const startDate = new Date(option.start);+ return (+ <div+ key={index}+ className="flex items-center space-x-3"+ >+ <TimePicker+ value={startDate}+ onChange={(newStart) => {+ const newEnd = dayjs(newStart).add(+ slotDuration,+ "minutes",+ );++ // replace enter with updated start time+ onChange([+ ...options.slice(0, index),+ {+ ...option,+ start: formatDateWithoutTz(newStart),+ end: formatDateWithoutTz(+ newEnd.toDate(),+ ),+ },+ ...options.slice(index + 1),+ ]);+ onNavigate(newStart);+ onChangeDuration(+ newEnd.diff(newStart, "minutes"),+ );+ }}+ />+ <TimePicker+ value={new Date(option.end)}+ after={startDate}+ onChange={(newEnd) => {+ onChange([+ ...options.slice(0, index),+ {+ ...option,+ end: formatDateWithoutTz(newEnd),+ },+ ...options.slice(index + 1),+ ]);+ onNavigate(newEnd);+ onChangeDuration(+ dayjs(newEnd).diff(startDate, "minutes"),+ );+ }}+ />+ <Button+ size="icon"+ variant="ghost"+ onClick={() => {+ onChange([+ ...options.slice(0, index),+ ...options.slice(index + 1),+ ]);+ }}+ >+ <XIcon />+ </Button>+ </div>+ );+ })}+ <div className="flex items-center space-x-2">+ <Button+ onClick={() => {+ const lastOption = expectTimeOption(+ optionsForDay[optionsForDay.length - 1]+ .option,+ );++ const startTime = dayjs(lastOption.end).isSame(+ lastOption.start,+ "day",+ )+ ? // if the end time of the previous option is on the same day as the start time, use the end time+ lastOption.end+ : // otherwise use the start time+ lastOption.start;++ onChange([+ ...options,+ {+ type: "timeSlot",+ start: startTime,+ end: formatDateWithoutTz(+ dayjs(new Date(startTime))+ .add(slotDuration, "minutes")+ .toDate(),+ ),+ },+ ]);+ }}+ >+ <PlusIcon data-icon="inline-start" />+ {t("addTimeOption")}+ </Button>+ <DropdownMenu>+ <DropdownMenuTrigger asChild={true}>+ <Button variant="ghost" size="icon">+ <MoreVerticalIcon />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start">+ <DropdownMenuItem+ onClick={() => {+ const times = optionsForDay.map(+ ({ option }) => {+ if (option.type === "date") {+ throw new Error(+ "Expected timeSlot but got date",+ );+ }++ return {+ startTime: option.start.substring(+ option.start.indexOf("T"),+ ),+ endTime: option.end.substring(+ option.end.indexOf("T"),+ ),+ };+ },+ );+ const newOptions: DateTimeOption[] = [];+ Object.keys(optionsByDay).forEach(+ (dateString) => {+ times.forEach((time) => {+ const start =+ dateString + time.startTime;+ newOptions.push({+ type: "timeSlot",+ start: start,+ end: dayjs(start)+ .add(slotDuration, "minutes")+ .format("YYYY-MM-DDTHH:mm"),+ });+ });+ },+ );+ onChange(newOptions);+ }}+ >+ <Icon>+ <SparklesIcon />+ </Icon>+ <Trans i18nKey="applyToAllDates" />+ </DropdownMenuItem>+ <DropdownMenuItem+ onClick={() => {+ onChange(+ removeAllOptionsForDay(+ options,+ new Date(dateString),+ ),+ );+ }}+ >+ <Icon>+ <CalendarXIcon />+ </Icon>+ <Trans i18nKey="deleteDate" />+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </div>+ </div>+ </div>+ );+ })}+ </div>+ ) : (+ <div className="flex flex-wrap gap-3 p-3 sm:gap-4 sm:p-4">+ {datepicker.selection+ .sort((a, b) => a.getTime() - b.getTime())+ .map((selectedDate, i) => {+ return (+ <DateCard+ // biome-ignore lint/suspicious/noArrayIndexKey: Fix this later+ key={i}+ {...getDateProps(selectedDate)}+ // annotation={+ // <CompactButton+ // icon={XIcon}+ // onClick={() => {+ // // TODO (Luke Vella) [2022-03-19]: Find cleaner way to manage this state+ // // Quite tedious right now to remove a single element+ // onChange(+ // removeAllOptionsForDay(options, selectedDate),+ // );+ // }}+ // />+ // }+ />+ );+ })}+ </div>+ )}+ </div></div></div></div>diff --git a/apps/web/src/components/forms/poll-options-form/week-calendar.tsx b/apps/web/src/components/forms/poll-options-form/week-calendar.tsxindex e1c9260cc..874aace5a 100644--- a/apps/web/src/components/forms/poll-options-form/week-calendar.tsx+++ b/apps/web/src/components/forms/poll-options-form/week-calendar.tsx@@ -168,8 +168,12 @@ const WeekCalendar: React.FunctionComponent<DateTimePickerProps> = ({onChangeDuration(diff);}} else {+ // Fall back to an hour when the duration is 0 (all-day mode) so a+ // click never creates a zero-length time slot.newEvent.end = formatDateWithoutTz(- dayjs(startDate).add(duration, "minutes").toDate(),+ dayjs(startDate)+ .add(duration || 60, "minutes")+ .toDate(),);}diff --git a/apps/web/tests/edit-options-page.ts b/apps/web/tests/edit-options-page.tsindex f913a62dc..7689cdff5 100644--- a/apps/web/tests/edit-options-page.ts+++ b/apps/web/tests/edit-options-page.ts@@ -3,7 +3,7 @@ import type { Page } from "@playwright/test";export class EditOptionsPage {constructor(public readonly page: Page) {}- async switchToSpecifyTimes() {- await this.page.click("[data-testid='specify-times-switch']");+ async selectAllDay() {+ await this.page.click("[data-testid='all-day-option']");}}diff --git a/apps/web/tests/edit-options.spec.ts b/apps/web/tests/edit-options.spec.tsindex c2ed20b41..20951b7aa 100644--- a/apps/web/tests/edit-options.spec.ts+++ b/apps/web/tests/edit-options.spec.ts@@ -18,11 +18,9 @@ test.describe("edit options", () => {});test("should show warning when deleting options with votes in them", async () => {- editOptionsPage.switchToSpecifyTimes();-- await page.click("text='12:00 PM'");- const listbox = page.getByRole("listbox");- listbox.getByText("1:00 PM", { exact: true }).click();+ // Polls default to timed options. Selecting all-day replaces the voted+ // time options with date options, which deletes the options that have votes.+ await editOptionsPage.selectAllDay();await page.getByRole("button", { name: "Save" }).click();await expect(page.locator('text="Are you sure?"')).toBeVisible();await page.click("text='Delete'");