From 33418ffd514077b199536a3ca16ea7cb7cf41d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Fri, 17 Jul 2026 20:06:38 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20shared=20schedule=20status?= =?UTF-8?q?=20chips=20and=20more=20empty=20states=20-=20schedule-status=20?= =?UTF-8?q?helper=20for=20exam/event=20active/upcoming/finished=20tones=20?= =?UTF-8?q?-=20wire=20exams=20list,=20exam=20card/detail,=20dashboard=20at?= =?UTF-8?q?tention,=20event=20cards=20-=20EmptyState=20on=20terms=20(with?= =?UTF-8?q?=20create=20CTA),=20marks,=20work=20log,=20staff=20work=20-=20t?= =?UTF-8?q?erms=20create/save/delete=20flash=20banners?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/events/event-card.tsx | 44 +++++++++++++++++++++++----- src/components/exams/exam-card.tsx | 21 ++----------- src/lib/schedule-status.ts | 25 ++++++++++++++++ src/pages/dashboard-page.tsx | 12 ++------ src/pages/exam-detail-page.tsx | 44 +++++++++++++++++++--------- src/pages/exams-page.tsx | 9 ++---- src/pages/marks-page.tsx | 10 ++----- src/pages/staff-work-page.tsx | 3 +- src/pages/terms-page.tsx | 26 ++++++++++++++-- src/pages/work-log-page.tsx | 3 +- 10 files changed, 129 insertions(+), 68 deletions(-) create mode 100644 src/lib/schedule-status.ts diff --git a/src/components/events/event-card.tsx b/src/components/events/event-card.tsx index cde639a..1f90093 100644 --- a/src/components/events/event-card.tsx +++ b/src/components/events/event-card.tsx @@ -1,7 +1,11 @@ +import { Show } from "solid-js"; import { Link } from "@tanstack/solid-router"; import type { Event, EventAudience } from "@/api/types"; import type { MessageKey } from "@/i18n/messages"; +import { Badge } from "@/components/ui/badge"; +import { cn } from "@/lib/cn"; import { formatDateTime } from "@/lib/format"; +import { scheduleStatusClass, scheduleStatusDotClass, type ScheduleStatus } from "@/lib/schedule-status"; import { usePreferences, useT } from "@/stores/preferences-context"; function audienceLabel(audience: EventAudience, t: ReturnType): string { @@ -11,17 +15,39 @@ function audienceLabel(audience: EventAudience, t: ReturnType): str return t("events.audience.school"); } +function eventStatus(event: Event, now: number): ScheduleStatus { + if (event.starts_at == null) return "unscheduled"; + if (event.ends_at != null && event.ends_at < now) return "finished"; + if (event.starts_at > now) return "upcoming"; + return "active"; +} + export function EventCard(props: { event: Event }) { const t = useT(); const { locale } = usePreferences(); + const status = () => eventStatus(props.event, Date.now()); + const statusLabel = () => { + const s = status(); + if (s === "unscheduled") return t("exams.unscheduled"); + if (s === "finished") return t("events.past"); + if (s === "upcoming") return t("events.upcoming"); + return t("dashboard.activeNow"); + }; + return (
-

- {props.event.title} -

-

+

+

+ {props.event.title} +

+ + + {statusLabel()} + +
+

{props.event.description || "—"}

{audienceLabel(props.event.audience, t)}

@@ -32,10 +58,12 @@ export function EventCard(props: { event: Event }) {
{t("events.starts")}
{formatDateTime(props.event.starts_at, locale())}
-
-
{t("events.ends")}
-
{formatDateTime(props.event.ends_at, locale())}
-
+ +
+
{t("events.ends")}
+
{formatDateTime(props.event.ends_at, locale())}
+
+
diff --git a/src/components/exams/exam-card.tsx b/src/components/exams/exam-card.tsx index 71357f0..ffd94b2 100644 --- a/src/components/exams/exam-card.tsx +++ b/src/components/exams/exam-card.tsx @@ -7,6 +7,7 @@ import { cn } from "@/lib/cn"; import { examKindLabel } from "@/lib/exam-labels"; import { examWeight } from "@/lib/exam-weight"; import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/format"; +import { scheduleStatusClass, scheduleStatusDotClass } from "@/lib/schedule-status"; import { usePreferences, useT } from "@/stores/preferences-context"; export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number }) { @@ -37,22 +38,6 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number return t("exams.active"); }; - const statusClass = () => { - const s = status(); - if (s === "unscheduled") return "bg-muted text-muted-foreground border-muted"; - if (s === "finished") return "bg-muted text-muted-foreground border-muted"; - if (s === "upcoming") return "bg-amber-500/15 text-amber-600 border-amber-500/30"; - return "bg-emerald-500/15 text-emerald-600 border-emerald-500/30"; - }; - - const statusDot = () => { - const s = status(); - if (s === "unscheduled") return "bg-muted-foreground"; - if (s === "finished") return "bg-muted-foreground"; - if (s === "upcoming") return "bg-amber-600"; - return "bg-emerald-600"; - }; - return (
@@ -66,8 +51,8 @@ export function ExamCard(props: { exam: Exam; courseTitle?: string; now?: number {props.exam.title} - - + + {statusLabel()} diff --git a/src/lib/schedule-status.ts b/src/lib/schedule-status.ts new file mode 100644 index 0000000..3b70764 --- /dev/null +++ b/src/lib/schedule-status.ts @@ -0,0 +1,25 @@ +/** Shared semantic colors for exam/event schedule chips (dashboard, lists, cards). */ +export type ScheduleStatus = + | "active" + | "upcoming" + | "today" + | "soon" + | "finished" + | "past" + | "unscheduled"; + +export function scheduleStatusClass(status: ScheduleStatus | string): string { + if (status === "active") { + return "border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300"; + } + if (status === "today" || status === "upcoming" || status === "soon") { + return "border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300"; + } + return "border-muted bg-muted/50 text-muted-foreground"; +} + +export function scheduleStatusDotClass(status: ScheduleStatus | string): string { + if (status === "active") return "bg-emerald-600"; + if (status === "today" || status === "upcoming" || status === "soon") return "bg-amber-600"; + return "bg-muted-foreground"; +} diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index 97e89a5..ea5f243 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -28,6 +28,7 @@ import { cn } from "@/lib/cn"; import { examKindLabel } from "@/lib/exam-labels"; import { formatDateTime } from "@/lib/format"; import { hasMinRole } from "@/lib/roles"; +import { scheduleStatusClass, scheduleStatusDotClass } from "@/lib/schedule-status"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -478,12 +479,7 @@ function PortalCard(props: { card: PortalCardDef }) { function StatusDot(props: { status: AttentionKind }) { return (