forge
Explore
Log in

Don't you dare go Hollow

🗓️ stacked slot date/time cell + localized overlap errors

Browse files at this commit

8bba96b9545914e0205716c7fa6538b8f7fde0b3Ahmet Kaan GümüşParent: e70073f
  • fix
    • 🗓️ stacked slot date/time cell + localized overlap errors
Show full message
fix: 🗓️ stacked slot date/time cell + localized overlap errors
- appointments: split the crammed one-line "date time – time" column
  into a stacked cell (date over clock range, mono + tabular-nums so
  digits align); drops the clipped end-time, narrows the column
- add formatDate (date-only) helper
- localize the three slot-overlap 409 messages (EN/TR) so they stop
  rendering half-Turkish/half-English; test the exact backend strings map
src/api/__tests__/client/client.test.tsmodified+15 -0
@@ -124,6 +124,21 @@ describe("client", () => {
124124 expect(formatApiErrorMessage("forbidden", "tr")).toBe("Bu işlem için yetkin yok.");
125125 });
126126
127+ it("localizes slot-overlap conflicts (no half-English fallback)", () => {
128+ // exact backend strings (lowercase) must map, not fall through to "İşlem tamamlanamadı: <english>"
129+ expect(formatApiErrorMessage("this time overlaps a slot you have already published", "tr")).toBe(
130+ "Bu zaman aralığı, daha önce yayınladığın bir müsaitlikle çakışıyor.",
131+ );
132+ expect(formatApiErrorMessage("a repeated slot overlaps one you have already published", "tr")).toBe(
133+ "Tekrarlanan müsaitliklerden biri, daha önce yayınladığın bir müsaitlikle çakışıyor.",
134+ );
135+ expect(formatApiErrorMessage("the repeated slots overlap each other", "en")).toBe("The repeated slots overlap each other.");
136+ // a 409 ApiError carrying the backend message resolves the same way
137+ expect(formatApiError(new ApiError(409, "this time overlaps a slot you have already published"), "tr")).toBe(
138+ "Bu zaman aralığı, daha önce yayınladığın bir müsaitlikle çakışıyor.",
139+ );
140+ });
141+
127142 it("handles unknown messages with sentence case", () => {
128143 expect(formatApiErrorMessage("custom error occurred", "en")).toBe("Custom error occurred");
129144 expect(formatApiErrorMessage("custom error occurred", "tr")).toBe("İşlem tamamlanamadı: Custom error occurred");
src/api/client/client.tsmodified+12 -0
@@ -78,6 +78,18 @@ const API_ERROR_MESSAGES: Record<string, Record<Locale, string>> = {
7878 en: "This note already has the maximum number of files.",
7979 tr: "Bu notta en fazla dosya sayısına ulaşılmış.",
8080 },
81+ "this time overlaps a slot you have already published": {
82+ en: "This time overlaps a slot you already published.",
83+ tr: "Bu zaman aralığı, daha önce yayınladığın bir müsaitlikle çakışıyor.",
84+ },
85+ "a repeated slot overlaps one you have already published": {
86+ en: "One of the repeated slots overlaps a slot you already published.",
87+ tr: "Tekrarlanan müsaitliklerden biri, daha önce yayınladığın bir müsaitlikle çakışıyor.",
88+ },
89+ "the repeated slots overlap each other": {
90+ en: "The repeated slots overlap each other.",
91+ tr: "Tekrarlanan müsaitlikler birbiriyle çakışıyor.",
92+ },
8193 "course not found": {
8294 en: "Course not found.",
8395 tr: "Ders bulunamadı.",
src/lib/format.tsmodified+8 -0
@@ -8,6 +8,14 @@ export function formatDateTime(ms: number | null | undefined, locale: Locale = "
88 }).format(new Date(ms));
99 }
1010
11+/** Date only, no time — for stacked date/time cells. */
12+export function formatDate(ms: number | null | undefined, locale: Locale = "en"): string {
13+ if (ms == null) return "—";
14+ return new Intl.DateTimeFormat(locale === "tr" ? "tr-TR" : "en-US", {
15+ dateStyle: "medium",
16+ }).format(new Date(ms));
17+}
18+
1119 /** Convert datetime-local input value to unix ms, or null if empty. */
1220 export function localInputToMs(value: string): number | null {
1321 if (!value) return null;
src/pages/appointments-page.tsxmodified+27 -13
@@ -35,7 +35,7 @@ import { appointmentStatusClass, appointmentStatusDotClass, appointmentStatusLab
3535 import { cn } from "@/lib/cn";
3636 import { createFlash } from "@/lib/flash";
3737 import { createNow } from "@/lib/create-now";
38-import { formatDateTime } from "@/lib/format";
38+import { formatDate, formatDateTime } from "@/lib/format";
3939 import { personLabel } from "@/lib/person";
4040 import { hasMinRole } from "@/lib/roles";
4141 import { useAuth } from "@/stores/auth-context";
@@ -119,6 +119,19 @@ function AppointmentsContent() {
119119 sameDay(starts, ends)
120120 ? `${formatDateTime(starts, locale())} – ${timeOnly(ends)}`
121121 : `${formatDateTime(starts, locale())} — ${formatDateTime(ends, locale())}`;
122+ // Stacked date/time cell: date on top, clock range below (tabular-nums so
123+ // digits line up across rows). Same-day windows show one date; cross-day
124+ // spells out the end date on the second line.
125+ const timeCell = (starts: number | null, ends: number | null) => (
126+ <div class="mono flex flex-col text-xs leading-tight tabular-nums">
127+ <span class="text-foreground">{formatDate(starts, locale())}</span>
128+ <span class="text-muted-foreground">
129+ {sameDay(starts, ends)
130+ ? `${timeOnly(starts)} – ${timeOnly(ends)}`
131+ : `${timeOnly(starts)} → ${formatDate(ends, locale())} ${timeOnly(ends)}`}
132+ </span>
133+ </div>
134+ );
122135 const statusBadge = (status: AppointmentStatus) => (
123136 <Badge variant="outline" class={cn("w-28 justify-center rounded-full", appointmentStatusClass(status))}>
124137 <span class={cn("mr-1.5 h-1.5 w-1.5 rounded-full", appointmentStatusDotClass(status))} />
@@ -151,8 +164,8 @@ function AppointmentsContent() {
151164 {
152165 id: "time",
153166 header: t("appointments.time"),
154- meta: { headerClass: "w-56", cellClass: "mono text-xs text-muted-foreground align-top whitespace-normal break-words pr-4" },
155- cell: (cell) => timeWindow(cell.row.original.starts_at, cell.row.original.ends_at),
167+ meta: { headerClass: "w-44", cellClass: "align-top pr-4" },
168+ cell: (cell) => timeCell(cell.row.original.starts_at, cell.row.original.ends_at),
156169 },
157170 {
158171 id: "note",
@@ -221,12 +234,12 @@ function AppointmentsContent() {
221234 {
222235 id: "time",
223236 header: t("appointments.time"),
224- meta: { headerClass: "w-56", cellClass: "mono text-xs text-muted-foreground align-top whitespace-normal break-words pr-4" },
237+ meta: { headerClass: "w-44", cellClass: "align-top pr-4" },
225238 cell: (cell) => (
226- <div>
227- <div>{timeWindow(cell.row.original.starts_at, cell.row.original.ends_at)}</div>
239+ <div class="flex flex-col gap-0.5">
240+ {timeCell(cell.row.original.starts_at, cell.row.original.ends_at)}
228241 <Show when={hasProposal(cell.row.original) && cell.row.original.status === "pending"}>
229- <div class="text-info">{t("appointments.rescheduleProposed")}</div>
242+ <div class="text-info text-xs">{t("appointments.rescheduleProposed")}</div>
230243 </Show>
231244 </div>
232245 ),
@@ -274,8 +287,8 @@ function AppointmentsContent() {
274287 {
275288 id: "time",
276289 header: t("appointments.time"),
277- meta: { headerClass: "w-56", cellClass: "mono text-xs text-muted-foreground align-top whitespace-normal break-words pr-4" },
278- cell: (cell) => timeWindow(cell.row.original.starts_at, cell.row.original.ends_at),
290+ meta: { headerClass: "w-44", cellClass: "align-top pr-4" },
291+ cell: (cell) => timeCell(cell.row.original.starts_at, cell.row.original.ends_at),
279292 },
280293 {
281294 id: "note",
@@ -307,12 +320,13 @@ function AppointmentsContent() {
307320 {
308321 id: "time",
309322 header: t("appointments.time"),
310- meta: { headerClass: "w-56", cellClass: "mono text-xs text-muted-foreground align-top whitespace-normal break-words pr-4" },
323+ meta: { headerClass: "w-44", cellClass: "align-top pr-4" },
311324 cell: (cell) => (
312- <div>
313- <div>{timeWindow(cell.row.original.starts_at, cell.row.original.ends_at)}</div>
325+ <div class="flex flex-col gap-0.5">
326+ {timeCell(cell.row.original.starts_at, cell.row.original.ends_at)}
314327 <Show when={hasProposal(cell.row.original) && cell.row.original.status === "pending"}>
315- <div class="text-info">{t("appointments.proposedTime")}: {timeWindow(cell.row.original.proposed_starts_at, cell.row.original.proposed_ends_at)}</div>
328+ <div class="text-info text-xs">{t("appointments.proposedTime")}:</div>
329+ {timeCell(cell.row.original.proposed_starts_at, cell.row.original.proposed_ends_at)}
316330 </Show>
317331 </div>
318332 ),