diff --git a/README.md b/README.md index c215f75..d1d86ee 100644 --- a/README.md +++ b/README.md @@ -495,9 +495,9 @@ All authenticated routes are nested under `DashboardLayout`. The full list: /card-pins/:id/edit /visa-master (list route — note: different from CRUD base) -/visa-master-payments/create -/visa-master-payments/:id -/visa-master-payments/:id/edit +/visa-master/create +/visa-master/:id +/visa-master/:id/edit /sber-payments /sber-payments/create @@ -616,7 +616,6 @@ These items exist in the sidebar nav or codebase but are **not yet implemented** | **`/settings/language/resources`** | ❌ No route or page | Same as above | | **`/backups`** | ❌ No route or page | Sidebar entry exists | | **`/logs`** | ❌ No route or page | Sidebar entry exists | -| **`/visa-master` route inconsistency** | ⚠️ Minor | List route is `/visa-master` but CRUD routes use `/visa-master-payments/…` | | **`client.ts` uses `any`** | ⚠️ | `failedQueue: any[]` violates the no-`any` rule — should be typed | | **`authStore` role type** | ⚠️ | `role: 'admin' \| 'manager' \| 'viewer'` — actual role enforcement (RBAC) not wired to UI | | **`auth:unauthorized` / `auth:forbidden` events** | ⚠️ | Dispatched in `client.ts` but no global listener is registered in `App.tsx` or the router | diff --git a/src/app/router/index.tsx b/src/app/router/index.tsx index f342435..b78b14e 100644 --- a/src/app/router/index.tsx +++ b/src/app/router/index.tsx @@ -1,5 +1,6 @@ import { lazy, Suspense } from "react"; import { createBrowserRouter, Navigate, Outlet } from "react-router-dom"; +import type { RouteObject } from "react-router-dom"; import { useAuthStore } from "../store/authStore"; import { Spinner } from "@/components/ui/spinner"; import { DashboardLayout } from "@/layouts/DashboardLayout"; @@ -12,127 +13,104 @@ const DashboardPage = lazy(() => import("@/pages/dashboard")); const LoanOrdersPage = lazy(() => import("@/pages/loanDepartment/loanOrders")); const LoanOrderMobilesPage = lazy(() => import("@/pages/loanDepartment/loanOrderMobile")); const LoanRemainingPage = lazy(() => import("@/pages/loanDepartment/loanRemaining")); - const LoanRemainingCreatePage = lazy(() => import("@/pages/loanDepartment/loanRemainingCreate")); const LoanRemainingViewPage = lazy(() => import("@/pages/loanDepartment/loanRemainingView")); const LoanRemainingEditPage = lazy(() => import("@/pages/loanDepartment/loanRemainingEdit")); - const LoanPaidOffLettersPage = lazy(() => import("@/pages/loanDepartment/loanPaidOffLetters")); const LoanPaidOffLettersCreatePage = lazy(() => import("@/pages/loanDepartment/loanPaidOffLettersCreate")); const LoanPaidOffLettersViewPage = lazy(() => import("@/pages/loanDepartment/loanPaidOffLettersView")); const LoanPaidOffLettersEditPage = lazy(() => import("@/pages/loanDepartment/loanPaidOffLettersEdit")); - const LoanOrderCreatePage = lazy(() => import("@/pages/loanDepartment/loanOrderCreate")); const LoanOrderViewPage = lazy(() => import("@/pages/loanDepartment/loanOrderView")); const LoanOrderMobileViewPage = lazy(() => import("@/pages/loanDepartment/loanOrderMobileView")); const LoanOrderMobileEditPage = lazy(() => import("@/pages/loanDepartment/loanOrderMobileEdit")); const LoanOrderMobileCreatePage = lazy(() => import("@/pages/loanDepartment/loanOrderMobileCreate")); const LoanOrderEditPage = lazy(() => import("@/pages/loanDepartment/loanOrderEdit")); - const OrderNewCardPage = lazy(() => import("@/pages/cardDepartment/orderNewCard")); const OrderNewCardCreatePage = lazy(() => import("@/pages/cardDepartment/orderNewCardCreate")); const OrderNewCardViewPage = lazy(() => import("@/pages/cardDepartment/orderNewCardView")); const OrderNewCardEditPage = lazy(() => import("@/pages/cardDepartment/orderNewCardEdit")); - const CardTransactionsPage = lazy(() => import("@/pages/cardDepartment/cardTransactions")); const CardTransactionViewPage = lazy(() => import("@/pages/cardDepartment/cardTransactionsView")); const CardTransactionCreatePage = lazy(() => import("@/pages/cardDepartment/cardTransactionsCreate")); const CardTransactionEditPage = lazy(() => import("@/pages/cardDepartment/cardTransactionsEdit")); - const CardRequisitesPage = lazy(() => import("@/pages/cardDepartment/cardRequisites")); const CardRequisiteViewPage = lazy(() => import("@/pages/cardDepartment/cardRequisitesView")); const CardRequisiteCreatePage = lazy(() => import("@/pages/cardDepartment/cardRequisitesCreate")); const CardRequisiteEditPage = lazy(() => import("@/pages/cardDepartment/cardRequisitesEdit")); - const CardBalancePage = lazy(() => import("@/pages/cardDepartment/cardBalance")); const CardBalanceCreatePage = lazy(() => import("@/pages/cardDepartment/cardBalanceCreate")); const CardBalanceViewPage = lazy(() => import("@/pages/cardDepartment/cardBalanceView")); const CardBalanceEditPage = lazy(() => import("@/pages/cardDepartment/cardBalanceEdit")); - const CardPinsPage = lazy(() => import("@/pages/cardDepartment/cardPins")); const CardPinsCreatePage = lazy(() => import("@/pages/cardDepartment/cardPinsCreate")); const CardPinsViewPage = lazy(() => import("@/pages/cardDepartment/cardPinsView")); const CardPinsEditPage = lazy(() => import("@/pages/cardDepartment/cardPinsEdit")); - const VisaMasterPaymentsPage = lazy(() => import("@/pages/internationalPayments/visaMasterPayments")); const VisaMasterPaymentCreatePage = lazy(() => import("@/pages/internationalPayments/visaMasterPaymentsCreate")); const VisaMasterPaymentViewPage = lazy(() => import("@/pages/internationalPayments/visaMasterPaymentsView")); const VisaMasterPaymentEditPage = lazy(() => import("@/pages/internationalPayments/visaMasterPaymentsEdit")); - const SberPaymentPage = lazy(() => import("@/pages/internationalPayments/sberPayments")); const SberPaymentCreatePage = lazy(() => import("@/pages/internationalPayments/sberPaymentsCreate")); const SberPaymentViewPage = lazy(() => import("@/pages/internationalPayments/sberPaymentsView")); const SberPaymentEditPage = lazy(() => import("@/pages/internationalPayments/sberPaymentsEdit")); - const OperatorsPage = lazy(() => import("@/pages/users/operators")); const OperatorCreatePage = lazy(() => import("@/pages/users/operatorsCreate")); const OperatorsViewPage = lazy(() => import("@/pages/users/operatorsView")); const OperatorEditPage = lazy(() => import("@/pages/users/operatorsEdit")); - const AllUsersPage = lazy(() => import("@/pages/users/allUsers")); const AllUserCreatePage = lazy(() => import("@/pages/users/allUsersCreate")); const AllUsersViewPage = lazy(() => import("@/pages/users/allUsersView")); const AllUserEditPage = lazy(() => import("@/pages/users/allUsersEdit")); - const ClientsPage = lazy(() => import("@/pages/users/clients")); const ClientCreatePage = lazy(() => import("@/pages/users/clientsCreate")); const ClientViewPage = lazy(() => import("@/pages/users/clientsView")); const ClientEditPage = lazy(() => import("@/pages/users/clientsEdit")); - const CurrencyRatesPage = lazy(() => import("@/pages/currencies/currencyRates")); const CurrencyRateCreatePage = lazy(() => import("@/pages/currencies/currencyRatesCreate")); const CurrencyRateViewPage = lazy(() => import("@/pages/currencies/currencyRatesView")); const CurrencyRateEditPage = lazy(() => import("@/pages/currencies/currencyRatesEdit")); - const VisaMasterSberSettingsPage = lazy(() => import("@/pages/currencies/visaMasterSberSettings")); const VisaMasterSberSettingCreatePage = lazy(() => import("@/pages/currencies/visaMasterSberSettingsCreate")); const VisaMasterSberSettingEditPage = lazy(() => import("@/pages/currencies/visaMasterSberSettingsEdit")); - const OnlinePaymentsHistoryPage = lazy(() => import("@/pages/onlinePaymentsHistory")); const OnlinePaymentsHistoryViewPage = lazy(() => import("@/pages/onlinePaymentsHistory/onlinePaymenHistoryView")); - const RolesPage = lazy(() => import("@/pages/settings/users/roles")); const RoleCreatePage = lazy(() => import("@/pages/settings/users/createRole")); const RoleViewPage = lazy(() => import("@/pages/settings/users/rolesView")); const RoleEditPage = lazy(() => import("@/pages/settings/users/editRole")); - const PermissionsPage = lazy(() => import("@/pages/settings/users/permissions")); const PermissionCreatePage = lazy(() => import("@/pages/settings/users/permissionsCreate")); const PermissionsViewPage = lazy(() => import("@/pages/settings/users/permissionsView")); const PermissionEditPage = lazy(() => import("@/pages/settings/users/permissionsEdit")); - const LoanTypesPage = lazy(() => import("@/pages/settings/loan/loanTypes")); const LoanTypeCreatePage = lazy(() => import("@/pages/settings/loan/loanTypesCreate")); const LoanTypesViewPage = lazy(() => import("@/pages/settings/loan/loanTypesView")); const LoanTypeEditPage = lazy(() => import("@/pages/settings/loan/loanTypesEdit")); - const RequiredDocumentsPage = lazy(() => import("@/pages/settings/loan/requiredDocuments")); const RequiredDocumentCreatePage = lazy(() => import("@/pages/settings/loan/requiredDocumentsCreate")); const RequiredDocumentsViewPage = lazy(() => import("@/pages/settings/loan/requiredDocumentsView")); const RequiredDocumentEditPage = lazy(() => import("@/pages/settings/loan/requiredDocumentsEdit")); - const CardReasonsPage = lazy(() => import("@/pages/settings/card/reasons")); const CardReasonCreatePage = lazy(() => import("@/pages/settings/card/reasonsCreate")); const CardReasonsViewPage = lazy(() => import("@/pages/settings/card/reasonsView")); const CardReasonEditPage = lazy(() => import("@/pages/settings/card/reasonsEdit")); - const CardTypesPage = lazy(() => import("@/pages/settings/card/cardTypes")); const CardTypeCreatePage = lazy(() => import("@/pages/settings/card/cardTypesCreate")); const CardTypesViewPage = lazy(() => import("@/pages/settings/card/cardTypesView")); const CardTypeEditPage = lazy(() => import("@/pages/settings/card/cardTypesEdit")); - const DistrictsPage = lazy(() => import("@/pages/settings/location/districts")); const DistrictCreatePage = lazy(() => import("@/pages/settings/location/districtsCreate")); const DistrictsViewPage = lazy(() => import("@/pages/settings/location/districtsView")); const DistrictEditPage = lazy(() => import("@/pages/settings/location/districtsEdit")); - const BranchesPage = lazy(() => import("@/pages/settings/location/branches")); - 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")); +// ─── Guards ─────────────────────────────────────────────────────────────────── + function AuthGuard() { const isAuthenticated = useAuthStore((s) => s.isAuthenticated); if (!isAuthenticated) return ; @@ -153,24 +131,55 @@ function PageLoader() { ); } -export const router = createBrowserRouter([ +// ─── Types ──────────────────────────────────────────────────────────────────── + +type TitleFn = (t: (key: string, fallback: string) => string) => string; + +type AppHandle = { + title: TitleFn; + indexPath?: string; +}; + +type AppRoute = Omit & { + handle?: AppHandle; + children?: AppRoute[]; +}; + + + +// ─── Helpers ────────────────────────────────────────────────────────────────── + +// Wraps a lazy page in Suspense — keeps route definitions clean +function page(Component: React.LazyExoticComponent) { + return ( + }> + + + ); +} + +// Pathless wrapper route — carries breadcrumb title, renders children via Outlet +function bc(titleFn: TitleFn, indexPath?: string): AppRoute { + return { + element: , + handle: { + title: titleFn, + indexPath, + }, + }; +} + +// ─── Router ─────────────────────────────────────────────────────────────────── + +const routes: AppRoute[] = [ { element: , errorElement: , children: [ { - // AuthLayout: semantic wrapper for all public/unauthenticated pages. - // Login manages its own full-screen layout internally. element: , children: [ - { - path: "/login", - element: ( - }> - - - ), - }, + { path: "/login", element: page(LoginPage) }, ], }, ], @@ -183,815 +192,578 @@ export const router = createBrowserRouter([ element: , errorElement: , children: [ - { - path: "/dashboard", - element: ( - }> - - - ), - }, - { path: "/", element: }, - // ── KARZ BÖLÜMI ────────────────────────────────────────────────── { - path: "/loan-orders", - element: ( - }> - - - ), - }, - { - path: "/loan-orders/:id", - element: ( - }> - - - ), - }, - { - path: "/loan-orders/create", - element: ( - }> - - - ), - }, - { - path: "/loan-orders/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /loan-order-mobiles - path: "/loan-order-mobiles", - element: ( - }> - - - ), - }, - { - path: "/loan-order-mobiles/:id", - element: ( - }> - - - ), - }, - { - path: "/loan-order-mobiles/create", - element: ( - }> - - - ), - }, - { - path: "/loan-order-mobiles/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /loan-remaining - path: "/loan-remaining", - element: ( - }> - - - ), - }, - { - path: "/loan-remaining/create", - element: ( - }> - - - ), - }, - { - path: "/loan-remaining/:id", - element: ( - }> - - - ), - }, - { - path: "/loan-remaining/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /loan-paid-off-letters - path: "/loan-paid-off-letters", - element: ( - }> - - - ), - }, - { - path: "/loan-paid-off-letters/create", - element: ( - }> - - - ), - }, - { - path: "/loan-paid-off-letters/:id", - element: ( - }> - - - ), - }, - { - path: "/loan-paid-off-letters/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /order-new-card - path: "/order-new-card", - element: ( - }> - - - ), - }, - { - path: "/order-new-card/create", - element: ( - }> - - - ), - }, - { - path: "/order-new-card/:id", - element: ( - }> - - - ), - }, - { - path: "/order-new-card/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/card-transactions", - element: ( - }> - - - ), - }, - { - path: "/card-transactions/create", - element: ( - }> - - - ), - }, - { - path: "/card-transactions/:id", - element: ( - }> - - - ), - }, - { - path: "/card-transactions/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/card-requisites", - element: ( - }> - - - ), - }, - { - path: "/card-requisites/create", - element: ( - }> - - - ), - }, - { - path: "/card-requisites/:id", - element: ( - }> - - - ), - }, - { - path: "/card-requisites/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/card-balances", - element: ( - }> - - - ), - }, - { - path: "/card-balances/create", - element: ( - }> - - - ), - }, - { - path: "/card-balances/:id", - element: ( - }> - - - ), - }, - { - path: "/card-balances/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/card-pins", - element: ( - }> - - - ), - }, - { - path: "/card-pins/create", - element: ( - }> - - - ), - }, - { - path: "/card-pins/:id", - element: ( - }> - - - ), - }, - { - path: "/card-pins/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /visa-master-payments - path: "/visa-master", - element: ( - }> - - - ), - }, - { - path: "/visa-master-payments/create", - element: ( - }> - - - ), - }, - { - path: "/visa-master-payments/:id", - element: ( - }> - - - ), - }, - { - path: "/visa-master-payments/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /sber-payments - path: "/sber-payments", - element: ( - }> - - - ), - }, - { - path: "/sber-payments/create", - element: ( - }> - - - ), - }, - { - path: "/sber-payments/:id", - element: ( - }> - - - ), - }, - { - path: "/sber-payments/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /operators - path: "/operators", - element: ( - }> - - - ), - }, - { - path: "/operators/create", - element: ( - }> - - - ), - }, - { - path: "/operators/:id", - element: ( - }> - - - ), - }, - { - path: "/operators/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /all-users - path: "/all-users", - element: ( - }> - - - ), - }, - { - path: "/all-users/create", - element: ( - }> - - - ), - }, - { - path: "/all-users/:id", - element: ( - }> - - - ), - }, - { - path: "/all-users/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /clients - path: "/clients", - element: ( - }> - - - ), - }, - { - path: "/clients/create", - element: ( - }> - - - ), - }, - { - path: "/clients/:id", - element: ( - }> - - - ), - }, - { - path: "/clients/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /currencies-rates - path: "/currency-rates", - element: ( - }> - - - ), - }, - { - path: "/currency-rates/create", - element: ( - }> - - - ), - }, - { - path: "/currency-rates/:id", - element: ( - }> - - - ), - }, - { - path: "/currency-rates/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /visa-master-sber-settings - path: "/visa-master-sber-settings", - element: ( - }> - - - ), - }, - { - path: "/visa-master-sber-settings/create", - element: ( - }> - - - ), - }, - { - path: "/visa-master-sber-settings/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/online-payments-history", - element: ( - }> - - - ), - }, - { - path: "/online-payments-history/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/users/roles", - element: ( - }> - - - ), - }, - { - path: "/settings/users/roles/create", - element: ( - }> - - - ), - }, - { - path: "/settings/users/roles/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/users/roles/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/settings/users/permissions", - element: ( - }> - - - ), - }, - { - path: "/settings/users/permissions/create", - element: ( - }> - - - ), - }, - { - path: "/settings/users/permissions/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/users/permissions/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/loan-types", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/loan-types/create", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/loan-types/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/loan-types/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/required-documents", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/required-documents/create", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/required-documents/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/loan/required-documents/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-reasons", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-reasons/create", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-reasons/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-reasons/:id/edit", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-types", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-types/create", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-types/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/card/card-types/:id/edit", - element: ( - }> - - - ), - }, - { - // Sidebar: /settings/location/districts - path: "/settings/location/districts", - element: ( - }> - - - ), - }, - { - path: "/settings/location/districts/create", - element: ( - }> - - - ), - }, - { - path: "/settings/location/districts/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/location/districts/:id/edit", - element: ( - }> - - - ), - }, + path: "/dashboard", + handle: { title: (t) => t("nav.dashboard", "Baş sahypa") }, + element: page(DashboardPage), + }, + + // ── KARZ SARGYTLARY ─────────────────────────────────────────────── + { + ...bc((t) => t("loanOrders.title", "Karz sargytlary"), "/loan-orders"), + children: [ + { path: "/loan-orders", element: page(LoanOrdersPage) }, + { + path: "/loan-orders/create", + handle: { title: (t) => t("loanOrders.createTitle", "Karz sargyt döretmek") }, + element: page(LoanOrderCreatePage), + }, + { + path: "/loan-orders/:id", + handle: { title: (t) => t("loanOrders.viewTitle", "Karz sargyt giňişleýin") }, + element: page(LoanOrderViewPage), + }, + { + path: "/loan-orders/:id/edit", + handle: { title: (t) => t("loanOrders.editTitle", "Karz sargyt üýtgetmek") }, + element: page(LoanOrderEditPage), + }, + ], + }, + + // ── KARZ SARGYT (MOBILE) ────────────────────────────────────────── + { + ...bc((t) => t("loanOrderMobiles.title", "Karz sargytlary (Mobile)"), "/loan-order-mobiles"), + children: [ + { path: "/loan-order-mobiles", element: page(LoanOrderMobilesPage) }, + { + path: "/loan-order-mobiles/create", + handle: { title: (t) => t("loanOrderMobiles.createTitle", "Karz sargyt döretmek (Mobile)") }, + element: page(LoanOrderMobileCreatePage), + }, + { + path: "/loan-order-mobiles/:id", + handle: { title: (t) => t("loanOrderMobiles.viewTitle", "Karz sargyt giňişleýin (Mobile)") }, + element: page(LoanOrderMobileViewPage), + }, + { + path: "/loan-order-mobiles/:id/edit", + handle: { title: (t) => t("loanOrderMobiles.editTitle", "Karz sargyt üýtgetmek (Mobile)") }, + element: page(LoanOrderMobileEditPage), + }, + ], + }, + + // ── KARZYŇ GALYNDYSY ────────────────────────────────────────────── + { + ...bc((t) => t("loanRemaining.title", "Karzyň galyndysy"), "/loan-remaining"), + children: [ + { path: "/loan-remaining", element: page(LoanRemainingPage) }, + { + path: "/loan-remaining/create", + handle: { title: (t) => t("loanRemaining.createTitle", "Karz galyndy döretmek") }, + element: page(LoanRemainingCreatePage), + }, + { + path: "/loan-remaining/:id", + handle: { title: (t) => t("loanRemaining.viewTitle", "Karz galyndy giňişleýin") }, + element: page(LoanRemainingViewPage), + }, + { + path: "/loan-remaining/:id/edit", + handle: { title: (t) => t("loanRemaining.editTitle", "Karz galyndy üýtgetmek") }, + element: page(LoanRemainingEditPage), + }, + ], + }, + + // ── GÜWANAMALAR ─────────────────────────────────────────────────── + { + ...bc((t) => t("loanPaidOffLetters.title", "Güwanamalar"), "/loan-paid-off-letters"), + children: [ + { path: "/loan-paid-off-letters", element: page(LoanPaidOffLettersPage) }, + { + path: "/loan-paid-off-letters/create", + handle: { title: (t) => t("loanPaidOffLetters.createTitle", "Güwanama döretmek") }, + element: page(LoanPaidOffLettersCreatePage), + }, + { + path: "/loan-paid-off-letters/:id", + handle: { title: (t) => t("loanPaidOffLetters.viewTitle", "Güwanama giňişleýin") }, + element: page(LoanPaidOffLettersViewPage), + }, + { + path: "/loan-paid-off-letters/:id/edit", + handle: { title: (t) => t("loanPaidOffLetters.editTitle", "Güwanama üýtgetmek") }, + element: page(LoanPaidOffLettersEditPage), + }, + ], + }, + + // ── TÄZE KART AÇMAK ─────────────────────────────────────────────── + { + ...bc((t) => t("cardOrder.title", "Täze kart açmak"), "/order-new-card"), + children: [ + { path: "/order-new-card", element: page(OrderNewCardPage) }, + { + path: "/order-new-card/create", + handle: { title: (t) => t("cardOrder.createTitle", "Kart sargyt döretmek") }, + element: page(OrderNewCardCreatePage), + }, + { + path: "/order-new-card/:id", + handle: { title: (t) => t("cardOrder.viewTitle", "Kart sargyt giňişleýin") }, + element: page(OrderNewCardViewPage), + }, + { + path: "/order-new-card/:id/edit", + handle: { title: (t) => t("cardOrder.editTitle", "Kart sargyt üýtgetmek") }, + element: page(OrderNewCardEditPage), + }, + ], + }, + + // ── KART HEREKETLERI ────────────────────────────────────────────── + { + ...bc((t) => t("cardTransactions.title", "Kart hereketleri"), "/card-transactions"), + children: [ + { path: "/card-transactions", element: page(CardTransactionsPage) }, + { + path: "/card-transactions/create", + handle: { title: (t) => t("cardTransactions.createTitle", "Kart herekedi döretmek") }, + element: page(CardTransactionCreatePage), + }, + { + path: "/card-transactions/:id", + handle: { title: (t) => t("cardTransactions.viewTitle", "Kart hereketi giňişleýin") }, + element: page(CardTransactionViewPage), + }, + { + path: "/card-transactions/:id/edit", + handle: { title: (t) => t("cardTransactions.editTitle", "Kart herekedi üýtgetmek") }, + element: page(CardTransactionEditPage), + }, + ], + }, + + // ── KART REKWIZITLER ────────────────────────────────────────────── + { + ...bc((t) => t("cardRequisites.title", "Kart rekwizitler"), "/card-requisites"), + children: [ + { path: "/card-requisites", element: page(CardRequisitesPage) }, + { + path: "/card-requisites/create", + handle: { title: (t) => t("cardRequisites.createTitle", "Kart rekwizit döretmek") }, + element: page(CardRequisiteCreatePage), + }, + { + path: "/card-requisites/:id", + handle: { title: (t) => t("cardRequisites.viewTitle", "Kart rekwizit giňişleýin") }, + element: page(CardRequisiteViewPage), + }, + { + path: "/card-requisites/:id/edit", + handle: { title: (t) => t("cardRequisites.editTitle", "Kart rekwizit üýtgetmek") }, + element: page(CardRequisiteEditPage), + }, + ], + }, + + // ── KART GALYNDYLARY ────────────────────────────────────────────── + { + ...bc((t) => t("cardBalance.title", "Kart galyndylary"), "/card-balances"), + children: [ + { path: "/card-balances", element: page(CardBalancePage) }, + { + path: "/card-balances/create", + handle: { title: (t) => t("cardBalance.createTitle", "Kart galyndy döretmek") }, + element: page(CardBalanceCreatePage), + }, + { + path: "/card-balances/:id", + handle: { title: (t) => t("cardBalance.viewTitle", "Kart galyndy giňişleýin") }, + element: page(CardBalanceViewPage), + }, + { + path: "/card-balances/:id/edit", + handle: { title: (t) => t("cardBalance.editTitle", "Kart galyndy üýtgetmek") }, + element: page(CardBalanceEditPage), + }, + ], + }, + + // ── KART PIN BUKJALAR ───────────────────────────────────────────── + { + ...bc((t) => t("cardPins.title", "Kart pin bukjalar"), "/card-pins"), + children: [ + { path: "/card-pins", element: page(CardPinsPage) }, + { + path: "/card-pins/create", + handle: { title: (t) => t("cardPins.createTitle", "Kart pin bukja döretmek") }, + element: page(CardPinsCreatePage), + }, + { + path: "/card-pins/:id", + handle: { title: (t) => t("cardPins.viewTitle", "Kart pin bukja giňişleýin") }, + element: page(CardPinsViewPage), + }, + { + path: "/card-pins/:id/edit", + handle: { title: (t) => t("cardPins.editTitle", "Kart pin bukja üýtgetmek") }, + element: page(CardPinsEditPage), + }, + ], + }, + + // ── VISA/MASTER TÖLEGLERI ───────────────────────────────────────── + { + ...bc((t) => t("visaMaster.title", "Visa/Master tölegleri"), "/visa-master"), + children: [ + { path: "/visa-master", element: page(VisaMasterPaymentsPage) }, + { + path: "/visa-master/create", + handle: { title: (t) => t("visaMaster.createTitle", "Visa/Master töleg döretmek") }, + element: page(VisaMasterPaymentCreatePage), + }, + { + path: "/visa-master/:id", + handle: { title: (t) => t("visaMaster.viewTitle", "Visa/Master töleg giňişleýin") }, + element: page(VisaMasterPaymentViewPage), + }, + { + path: "/visa-master/:id/edit", + handle: { title: (t) => t("visaMaster.editTitle", "Visa/Master töleg üýtgetmek") }, + element: page(VisaMasterPaymentEditPage), + }, + ], + }, + + // ── SBER TÖLEGLER ───────────────────────────────────────────────── + { + ...bc((t) => t("sberPayments.title", "Sber tölegler"), "/sber-payments"), + children: [ + { path: "/sber-payments", element: page(SberPaymentPage) }, + { + path: "/sber-payments/create", + handle: { title: (t) => t("sberPayments.createTitle", "Sber töleg döretmek") }, + element: page(SberPaymentCreatePage), + }, + { + path: "/sber-payments/:id", + handle: { title: (t) => t("sberPayments.viewTitle", "Sber töleg giňişleýin") }, + element: page(SberPaymentViewPage), + }, + { + path: "/sber-payments/:id/edit", + handle: { title: (t) => t("sberPayments.editTitle", "Sber töleg üýtgetmek") }, + element: page(SberPaymentEditPage), + }, + ], + }, + + // ── OPERATORLAR ─────────────────────────────────────────────────── + { + ...bc((t) => t("operators.title", "Operatorlar"), "/operators"), + children: [ + { path: "/operators", element: page(OperatorsPage) }, + { + path: "/operators/create", + handle: { title: (t) => t("operators.createTitle", "Operator döretmek") }, + element: page(OperatorCreatePage), + }, + { + path: "/operators/:id", + handle: { title: (t) => t("operators.viewTitle", "Operator giňişleýin") }, + element: page(OperatorsViewPage), + }, + { + path: "/operators/:id/edit", + handle: { title: (t) => t("operators.editTitle", "Operator üýtgetmek") }, + element: page(OperatorEditPage), + }, + ], + }, + + // ── ÄHLI ULANYJYLAR ─────────────────────────────────────────────── + { + ...bc((t) => t("allUsers.title", "Ähli ulanyjylar"), "/all-users"), + children: [ + { path: "/all-users", element: page(AllUsersPage) }, + { + path: "/all-users/create", + handle: { title: (t) => t("allUsers.createTitle", "Ulanyjy döretmek") }, + element: page(AllUserCreatePage), + }, + { + path: "/all-users/:id", + handle: { title: (t) => t("allUsers.viewTitle", "Ulanyjy giňişleýin") }, + element: page(AllUsersViewPage), + }, + { + path: "/all-users/:id/edit", + handle: { title: (t) => t("allUsers.editTitle", "Ulanyjy üýtgetmek") }, + element: page(AllUserEditPage), + }, + ], + }, + + // ── MÜŞDERILER ──────────────────────────────────────────────────── + { + ...bc((t) => t("clients.title", "Müşderiler"), "/clients"), + children: [ + { path: "/clients", element: page(ClientsPage) }, + { + path: "/clients/create", + handle: { title: (t) => t("clients.createTitle", "Müşderi döretmek") }, + element: page(ClientCreatePage), + }, + { + path: "/clients/:id", + handle: { title: (t) => t("clients.viewTitle", "Müşderi giňişleýin") }, + element: page(ClientViewPage), + }, + { + path: "/clients/:id/edit", + handle: { title: (t) => t("clients.editTitle", "Müşderi üýtgetmek") }, + element: page(ClientEditPage), + }, + ], + }, + + // ── WALÝUTA KURSLARY ────────────────────────────────────────────── + { + ...bc((t) => t("currencyRates.title", "Walýuta kurslary"), "/currency-rates"), + children: [ + { path: "/currency-rates", element: page(CurrencyRatesPage) }, + { + path: "/currency-rates/create", + handle: { title: (t) => t("currencyRates.createTitle", "Walýuta kursy döretmek") }, + element: page(CurrencyRateCreatePage), + }, + { + path: "/currency-rates/:id", + handle: { title: (t) => t("currencyRates.viewTitle", "Walýuta kursy giňişleýin") }, + element: page(CurrencyRateViewPage), + }, + { + path: "/currency-rates/:id/edit", + handle: { title: (t) => t("currencyRates.editTitle", "Walýuta kursy üýtgetmek") }, + element: page(CurrencyRateEditPage), + }, + ], + }, + + // ── VISA/MASTER, SBER SAZLAMALARY ───────────────────────────────── + { + ...bc((t) => t("visaMasterSberSettings.title", "Visa/Master, Sber sazlamalary"), "/visa-master-sber-settings"), + children: [ + { path: "/visa-master-sber-settings", element: page(VisaMasterSberSettingsPage) }, + { + path: "/visa-master-sber-settings/create", + handle: { title: (t) => t("visaMasterSberSettings.createTitle", "Sazlama döretmek") }, + element: page(VisaMasterSberSettingCreatePage), + }, + { + path: "/visa-master-sber-settings/:id/edit", + handle: { title: (t) => t("visaMasterSberSettings.editTitle", "Sazlama üýtgetmek") }, + element: page(VisaMasterSberSettingEditPage), + }, + ], + }, + + // ── ONLAÝN TÖLEG TARYHY ─────────────────────────────────────────── + { + ...bc((t) => t("onlinePayments.title", "Onlaýn töleg taryhy"), "/online-payments-history"), + children: [ + { path: "/online-payments-history", element: page(OnlinePaymentsHistoryPage) }, + { + path: "/online-payments-history/:id", + handle: { title: (t) => t("onlinePayments.viewTitle", "Töleg giňišleýin") }, + element: page(OnlinePaymentsHistoryViewPage), + }, + ], + }, + + // ── BEKAPLAR ────────────────────────────────────────────────────── { - // Sidebar: /backups path: "/backups", - element: ( - }> - - - ), + handle: { title: (t) => t("backups.title", "Bekaplar") }, + element: page(BackupsPage), }, + + // ── SAZLAMALAR > ULANYJYLAR ─────────────────────────────────────── { - // Sidebar: /settings/location/branches - path: "/settings/location/branches", - element: ( - }> - - - ), - }, - { - path: "/settings/location/branches/create", - element: ( - }> - - - ), - }, - { - path: "/settings/location/branches/:id", - element: ( - }> - - - ), - }, - { - path: "/settings/location/branches/:id/edit", - element: ( - }> - - - ), + ...bc((t) => t("nav.settings", "Sazlamalar")), + children: [ + // Roles + { + ...bc((t) => t("roles.title", "Rollar"), "/settings/users/roles"), + children: [ + { path: "/settings/users/roles", element: page(RolesPage) }, + { + path: "/settings/users/roles/create", + handle: { title: (t) => t("roles.createTitle", "Rol döretmek") }, + element: page(RoleCreatePage), + }, + { + path: "/settings/users/roles/:id", + handle: { title: (t) => t("roles.viewTitle", "Rol giňişleýin") }, + element: page(RoleViewPage), + }, + { + path: "/settings/users/roles/:id/edit", + handle: { title: (t) => t("roles.editTitle", "Rol üýtgetmek") }, + element: page(RoleEditPage), + }, + ], + }, + // Permissions + { + ...bc((t) => t("permissions.title", "Rugsatlar"), "/settings/users/permissions"), + children: [ + { path: "/settings/users/permissions", element: page(PermissionsPage) }, + { + path: "/settings/users/permissions/create", + handle: { title: (t) => t("permissions.createTitle", "Rugsat döretmek") }, + element: page(PermissionCreatePage), + }, + { + path: "/settings/users/permissions/:id", + handle: { title: (t) => t("permissions.viewTitle", "Rugsat giňişleýin") }, + element: page(PermissionsViewPage), + }, + { + path: "/settings/users/permissions/:id/edit", + handle: { title: (t) => t("permissions.editTitle", "Rugsat üýtgetmek") }, + element: page(PermissionEditPage), + }, + ], + }, + // Loan types + { + ...bc((t) => t("loanTypes.title", "Karz görnüşleri"), "/settings/loan/loan-types"), + children: [ + { path: "/settings/loan/loan-types", element: page(LoanTypesPage) }, + { + path: "/settings/loan/loan-types/create", + handle: { title: (t) => t("loanTypes.createTitle", "Karz görnüşi döretmek") }, + element: page(LoanTypeCreatePage), + }, + { + path: "/settings/loan/loan-types/:id", + handle: { title: (t) => t("loanTypes.viewTitle", "Karz görnüşi giňişleýin") }, + element: page(LoanTypesViewPage), + }, + { + path: "/settings/loan/loan-types/:id/edit", + handle: { title: (t) => t("loanTypes.editTitle", "Karz görnüşi üýtgetmek") }, + element: page(LoanTypeEditPage), + }, + ], + }, + // Required documents + { + ...bc((t) => t("requiredDocuments.title", "Gerekli resminamalar"), "/settings/loan/required-documents"), + children: [ + { path: "/settings/loan/required-documents", element: page(RequiredDocumentsPage) }, + { + path: "/settings/loan/required-documents/create", + handle: { title: (t) => t("requiredDocuments.createTitle", "Resminama döretmek") }, + element: page(RequiredDocumentCreatePage), + }, + { + path: "/settings/loan/required-documents/:id", + handle: { title: (t) => t("requiredDocuments.viewTitle", "Resminama giňişleýin") }, + element: page(RequiredDocumentsViewPage), + }, + { + path: "/settings/loan/required-documents/:id/edit", + handle: { title: (t) => t("requiredDocuments.editTitle", "Resminama üýtgetmek") }, + element: page(RequiredDocumentEditPage), + }, + ], + }, + // Card reasons + { + ...bc((t) => t("cardReasons.title", "Kart çykarylyş sebäpleri"), "/settings/card/card-reasons"), + children: [ + { path: "/settings/card/card-reasons", element: page(CardReasonsPage) }, + { + path: "/settings/card/card-reasons/create", + handle: { title: (t) => t("cardReasons.createTitle", "Sebäp döretmek") }, + element: page(CardReasonCreatePage), + }, + { + path: "/settings/card/card-reasons/:id", + handle: { title: (t) => t("cardReasons.viewTitle", "Sebäp giňişleýin") }, + element: page(CardReasonsViewPage), + }, + { + path: "/settings/card/card-reasons/:id/edit", + handle: { title: (t) => t("cardReasons.editTitle", "Sebäp üýtgetmek") }, + element: page(CardReasonEditPage), + }, + ], + }, + // Card types + { + ...bc((t) => t("cardTypes.title", "Kart görnüşleri"), "/settings/card/card-types"), + children: [ + { path: "/settings/card/card-types", element: page(CardTypesPage) }, + { + path: "/settings/card/card-types/create", + handle: { title: (t) => t("cardTypes.createTitle", "Kart görnüşi döretmek") }, + element: page(CardTypeCreatePage), + }, + { + path: "/settings/card/card-types/:id", + handle: { title: (t) => t("cardTypes.viewTitle", "Kart görnüşi giňişleýin") }, + element: page(CardTypesViewPage), + }, + { + path: "/settings/card/card-types/:id/edit", + handle: { title: (t) => t("cardTypes.editTitle", "Kart görnüşi üýtgetmek") }, + element: page(CardTypeEditPage), + }, + ], + }, + // Districts + { + ...bc((t) => t("districts.title", "Etraplar"), "/settings/location/districts"), + children: [ + { path: "/settings/location/districts", element: page(DistrictsPage) }, + { + path: "/settings/location/districts/create", + handle: { title: (t) => t("districts.createTitle", "Etrap döretmek") }, + element: page(DistrictCreatePage), + }, + { + path: "/settings/location/districts/:id", + handle: { title: (t) => t("districts.viewTitle", "Etrap giňişleýin") }, + element: page(DistrictsViewPage), + }, + { + path: "/settings/location/districts/:id/edit", + handle: { title: (t) => t("districts.editTitle", "Etrap üýtgetmek") }, + element: page(DistrictEditPage), + }, + ], + }, + // Branches + { + ...bc((t) => t("branches.title", "Şahamçalar"), "/settings/location/branches"), + children: [ + { path: "/settings/location/branches", element: page(BranchesPage) }, + { + path: "/settings/location/branches/create", + handle: { title: (t) => t("branches.createTitle", "Şahamça döretmek") }, + element: page(BranchCreatePage), + }, + { + path: "/settings/location/branches/:id", + handle: { title: (t) => t("branches.viewTitle", "Şahamça giňišleýin") }, + element: page(BranchesViewPage), + }, + { + path: "/settings/location/branches/:id/edit", + handle: { title: (t) => t("branches.editTitle", "Şahamça üýtgetmek") }, + element: page(BranchEditPage), + }, + ], + }, + ], }, ], }, @@ -1001,4 +773,6 @@ export const router = createBrowserRouter([ path: "*", element: , }, -]); +]; + +export const router = createBrowserRouter(routes as RouteObject[]); \ No newline at end of file diff --git a/src/components/multiLangInput.tsx b/src/components/multiLangInput.tsx new file mode 100644 index 0000000..b55c9bb --- /dev/null +++ b/src/components/multiLangInput.tsx @@ -0,0 +1,53 @@ +import { FormInput, } from '@/components/formInput' + +export interface MultiLangField { + value: string; + onChange: (v: string) => void; + error?: string; +} + +export interface MultiLangInputProps { + fields: { + tk: MultiLangField; + ru: MultiLangField; + en: MultiLangField; + }; + placeholder?: string; + disabled?: boolean; + type?: 'text' | 'textarea'; + rows?: number; +} + +export function MultiLangInput({ fields, placeholder, disabled, type = 'text', rows }: MultiLangInputProps) { + const langs = [ + { code: 'TK', key: 'tk' as const }, + { code: 'RU', key: 'ru' as const }, + { code: 'EN', key: 'en' as const }, + ]; + + return ( +
+ {langs.map(({ code, key }) => { + const field = fields[key]; + return ( +
+ + {code} + +
+ +
+
+ ) + })} +
+ ) +} diff --git a/src/components/viewPageComponents.tsx b/src/components/viewPageComponents.tsx index f1d18ac..971b447 100644 --- a/src/components/viewPageComponents.tsx +++ b/src/components/viewPageComponents.tsx @@ -1,6 +1,47 @@ import { Download, Eye, ChevronRight } from "lucide-react"; import { useTranslation } from "react-i18next"; +// ─── BentoGrid ──────────────────────────────────────────────────────────────── + +export function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { + const colClass = { + 1: "grid-cols-1", + 2: "grid-cols-1 sm:grid-cols-2", + 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", + 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", + }[cols] + return
{children}
+} + +// ─── BentoCard ──────────────────────────────────────────────────────────────── + +interface BentoCardProps { + title?: string; + span?: "full" | 2 | 3; + children: React.ReactNode; + noPadding?: boolean; +} + +export function BentoCard({ title, span, children, noPadding }: BentoCardProps) { + const spanClass = + span === "full" ? "sm:col-span-full" : + span === 2 ? "sm:col-span-2" : + span === 3 ? "sm:col-span-3" : "" + + return ( +
+ {title && ( +
+

+ {title} +

+
+ )} + {noPadding ?
{children}
: children} +
+ ) +} + // ─── InfoRow ────────────────────────────────────────────────────────────────── // Supports both: // @@ -15,21 +56,21 @@ export interface InfoRowProps { isLink?: boolean; } + +// ─── InfoRow ────────────────────────────────────────────────────────────────── export function InfoRow({ label, value, children, isLink }: InfoRowProps) { const content = children ?? (value != null ? String(value) : null); return ( -
- {label} +
+ {label} {content != null && content !== "" ? ( typeof content === "string" ? ( - + {content} ) : ( -
{content}
+
{content}
) ) : ( — @@ -38,6 +79,48 @@ export function InfoRow({ label, value, children, isLink }: InfoRowProps) { ); } +// ─── MultiLangRow ───────────────────────────────────────────────────────────── + +export interface MultiLangRowProps { + label: string; + value?: { tk?: string; ru?: string; en?: string } | null; +} + +export function MultiLangRow({ label, value }: MultiLangRowProps) { + if (!value) { + return ; + } + + const langs = [ + { code: "TK", val: value.tk }, + { code: "RU", val: value.ru }, + { code: "EN", val: value.en }, + ]; + + const hasAny = langs.some((l) => l.val); + + return ( +
+ {label} +
+ {langs.map((l) => + l.val ? ( +
+ + {l.code} + + + {l.val} + +
+ ) : null + )} + {!hasAny && —} +
+
+ ); +} + // ─── Section ────────────────────────────────────────────────────────────────── // title is optional — omit or pass empty string to skip the heading @@ -70,13 +153,14 @@ export interface PassportImageProps { url?: string | null; } +// ─── PassportImage ──────────────────────────────────────────────────────────── export function PassportImage({ label, src, url }: PassportImageProps) { const { t } = useTranslation(); const imageSrc = src ?? url ?? null; return ( -
- {label} +
+ {label}
{imageSrc ? ( ) return result } -type FormErrors = FlatErrors - -// ─── Lang Tab ───────────────────────────────────────────────────────────────── - -type LangKey = 'tk' | 'ru' | 'en' - -const LANG_TABS: { key: LangKey; label: string }[] = [ - { key: 'tk', label: 'Türkmen' }, - { key: 'ru', label: 'Русский' }, - { key: 'en', label: 'English' }, -] // ─── CardReasonForm ───────────────────────────────────────────────────────────── @@ -79,8 +69,6 @@ export function CardReasonForm({ mode, initialData }: CardReasonFormProps) { const form = watch() const errors = useMemo(() => flattenErrors(rhfErrors as Record), [rhfErrors]) - const [activeLang, setActiveLang] = useState('tk') - const set = useCallback((key: K, value: CardReasonFormData[K]) => { (setValue as (name: K, val: CardReasonFormData[K]) => void)(key, value) clearErrors(key) @@ -111,11 +99,11 @@ export function CardReasonForm({ mode, initialData }: CardReasonFormProps) { } } - const nameFieldKey = `name${activeLang.charAt(0).toUpperCase() + activeLang.slice(1)}` as - | 'nameTk' - | 'nameRu' - | 'nameEn' - const nameErrorKey = nameFieldKey as keyof FormErrors + const nameFields = { + tk: { value: form.nameTk, onChange: (v: string) => set('nameTk', v), error: errors.nameTk }, + ru: { value: form.nameRu, onChange: (v: string) => set('nameRu', v), error: errors.nameRu }, + en: { value: form.nameEn, onChange: (v: string) => set('nameEn', v), error: errors.nameEn }, + } return (
@@ -125,39 +113,15 @@ export function CardReasonForm({ mode, initialData }: CardReasonFormProps) { : t('reasons.editTitle', 'Sebäp üýtgetmek')}
- {/* Language tabs */} -
- {LANG_TABS.map((tab) => ( - - ))} -
- {/* Form rows */}
{/* Name row */} -
- +
+ {t('CardReasons.fields.name', 'Ady')} * - set(nameFieldKey, v)} - placeholder={t('CardReasons.fields.name', 'Ady')} - error={errors[nameErrorKey]} - /> +
{/* Value row */} diff --git a/src/features/cardTypes/components/cardTypesForm.tsx b/src/features/cardTypes/components/cardTypesForm.tsx index 947a10b..48f8a27 100644 --- a/src/features/cardTypes/components/cardTypesForm.tsx +++ b/src/features/cardTypes/components/cardTypesForm.tsx @@ -1,4 +1,4 @@ -import { useState, useCallback, useMemo, useEffect } from 'react' +import { useCallback, useMemo, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useForm } from 'react-hook-form' @@ -6,6 +6,7 @@ import { zodResolver } from '@hookform/resolvers/zod' import { Checkbox } from '@/components/ui/checkbox' import { FormActions } from '@/components/formActions' import { FormInput } from '@/components/formInput' +import { MultiLangInput } from '@/components/multiLangInput' import type { CardType } from '../api/cardTypesApi' import { useCreateCardType, useUpdateCardType } from '../hooks/useCardTypes' import { createCardTypeFormSchema, DEFAULT_FORM_VALUES, buildPayload } from '../schemas/cardType.schema' @@ -18,14 +19,6 @@ export interface CardTypeFormProps { initialData?: CardType } -type LangKey = 'tk' | 'ru' | 'en' - -const LANG_TABS: { key: LangKey; label: string }[] = [ - { key: 'tk', label: 'Türkmen' }, - { key: 'ru', label: 'Русский' }, - { key: 'en', label: 'English' }, -] - // ─── Helpers ────────────────────────────────────────────────────────────────── function mapInitial(data: CardType): CardTypeFormData { @@ -65,8 +58,6 @@ export function CardTypeForm({ mode, initialData }: CardTypeFormProps) { const isPending = createMutation.isPending || updateMutation.isPending - const [activeLang, setActiveLang] = useState('tk') - const schema = useMemo(() => createCardTypeFormSchema(t), [t, i18n.language]) const { @@ -121,11 +112,11 @@ export function CardTypeForm({ mode, initialData }: CardTypeFormProps) { } }, [mode, initialData, createMutation, updateMutation, navigate, trigger, getValues]) - const nameFieldKey = `name${activeLang.charAt(0).toUpperCase() + activeLang.slice(1)}` as - | 'nameTk' - | 'nameRu' - | 'nameEn' - const nameErrorKey = nameFieldKey as keyof FlatErrors + const nameFields = { + tk: { value: form.nameTk, onChange: (v: string) => set('nameTk')(v), error: errors.nameTk }, + ru: { value: form.nameRu, onChange: (v: string) => set('nameRu')(v), error: errors.nameRu }, + en: { value: form.nameEn, onChange: (v: string) => set('nameEn')(v), error: errors.nameEn }, + } return (
@@ -135,39 +126,15 @@ export function CardTypeForm({ mode, initialData }: CardTypeFormProps) { : t('cardTypes.editTitle', 'Kart görnüşi üýtgetmek')}
- {/* Language tabs */} -
- {LANG_TABS.map((tab) => ( - - ))} -
- {/* Form rows */}
{/* Name */} -
- +
+ {t('cardTypes.fields.name', 'Ady')} * - +
{/* Value */} diff --git a/src/features/loanTypes/components/loanTypesForm.tsx b/src/features/loanTypes/components/loanTypesForm.tsx index bc7517d..a3452cb 100644 --- a/src/features/loanTypes/components/loanTypesForm.tsx +++ b/src/features/loanTypes/components/loanTypesForm.tsx @@ -1,4 +1,4 @@ -import { useState, useCallback, useMemo, useEffect } from 'react' +import { useCallback, useMemo, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useForm } from 'react-hook-form' @@ -6,6 +6,7 @@ import { zodResolver } from '@hookform/resolvers/zod' import { FormInput } from '@/components/formInput' import { Label } from '@/components/ui/label' import { FormActions } from '@/components/formActions' +import { MultiLangInput } from '@/components/multiLangInput' import { Checkbox } from '@/components/ui/checkbox' import { useCreateLoanType, useUpdateLoanType } from '../hooks/useLoanTypes' import type { LoanType } from '../api/loanTypesApi' @@ -46,16 +47,6 @@ function mapInitial(data: LoanType): LoanTypeFormData { } } -// ─── Language Tab ───────────────────────────────────────────────────────────── - -type Lang = 'tk' | 'ru' | 'en' - -const LANG_TABS: { key: Lang; label: string }[] = [ - { key: 'tk', label: 'Türkmen' }, - { key: 'ru', label: 'Русский' }, - { key: 'en', label: 'English' }, -] - // ─── LoanTypeForm ───────────────────────────────────────────────────────────── export function LoanTypeForm({ mode, initialData }: LoanTypeFormProps) { @@ -69,9 +60,8 @@ export function LoanTypeForm({ mode, initialData }: LoanTypeFormProps) { const createMutation = useCreateLoanType() const updateMutation = useUpdateLoanType(initialData?.id ?? 0) - const isPending = createMutation.isPending || updateMutation.isPending - const [activeLang, setActiveLang] = useState('tk') + const isPending = createMutation.isPending || updateMutation.isPending const schema = useMemo(() => createLoanTypeFormSchema(t), [t, i18n.language]) @@ -128,13 +118,13 @@ export function LoanTypeForm({ mode, initialData }: LoanTypeFormProps) { const handleCancel = () => navigate('/resources/loan-types') // ── Name fields per lang ─────────────────────────────────────────────────── - const nameFields: Record void; error?: string }> = { + const nameFields = { tk: { value: form.nameTk, onChange: set('nameTk'), error: errors.nameTk }, ru: { value: form.nameRu, onChange: set('nameRu'), error: errors.nameRu }, en: { value: form.nameEn, onChange: set('nameEn'), error: errors.nameEn }, } - const notesFields: Record void }> = { + const notesFields = { tk: { value: form.notesTk ?? '', onChange: set('notesTk') }, ru: { value: form.notesRu ?? '', onChange: set('notesRu') }, en: { value: form.notesEn ?? '', onChange: set('notesEn') }, @@ -150,39 +140,15 @@ export function LoanTypeForm({ mode, initialData }: LoanTypeFormProps) { : t('loanTypes.editTitle', 'Karz görnüşi üýtgetmek')}
- {/* Language tabs row */} -
- {LANG_TABS.map((tab) => ( - - ))} -
- {/* Form card */}
{/* Ady */} -
- +
+ {t('loanTypes.fields.name', 'Ady')} * - +
{/* Salgyt */} @@ -216,16 +182,11 @@ export function LoanTypeForm({ mode, initialData }: LoanTypeFormProps) {
{/* Bellikler */} -
- +
+ {t('loanTypes.fields.notes', 'Bellikler')} - +
{/* Işjeň */} diff --git a/src/features/permissions/components/permissionsForm.tsx b/src/features/permissions/components/permissionsForm.tsx index a513f89..6a17c21 100644 --- a/src/features/permissions/components/permissionsForm.tsx +++ b/src/features/permissions/components/permissionsForm.tsx @@ -1,15 +1,15 @@ -import { useState, useMemo, useEffect, useCallback } from 'react' +import { useMemo, useEffect, useCallback } from 'react' import { useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' -import { FormInput } from '@/components/formInput' import { FormActions } from '@/components/formActions' +import { MultiLangInput } from '@/components/multiLangInput' import { useCreatePermission, useUpdatePermission } from '../hooks/usePermissions' import { createPermissionFormSchema, DEFAULT_FORM_VALUES, buildPayload } from '../schemas/permission.schema' import type { PermissionFormData } from '../schemas/permission.schema' import type { Permission } from '../api/permissionsApi' - +import { FormInput } from '@/components/formInput' // ─── Types ──────────────────────────────────────────────────────────────────── interface PermissionFormProps { @@ -17,14 +17,6 @@ interface PermissionFormProps { initialData?: Permission } -type LangKey = 'tk' | 'ru' | 'en' - -const LANG_TABS: { key: LangKey; label: string }[] = [ - { key: 'tk', label: 'Türkmen' }, - { key: 'ru', label: 'Русский' }, - { key: 'en', label: 'English' }, -] - const GUARD_OPTIONS = [ { value: 'web', label: 'web' }, { value: 'api', label: 'api' }, @@ -57,8 +49,6 @@ export function PermissionForm({ mode, initialData }: PermissionFormProps) { const isPending = createPermission.isPending || updatePermission.isPending - const [activeLang, setActiveLang] = useState('tk') - const schema = useMemo(() => createPermissionFormSchema(t), [t, i18n.language]) const { @@ -88,10 +78,10 @@ export function PermissionForm({ mode, initialData }: PermissionFormProps) { [setValue, clearErrors], ) - const setNameField = (lang: LangKey, value: string) => { - const key = `name${lang.charAt(0).toUpperCase() + lang.slice(1)}` as 'nameTk' | 'nameRu' | 'nameEn' - setValue(key, value) - clearErrors(key) + const nameFields = { + tk: { value: form.nameTk, onChange: (v: string) => { setValue('nameTk', v); clearErrors('nameTk'); }, error: errors.nameTk }, + ru: { value: form.nameRu, onChange: (v: string) => { setValue('nameRu', v); clearErrors('nameRu'); }, error: errors.nameRu }, + en: { value: form.nameEn, onChange: (v: string) => { setValue('nameEn', v); clearErrors('nameEn'); }, error: errors.nameEn }, } // ── Re-validate on language change ── @@ -122,9 +112,6 @@ export function PermissionForm({ mode, initialData }: PermissionFormProps) { // ── Render ───────────────────────────────────────────────────────────────── - const activeNameKey = `name${activeLang.charAt(0).toUpperCase() + activeLang.slice(1)}` as 'nameTk' | 'nameRu' | 'nameEn' - const nameError = errors[activeNameKey] - return (

@@ -156,32 +143,7 @@ export function PermissionForm({ mode, initialData }: PermissionFormProps) { {t('permissions.fields.name', 'Ady')} * -
-
- {LANG_TABS.map((tab) => ( - - ))} -
- setNameField(activeLang, v)} - placeholder={t('permissions.fields.name', 'Ady')} - error={nameError} - disabled={isPending} - /> -
+

{/* Guard name */} diff --git a/src/features/roles/components/roleForm.tsx b/src/features/roles/components/roleForm.tsx index 0f071aa..b382c3e 100644 --- a/src/features/roles/components/roleForm.tsx +++ b/src/features/roles/components/roleForm.tsx @@ -1,15 +1,15 @@ -import { useState, useMemo, useEffect, useCallback } from 'react' +import { useMemo, useEffect, useCallback } from 'react' import { useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' -import { FormInput } from '@/components/formInput' import { FormActions } from '@/components/formActions' +import { MultiLangInput } from '@/components/multiLangInput' import { useCreateRole, useUpdateRole } from '../hooks/useRoles' import { createRoleFormSchema, DEFAULT_FORM_VALUES, buildPayload } from '../schemas/role.schema' import type { RoleFormData } from '../schemas/role.schema' import type { Role } from '../api/rolesApi' - +import { FormInput } from '@/components/formInput' // ─── Types ──────────────────────────────────────────────────────────────────── interface RoleFormProps { @@ -17,14 +17,6 @@ interface RoleFormProps { initialData?: Role } -type LangKey = 'tk' | 'ru' | 'en' - -const LANG_TABS: { key: LangKey; label: string }[] = [ - { key: 'tk', label: 'Türkmen' }, - { key: 'ru', label: 'Русский' }, - { key: 'en', label: 'English' }, -] - const GUARD_OPTIONS = [ { value: 'web', label: 'web' }, { value: 'api', label: 'api' }, @@ -57,8 +49,6 @@ export function RoleForm({ mode, initialData }: RoleFormProps) { const isPending = createRole.isPending || updateRole.isPending - const [activeLang, setActiveLang] = useState('tk') - const schema = useMemo(() => createRoleFormSchema(t), [t, i18n.language]) const { @@ -88,10 +78,10 @@ export function RoleForm({ mode, initialData }: RoleFormProps) { [setValue, clearErrors], ) - const setNameField = (lang: LangKey, value: string) => { - const key = `name${lang.charAt(0).toUpperCase() + lang.slice(1)}` as 'nameTk' | 'nameRu' | 'nameEn' - setValue(key, value) - clearErrors(key) + const nameFields = { + tk: { value: form.nameTk, onChange: (v: string) => { setValue('nameTk', v); clearErrors('nameTk'); }, error: errors.nameTk }, + ru: { value: form.nameRu, onChange: (v: string) => { setValue('nameRu', v); clearErrors('nameRu'); }, error: errors.nameRu }, + en: { value: form.nameEn, onChange: (v: string) => { setValue('nameEn', v); clearErrors('nameEn'); }, error: errors.nameEn }, } // ── Re-validate on language change ── @@ -122,9 +112,6 @@ export function RoleForm({ mode, initialData }: RoleFormProps) { // ── Render ───────────────────────────────────────────────────────────────── - const activeNameKey = `name${activeLang.charAt(0).toUpperCase() + activeLang.slice(1)}` as 'nameTk' | 'nameRu' | 'nameEn' - const nameError = activeLang === 'tk' ? errors[activeNameKey] : undefined - return (

@@ -156,32 +143,7 @@ export function RoleForm({ mode, initialData }: RoleFormProps) { {t('roles.fields.name', 'Ady')} * -
-
- {LANG_TABS.map((tab) => ( - - ))} -
- setNameField(activeLang, v)} - placeholder={t('roles.fields.name', 'Ady')} - error={nameError} - disabled={isPending} - /> -
+

{/* Guard name */} diff --git a/src/layouts/DashboardLayout.tsx b/src/layouts/DashboardLayout.tsx index 56bd642..ae7fa96 100644 --- a/src/layouts/DashboardLayout.tsx +++ b/src/layouts/DashboardLayout.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useRef } from "react"; -import { Outlet, Link, useLocation } from "react-router-dom"; +import { Outlet, Link, useLocation, useMatches } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Sidebar, @@ -82,13 +82,7 @@ function isActiveItem(item: NavItem | NavSubItem, pathname: string): boolean { // ─── Sub-sub collapsible (3rd level) ────────────────────────────────────────── -function NavSubGroup({ - subItem, - pathname, -}: { - subItem: NavSubItem; - pathname: string; -}) { +function NavSubGroup({ subItem, pathname }: { subItem: NavSubItem; pathname: string }) { const active = subItem.items?.some((s) => pathname === s.url) ?? false; const [open, setOpen] = useState(active); @@ -107,13 +101,7 @@ function NavSubGroup({ )} > {subItem.title} - + @@ -156,10 +144,7 @@ function NavGroupItem({ item }: { item: NavItem }) { }, [active, collapsed]); return ( - !collapsed && setOpen(v)} - > + !collapsed && setOpen(v)}> - + {item.title} {item.items?.map((subItem, i) => { if (subItem.items) { - return ( - - ); + return ; } return ( @@ -230,9 +211,7 @@ function NavGroupLabel({ label }: { label: string }) { return (
-

- {label} -

+

{label}

); } @@ -341,10 +320,7 @@ function AppSidebar() { url: "/currency-rates", }, { - title: t( - "Visa/Master, Sber Settings", - "Visa/Master, Sber sazlamalary", - ), + title: t("Visa/Master, Sber Settings", "Visa/Master, Sber sazlamalary"), url: "/visa-master-sber-settings", }, ], @@ -390,10 +366,7 @@ function AppSidebar() { title: t("Card", "Kart"), items: [ { - title: t( - "Card Issuance Reasons", - "Kartyň çykarylmagynyň sebäpleri", - ), + title: t("Card Issuance Reasons", "Kartyň çykarylmagynyň sebäpleri"), url: "/settings/card/card-reasons", }, { @@ -452,12 +425,8 @@ function AppSidebar() {
- - TBBANK - - - Admin Panel v2.0 - + TBBANK + Admin Panel v2.0
@@ -482,12 +451,7 @@ function AppSidebar() { )} > - + {item.title} @@ -508,12 +472,8 @@ function AppSidebar() {
-

- {user?.name ?? "Admin"} -

-

- {user?.email ?? ""} -

+

{user?.name ?? "Admin"}

+

{user?.email ?? ""}

{/* Name + email */}
- - {user?.name ?? "Admin"} - - - {user?.email ?? ""} - + {user?.name ?? "Admin"} + {user?.email ?? ""}
- + @@ -567,7 +520,7 @@ function AppSidebar() { function DashboardHeader() { const { t } = useTranslation(); - const location = useLocation(); + const matches = useMatches(); const { theme, toggleTheme } = useThemeStore(); const { language, setLanguage } = useI18nStore(); @@ -576,11 +529,7 @@ function DashboardHeader() { useEffect(() => { function handler(e: MouseEvent) { - if ( - langMenuRef.current && - !langMenuRef.current.contains(e.target as Node) - ) - setLangMenuOpen(false); + if (langMenuRef.current && !langMenuRef.current.contains(e.target as Node)) setLangMenuOpen(false); } document.addEventListener("mousedown", handler); return () => document.removeEventListener("mousedown", handler); @@ -592,49 +541,78 @@ function DashboardHeader() { { code: "tk", label: "Türkmençe" }, ] as const; + // ── Breadcrumbs ──────────────────────────────────────────────────────────── + + const breadcrumbs = matches + .filter( + (m) => + ( + m.handle as { + title?: (t: (key: string, fallback: string) => string) => string; + indexPath?: string; + } + )?.title, + ) + .map((m) => { + const handle = m.handle as { + title: (t: (key: string, fallback: string) => string) => string; + indexPath?: string; + }; + + return { + title: handle.title(t), + url: handle.indexPath, + isClickable: !!handle.indexPath, + }; + }); + + // DashboardHeader içindeki breadcrumb render kısmı + const generateBreadcrumbs = () => { - const paths = location.pathname.split("/").filter(Boolean); - if ( - paths.length === 0 || - (paths.length === 1 && paths[0] === "dashboard") - ) { + if (breadcrumbs.length === 0) return null; + + if (breadcrumbs.length === 1) { return ( - {t("Dashboard", "Baş sahypa")} + {breadcrumbs[0].title} ); } + + const last = breadcrumbs[breadcrumbs.length - 1]; + return ( - - - Dashboard - + {/* Mobilde sadece "… / Son Sayfa" göster */} + + … - - {paths.map((path, index) => { - const isLast = index === paths.length - 1; - const url = `/${paths.slice(0, index + 1).join("/")}`; - const formatted = path - .replace(/-/g, " ") - .split(" ") - .map((w) => w.charAt(0).toUpperCase() + w.slice(1)) - .join(" "); - const title = t(formatted, formatted); + + + {last.title} + + + {/* Tablet+ full breadcrumb */} + {breadcrumbs.map((crumb, index) => { + const isLast = index === breadcrumbs.length - 1; return ( - - + + {index > 0 && } + {isLast ? ( - {title} - ) : ( + {crumb.title} + ) : crumb.isClickable ? ( - {title} + + {crumb.title} + + ) : ( + {crumb.title} )} - {!isLast && } ); })} @@ -660,17 +638,13 @@ function DashboardHeader() { className="flex items-center gap-1.5 h-8 px-2.5 rounded-md hover:bg-accent text-muted-foreground hover:text-foreground transition-colors" > - - {language} - + {language}
{languages.map((lang) => ( @@ -682,9 +656,7 @@ function DashboardHeader() { }} className={cn( "w-full text-left px-3 py-2 text-sm hover:bg-accent transition-colors", - language === lang.code - ? "text-primary font-medium" - : "text-foreground", + language === lang.code ? "text-primary font-medium" : "text-foreground", )} > {lang.label} @@ -728,9 +700,7 @@ export function DashboardLayout() { -
- © 2026 TBBANK.GOV.TM -
+
© 2026 TBBANK.GOV.TM
diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index da59212..e80ab05 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -688,6 +688,75 @@ "sberPayments.view.noPaymentHistory": "No payment history matching criteria.", "sberPayments.view.edit": "Edit", "sberPayments.view.delete": "Delete", + "allUsers.title": "All users", + "backups.title": "Backups", + "branches.createTitle": "Create branch", + "branches.editTitle": "Edit branch", + "branches.title": "Branches", + "branches.viewTitle": "Branch detail", + "cardBalance.createTitle": "Create card balance", + "cardBalance.editTitle": "Edit card balance", + "cardBalance.title": "Card balances", + "cardOrder.createTitle": "Create card order", + "cardOrder.editTitle": "Edit card order", + "cardOrder.title": "Card orders", + "cardPins.createTitle": "Create card PIN envelope", + "cardPins.editTitle": "Edit card PIN envelope", + "cardReasons.createTitle": "Create reason", + "cardReasons.editTitle": "Edit reason", + "cardReasons.title": "Card issuance reasons", + "cardReasons.viewTitle": "Reason detail", + "cardRequisites.createTitle": "Create card requisites", + "cardRequisites.editTitle": "Edit card requisites", + "cardTransactions.createTitle": "Create card transaction", + "cardTransactions.editTitle": "Edit card transaction", + "cardTypes.createTitle": "Create card type", + "cardTypes.editTitle": "Edit card type", + "cardTypes.title": "Card types", + "cardTypes.view.title": "Card type detail", + "clients.createTitle": "Create client", + "clients.editTitle": "Edit client", + "clients.title": "Clients", + "currencyRates.createTitle": "Create currency rate", + "currencyRates.detail.title": "Currency rate detail", + "currencyRates.editTitle": "Edit currency rate", + "currencyRates.title": "Currency rates", + "districts.createTitle": "Create district", + "districts.editTitle": "Edit district", + "districts.title": "Districts", + "districts.viewTitle": "District detail", + "intlPayment.createTitle": "Create Visa/Master payment", + "intlPayment.editTitle": "Edit Visa/Master payment", + "intlPayment.title": "Visa/Master payments", + "loanOrders.createTitle": "Create loan order", + "loanOrders.editTitle": "Edit loan order", + "loanPaidOffLetters.createTitle": "Create certificate", + "loanPaidOffLetters.editTitle": "Edit certificate", + "loanRemaining.createTitle": "Create loan remaining", + "loanRemaining.editTitle": "Edit loan remaining", + "loanTypes.createTitle": "Create loan type", + "loanTypes.editTitle": "Edit loan type", + "loanTypes.title": "Loan types", + "loanTypes.viewTitle": "Loan type detail", + "notFound": "Not found", + "onlinePayments.title": "Online payments", + "permissions.createTitle": "Create permission", + "permissions.editTitle": "Edit permission", + "permissions.title": "Permissions", + "permissions.viewTitle": "Permission detail", + "requiredDocuments.createTitle": "Create document", + "requiredDocuments.editTitle": "Edit document", + "requiredDocuments.title": "Required documents", + "requiredDocuments.viewTitle": "Document detail", + "roles.createTitle": "Create role", + "roles.editTitle": "Edit role", + "roles.title": "Roles", + "roles.viewTitle": "Role detail", + "sberPayments.createTitle": "Create Sber payment", + "sberPayments.editTitle": "Edit Sber payment", + "users.editTitle": "Edit user", + "visaMasterSettings.createTitle": "Create settings", + "visaMasterSettings.editTitle": "Edit settings", "operators.title": "Operators", "operators.detailTitle": "Operator details", "operators.createTitle": "Create operator", @@ -916,6 +985,7 @@ "branches.fields.billingIbr": "BILLING USERNAME (IBR)", "branches.fields.billingSber": "BILLING USERNAME (SBER)", "branches.fields.billingVisa": "BILLING USERNAME (VISA)", + "users.createTitle": "Add New User", "users.viewTitle": "User details", "users.fields.username": "Username", "users.fields.name": "Name", diff --git a/src/lib/i18n/locales/ru.json b/src/lib/i18n/locales/ru.json index 4c1706b..4c1c481 100644 --- a/src/lib/i18n/locales/ru.json +++ b/src/lib/i18n/locales/ru.json @@ -689,6 +689,75 @@ "sberPayments.view.noPaymentHistory": "Платежей по заданным критериям не найдено.", "sberPayments.view.edit": "Редактировать", "sberPayments.view.delete": "Удалить", + "allUsers.title": "Все пользователи", + "backups.title": "Резервные копии", + "branches.createTitle": "Создать филиал", + "branches.editTitle": "Редактировать филиал", + "branches.title": "Филиалы", + "branches.viewTitle": "Детали филиала", + "cardBalance.createTitle": "Создать остаток карты", + "cardBalance.editTitle": "Редактировать остаток карты", + "cardBalance.title": "Остатки карт", + "cardOrder.createTitle": "Создать заказ карты", + "cardOrder.editTitle": "Редактировать заказ карты", + "cardOrder.title": "Заказы карт", + "cardPins.createTitle": "Создать ПИН-конверт карты", + "cardPins.editTitle": "Редактировать ПИН-конверт карты", + "cardReasons.createTitle": "Создать причину", + "cardReasons.editTitle": "Редактировать причину", + "cardReasons.title": "Причины выпуска карт", + "cardReasons.viewTitle": "Детали причины", + "cardRequisites.createTitle": "Создать реквизиты карты", + "cardRequisites.editTitle": "Редактировать реквизиты карты", + "cardTransactions.createTitle": "Создать транзакцию карты", + "cardTransactions.editTitle": "Редактировать транзакцию карты", + "cardTypes.createTitle": "Создать тип карты", + "cardTypes.editTitle": "Редактировать тип карты", + "cardTypes.title": "Типы карт", + "cardTypes.view.title": "Детали типа карты", + "clients.createTitle": "Создать клиента", + "clients.editTitle": "Редактировать клиента", + "clients.title": "Клиенты", + "currencyRates.createTitle": "Создать курс валют", + "currencyRates.detail.title": "Детали курса валют", + "currencyRates.editTitle": "Редактировать курс валют", + "currencyRates.title": "Курсы валют", + "districts.createTitle": "Создать район", + "districts.editTitle": "Редактировать район", + "districts.title": "Районы", + "districts.viewTitle": "Детали района", + "intlPayment.createTitle": "Создать платеж Visa/Master", + "intlPayment.editTitle": "Редактировать платеж Visa/Master", + "intlPayment.title": "Платежи Visa/Master", + "loanOrders.createTitle": "Создать заявку на кредит", + "loanOrders.editTitle": "Редактировать заявку на кредит", + "loanPaidOffLetters.createTitle": "Создать справку", + "loanPaidOffLetters.editTitle": "Редактировать справку", + "loanRemaining.createTitle": "Создать остаток кредита", + "loanRemaining.editTitle": "Редактировать остаток кредита", + "loanTypes.createTitle": "Создать тип кредита", + "loanTypes.editTitle": "Редактировать тип кредита", + "loanTypes.title": "Типы кредитов", + "loanTypes.viewTitle": "Детали типа кредита", + "notFound": "Не найдено", + "onlinePayments.title": "Онлайн-платежи", + "permissions.createTitle": "Создать разрешение", + "permissions.editTitle": "Редактировать разрешение", + "permissions.title": "Разрешения", + "permissions.viewTitle": "Детали разрешения", + "requiredDocuments.createTitle": "Создать документ", + "requiredDocuments.editTitle": "Редактировать документ", + "requiredDocuments.title": "Необходимые документы", + "requiredDocuments.viewTitle": "Детали документа", + "roles.createTitle": "Создать роль", + "roles.editTitle": "Редактировать роль", + "roles.title": "Роли", + "roles.viewTitle": "Детали роли", + "sberPayments.createTitle": "Создать платеж Сбер", + "sberPayments.editTitle": "Редактировать платеж Сбер", + "users.editTitle": "Редактировать пользователя", + "visaMasterSettings.createTitle": "Создать настройки", + "visaMasterSettings.editTitle": "Редактировать настройки", "operators.title": "Операторы", "operators.detailTitle": "Детали оператора", "operators.createTitle": "Создать оператора", @@ -917,6 +986,7 @@ "branches.fields.billingIbr": "ЛОГИН БИЛЛИНГА (IBR)", "branches.fields.billingSber": "ЛОГИН БИЛЛИНГА (SBER)", "branches.fields.billingVisa": "ЛОГИН БИЛЛИНГА (VISA)", + "users.createTitle": "Создание пользователя", "users.viewTitle": "Детали пользователя", "users.fields.username": "Имя пользователя", "users.fields.name": "Имя", diff --git a/src/lib/i18n/locales/tk.json b/src/lib/i18n/locales/tk.json index dd3b55a..c8fe74a 100644 --- a/src/lib/i18n/locales/tk.json +++ b/src/lib/i18n/locales/tk.json @@ -705,6 +705,75 @@ "sberPayments.view.noPaymentHistory": "Berlen kriteriýalara Töleg gabat gelmedi.", "sberPayments.view.edit": "Redaktirle", "sberPayments.view.delete": "Poz", + "allUsers.title": "Ähli müşderiler", + "backups.title": "Bekaplar", + "branches.createTitle": "Şahamça döretmek", + "branches.editTitle": "Şahamça üýtgetmek", + "branches.title": "Şahamçalar", + "branches.viewTitle": "Şahamça giňişleýin", + "cardBalance.createTitle": "Kart galyndy döretmek", + "cardBalance.editTitle": "Kart galyndy üýtgetmek", + "cardBalance.title": "Kart galyndylary", + "cardOrder.createTitle": "Kart sargyt döretmek", + "cardOrder.editTitle": "Kart sargyt üýtgetmek", + "cardOrder.title": "Kart sargytlary", + "cardPins.createTitle": "Kart pin bukja döretmek", + "cardPins.editTitle": "Kart pin bukja üýtgetmek", + "cardReasons.createTitle": "Sebäp döretmek", + "cardReasons.editTitle": "Sebäp üýtgetmek", + "cardReasons.title": "Kart çykarylyş sebäpleri", + "cardReasons.viewTitle": "Sebäp giňişleýin", + "cardRequisites.createTitle": "Kart rekwizit döretmek", + "cardRequisites.editTitle": "Kart rekwizit üýtgetmek", + "cardTransactions.createTitle": "Kart herekedi döretmek", + "cardTransactions.editTitle": "Kart herekedi üýtgetmek", + "cardTypes.createTitle": "Kart görnüşi döretmek", + "cardTypes.editTitle": "Kart görnüşi üýtgetmek", + "cardTypes.title": "Kart görnüşleri", + "cardTypes.view.title": "Kart görnüşi giňişleýin", + "clients.createTitle": "Müşderi döretmek", + "clients.editTitle": "Müşderi üýtgetmek", + "clients.title": "Müşderiler", + "currencyRates.createTitle": "Walýuta kursy döretmek", + "currencyRates.detail.title": "Walýuta kursy giňişleýin", + "currencyRates.editTitle": "Walýuta kursy üýtgetmek", + "currencyRates.title": "Walýuta kursy", + "districts.createTitle": "Etrap döretmek", + "districts.editTitle": "Etrap üýtgetmek", + "districts.title": "Etraplar", + "districts.viewTitle": "Etrap giňişleýin", + "intlPayment.createTitle": "Visa/Master töleg döretmek", + "intlPayment.editTitle": "Visa/Master töleg üýtgetmek", + "intlPayment.title": "Visa/Master tölegleri", + "loanOrders.createTitle": "Karz sargyt döretmek", + "loanOrders.editTitle": "Karz sargyt üýtgetmek", + "loanPaidOffLetters.createTitle": "Güwanama döretmek", + "loanPaidOffLetters.editTitle": "Güwanama üýtgetmek", + "loanRemaining.createTitle": "Karz galyndy döretmek", + "loanRemaining.editTitle": "Karz galyndy üýtgetmek", + "loanTypes.createTitle": "Karz görnüşi döretmek", + "loanTypes.editTitle": "Karz görnüşi üýtgetmek", + "loanTypes.title": "Karz görnüşleri", + "loanTypes.viewTitle": "Karz görnüşi giňişleýin", + "notFound": "Tapylmady", + "onlinePayments.title": "Onlaýn töleg taryhy", + "permissions.createTitle": "Rugsat döretmek", + "permissions.editTitle": "Rugsat üýtgetmek", + "permissions.title": "Rugsatlar", + "permissions.viewTitle": "Rugsat giňişleýin", + "requiredDocuments.createTitle": "Resminama döretmek", + "requiredDocuments.editTitle": "Resminama üýtgetmek", + "requiredDocuments.title": "Gerekli resminamalar", + "requiredDocuments.viewTitle": "Resminama giňişleýin", + "roles.createTitle": "Rol döretmek", + "roles.editTitle": "Rol üýtgetmek", + "roles.title": "Rollar", + "roles.viewTitle": "Rol giňişleýin", + "sberPayments.createTitle": "Sber töleg döretmek", + "sberPayments.editTitle": "Sber töleg üýtgetmek", + "users.editTitle": "Ulanyjy üýtgetmek", + "visaMasterSettings.createTitle": "Visa/Master, Sber sazlamalar döretmek", + "visaMasterSettings.editTitle": "Visa/Master, Sber sazlamalar üýtgetmek", "operators.title": "Operatorlar", "operators.detailTitle": "Operator giňişleýin", "operators.createTitle": "Operator dörediň", @@ -933,6 +1002,7 @@ "branches.fields.billingIbr": "BILLING ULANYJY ADY", "branches.fields.billingSber": "BILLING USERNAME (SBER)", "branches.fields.billingVisa": "BILLING USERNAME (VISA)", + "users.createTitle": "Ulanyjy döretmek", "users.viewTitle": "Ulanyjy giňişleýin", "users.fields.username": "Ulanyjy ady", "users.fields.name": "Ady", diff --git a/src/pages/cardDepartment/cardBalanceView/index.tsx b/src/pages/cardDepartment/cardBalanceView/index.tsx index 7cad1b9..a9fa6ba 100644 --- a/src/pages/cardDepartment/cardBalanceView/index.tsx +++ b/src/pages/cardDepartment/cardBalanceView/index.tsx @@ -3,7 +3,7 @@ import { useParams, useNavigate, Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Download, Trash2, Pencil, ChevronDown } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { Spinner } from "@/components/ui/spinner"; +import { Skeleton } from "@/components/ui/skeleton"; import { AlertDialog, AlertDialogAction, @@ -78,8 +78,16 @@ export default function CardBalanceViewPage() { if (isLoading) { return ( -
- +
+ +
+ {Array.from({ length: 5 }).map((_, i) => ( +
+ + +
+ ))} +
); } diff --git a/src/pages/cardDepartment/cardPinsView/index.tsx b/src/pages/cardDepartment/cardPinsView/index.tsx index 6cecb47..67a7308 100644 --- a/src/pages/cardDepartment/cardPinsView/index.tsx +++ b/src/pages/cardDepartment/cardPinsView/index.tsx @@ -5,7 +5,7 @@ import { useDeleteCardPin, } from "@/features/cardPins/hooks/useCardPins"; import type { CardPinStatus } from "@/features/cardPins/api/cardPinApi"; -import { Spinner } from "@/components/ui/spinner"; +import { Skeleton } from "@/components/ui/skeleton"; import { Button } from "@/components/ui/button"; import { Pencil, Trash2 } from "lucide-react"; import { @@ -17,14 +17,13 @@ import { AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, - AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { StatusBadge, type StatusBadgeVariant, } from "@/components/ui/statusBadge"; import { AlertCircle, CheckCircle2, XCircle } from "lucide-react"; -import { InfoRow, PassportImage } from "@/components/viewPageComponents"; +import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents"; // ─── Status config ──────────────────────────────────────────────────────────── @@ -48,42 +47,22 @@ function CardPinStatusBadge({ status }: { status: CardPinStatus }) { return } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: "grid-cols-1", - 2: "grid-cols-1 sm:grid-cols-2", - 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", - 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: "full" | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === "full" ? "sm:col-span-full" : - span === 2 ? "sm:col-span-2" : - span === 3 ? "sm:col-span-3" : "" +// ─── Skeleton ───────────────────────────────────────────────────────────────── +function CardPinViewSkeleton() { return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} +
+ +
+ {Array.from({ length: 4 }).map((_, i) => ( +
+ + {Array.from({ length: 3 }).map((_, j) => ( + + ))} +
+ ))} +
) } @@ -99,11 +78,7 @@ export default function CardPinViewPage() { const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin() if (isLoading) { - return ( -
- -
- ) + return } if (isError || !data) { @@ -124,7 +99,7 @@ export default function CardPinViewPage() {
- + - + diff --git a/src/pages/cardDepartment/cardRequisitesView/index.tsx b/src/pages/cardDepartment/cardRequisitesView/index.tsx index e6ed400..9e8cb42 100644 --- a/src/pages/cardDepartment/cardRequisitesView/index.tsx +++ b/src/pages/cardDepartment/cardRequisitesView/index.tsx @@ -6,7 +6,7 @@ import { useDownloadCardRequisite, } from "@/features/cardRequisites/hooks/useCardRequisites"; import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi"; -import { Spinner } from "@/components/ui/spinner"; +import { Skeleton } from "@/components/ui/skeleton"; import { Button } from "@/components/ui/button"; import { Pencil, Trash2, Download } from "lucide-react"; import { @@ -18,14 +18,13 @@ import { AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, - AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { StatusBadge, type StatusBadgeVariant, } from "@/components/ui/statusBadge"; import { AlertCircle, CheckCircle2, XCircle } from "lucide-react"; -import { InfoRow, PassportImage } from "@/components/viewPageComponents"; +import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents"; // ─── Status config ──────────────────────────────────────────────────────────── @@ -49,42 +48,22 @@ function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) { return } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: "grid-cols-1", - 2: "grid-cols-1 sm:grid-cols-2", - 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", - 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: "full" | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === "full" ? "sm:col-span-full" : - span === 2 ? "sm:col-span-2" : - span === 3 ? "sm:col-span-3" : "" +// ─── Skeleton ───────────────────────────────────────────────────────────────── +function CardRequisiteViewSkeleton() { return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} +
+ +
+ {Array.from({ length: 4 }).map((_, i) => ( +
+ + {Array.from({ length: 3 }).map((_, j) => ( + + ))} +
+ ))} +
) } @@ -101,11 +80,7 @@ export default function CardRequisiteViewPage() { const downloadMutation = useDownloadCardRequisite() if (isLoading) { - return ( -
- -
- ) + return } if (isError || !data) { @@ -134,7 +109,7 @@ export default function CardRequisiteViewPage() { - + - + diff --git a/src/pages/cardDepartment/cardTransactionsView/index.tsx b/src/pages/cardDepartment/cardTransactionsView/index.tsx index 0bff606..ae6d8bc 100644 --- a/src/pages/cardDepartment/cardTransactionsView/index.tsx +++ b/src/pages/cardDepartment/cardTransactionsView/index.tsx @@ -3,7 +3,7 @@ import { useParams, useNavigate, Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Download, Trash2, Pencil } from "lucide-react"; import { Button } from "@/components/ui/button"; -import { Spinner } from "@/components/ui/spinner"; +import { Skeleton } from "@/components/ui/skeleton"; import { AlertDialog, AlertDialogAction, @@ -42,8 +42,16 @@ export default function CardTransactionViewPage() { if (isLoading) { return ( -
- +
+ +
+ {Array.from({ length: 5 }).map((_, i) => ( +
+ + +
+ ))} +
); } diff --git a/src/pages/cardDepartment/orderNewCardView/index.tsx b/src/pages/cardDepartment/orderNewCardView/index.tsx index 9fce18f..3cfeac2 100644 --- a/src/pages/cardDepartment/orderNewCardView/index.tsx +++ b/src/pages/cardDepartment/orderNewCardView/index.tsx @@ -19,7 +19,7 @@ import { useDeleteCardOrder, } from "@/features/orderNewCard/hooks/useOrderNewCard"; import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi"; -import { InfoRow, PassportImage } from "@/components/viewPageComponents"; +import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents"; // ─── Status badge ───────────────────────────────────────────────────────────── @@ -40,46 +40,6 @@ function StatusBadge({ status }: { status: CardOrderStatus }) { ) } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: "grid-cols-1", - 2: "grid-cols-1 sm:grid-cols-2", - 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", - 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: "full" | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === "full" ? "sm:col-span-full" : - span === 2 ? "sm:col-span-2" : - span === 3 ? "sm:col-span-3" : "" - - return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} -
- ) -} - // ─── Skeleton ───────────────────────────────────────────────────────────────── function DetailSkeleton() { diff --git a/src/pages/currencies/currencyRatesView/index.tsx b/src/pages/currencies/currencyRatesView/index.tsx index bacf132..2c13963 100644 --- a/src/pages/currencies/currencyRatesView/index.tsx +++ b/src/pages/currencies/currencyRatesView/index.tsx @@ -5,6 +5,7 @@ import { useNavigate, useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { Pencil, Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' +import { Skeleton } from '@/components/ui/skeleton' import { Section, InfoRow } from '@/components/viewPageComponents' import { useGetCurrencyRateById, useDeleteCurrencyRate } from '@/features/currencyRates/hooks/useCurrencyRates' import { ConfirmDialog } from '@/components/confirmDialog' @@ -32,15 +33,15 @@ export default function CurrencyRateDetailPage() { if (isLoading) { return (
-
-
+ +
) } if (!rate) { return ( -
+

{t('currencyRates.notFound', 'Walýuta kursy tapylmady')}

@@ -51,7 +52,7 @@ export default function CurrencyRateDetailPage() { // ─── Render ─────────────────────────────────────────────────────────────── return ( -
+
{/* Header */} diff --git a/src/pages/internationalPayments/sberPaymentsView/index.tsx b/src/pages/internationalPayments/sberPaymentsView/index.tsx index fcd50d5..1965547 100644 --- a/src/pages/internationalPayments/sberPaymentsView/index.tsx +++ b/src/pages/internationalPayments/sberPaymentsView/index.tsx @@ -4,7 +4,7 @@ import { useParams, useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { Skeleton } from '@/components/ui/skeleton' import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge' -import { InfoRow, AuditLog, type AuditRowProps } from '@/components/viewPageComponents' +import { BentoGrid, BentoCard, InfoRow, AuditLog, type AuditRowProps } from '@/components/viewPageComponents' import { useSberPaymentOrder, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments' import type { PaymentPaidStatus, PaymentStatus } from '@/features/sberPayments/api/sberPaymentsApi' import { useState } from 'react' @@ -61,46 +61,6 @@ function PaymentPaidStatusBadge({ status }: { status: PaymentPaidStatus }) { return } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: 'grid-cols-1', - 2: 'grid-cols-1 sm:grid-cols-2', - 3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3', - 4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4', - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: 'full' | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === 'full' ? 'sm:col-span-full' : - span === 2 ? 'sm:col-span-2' : - span === 3 ? 'sm:col-span-3' : '' - - return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} -
- ) -} - // ─── Document row ───────────────────────────────────────────────────────────── function DocumentRow({ diff --git a/src/pages/internationalPayments/visaMasterPayments/index.tsx b/src/pages/internationalPayments/visaMasterPayments/index.tsx index 2c4f7bd..40e2882 100644 --- a/src/pages/internationalPayments/visaMasterPayments/index.tsx +++ b/src/pages/internationalPayments/visaMasterPayments/index.tsx @@ -163,13 +163,13 @@ export default function IntlPaymentsPage() {
@@ -237,7 +237,7 @@ export default function IntlPaymentsPage() { perPage={perPage} onPerPageChange={(v) => { setPerPage(v); setPage(1) }} actionLabel={t('intlPayment.createBtn', 'Visa/Master tölegler (talyplar üçin) dörediň')} - onAction={() => navigate('/visa-master-payments/create')} + onAction={() => navigate('/visa-master/create')} /> } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: 'grid-cols-1', - 2: 'grid-cols-1 sm:grid-cols-2', - 3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3', - 4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4', - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: 'full' | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === 'full' ? 'sm:col-span-full' : - span === 2 ? 'sm:col-span-2' : - span === 3 ? 'sm:col-span-3' : '' - - return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} -
- ) -} - // ─── DocFile row ────────────────────────────────────────────────────────────── function DocFileRow({ label, url }: { label: string; url: string | null }) { diff --git a/src/pages/loanDepartment/loanOrderMobileView/index.tsx b/src/pages/loanDepartment/loanOrderMobileView/index.tsx index 0390dae..c04f1ac 100644 --- a/src/pages/loanDepartment/loanOrderMobileView/index.tsx +++ b/src/pages/loanDepartment/loanOrderMobileView/index.tsx @@ -15,6 +15,8 @@ import { } from "@/components/ui/statusBadge"; import { AlertCircle, CheckCircle2, XCircle } from "lucide-react"; import { + BentoGrid, + BentoCard, InfoRow, PassportImage, AuditLog, @@ -46,48 +48,6 @@ function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus return } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: "grid-cols-1", - 2: "grid-cols-1 sm:grid-cols-2", - 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", - 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, - noPadding, -}: { - title?: string - span?: "full" | 2 | 3 - children: React.ReactNode - noPadding?: boolean -}) { - const spanClass = - span === "full" ? "sm:col-span-full" : - span === 2 ? "sm:col-span-2" : - span === 3 ? "sm:col-span-3" : "" - - return ( -
- {title && ( -
-

- {title} -

-
- )} -
{children}
-
- ) -} - // ─── Skeleton ───────────────────────────────────────────────────────────────── function LoanOrderMobilesViewSkeleton() { diff --git a/src/pages/loanDepartment/loanOrderView/index.tsx b/src/pages/loanDepartment/loanOrderView/index.tsx index d128b51..dce6449 100644 --- a/src/pages/loanDepartment/loanOrderView/index.tsx +++ b/src/pages/loanDepartment/loanOrderView/index.tsx @@ -14,6 +14,8 @@ import { import { AlertCircle, CheckCircle2, XCircle } from "lucide-react"; import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi"; import { + BentoGrid, + BentoCard, InfoRow, PassportImage, AuditLog, @@ -45,46 +47,6 @@ function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus return } -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: "grid-cols-1", - 2: "grid-cols-1 sm:grid-cols-2", - 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", - 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: "full" | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === "full" ? "sm:col-span-full" : - span === 2 ? "sm:col-span-2" : - span === 3 ? "sm:col-span-3" : "" - - return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} -
- ) -} - // ─── Skeleton ───────────────────────────────────────────────────────────────── function LoanOrderViewSkeleton() { diff --git a/src/pages/settings/card/cardTypesView/index.tsx b/src/pages/settings/card/cardTypesView/index.tsx index b6b2d2d..dcf7b98 100644 --- a/src/pages/settings/card/cardTypesView/index.tsx +++ b/src/pages/settings/card/cardTypesView/index.tsx @@ -13,7 +13,8 @@ import { AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' -import { Section, InfoRow } from '@/components/viewPageComponents' +import { Skeleton } from '@/components/ui/skeleton' +import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents' import { useCardTypeById, useDeleteCardType } from '@/features/cardTypes/hooks/useCardTypes' export function CardTypeViewPage() { @@ -29,7 +30,7 @@ export function CardTypeViewPage() { const [deleteOpen, setDeleteOpen] = useState(false) return ( -
+
@@ -67,10 +68,10 @@ export function CardTypeViewPage() { {Array.from({ length: 4 }).map((_, i) => (
-
-
+ +
))}
@@ -78,29 +79,7 @@ export function CardTypeViewPage() {
- {/* Multilang name with tabs */} -
- - {t('cardTypes.fields.name', 'Ady')} - -
-
- {(['tk', 'ru', 'en'] as const).map((l) => ( - - {l === 'tk' ? 'Türkmen' : l === 'ru' ? 'Русский' : 'English'} - - ))} -
- {data.name[lang]} -
-
+ -
- +
+ {t('cardTypes.fields.isActive', 'Işjeň')} {data.isActive ? ( diff --git a/src/pages/settings/card/reasonsView/index.tsx b/src/pages/settings/card/reasonsView/index.tsx index 371c4ba..3bffb41 100644 --- a/src/pages/settings/card/reasonsView/index.tsx +++ b/src/pages/settings/card/reasonsView/index.tsx @@ -14,7 +14,8 @@ import { AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' -import { Section, InfoRow } from '@/components/viewPageComponents' +import { Skeleton } from '@/components/ui/skeleton' +import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents' import { useCardReasonById, useDeleteCardReason } from '@/features/cardReasons/hooks/useCardReasons' // ─── CardReasonViewPage ──────────────────────────────────────────────────────── @@ -32,7 +33,7 @@ export function CardReasonViewPage() { const [deleteOpen, setDeleteOpen] = useState(false) return ( -
+
@@ -70,10 +71,10 @@ export function CardReasonViewPage() { {Array.from({ length: 4 }).map((_, i) => (
-
-
+ +
))}
@@ -81,28 +82,7 @@ export function CardReasonViewPage() {
- {/* Multilang name tabs */} -
- - {t('CardReasons.fields.name', 'Ady')} - -
- {/* Lang switcher is displayed in top-right corner of this cell */} -
- {(['tk', 'ru', 'en'] as const).map((l) => ( - - {l === 'tk' ? 'Türkmen' : l === 'ru' ? 'Русский' : 'English'} - - ))} -
- {data.name[lang]} -
-
+ {/* isActive custom row */} -
- +
+ {t('CardReasons.fields.isActive', 'Işjeň')} {data.isActive ? ( diff --git a/src/pages/settings/loan/loanTypesView/index.tsx b/src/pages/settings/loan/loanTypesView/index.tsx index bc72fd8..421fe4d 100644 --- a/src/pages/settings/loan/loanTypesView/index.tsx +++ b/src/pages/settings/loan/loanTypesView/index.tsx @@ -16,7 +16,7 @@ import { AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' -import { Section, InfoRow } from '@/components/viewPageComponents' +import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents' import { useGetLoanTypeById, useDeleteLoanType } from '@/features/loanTypes/hooks/useLoanTypes' // ─── LoanTypeViewPage ───────────────────────────────────────────────────────── @@ -42,12 +42,12 @@ export default function LoanTypeViewPage() { // ── Skeleton ─────────────────────────────────────────────────────────────── if (isLoading) { return ( -
+
{Array.from({ length: 5 }).map((_, i) => ( -
+
@@ -60,7 +60,7 @@ export default function LoanTypeViewPage() { // ── Error ────────────────────────────────────────────────────────────────── if (isError || !data) { return ( -
+
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
) @@ -68,7 +68,7 @@ export default function LoanTypeViewPage() { // ── View ─────────────────────────────────────────────────────────────────── return ( -
+
{/* Page header */} @@ -102,26 +102,7 @@ export default function LoanTypeViewPage() {
- {/* Multilingual name rows */} -
- - {t('loanTypes.fields.name', 'Ady')} - -
-
- TK - {data.name.tk} -
-
- RU - {data.name.ru} -
-
- EN - {data.name.en} -
-
-
+ -
- +
+ {t('loanTypes.fields.notes', 'Bellikler')} - + {data.notes ? data.notes[lang] || '—' : '—'}
-
- +
+ {t('loanTypes.fields.isActive', 'Işjeň')} {data.isActive ? ( diff --git a/src/pages/settings/loan/requiredDocumentsView/index.tsx b/src/pages/settings/loan/requiredDocumentsView/index.tsx index 78d7614..b7f7b64 100644 --- a/src/pages/settings/loan/requiredDocumentsView/index.tsx +++ b/src/pages/settings/loan/requiredDocumentsView/index.tsx @@ -3,6 +3,7 @@ import { useParams, useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { Pencil, Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' +import { Skeleton } from '@/components/ui/skeleton' import { Section, InfoRow } from '@/components/viewPageComponents' import { useGetRequiredDocumentById, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments' import { ConfirmDialog } from '@/components/confirmDialog' @@ -26,7 +27,7 @@ export default function RequiredDocumentsViewPage() { return (
{Array.from({ length: 3 }).map((_, i) => ( -
+ ))}
) diff --git a/src/pages/settings/location/branchesView/index.tsx b/src/pages/settings/location/branchesView/index.tsx index 929b34e..bbb6c1b 100644 --- a/src/pages/settings/location/branchesView/index.tsx +++ b/src/pages/settings/location/branchesView/index.tsx @@ -13,6 +13,7 @@ import { AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' +import { Skeleton } from '@/components/ui/skeleton' import { Section, InfoRow } from '@/components/viewPageComponents' import { useBranchById, useDeleteBranch } from '@/features/branches/hooks/useBranches' @@ -29,7 +30,7 @@ export function BranchViewPage() { const [deleteOpen, setDeleteOpen] = useState(false) return ( -
+
@@ -68,8 +69,8 @@ export function BranchViewPage() { key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0" > -
-
+ +
))}
diff --git a/src/pages/settings/location/districtsView/index.tsx b/src/pages/settings/location/districtsView/index.tsx index b3aa914..d468682 100644 --- a/src/pages/settings/location/districtsView/index.tsx +++ b/src/pages/settings/location/districtsView/index.tsx @@ -13,6 +13,7 @@ import { AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' +import { Skeleton } from '@/components/ui/skeleton' import { Section, InfoRow } from '@/components/viewPageComponents' import { useDistrictById, useDeleteDistrict } from '@/features/districts/hooks/useDistricts' @@ -29,7 +30,7 @@ export function DistrictViewPage() { const [deleteOpen, setDeleteOpen] = useState(false) return ( -
+
@@ -68,8 +69,8 @@ export function DistrictViewPage() { key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0" > -
-
+ +
))}
diff --git a/src/pages/settings/users/permissionsView/index.tsx b/src/pages/settings/users/permissionsView/index.tsx index 75f07fd..552a917 100644 --- a/src/pages/settings/users/permissionsView/index.tsx +++ b/src/pages/settings/users/permissionsView/index.tsx @@ -14,46 +14,9 @@ import { AlertDialogTitle, } from '@/components/ui/alert-dialog' import { Skeleton } from '@/components/ui/skeleton' -import { Section, InfoRow } from '@/components/viewPageComponents' +import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents' import { usePermission, useDeletePermission } from '@/features/permissions/hooks/usePermissions' -// ─── LangTabs ───────────────────────────────────────────────────────────────── - -type LangKey = 'tk' | 'ru' | 'en' - -function LangTabs({ - active, - onChange, -}: { - active: LangKey - onChange: (l: LangKey) => void -}) { - const { t } = useTranslation() - const LANG_TABS: { key: LangKey; label: string }[] = [ - { key: 'tk', label: t('languages.tk', 'Türkmen') }, - { key: 'ru', label: t('languages.ru', 'Русский') }, - { key: 'en', label: t('languages.en', 'English') }, - ] - return ( -
- {LANG_TABS.map((tab) => ( - - ))} -
- ) -} - // ─── PermissionViewPage ─────────────────────────────────────────────────────── export default function PermissionViewPage() { @@ -62,7 +25,6 @@ export default function PermissionViewPage() { const navigate = useNavigate() const permissionId = Number(id) - const [activeLang, setActiveLang] = useState('tk') const [showDelete, setShowDelete] = useState(false) const { data: permission, isLoading, isError } = usePermission(permissionId) @@ -82,7 +44,7 @@ export default function PermissionViewPage() {
{Array.from({ length: 4 }).map((_, i) => ( -
+
@@ -133,18 +95,7 @@ export default function PermissionViewPage() { - {/* Name row — with lang switcher */} -
- - {t('permissions.fields.name', 'Ady')} - -
- - - {permission.name?.[activeLang] || '—'} - -
-
+
diff --git a/src/pages/settings/users/rolesView/index.tsx b/src/pages/settings/users/rolesView/index.tsx index 77b74d9..de17d05 100644 --- a/src/pages/settings/users/rolesView/index.tsx +++ b/src/pages/settings/users/rolesView/index.tsx @@ -14,46 +14,9 @@ import { AlertDialogTitle, } from '@/components/ui/alert-dialog' import { Skeleton } from '@/components/ui/skeleton' -import { Section, InfoRow } from '@/components/viewPageComponents' +import { Section, InfoRow, MultiLangRow } from '@/components/viewPageComponents' import { useRole, useDeleteRole } from '@/features/roles/hooks/useRoles' -// ─── LangTabs ───────────────────────────────────────────────────────────────── - -type LangKey = 'tk' | 'ru' | 'en' - -const LANG_TABS: { key: LangKey; label: string }[] = [ - { key: 'tk', label: 'Türkmen' }, - { key: 'ru', label: 'Русский' }, - { key: 'en', label: 'English' }, -] - -function LangTabs({ - active, - onChange, -}: { - active: LangKey - onChange: (l: LangKey) => void -}) { - return ( -
- {LANG_TABS.map((tab) => ( - - ))} -
- ) -} - // ─── RoleViewPage ───────────────────────────────────────────────────────────── export default function RoleViewPage() { @@ -62,7 +25,6 @@ export default function RoleViewPage() { const navigate = useNavigate() const roleId = Number(id) - const [activeLang, setActiveLang] = useState('tk') const [showDelete, setShowDelete] = useState(false) const { data: role, isLoading, isError } = useRole(roleId) @@ -82,7 +44,7 @@ export default function RoleViewPage() {
{Array.from({ length: 4 }).map((_, i) => ( -
+
@@ -133,18 +95,7 @@ export default function RoleViewPage() { - {/* Name row — with lang switcher */} -
- - {t('roles.fields.name', 'Ady')} - -
- - - {role.name?.[activeLang] || '—'} - -
-
+
diff --git a/src/pages/users/allUsersView/index.tsx b/src/pages/users/allUsersView/index.tsx index dad507a..a307d07 100644 --- a/src/pages/users/allUsersView/index.tsx +++ b/src/pages/users/allUsersView/index.tsx @@ -1,8 +1,9 @@ import { useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; -import { Loader2, Pencil, Trash2, CheckCircle2, XCircle, ChevronDown, Plus, Search, SlidersHorizontal, ChevronUp } from "lucide-react"; +import { Pencil, Trash2, CheckCircle2, XCircle, ChevronDown, Plus, Search, SlidersHorizontal, ChevronUp } from "lucide-react"; import { Button } from "@/components/ui/button"; +import { Skeleton } from "@/components/ui/skeleton"; import { AlertDialog, AlertDialogAction, @@ -111,8 +112,16 @@ export default function UserViewPage() { if (isLoading) { return ( -
- +
+ +
+ {Array.from({ length: 5 }).map((_, i) => ( +
+ + +
+ ))} +
); } @@ -122,7 +131,7 @@ export default function UserViewPage() { } return ( -
+
{/* Title + actions */}

diff --git a/src/pages/users/clientsView/index.tsx b/src/pages/users/clientsView/index.tsx index 3d07d9d..c889774 100644 --- a/src/pages/users/clientsView/index.tsx +++ b/src/pages/users/clientsView/index.tsx @@ -3,53 +3,14 @@ import { useParams, useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { Pencil, Trash2, ChevronDown, XCircle, CheckCircle2 } from 'lucide-react' import { Button } from '@/components/ui/button' +import { Skeleton } from '@/components/ui/skeleton' import { ConfirmDialog } from '@/components/confirmDialog' -import { InfoRow, AuditLog } from '@/components/viewPageComponents' +import { BentoGrid, BentoCard, InfoRow, AuditLog } from '@/components/viewPageComponents' import { DataTable, type ColumnDef } from '@/components/dataTable' import { DataTableToolbar } from '@/components/dataTableToolbar' import { useClient, useDeleteClient } from '@/features/clients/hooks/useClients' import type { ClientRole, ClientBranch, ClientAuditLog } from '@/features/clients/api/clientsApi' -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: 'grid-cols-1', - 2: 'grid-cols-1 sm:grid-cols-2', - 3: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-3', - 4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4', - }[cols] - return
{children}
-} - -function BentoCard({ - title, - span, - children, -}: { - title?: string - span?: 'full' | 2 | 3 - children: React.ReactNode -}) { - const spanClass = - span === 'full' ? 'sm:col-span-full' : - span === 2 ? 'sm:col-span-2' : - span === 3 ? 'sm:col-span-3' : '' - - return ( -
- {title && ( -
-

- {title} -

-
- )} - {children} -
- ) -} - // ─── ActiveIndicator ────────────────────────────────────────────────────────── function ActiveIndicator({ active }: { active: boolean }) { @@ -232,10 +193,18 @@ export default function ClientDetailPage() { if (isLoading) { return ( -
- {Array.from({ length: 3 }).map((_, i) => ( -
- ))} +
+ +
+ {Array.from({ length: 4 }).map((_, i) => ( +
+ + {Array.from({ length: 3 }).map((_, j) => ( + + ))} +
+ ))} +
) } @@ -260,7 +229,7 @@ export default function ClientDetailPage() { ) return ( -
+
{/* ── Page header ──────────────────────────────────────────────────── */}
diff --git a/src/pages/users/operatorsView/index.tsx b/src/pages/users/operatorsView/index.tsx index 1d5866b..d0aabdb 100644 --- a/src/pages/users/operatorsView/index.tsx +++ b/src/pages/users/operatorsView/index.tsx @@ -3,40 +3,14 @@ import { useTranslation } from "react-i18next"; import { Pencil, Trash2, ChevronDown, CheckCircle2, XCircle, } from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; +import { Skeleton } from "@/components/ui/skeleton"; import { ConfirmDialog } from "@/components/confirmDialog"; -import { InfoRow, AuditLog } from "@/components/viewPageComponents"; +import { BentoGrid, BentoCard, InfoRow, AuditLog } from "@/components/viewPageComponents"; import { DataTable, type ColumnDef } from "@/components/dataTable"; import { DataTableToolbar } from "@/components/dataTableToolbar"; import { useOperator, useDeleteOperator } from "@/features/operators/hooks/useOperators"; import type { OperatorRole, OperatorBranch, OperatorAuditLog } from "@/features/operators/api/operatorsApi"; -// ─── Bento primitives ───────────────────────────────────────────────────────── - -function BentoGrid({ cols = 2, children }: { cols?: 1 | 2 | 3 | 4; children: React.ReactNode }) { - const colClass = { - 1: "grid-cols-1", - 2: "grid-cols-1 sm:grid-cols-2", - 3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3", - 4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", - }[cols]; - return
{children}
; -} - -function BentoCard({ title, span, children }: { title?: string; span?: "full" | 2 | 3; children: React.ReactNode }) { - const spanClass = span === "full" ? "sm:col-span-full" : span === 2 ? "sm:col-span-2" : span === 3 ? "sm:col-span-3" : ""; - - return ( -
- {title && ( -
-

{title}

-
- )} - {children} -
- ); -} - // ─── IsActive indicator ─────────────────────────────────────────────────────── function ActiveIndicator({ active }: { active: boolean }) { @@ -243,10 +217,18 @@ export default function OperatorDetailPage() { if (isLoading) { return ( -
- {Array.from({ length: 3 }).map((_, i) => ( -
- ))} +
+ +
+ {Array.from({ length: 4 }).map((_, i) => ( +
+ + {Array.from({ length: 3 }).map((_, j) => ( + + ))} +
+ ))} +
); }