👤 reorganize admin user details
Browse files at this commit451cb5872010b7a832f3e5faf315489865a6d42bParent: 6e2339e- feat
- 👤 reorganize admin user details
5 changed files +108 -61
- src/components/users/profile-form.tsx +1 -1
- src/i18n/locales/en.ts +3 -0
- src/i18n/locales/tr.ts +3 -0
- src/i18n/messages.ts +3 -0
- src/pages/admin-user-detail-page.tsx +98 -60
src/components/users/profile-form.tsxmodified+1 -1
| @@ -275,7 +275,7 @@ export function ProfileForm(props: { | |||
| 275 | </div> | 275 | </div> |
| 276 | {error() && <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>} | 276 | {error() && <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>} |
| 277 | <div class="!mt-auto sticky bottom-0 -mx-5 flex justify-end border-t border-border-hairline bg-surface-base px-5 pb-1 pt-4"> | 277 | <div class="!mt-auto sticky bottom-0 -mx-5 flex justify-end border-t border-border-hairline bg-surface-base px-5 pb-1 pt-4"> |
| 278 | - <Button type="submit" class="w-full sm:w-auto" disabled={pending()}>{t("common.save")}</Button> | 278 | + <Button type="submit" class="h-10 w-full sm:w-auto" disabled={pending()}>{t("common.save")}</Button> |
| 279 | </div> | 279 | </div> |
| 280 | </form> | 280 | </form> |
| 281 | ); | 281 | ); |
src/i18n/locales/en.tsmodified+3 -0
| @@ -1687,6 +1687,9 @@ export const en: Dict = { | |||
| 1687 | "admin.username": "Username", | 1687 | "admin.username": "Username", |
| 1688 | "admin.id": "Id", | 1688 | "admin.id": "Id", |
| 1689 | "admin.role": "Role", | 1689 | "admin.role": "Role", |
| 1690 | + "admin.personalDetails": "Personal details", | ||
| 1691 | + "admin.contactDetails": "Contact details", | ||
| 1692 | + "admin.accountAccess": "Account and access", | ||
| 1690 | "admin.directory": "Directory", | 1693 | "admin.directory": "Directory", |
| 1691 | "admin.helpTitle": "Role hierarchy", | 1694 | "admin.helpTitle": "Role hierarchy", |
| 1692 | "admin.helpBody": | 1695 | "admin.helpBody": |
src/i18n/locales/tr.tsmodified+3 -0
| @@ -1683,6 +1683,9 @@ export const tr: Dict = { | |||
| 1683 | "admin.username": "Kullanıcı adı", | 1683 | "admin.username": "Kullanıcı adı", |
| 1684 | "admin.id": "Id", | 1684 | "admin.id": "Id", |
| 1685 | "admin.role": "Rol", | 1685 | "admin.role": "Rol", |
| 1686 | + "admin.personalDetails": "Kişisel bilgiler", | ||
| 1687 | + "admin.contactDetails": "İletişim bilgileri", | ||
| 1688 | + "admin.accountAccess": "Hesap ve yetki", | ||
| 1686 | "admin.directory": "Kayıt listesi", | 1689 | "admin.directory": "Kayıt listesi", |
| 1687 | "admin.helpTitle": "Rol hiyerarşisi", | 1690 | "admin.helpTitle": "Rol hiyerarşisi", |
| 1688 | "admin.helpBody": | 1691 | "admin.helpBody": |
src/i18n/messages.tsmodified+3 -0
| @@ -1580,6 +1580,9 @@ export type MessageKey = | |||
| 1580 | | "admin.username" | 1580 | | "admin.username" |
| 1581 | | "admin.id" | 1581 | | "admin.id" |
| 1582 | | "admin.role" | 1582 | | "admin.role" |
| 1583 | + | "admin.personalDetails" | ||
| 1584 | + | "admin.contactDetails" | ||
| 1585 | + | "admin.accountAccess" | ||
| 1583 | | "admin.directory" | 1586 | | "admin.directory" |
| 1584 | | "admin.helpTitle" | 1587 | | "admin.helpTitle" |
| 1585 | | "admin.helpBody" | 1588 | | "admin.helpBody" |
src/pages/admin-user-detail-page.tsxmodified+98 -60
| @@ -7,8 +7,10 @@ import type { MessageKey } from "@/i18n/messages"; | |||
| 7 | import { PageHeader } from "@/components/layout/page-header"; | 7 | import { PageHeader } from "@/components/layout/page-header"; |
| 8 | import { Breadcrumbs } from "@/components/layout/breadcrumbs"; | 8 | import { Breadcrumbs } from "@/components/layout/breadcrumbs"; |
| 9 | import { RouteGuard } from "@/components/layout/route-guard"; | 9 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 10 | +import { RoleBadge } from "@/components/layout/role-badge"; | ||
| 10 | import { ParentStudentsPanel } from "@/components/users/parent-students-panel"; | 11 | import { ParentStudentsPanel } from "@/components/users/parent-students-panel"; |
| 11 | import { AdminUserEditPanel } from "@/components/users/admin-user-edit-panel"; | 12 | import { AdminUserEditPanel } from "@/components/users/admin-user-edit-panel"; |
| 13 | +import { UserAvatar } from "@/components/users/user-avatar"; | ||
| 12 | import { Alert } from "@/components/ui/alert"; | 14 | import { Alert } from "@/components/ui/alert"; |
| 13 | import { Button } from "@/components/ui/button"; | 15 | import { Button } from "@/components/ui/button"; |
| 14 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 16 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| @@ -67,73 +69,109 @@ function AdminUserDetailContent() { | |||
| 67 | <Show when={error()}> | 69 | <Show when={error()}> |
| 68 | <Alert variant="destructive">{error()}</Alert> | 70 | <Alert variant="destructive">{error()}</Alert> |
| 69 | </Show> | 71 | </Show> |
| 70 | - <section class="data-shell space-y-2 p-4 sm:p-5"> | 72 | + <div class="space-y-4 px-1 pt-1"> |
| 71 | <Breadcrumbs | 73 | <Breadcrumbs |
| 72 | items={[ | 74 | items={[ |
| 73 | { label: t("nav.users"), to: "/admin/users" }, | 75 | { label: t("nav.users"), to: "/admin/users" }, |
| 74 | { label: [current().name, current().surname].filter(Boolean).join(" ") || current().username }, | 76 | { label: [current().name, current().surname].filter(Boolean).join(" ") || current().username }, |
| 75 | ]} | 77 | ]} |
| 76 | /> | 78 | /> |
| 77 | - <PageHeader | 79 | + <div class="flex flex-wrap items-center gap-4"> |
| 78 | - title={[current().name, current().surname].filter(Boolean).join(" ") || current().username} | 80 | + <UserAvatar |
| 79 | - description={`@${current().username}`} | 81 | + userId={current().id} |
| 80 | - actions={ | 82 | + name={[current().name, current().surname].filter(Boolean).join(" ") || current().username} |
| 81 | - <> | 83 | + hasAvatar={profile.latest?.id === current().id ? profile.latest.avatar !== null : false} |
| 82 | - <Link to="/profile/$userId" params={{ userId: current().id }}> | 84 | + size="lg" |
| 83 | - <Button type="button" variant="ghost" size="sm"> | 85 | + /> |
| 84 | - <IconExternalLink class="h-4 w-4" /> | 86 | + <div class="min-w-0 flex-1"> |
| 85 | - {t("profile.viewProfile")} | 87 | + <PageHeader |
| 86 | - </Button> | 88 | + title={[current().name, current().surname].filter(Boolean).join(" ") || current().username} |
| 87 | - </Link> | 89 | + description={`@${current().username}`} |
| 88 | - <Button type="button" size="sm" onClick={() => setEditing(true)}> | 90 | + class="[&>div]:min-h-0" |
| 89 | - <IconEdit class="h-4 w-4" /> | 91 | + actions={ |
| 90 | - {t("common.edit")} | 92 | + <> |
| 91 | - </Button> | 93 | + <Link to="/profile/$userId" params={{ userId: current().id }}> |
| 92 | - <Show when={current().role === "parent"}> | 94 | + <Button type="button" variant="outline" class="h-9 rounded-lg"> |
| 93 | - <Button type="button" variant="outline" size="sm" onClick={() => setStudentsOpen(true)}> | 95 | + <IconExternalLink class="h-4 w-4" /> |
| 94 | - <IconUsers class="h-4 w-4" /> | 96 | + {t("profile.viewProfile")} |
| 95 | - {t("parentLink.manage")} | 97 | + </Button> |
| 96 | - </Button> | 98 | + </Link> |
| 97 | - </Show> | 99 | + <Show when={current().role === "parent"}> |
| 98 | - </> | 100 | + <Button type="button" variant="outline" class="h-9 rounded-lg" onClick={() => setStudentsOpen(true)}> |
| 99 | - } | 101 | + <IconUsers class="h-4 w-4" /> |
| 100 | - /> | 102 | + {t("parentLink.manage")} |
| 101 | - </section> | 103 | + </Button> |
| 104 | + </Show> | ||
| 105 | + <Button type="button" class="h-9 rounded-lg" onClick={() => setEditing(true)}> | ||
| 106 | + <IconEdit class="h-4 w-4" /> | ||
| 107 | + {t("common.edit")} | ||
| 108 | + </Button> | ||
| 109 | + </> | ||
| 110 | + } | ||
| 111 | + /> | ||
| 112 | + <div class="mt-2"> | ||
| 113 | + <RoleBadge role={current().role} /> | ||
| 114 | + </div> | ||
| 115 | + </div> | ||
| 116 | + </div> | ||
| 117 | + </div> | ||
| 102 | 118 | ||
| 103 | - <section class="data-shell grid gap-4 p-4 sm:grid-cols-2 sm:p-5 lg:grid-cols-3"> | 119 | + <div class="grid gap-4 lg:grid-cols-2"> |
| 104 | - <DetailField label={t("admin.username")} value={current().username} /> | 120 | + <section class="data-shell space-y-5 p-4 sm:p-5" aria-labelledby="admin-personal-details"> |
| 105 | - <DetailField label={t("profile.email")} value={current().email || "—"} /> | 121 | + <h2 id="admin-personal-details" class="text-sm font-semibold">{t("admin.personalDetails")}</h2> |
| 106 | - <DetailField label={t("profile.phone")} value={current().phone || "—"} /> | 122 | + <div class="grid gap-5 sm:grid-cols-2"> |
| 107 | - <DetailField label={t("profile.birthDate")} value={current().birth_date || "—"} /> | 123 | + <DetailField label={t("profile.birthDate")} value={current().birth_date || "—"} /> |
| 108 | - <DetailField label={t("profile.gender")} value={genderLabel(current().gender, t)} /> | 124 | + <DetailField label={t("profile.gender")} value={genderLabel(current().gender, t)} /> |
| 109 | - <DetailField label={t("profile.address")} value={current().address || "—"} /> | 125 | + <Show when={current().role === "student"}> |
| 110 | - <DetailField label={t("profile.emergencyContactName")} value={current().emergency_contact_name || "—"} /> | 126 | + <DetailField label={t("roster.studentNumber")} value={current().student_number || "—"} /> |
| 111 | - <DetailField label={t("profile.emergencyContactPhone")} value={current().emergency_contact_phone || "—"} /> | 127 | + </Show> |
| 112 | - <Show when={current().role === "student"}> | 128 | + <Show when={hasMinRole(current().role, "teacher")}> |
| 113 | - <DetailField label={t("roster.studentNumber")} value={current().student_number || "—"} /> | 129 | + <DetailField label={t("profile.branch")} value={profile.latest?.id === current().id ? profile.latest.branch || "—" : "—"} /> |
| 114 | - </Show> | 130 | + </Show> |
| 115 | - <Show when={hasMinRole(current().role, "teacher")}> | 131 | + </div> |
| 116 | - <DetailField label={t("profile.branch")} value={profile.latest?.branch || "—"} /> | 132 | + </section> |
| 117 | - </Show> | 133 | + |
| 118 | - <DetailField label={t("admin.id")} value={current().id} mono /> | 134 | + <section class="data-shell space-y-5 p-4 sm:p-5" aria-labelledby="admin-contact-details"> |
| 119 | - <div class="space-y-1.5"> | 135 | + <h2 id="admin-contact-details" class="text-sm font-semibold">{t("admin.contactDetails")}</h2> |
| 120 | - <p class="text-xs font-medium text-text-subtle">{t("admin.role")}</p> | 136 | + <div class="grid gap-5 sm:grid-cols-2"> |
| 121 | - <div class="flex gap-2"> | 137 | + <DetailField label={t("profile.email")} value={current().email || "—"} /> |
| 122 | - <Select | 138 | + <DetailField label={t("profile.phone")} value={current().phone || "—"} /> |
| 123 | - class="h-9" | 139 | + <div class="sm:col-span-2"> |
| 124 | - value={pendingRole()} | 140 | + <DetailField label={t("profile.address")} value={current().address || "—"} wrap /> |
| 125 | - disabled={current().id === auth.user()?.id} | 141 | + </div> |
| 126 | - onChange={(event) => setPendingRole(event.currentTarget.value as Role)} | 142 | + </div> |
| 127 | - > | 143 | + <div class="grid gap-5 border-t border-border-line pt-4 sm:grid-cols-2"> |
| 128 | - {ROLES.map((role) => <option value={role}>{t(`role.${role}` as MessageKey)}</option>)} | 144 | + <DetailField label={t("profile.emergencyContactName")} value={current().emergency_contact_name || "—"} /> |
| 129 | - </Select> | 145 | + <DetailField label={t("profile.emergencyContactPhone")} value={current().emergency_contact_phone || "—"} /> |
| 130 | - <Button | 146 | + </div> |
| 131 | - size="sm" | 147 | + </section> |
| 132 | - disabled={current().id === auth.user()?.id || pendingRole() === current().role} | 148 | + </div> |
| 133 | - onClick={() => setRoleConfirmOpen(true)} | 149 | + |
| 134 | - > | 150 | + <section class="data-shell space-y-5 p-4 sm:p-5" aria-labelledby="admin-account-access"> |
| 135 | - {t("common.update")} | 151 | + <h2 id="admin-account-access" class="text-sm font-semibold">{t("admin.accountAccess")}</h2> |
| 136 | - </Button> | 152 | + <div class="grid gap-5 sm:grid-cols-2 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(16rem,1.25fr)]"> |
| 153 | + <DetailField label={t("admin.username")} value={current().username} /> | ||
| 154 | + <DetailField label={t("admin.id")} value={current().id} mono wrap /> | ||
| 155 | + <div class="min-w-0 space-y-1.5"> | ||
| 156 | + <p class="text-xs font-medium text-muted-foreground">{t("admin.role")}</p> | ||
| 157 | + <div class="flex gap-2"> | ||
| 158 | + <Select | ||
| 159 | + aria-label={t("admin.role")} | ||
| 160 | + class="h-9" | ||
| 161 | + value={pendingRole()} | ||
| 162 | + disabled={current().id === auth.user()?.id} | ||
| 163 | + onChange={(event) => setPendingRole(event.currentTarget.value as Role)} | ||
| 164 | + > | ||
| 165 | + {ROLES.map((role) => <option value={role}>{t(`role.${role}` as MessageKey)}</option>)} | ||
| 166 | + </Select> | ||
| 167 | + <Button | ||
| 168 | + class="h-9 shrink-0 rounded-lg" | ||
| 169 | + disabled={current().id === auth.user()?.id || pendingRole() === current().role} | ||
| 170 | + onClick={() => setRoleConfirmOpen(true)} | ||
| 171 | + > | ||
| 172 | + {t("common.update")} | ||
| 173 | + </Button> | ||
| 174 | + </div> | ||
| 137 | </div> | 175 | </div> |
| 138 | </div> | 176 | </div> |
| 139 | </section> | 177 | </section> |