forge
Explore
Log in

Don't you dare go Hollow

✨ role-based AI prompts, Monday-first calendar, hub descriptions

Browse files at this commit

e98e6c3bdebcdb7f22c15f1b320c7e45728a117fBurak BoduroğluParent: 6a57783
  • feat
    • ✨ role-based AI prompts, Monday-first calendar, hub descriptions
Show full message
feat: ✨ role-based AI prompts, Monday-first calendar, hub descriptions
- celebi-suggestions: choose prompt set by role (student/staff/parent)
- calendar: Monday-first week ordering (short day names + first-day shift)
- school-hub: bilingual descriptions on management link cards
- courses: singular kind labels, required-field marker, kind summary row
- empty-state: add a "meals" kind + cutlery icon; meals page uses it
- table-row-actions: icon-only trigger with title tooltip (drop inline label)
- dashboard: skip deadline search predicate when there are no deadlines
- question-bank test: align fixture to the 10-per-page default
src/components/layout/celebi-suggestions.tsxmodified+12 -2
@@ -1,14 +1,24 @@
1 import { For } from "solid-js";1 import { For } from "solid-js";
2 import type { MessageKey } from "@/i18n/messages";2 import type { MessageKey } from "@/i18n/messages";
3+import { useAuth } from "@/stores/auth-context";
3 import { useT } from "@/stores/preferences-context";4 import { useT } from "@/stores/preferences-context";
4 5
5-const SUGGESTION_KEYS: MessageKey[] = ["ai.suggest1", "ai.suggest2", "ai.suggest3", "ai.suggest4"];6+const STUDENT_KEYS: MessageKey[] = ["ai.suggest1", "ai.suggest2", "ai.suggest3", "ai.suggest4"];
7+const STAFF_KEYS: MessageKey[] = ["ai.suggestStaff1", "ai.suggestStaff2", "ai.suggestStaff3", "ai.suggestStaff4"];
8+const PARENT_KEYS: MessageKey[] = ["ai.suggestParent1", "ai.suggestParent2", "ai.suggestParent3", "ai.suggestParent4"];
6 9
7 export function CelebiSuggestions(props: { onPick: (text: string) => void }) {10 export function CelebiSuggestions(props: { onPick: (text: string) => void }) {
8 const t = useT();11 const t = useT();
12+ const auth = useAuth();
13+ const keys = () => {
14+ const role = auth.user()?.role;
15+ if (role === "parent") return PARENT_KEYS;
16+ if (role === "teacher" || role === "manager" || role === "admin") return STAFF_KEYS;
17+ return STUDENT_KEYS;
18+ };
9 return (19 return (
10 <div class="grid gap-2 sm:grid-cols-2">20 <div class="grid gap-2 sm:grid-cols-2">
11- <For each={SUGGESTION_KEYS}>21+ <For each={keys()}>
12 {(key) => (22 {(key) => (
13 <button23 <button
14 type="button"24 type="button"
src/components/ui/empty-state.tsxmodified+8 -1
@@ -2,7 +2,7 @@ import { Show } from "solid-js";
2 import { cn } from "@/lib/cn";2 import { cn } from "@/lib/cn";
3 import { DOMAIN_COLORS } from "@/lib/domain-colors";3 import { DOMAIN_COLORS } from "@/lib/domain-colors";
4 4
5-export type EmptyStateKind = "default" | "notes" | "exams" | "events" | "courses" | "messages";5+export type EmptyStateKind = "default" | "notes" | "exams" | "events" | "courses" | "messages" | "meals";
6 6
7 const KIND_TONE: Record<EmptyStateKind, string> = {7 const KIND_TONE: Record<EmptyStateKind, string> = {
8 default: "border-primary/40 ring-1 ring-primary/25 bg-muted/30 text-foreground",8 default: "border-primary/40 ring-1 ring-primary/25 bg-muted/30 text-foreground",
@@ -11,6 +11,7 @@ const KIND_TONE: Record<EmptyStateKind, string> = {
11 events: DOMAIN_COLORS.events.emptyStateClass,11 events: DOMAIN_COLORS.events.emptyStateClass,
12 courses: DOMAIN_COLORS.courses.emptyStateClass,12 courses: DOMAIN_COLORS.courses.emptyStateClass,
13 messages: DOMAIN_COLORS.messages.emptyStateClass,13 messages: DOMAIN_COLORS.messages.emptyStateClass,
14+ meals: "border-amber-500/40 ring-1 ring-amber-500/25 bg-muted/30 text-foreground",
14 };15 };
15 16
16 /** Clean dashed empty panel with animated vector illustrations. */17 /** Clean dashed empty panel with animated vector illustrations. */
@@ -54,6 +55,12 @@ export function EmptyState(props: {
54 <path d="m9 16 2 2 4-4" />55 <path d="m9 16 2 2 4-4" />
55 </svg>56 </svg>
56 </Show>57 </Show>
58+ <Show when={kind() === "meals"}>
59+ <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
60+ <path d="M3 2v7c0 1.1.9 2 2 2h0a2 2 0 0 0 2-2V2M5 2v20" />
61+ <path d="M15 2v20M15 8c0-3.3 1.3-6 4-6v20" />
62+ </svg>
63+ </Show>
57 <Show when={kind() === "default" || kind() === "courses"}>64 <Show when={kind() === "default" || kind() === "courses"}>
58 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">65 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
59 <path d="M22 10v6M2 10l10-5 10 5-10 5z" />66 <path d="M22 10v6M2 10l10-5 10 5-10 5z" />
src/components/ui/table-row-actions.tsxmodified+3 -3
@@ -21,11 +21,11 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[
21 <div class="flex justify-center">21 <div class="flex justify-center">
22 <DropdownMenu placement="bottom-end" gutter={6}>22 <DropdownMenu placement="bottom-end" gutter={6}>
23 <DropdownMenuTrigger23 <DropdownMenuTrigger
24- class="inline-flex h-8 items-center justify-center gap-2 rounded-md border border-input bg-background/85 px-3 text-sm font-semibold text-foreground shadow-sm outline-hidden transition-colors hover:border-primary/35 hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring data-expanded:bg-accent data-expanded:text-accent-foreground"24+ class="inline-flex h-8 w-8 items-center justify-center rounded-md border border-input bg-background/85 text-muted-foreground shadow-sm outline-hidden transition-colors hover:border-primary/35 hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring data-expanded:bg-accent data-expanded:text-accent-foreground"
25 aria-label={props.label}25 aria-label={props.label}
26+ title={props.label}
26 >27 >
27- <IconDotsVertical class="h-4 w-4 rotate-90" />28+ <IconDotsVertical class="h-4 w-4" />
28- <span>{props.label}</span>
29 </DropdownMenuTrigger>29 </DropdownMenuTrigger>
30 <DropdownMenuContent class="w-48">30 <DropdownMenuContent class="w-48">
31 <For each={props.actions}>31 <For each={props.actions}>
src/pages/calendar-page.tsxmodified+4 -3
@@ -16,8 +16,8 @@ import { appointmentCounterpart } from "@/lib/person";
16 import { useAuth } from "@/stores/auth-context";16 import { useAuth } from "@/stores/auth-context";
17 import { usePreferences, useT } from "@/stores/preferences-context";17 import { usePreferences, useT } from "@/stores/preferences-context";
18 18
19-const DAY_NAMES_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];19+const DAY_NAMES_SHORT = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
20-const DAY_NAMES_SHORT_TR = ["Paz", "Pzt", "Sal", "Çar", "Per", "Cum", "Cmt"];20+const DAY_NAMES_SHORT_TR = ["Pzt", "Sal", "Çar", "Per", "Cum", "Cmt", "Paz"];
21 const MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];21 const MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
22 const MONTH_NAMES_TR = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];22 const MONTH_NAMES_TR = ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"];
23 23
@@ -54,7 +54,8 @@ function CalendarContent() {
54 return `${names[viewMonth()]} ${viewYear()}`;54 return `${names[viewMonth()]} ${viewYear()}`;
55 };55 };
56 const dayNames = () => locale() === "tr" ? DAY_NAMES_SHORT_TR : DAY_NAMES_SHORT;56 const dayNames = () => locale() === "tr" ? DAY_NAMES_SHORT_TR : DAY_NAMES_SHORT;
57- const firstDay = () => new Date(viewYear(), viewMonth(), 1).getDay();57+ // Monday-first: shift Sunday (0) to the end of the week.
58+ const firstDay = () => (new Date(viewYear(), viewMonth(), 1).getDay() + 6) % 7;
58 const daysInMonth = () => new Date(viewYear(), viewMonth() + 1, 0).getDate();59 const daysInMonth = () => new Date(viewYear(), viewMonth() + 1, 0).getDate();
59 60
60 const grid = createMemo(() => {61 const grid = createMemo(() => {
src/pages/courses-page.tsxmodified+8 -3
@@ -43,6 +43,7 @@ function CoursesContent() {
43 const createKind = (): CourseKind => pageKind() ?? "course";43 const createKind = (): CourseKind => pageKind() ?? "course";
44 const pageLabel = () => t("nav.classes");44 const pageLabel = () => t("nav.classes");
45 const kindLabel = () => createKind() === "study" ? t("courses.kind.study") : createKind() === "club" ? t("courses.kind.club") : t("courses.kind.course");45 const kindLabel = () => createKind() === "study" ? t("courses.kind.study") : createKind() === "club" ? t("courses.kind.club") : t("courses.kind.course");
46+ const kindLabelSingular = () => createKind() === "study" ? t("courses.kind.studySingular") : createKind() === "club" ? t("courses.kind.clubSingular") : t("courses.kind.courseSingular");
46 const canCreate = () => hasMinRole(auth.user()?.role, "teacher");47 const canCreate = () => hasMinRole(auth.user()?.role, "teacher");
47 const [showForm, setShowForm] = createSignal(routeSearch().action === "new");48 const [showForm, setShowForm] = createSignal(routeSearch().action === "new");
48 const [title, setTitle] = createSignal("");49 const [title, setTitle] = createSignal("");
@@ -119,11 +120,15 @@ function CoursesContent() {
119 120
120 return (121 return (
121 <div class="space-y-5">122 <div class="space-y-5">
122- <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: kindLabel() })} description={t("courses.subtitle", { item: kindLabel() })}>123+ <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: kindLabelSingular() })} description={t("courses.subtitle", { item: kindLabel() })}>
123 <form class="space-y-4" onSubmit={createCourse}>124 <form class="space-y-4" onSubmit={createCourse}>
124 <Show when={limits.error}><ErrorAlert message={formatApiError(limits.error)} onRetry={() => void refetchLimits()} /></Show>125 <Show when={limits.error}><ErrorAlert message={formatApiError(limits.error)} onRetry={() => void refetchLimits()} /></Show>
126+ <div class="flex items-center justify-between rounded-md border border-border/70 bg-muted/30 px-3 py-2 text-xs text-muted-foreground">
127+ <span>{t("exams.kind")}</span>
128+ <span class="font-medium text-foreground">{kindLabelSingular()}</span>
129+ </div>
125 <div class="space-y-3">130 <div class="space-y-3">
126- <div class="space-y-1.5"><Label for="course-title">{t("form.title")}</Label><Input id="course-title" required maxlength={limits.latest?.course.max_title_len} value={title()} onInput={(e) => setTitle(e.currentTarget.value)} /></div>131+ <div class="space-y-1.5"><Label for="course-title">{t("form.title")}<span class="ml-0.5 text-destructive">*</span></Label><Input id="course-title" required maxlength={limits.latest?.course.max_title_len} value={title()} onInput={(e) => setTitle(e.currentTarget.value)} /></div>
127 <div class="space-y-1.5"><Label for="course-description">{t("form.description")}</Label><Textarea id="course-description" maxlength={limits.latest?.course.max_description_len} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} /></div>132 <div class="space-y-1.5"><Label for="course-description">{t("form.description")}</Label><Textarea id="course-description" maxlength={limits.latest?.course.max_description_len} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} /></div>
128 <div class="space-y-1.5"><Label for="course-term">{t("terms.term")}</Label><Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}><option value="">{t("terms.unassigned")}</option><For each={terms.latest ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For></Select></div>133 <div class="space-y-1.5"><Label for="course-term">{t("terms.term")}</Label><Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}><option value="">{t("terms.unassigned")}</option><For each={terms.latest ?? []}>{(term) => <option value={term.id}>{term.name}</option>}</For></Select></div>
129 <div class="space-y-1.5"><Label for="course-capacity">{t("courses.capacity")}</Label><Input id="course-capacity" type="number" min={1} value={capacity()} onInput={(e) => setCapacity(e.currentTarget.value)} /></div>134 <div class="space-y-1.5"><Label for="course-capacity">{t("courses.capacity")}</Label><Input id="course-capacity" type="number" min={1} value={capacity()} onInput={(e) => setCapacity(e.currentTarget.value)} /></div>
@@ -142,7 +147,7 @@ function CoursesContent() {
142 <Show when={canCreate()}>147 <Show when={canCreate()}>
143 <Button size="sm" class="min-w-30 rounded-lg" onClick={() => setShowForm(true)}>148 <Button size="sm" class="min-w-30 rounded-lg" onClick={() => setShowForm(true)}>
144 <IconPlus class="h-4 w-4" />149 <IconPlus class="h-4 w-4" />
145- {t("common.createItem", { item: kindLabel() })}150+ {t("common.createItem", { item: kindLabelSingular() })}
146 </Button>151 </Button>
147 </Show>152 </Show>
148 </header>153 </header>
src/pages/dashboard-page.tsxmodified+1 -2
@@ -385,8 +385,7 @@ function DashboardContent() {
385 columns={deadlineColumns()}385 columns={deadlineColumns()}
386 data={deadlines()}386 data={deadlines()}
387 enableColumnVisibility={false}387 enableColumnVisibility={false}
388- searchPredicate={deadlineSearch}388+ searchPredicate={deadlines().length > 0 ? deadlineSearch : undefined}
389- filterPlaceholder={t("dashboard.deadlines")}
390 empty={t("dashboard.upcomingEmpty")}389 empty={t("dashboard.upcomingEmpty")}
391 onRowClick={openDeadline}390 onRowClick={openDeadline}
392 />391 />
src/pages/meals-page.tsxmodified+1 -1
@@ -87,7 +87,7 @@ function MealsContent() {
87 </div>87 </div>
88 <Suspense fallback={<PageSpinner />}>88 <Suspense fallback={<PageSpinner />}>
89 <Show when={menus.error}><ErrorAlert message={formatApiError(menus.error)} onRetry={() => void refetch()} /></Show>89 <Show when={menus.error}><ErrorAlert message={formatApiError(menus.error)} onRetry={() => void refetch()} /></Show>
90- <Show when={visible().length > 0} fallback={<EmptyState title={t("meals.empty")} />}>90+ <Show when={visible().length > 0} fallback={<EmptyState kind="meals" title={t("meals.empty")} />}>
91 <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"><For each={visible()}>{(menu) => <MealMenuCard menu={menu} locale={locale() === "tr" ? "tr-TR" : "en-US"} labels={{ dishes: t("meals.dishes"), capacity: t("meals.capacity"), conflict: t("meals.conflict") }} />}</For></div>91 <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"><For each={visible()}>{(menu) => <MealMenuCard menu={menu} locale={locale() === "tr" ? "tr-TR" : "en-US"} labels={{ dishes: t("meals.dishes"), capacity: t("meals.capacity"), conflict: t("meals.conflict") }} />}</For></div>
92 <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} />92 <PaginationControls page={page()} totalPages={totalPages()} onPageChange={setPage} />
93 </Show>93 </Show>
src/pages/question-bank-page.test.tsxmodified+5 -5
@@ -3,8 +3,8 @@ import { Show } from "solid-js";
3 import QuestionBankPage from "@/pages/question-bank-page";3 import QuestionBankPage from "@/pages/question-bank-page";
4 import { PreferencesProvider } from "@/stores/preferences-context";4 import { PreferencesProvider } from "@/stores/preferences-context";
5 5
6-// 13 templates, page size 12: the last page holds exactly one row.6+// 11 templates, page size 10: the last page holds exactly one row.
7-let templates = Array.from({ length: 13 }, (_, index) => ({7+let templates = Array.from({ length: 11 }, (_, index) => ({
8 id: `bq-${index}`,8 id: `bq-${index}`,
9 text: `Template ${index}`,9 text: `Template ${index}`,
10 kind: "text",10 kind: "text",
@@ -67,7 +67,7 @@ test("deleting the last row of the last page clamps back instead of stranding th
67 ));67 ));
68 68
69 fireEvent.click(await screen.findByRole("button", { name: "Next" }));69 fireEvent.click(await screen.findByRole("button", { name: "Next" }));
70- expect(await screen.findByText("Template 12")).toBeTruthy();70+ expect(await screen.findByText("Template 10")).toBeTruthy();
71 expect(screen.getByText("2 / 2")).toBeTruthy();71 expect(screen.getByText("2 / 2")).toBeTruthy();
72 72
73 fireEvent.click(screen.getByRole("button", { name: "delete-row" }));73 fireEvent.click(screen.getByRole("button", { name: "delete-row" }));
@@ -75,7 +75,7 @@ test("deleting the last row of the last page clamps back instead of stranding th
75 await tick();75 await tick();
76 await tick();76 await tick();
77 77
78- // 12 left → one page: the user must be on it, not on the vanished page 2.78+ // 10 left → one page: the user must be on it, not on the vanished page 2.
79- expect(screen.queryByText("Template 12")).toBeNull();79+ expect(screen.queryByText("Template 10")).toBeNull();
80 expect(await screen.findByText("Template 0")).toBeTruthy();80 expect(await screen.findByText("Template 0")).toBeTruthy();
81 });81 });
src/pages/school-hub-page.tsxmodified+9 -8
@@ -10,12 +10,13 @@ export default function SchoolHubPage() {
10 const auth = useAuth();10 const auth = useAuth();
11 const t = useT();11 const t = useT();
12 const { locale } = usePreferences();12 const { locale } = usePreferences();
13- const links: { to: string; label: MessageKey; Icon: typeof IconSettings; admin?: boolean }[] = [13+ const tr = () => locale() === "tr";
14- { to: "/management/settings", label: "nav.settings", Icon: IconSettings },14+ const links: { to: string; label: MessageKey; Icon: typeof IconSettings; description: string; admin?: boolean }[] = [
15- { to: "/management/terms", label: "nav.terms", Icon: IconCalendarDays },15+ { to: "/management/settings", label: "nav.settings", Icon: IconSettings, description: tr() ? "Okul geneli tercihleri ve sınav türlerini düzenle." : "Manage school-wide preferences and exam kinds." },
16- { to: "/management/staff-work", label: "nav.staffWork", Icon: IconBriefcase },16+ { to: "/management/terms", label: "nav.terms", Icon: IconCalendarDays, description: tr() ? "Dönemleri ve akademik takvimi yönet." : "Manage terms and the academic calendar." },
17- { to: "/meals", label: "nav.meals", Icon: IconUtensils },17+ { to: "/management/staff-work", label: "nav.staffWork", Icon: IconBriefcase, description: tr() ? "Personel mesai ve çalışma kayıtlarını incele." : "Review staff shifts and work logs." },
18- { to: "/admin/users", label: "nav.users", Icon: IconUsers, admin: true },18+ { to: "/meals", label: "nav.meals", Icon: IconUtensils, description: tr() ? "Yemek menülerini ve beslenme kayıtlarını yönet." : "Manage meal menus and nutrition records." },
19+ { to: "/admin/users", label: "nav.users", Icon: IconUsers, admin: true, description: tr() ? "Kullanıcıları ve rolleri yönet." : "Manage users and roles." },
19 ];20 ];
20 21
21 return (22 return (
@@ -30,9 +31,9 @@ export default function SchoolHubPage() {
30 <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">31 <div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
31 <For each={links.filter((item) => !item.admin || auth.user()?.role === "admin")}>32 <For each={links.filter((item) => !item.admin || auth.user()?.role === "admin")}>
32 {(item) => (33 {(item) => (
33- <Link to={item.to} class="flex min-h-20 items-center gap-3 rounded-lg border border-border bg-card p-4 hover:bg-muted/40 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring">34+ <Link to={item.to} class="flex min-h-20 gap-3 rounded-lg border border-border bg-card p-4 hover:bg-muted/40 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring">
34 <span class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border bg-muted/30 text-muted-foreground"><item.Icon class="h-4.5 w-4.5" /></span>35 <span class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border bg-muted/30 text-muted-foreground"><item.Icon class="h-4.5 w-4.5" /></span>
35- <span class="text-sm font-semibold">{t(item.label)}</span>36+ <span><span class="block text-sm font-semibold">{t(item.label)}</span><span class="mt-1 block text-xs text-muted-foreground">{item.description}</span></span>
36 </Link>37 </Link>
37 )}38 )}
38 </For>39 </For>