Scheduling infrastructure for absolutely everyone.
fix(ooo): make show note publicly consistent across all booking views (#25827)
Dhairyashil Shinde6e2e8260011d
diff --git a/packages/features/calendars/weeklyview/components/event/Empty.tsx b/packages/features/calendars/weeklyview/components/event/Empty.tsxindex e67f99c9b01..66f753c3860 100644--- a/packages/features/calendars/weeklyview/components/event/Empty.tsx+++ b/packages/features/calendars/weeklyview/components/event/Empty.tsx@@ -78,7 +78,7 @@ export function AvailableCellsForDay({ timezone, availableSlots, day, startHourconst lastSlot = slotsForToday[lastSlotIndex];startEndTimeDuration = dayjs(lastSlot.end).diff(dayjs(firstSlot.start), "minutes");- if (firstSlot.toUser == null) {+ if (firstSlot.toUser == null && !firstSlot.showNotePublicly) {return null;}@@ -108,6 +108,8 @@ export function AvailableCellsForDay({ timezone, availableSlots, day, startHourtoUser={firstSlot?.toUser}reason={firstSlot?.reason}emoji={firstSlot?.emoji}+ notes={firstSlot?.notes}+ showNotePublicly={firstSlot?.showNotePublicly}borderDashed={false}date={dateFormatted}className="pb-0"diff --git a/packages/features/calendars/weeklyview/types/state.ts b/packages/features/calendars/weeklyview/types/state.tsindex edd5f33d19c..572f038d719 100644--- a/packages/features/calendars/weeklyview/types/state.ts+++ b/packages/features/calendars/weeklyview/types/state.ts@@ -58,6 +58,8 @@ type TimeRangeExtended = TimeRange & {toUser?: IToUser;reason?: string;emoji?: string;+ notes?: string | null;+ showNotePublicly?: boolean;};export type CalendarAvailableTimeslots = {diff --git a/packages/features/schedules/lib/use-schedule/useNonEmptyScheduleDays.ts b/packages/features/schedules/lib/use-schedule/useNonEmptyScheduleDays.tsindex c256946c96a..883dab758a5 100644--- a/packages/features/schedules/lib/use-schedule/useNonEmptyScheduleDays.ts+++ b/packages/features/schedules/lib/use-schedule/useNonEmptyScheduleDays.ts@@ -8,7 +8,7 @@ export const getNonEmptyScheduleDays = (slots?: Slots) => {const nonEmptyDays: string[] = [];Object.keys(slots).forEach((date) => {- if (slots[date].some((slot) => !(slot?.away && !slot.toUser) && slots[date].length > 0)) {+ if (slots[date].some((slot) => !(slot?.away && !slot.toUser && !slot.showNotePublicly) && slots[date].length > 0)) {nonEmptyDays.push(date);}});diff --git a/packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx b/packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsxindex 7772f36ebdf..2f13c9226c9 100644--- a/packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx+++ b/packages/features/settings/outOfOffice/CreateOrEditOutOfOfficeModal.tsx@@ -162,6 +162,8 @@ export const CreateOrEditOutOfOfficeEntryModal = ({const watchedTeamUserId = watch("toTeamUserId");const watchForUserId = watch("forUserId");+ const watchedNotes = watch("notes");+ const hasValidNotes = Boolean(watchedNotes?.trim());const createOrEditOutOfOfficeEntry = trpc.viewer.ooo.outOfOfficeCreateOrUpdate.useMutation({onSuccess: () => {@@ -345,7 +347,11 @@ export const CreateOrEditOutOfOfficeEntryModal = ({placeholder={t("additional_notes")}{...register("notes")}onChange={(e) => {- setValue("notes", e?.target.value);+ const newNotes = e?.target.value;+ setValue("notes", newNotes);+ if (!newNotes?.trim()) {+ setValue("showNotePublicly", false);+ }}}/><Controller@@ -358,8 +364,14 @@ export const CreateOrEditOutOfOfficeEntryModal = ({data-testid="show-note-publicly-checkbox"checked={value ?? false}onCheckedChange={onChange}+ disabled={!hasValidNotes}/>- <label htmlFor="show-note-publicly" className="text-emphasis ml-2 cursor-pointer text-sm">+ <label+ htmlFor="show-note-publicly"+ className={classNames(+ "ml-2 text-sm",+ hasValidNotes ? "text-emphasis cursor-pointer" : "text-muted cursor-not-allowed"+ )}>{t("show_note_publicly_description")}</label></div>