fix(settings): every settings page renders the settings shell

Resources, branches, price lists, holidays and the new categories page sat
in the settings menu but rendered bare, so clicking one made the settings
sidebar disappear — the subscription page was the only one that kept it.

Eleven pages now wrap in SettingsLayout with the key of the menu entry they
belong to, and the four resource pages (list, types, skills, pools) share
one menu entry plus a sub-nav between them, rather than four entries that
would make the menu a third longer without making anything clearer.

.seg accepts `a` as well as `button`, and treats `active` as an alias of
`on`. Both were needed: cross-page tabs must be real links, and the pages
already using `active` (service detail, clinic appointment settings) had no
visible highlight at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-02 13:34:49 +03:30
co-authored by Claude Opus 5
parent f11514950e
commit 4380e64a5d
13 changed files with 1010 additions and 919 deletions
+64 -61
View File
@@ -7,6 +7,7 @@ import { usePermissions } from '../hooks/usePermissions';
import { useHolidays } from '../hooks/useResourceCalendar';
import { formatDate } from '../lib/utils';
import type { NationalHoliday } from '../types';
import SettingsLayout from '../components/layout/SettingsLayout';
/** سالِ شمسی جاری از همان فرمت‌کنندهٔ شمسیِ مرورگر گرفته می‌شود، نه با محاسبهٔ دستی. */
function currentJalaliYear(): number {
@@ -54,69 +55,71 @@ export default function HolidaysSettingsPage() {
const years = Array.from({ length: 5 }, (_, i) => thisYear - 1 + i);
return (
<div className="fade-in">
<PageHeader
title="تعطیلات رسمی"
description="تعطیلات کشوری برای همهٔ محیط‌ها اعمال می‌شود. اگر این محیط روزی را باز است، همین‌جا استثنا بزنید."
backTo="/admin/settings-menu"
/>
<SettingsLayout active="holidays">
<div className="fade-in">
<PageHeader
title="تعطیلات رسمی"
description="تعطیلات کشوری برای همهٔ محیط‌ها اعمال می‌شود. اگر این محیط روزی را باز است، همین‌جا استثنا بزنید."
backTo="/admin/settings-menu"
/>
<DataTable
columns={columns}
data={holidays}
loading={loading}
emptyMessage={`برای سال ${year} تعطیلی ثبت نشده است`}
headerExtra={
<div style={{ minWidth: 160, marginRight: 'auto' }}>
<SearchableSelect
options={years.map((y) => ({ value: String(y), label: String(y) }))}
value={String(year)}
onChange={(v) => setUrlState({ year: v ? String(v) : String(thisYear) })}
placeholder="سال"
height={36}
/>
</div>
}
actions={
canUpdate
? (h) => {
const override = overrideByDate.get(h.date);
return (
<div style={{ display: 'flex', gap: 6 }}>
{override?.is_working ? (
<button
type="button"
className="btn secondary sm"
disabled={removeOverride.isPending}
onClick={() => removeOverride.mutate(override.uuid)}
>
تعطیل کن
</button>
) : (
<button
type="button"
className="btn secondary sm"
disabled={setOverride.isPending}
onClick={() => setOverride.mutate({ date: h.date, is_working: true })}
>
این روز بازیم
</button>
)}
</div>
);
}
: undefined
}
/>
<DataTable
columns={columns}
data={holidays}
loading={loading}
emptyMessage={`برای سال ${year} تعطیلی ثبت نشده است`}
headerExtra={
<div style={{ minWidth: 160, marginRight: 'auto' }}>
<SearchableSelect
options={years.map((y) => ({ value: String(y), label: String(y) }))}
value={String(year)}
onChange={(v) => setUrlState({ year: v ? String(v) : String(thisYear) })}
placeholder="سال"
height={36}
/>
</div>
}
actions={
canUpdate
? (h) => {
const override = overrideByDate.get(h.date);
return (
<div style={{ display: 'flex', gap: 6 }}>
{override?.is_working ? (
<button
type="button"
className="btn secondary sm"
disabled={removeOverride.isPending}
onClick={() => removeOverride.mutate(override.uuid)}
>
تعطیل کن
</button>
) : (
<button
type="button"
className="btn secondary sm"
disabled={setOverride.isPending}
onClick={() => setOverride.mutate({ date: h.date, is_working: true })}
>
این روز بازیم
</button>
)}
</div>
);
}
: undefined
}
/>
<ClosureCard
overrides={overrides.filter((o) => !o.is_working)}
canUpdate={canUpdate}
saving={setOverride.isPending}
onAdd={(date, note) => setOverride.mutate({ date, is_working: false, note })}
onRemove={(uuid) => removeOverride.mutate(uuid)}
/>
</div>
<ClosureCard
overrides={overrides.filter((o) => !o.is_working)}
canUpdate={canUpdate}
saving={setOverride.isPending}
onAdd={(date, note) => setOverride.mutate({ date, is_working: false, note })}
onRemove={(uuid) => removeOverride.mutate(uuid)}
/>
</div>
</SettingsLayout>
);
}