fix(ooo): make show note publicly consistent across all booking views (#25827)

- Update weekly view to display OOO when showNotePublicly is true
- Update column view to include days with public notes in schedule
- Add notes and showNotePublicly props to weekly view calendar
- Disable show note publicly checkbox when notes field is empty
This commit is contained in:
Dhairyashil Shinde authored and GitHub committed 2025-12-15 10:24:10 +01:00
1 parent 84a4dd4147
commit 6e2e826001
4 files changed
+20 -4

No files matched your search

@@ -78,7 +78,7 @@ export function AvailableCellsForDay({ timezone, availableSlots, day, startHour
const 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, startHour
toUser={firstSlot?.toUser}
reason={firstSlot?.reason}
emoji={firstSlot?.emoji}
notes={firstSlot?.notes}
showNotePublicly={firstSlot?.showNotePublicly}
borderDashed={false}
date={dateFormatted}
className="pb-0"
@@ -58,6 +58,8 @@ type TimeRangeExtended = TimeRange & {
toUser?: IToUser;
reason?: string;
emoji?: string;
notes?: string | null;
showNotePublicly?: boolean;
};
export type CalendarAvailableTimeslots = {
@@ -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);
}
});
@@ -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>