From 0946d32273271b55963181149711d03171d2e8ce Mon Sep 17 00:00:00 2001 From: Jelaletdin12 Date: Thu, 4 Jun 2026 12:34:39 +0500 Subject: [PATCH] added profile page --- .lintstagedrc | 1 - src/app/router/index.tsx | 16 ++- src/layouts/DashboardLayout.tsx | 15 +- src/lib/i18n/locales/en.json | 3 +- src/lib/i18n/locales/ru.json | 3 +- src/lib/i18n/locales/tk.json | 3 +- src/pages/profile/index.tsx | 241 ++++++++++++++++++++++++++++++++ 7 files changed, 264 insertions(+), 18 deletions(-) create mode 100644 src/pages/profile/index.tsx diff --git a/.lintstagedrc b/.lintstagedrc index bd5a727..12c2351 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,6 +1,5 @@ { "*.{js,jsx,ts,tsx}": [ - "eslint --fix", "prettier --write" ], "*.{css,scss,md,json,html}": [ diff --git a/src/app/router/index.tsx b/src/app/router/index.tsx index b78b14e..90f0f01 100644 --- a/src/app/router/index.tsx +++ b/src/app/router/index.tsx @@ -108,6 +108,7 @@ const BackupsPage = lazy(() => import("@/pages/backups")); const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate")); const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView")); const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit")); +const ProfilePage = lazy(() => import("@/pages/profile")); // ─── Guards ─────────────────────────────────────────────────────────────────── @@ -145,8 +146,6 @@ type AppRoute = Omit & { children?: AppRoute[]; }; - - // ─── Helpers ────────────────────────────────────────────────────────────────── // Wraps a lazy page in Suspense — keeps route definitions clean @@ -178,9 +177,7 @@ const routes: AppRoute[] = [ children: [ { element: , - children: [ - { path: "/login", element: page(LoginPage) }, - ], + children: [{ path: "/login", element: page(LoginPage) }], }, ], }, @@ -576,6 +573,13 @@ const routes: AppRoute[] = [ ], }, + // ── PROFIL ──────────────────────────────────────────────────────── + { + path: "/profile", + handle: { title: (t) => t("profile.title", "Meniň profilim") }, + element: page(ProfilePage), + }, + // ── BEKAPLAR ────────────────────────────────────────────────────── { path: "/backups", @@ -775,4 +779,4 @@ const routes: AppRoute[] = [ }, ]; -export const router = createBrowserRouter(routes as RouteObject[]); \ No newline at end of file +export const router = createBrowserRouter(routes as RouteObject[]); diff --git a/src/layouts/DashboardLayout.tsx b/src/layouts/DashboardLayout.tsx index 13ebc9c..d663cf9 100644 --- a/src/layouts/DashboardLayout.tsx +++ b/src/layouts/DashboardLayout.tsx @@ -474,17 +474,19 @@ function AppSidebar() { {/* Footer — user block */} - {/* Items — trigger'dan ÖNCE render edilir, yukarı doğru açılır */}

{user?.name ?? "Admin"}

{user?.email ?? ""}

- + {t("profile.title", "Meniň profilim")} +
diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index 3fa3579..4fa78f8 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -1215,5 +1215,6 @@ "visaMasterSberSettings.createTitle": "Create setting", "visaMasterSberSettings.editTitle": "Edit setting", "onlinePayments.viewTitle": "Payment detail", - "cardTypes.viewTitle": "Card type detail" + "cardTypes.viewTitle": "Card type detail", + "profile.title": "My Profile" } diff --git a/src/lib/i18n/locales/ru.json b/src/lib/i18n/locales/ru.json index ebdbbfc..3bd8bd0 100644 --- a/src/lib/i18n/locales/ru.json +++ b/src/lib/i18n/locales/ru.json @@ -1216,5 +1216,6 @@ "visaMasterSberSettings.createTitle": "Создать настройку", "visaMasterSberSettings.editTitle": "Редактировать настройку", "onlinePayments.viewTitle": "Детали платежа", - "cardTypes.viewTitle": "Детали типа карты" + "cardTypes.viewTitle": "Детали типа карты", + "profile.title": "Мой профиль" } diff --git a/src/lib/i18n/locales/tk.json b/src/lib/i18n/locales/tk.json index 0c374f4..b71a1f5 100644 --- a/src/lib/i18n/locales/tk.json +++ b/src/lib/i18n/locales/tk.json @@ -1214,5 +1214,6 @@ "visaMasterSberSettings.createTitle": "Sazlama döretmek", "visaMasterSberSettings.editTitle": "Sazlama üýtgetmek", "onlinePayments.viewTitle": "Töleg giňišleýin", - "cardTypes.viewTitle": "Kart görnüşi giňişleýin" + "cardTypes.viewTitle": "Kart görnüşi giňişleýin", + "profile.title": "Meniň profilim" } diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx new file mode 100644 index 0000000..472f83e --- /dev/null +++ b/src/pages/profile/index.tsx @@ -0,0 +1,241 @@ +import { useState, useMemo } from "react"; +import { useNavigate } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import { Pencil, CheckCircle2, Eye, Trash2 } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Skeleton } from "@/components/ui/skeleton"; +import { Section, InfoRow, CollapsibleSection, EmptyState, AuditLog, type AuditRowProps } from "@/components/viewPageComponents"; +import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar"; +import { DataTable, type ColumnDef } from "@/components/dataTable"; +import { useAuthStore } from "@/app/store/authStore"; + +// ─── Types ──────────────────────────────────────────────────────────────────── + +interface RoleRow { + id: number; + code: string; + name: string; + guardName: string; +} + +// ─── Mock Data ──────────────────────────────────────────────────────────────── + +const MOCK_ROLES: RoleRow[] = [{ id: 2, code: "superadmin", name: "Superadmin", guardName: "web" }]; + +const MOCK_AUDIT: AuditRowProps[] = [ + { + id: "9043", + action: "Üýtgetmek", + by: "Nurmuhammet Allanov", + target: "Ulanyç: Nurmuhammet Allanov (nurmuhammet)", + status: "success", + date: "2026-06-04 10:23", + }, + { + id: "5869", + action: "Üýtgetmek", + by: "Nurmuhammet Allanov", + target: "Ulanyç: Nurmuhammet Allanov (nurmuhammet)", + status: "success", + date: "2026-06-03 14:11", + }, +]; + +// ─── ProfilePage ────────────────────────────────────────────────────────────── + +export default function ProfilePage() { + const { t } = useTranslation(); + const navigate = useNavigate(); + const user = useAuthStore((s) => s.user); + + const [roleSearch, setRoleSearch] = useState(""); + const [permSearch, setPermSearch] = useState(""); + const [branchSearch, setBranchSearch] = useState(""); + const [roleColVisibility, setRoleColVisibility] = useState({}); + const [roleColOrder, setRoleColOrder] = useState([]); + + // ── Role table columns (ColumnDef for DataTable) ─────────────────────────── + + const roleColumns: ColumnDef[] = useMemo( + () => [ + { + accessorKey: "id", + header: t("common.id", "ID"), + cell: ({ row }) => {row.original.id}, + size: 60, + }, + { + accessorKey: "code", + header: t("roles.fields.code", "KOD"), + cell: ({ row }) => {row.original.code}, + }, + { + accessorKey: "name", + header: t("roles.fields.name", "ADY"), + cell: ({ row }) => {row.original.name}, + }, + { + accessorKey: "guardName", + header: t("roles.fields.guardName", "GUARD NAME"), + cell: ({ row }) => {row.original.guardName}, + }, + { + id: "actions", + header: "", + enableHiding: false, + size: 90, + cell: () => ( +
+ + + +
+ ), + }, + ], + [t], + ); + + // ── ColumnMeta for DataTableToolbar ─────────────────────────────────────── + + const roleColumnMeta: ColumnMeta[] = useMemo( + () => [ + { id: "id", label: t("common.id", "ID") }, + { id: "code", label: t("roles.fields.code", "KOD") }, + { id: "name", label: t("roles.fields.name", "ADY") }, + { id: "guardName", label: t("roles.fields.guardName", "GUARD NAME") }, + ], + [t], + ); + + // ── Filtered roles ──────────────────────────────────────────────────────── + + const filteredRoles = useMemo(() => { + const q = roleSearch.toLowerCase().trim(); + if (!q) return MOCK_ROLES; + return MOCK_ROLES.filter( + (r) => r.code.toLowerCase().includes(q) || r.name.toLowerCase().includes(q) || r.guardName.toLowerCase().includes(q), + ); + }, [roleSearch]); + + // ── Loading skeleton ────────────────────────────────────────────────────── + + if (!user) { + return ( +
+ +
+ {Array.from({ length: 5 }).map((_, i) => ( +
+ + +
+ ))} +
+
+ ); + } + + return ( +
+ {/* ── Title + actions ──────────────────────────────────────────────── */} +
+

+ {t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name} +

+
+ +
+
+ + {/* ── Main info ────────────────────────────────────────────────────── */} +
+ + + + + + + + +
+ + {/* ── Rollar ───────────────────────────────────────────────────────── */} + + {}} + /> + String(row.id)} + currentPage={1} + totalPages={1} + totalCount={filteredRoles.length} + /> + + + {/* ── Rugsatlar ────────────────────────────────────────────────────── */} + + {}} + columnOrder={[]} + onColumnOrderChange={() => {}} + actionLabel={t("users.actions.addPermission", "Rugsat birikdiriň")} + onAction={() => {}} + /> + + + + {/* ── Şahamçalar ───────────────────────────────────────────────────── */} + + {}} + columnOrder={[]} + onColumnOrderChange={() => {}} + actionLabel={t("users.actions.addBranch", "Şahamça birikdiriň")} + onAction={() => {}} + /> + + + + {/* ── Ammallar ─────────────────────────────────────────────────────── */} + + + +
+ ); +}