added read me file
This commit is contained in:
1 parent
1f79766192
commit
b4085e5340
11 files changed
+882
-254
No files matched your search
@@ -1,73 +1,657 @@
|
|||||||
# React + TypeScript + Vite
|
# TBBank Admin Panel
|
||||||
|
|
||||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
A full-featured internal banking administration panel built with **React 19 + Vite + TypeScript**. It supports loan management, card operations, international payments, user/role management, currency tracking, and system configuration — all in one place.
|
||||||
|
|
||||||
Currently, two official plugins are available:
|
---
|
||||||
|
|
||||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
## Table of Contents
|
||||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
||||||
|
|
||||||
## React Compiler
|
1. [Tech Stack](#tech-stack)
|
||||||
|
2. [Prerequisites](#prerequisites)
|
||||||
|
3. [Getting Started](#getting-started)
|
||||||
|
4. [Environment Variables](#environment-variables)
|
||||||
|
5. [Project Structure](#project-structure)
|
||||||
|
6. [Architecture Overview](#architecture-overview)
|
||||||
|
- [Entry Point & Provider Tree](#entry-point--provider-tree)
|
||||||
|
- [Router](#router)
|
||||||
|
- [Layouts](#layouts)
|
||||||
|
- [State Management (Zustand)](#state-management-zustand)
|
||||||
|
- [Data Fetching (React Query)](#data-fetching-react-query)
|
||||||
|
- [HTTP Client (Axios)](#http-client-axios)
|
||||||
|
- [Internationalization (i18n)](#internationalization-i18n)
|
||||||
|
- [Theming (Light / Dark)](#theming-light--dark)
|
||||||
|
- [Error Handling](#error-handling)
|
||||||
|
- [Form Validation (Zod + RHF)](#form-validation-zod--rhf)
|
||||||
|
7. [Feature Modules](#feature-modules)
|
||||||
|
8. [Shared Components](#shared-components)
|
||||||
|
9. [Route Map](#route-map)
|
||||||
|
10. [Development Standards](#development-standards)
|
||||||
|
11. [Known Issues & Gaps](#known-issues--gaps)
|
||||||
|
|
||||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
---
|
||||||
|
|
||||||
## Expanding the ESLint configuration
|
## Tech Stack
|
||||||
|
|
||||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
| Layer | Library | Version |
|
||||||
|
|---|---|---|
|
||||||
|
| UI Framework | React | ^19.2.5 |
|
||||||
|
| Build Tool | Vite | ^8.0 |
|
||||||
|
| Language | TypeScript | ~6.0 |
|
||||||
|
| Styling | Tailwind CSS v4 | ^4.2 |
|
||||||
|
| UI Components | shadcn/ui (Radix-UI) | ^1.4 |
|
||||||
|
| State Management | Zustand | ^5.0 |
|
||||||
|
| Data Fetching | TanStack React Query | ^5.100 |
|
||||||
|
| HTTP Client | Axios | ^1.15 |
|
||||||
|
| Routing | React Router DOM | ^7.14 |
|
||||||
|
| Forms | React Hook Form + Zod | ^7.75 / ^4.4 |
|
||||||
|
| Tables | TanStack React Table | ^8.21 |
|
||||||
|
| Notifications | Sonner | ^2.0 |
|
||||||
|
| i18n | i18next + react-i18next | ^26 / ^17 |
|
||||||
|
| Charts | Recharts | ^3.8 |
|
||||||
|
| Rich Text | Tiptap | ^3.23 |
|
||||||
|
| Icons | Lucide React | ^1.14 |
|
||||||
|
| Fonts | Geist + Inter (variable) | ^5.2 |
|
||||||
|
|
||||||
```js
|
---
|
||||||
export default defineConfig([
|
|
||||||
globalIgnores(['dist']),
|
|
||||||
{
|
|
||||||
files: ['**/*.{ts,tsx}'],
|
|
||||||
extends: [
|
|
||||||
// Other configs...
|
|
||||||
|
|
||||||
// Remove tseslint.configs.recommended and replace with this
|
## Prerequisites
|
||||||
tseslint.configs.recommendedTypeChecked,
|
|
||||||
// Alternatively, use this for stricter rules
|
|
||||||
tseslint.configs.strictTypeChecked,
|
|
||||||
// Optionally, add this for stylistic rules
|
|
||||||
tseslint.configs.stylisticTypeChecked,
|
|
||||||
|
|
||||||
// Other configs...
|
- **Node.js** ≥ 20.x (LTS recommended)
|
||||||
],
|
- **npm** ≥ 10.x
|
||||||
languageOptions: {
|
- A running backend API — see [Environment Variables](#environment-variables)
|
||||||
parserOptions: {
|
|
||||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
---
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
## Getting Started
|
||||||
// other options...
|
|
||||||
},
|
```bash
|
||||||
},
|
# 1. Clone the repository
|
||||||
])
|
git clone <repo-url>
|
||||||
|
cd tbbank-admin
|
||||||
|
|
||||||
|
# 2. Install dependencies
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# 3. Create your local environment file
|
||||||
|
cp .env.example .env.local # then fill in VITE_API_BASE_URL
|
||||||
|
|
||||||
|
# 4. Start the dev server
|
||||||
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
The app will be available at **http://localhost:5173** by default.
|
||||||
|
|
||||||
```js
|
```bash
|
||||||
// eslint.config.js
|
# Type-check + production build
|
||||||
import reactX from 'eslint-plugin-react-x'
|
npm run build
|
||||||
import reactDom from 'eslint-plugin-react-dom'
|
|
||||||
|
|
||||||
export default defineConfig([
|
# Preview the production build locally
|
||||||
globalIgnores(['dist']),
|
npm run preview
|
||||||
{
|
|
||||||
files: ['**/*.{ts,tsx}'],
|
# Run ESLint
|
||||||
extends: [
|
npm run lint
|
||||||
// Other configs...
|
|
||||||
// Enable lint rules for React
|
|
||||||
reactX.configs['recommended-typescript'],
|
|
||||||
// Enable lint rules for React DOM
|
|
||||||
reactDom.configs.recommended,
|
|
||||||
],
|
|
||||||
languageOptions: {
|
|
||||||
parserOptions: {
|
|
||||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
||||||
tsconfigRootDir: import.meta.dirname,
|
|
||||||
},
|
|
||||||
// other options...
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
Create a `.env.local` file in the project root. **All variables must be prefixed with `VITE_`** to be exposed to the client bundle.
|
||||||
|
|
||||||
|
```env
|
||||||
|
# Base URL for all API requests — no trailing slash
|
||||||
|
VITE_API_BASE_URL=https://api.tbbank.gov.tm/v1
|
||||||
|
```
|
||||||
|
|
||||||
|
> The Axios client reads `import.meta.env.VITE_API_BASE_URL` at runtime.
|
||||||
|
> The refresh-token endpoint is called at `{VITE_API_BASE_URL}/auth/refresh`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── App.tsx # Root component — mounts RouterProvider
|
||||||
|
├── main.tsx # Entry point — renders provider tree into #root
|
||||||
|
├── index.css # Global styles, CSS tokens, Tailwind directives
|
||||||
|
│
|
||||||
|
├── app/
|
||||||
|
│ ├── providers/
|
||||||
|
│ │ ├── QueryProvider.tsx # TanStack Query client + global error toasts
|
||||||
|
│ │ ├── ThemeProvider.tsx # next-themes wrapper (light/dark)
|
||||||
|
│ │ └── ErrorBoundary.tsx # GlobalErrorBoundary + PageErrorBoundary
|
||||||
|
│ ├── router/
|
||||||
|
│ │ └── index.tsx # All routes (createBrowserRouter), lazy imports
|
||||||
|
│ └── store/
|
||||||
|
│ ├── authStore.ts # Zustand — token, user, login, logout, refreshToken
|
||||||
|
│ ├── themeStore.ts # Zustand — light/dark toggle, persisted
|
||||||
|
│ └── i18nStore.ts # Zustand — active language, persisted
|
||||||
|
│
|
||||||
|
├── assets/ # Static files (SVG icons, images)
|
||||||
|
│
|
||||||
|
├── components/
|
||||||
|
│ ├── ui/ # shadcn/ui primitives (button, input, select, …)
|
||||||
|
│ │ ├── sonner.tsx # <Toaster /> — placed once in main.tsx
|
||||||
|
│ │ ├── spinner.tsx # Reusable loading spinner
|
||||||
|
│ │ ├── skeleton.tsx # Skeleton loader
|
||||||
|
│ │ └── statusBadge.tsx # Colored status chip (success/warning/error/info)
|
||||||
|
│ ├── dataTable.tsx # Generic paginated TanStack Table wrapper
|
||||||
|
│ ├── dataTableToolbar.tsx # Search, filters, column toggle, per-page selector
|
||||||
|
│ ├── formInput.tsx # Comprehensive single-step form builder
|
||||||
|
│ ├── stepBarV2.tsx # Multi-step form with Progressive Disclosure
|
||||||
|
│ ├── viewPageComponents.tsx # <InfoRow>, section wrappers for detail pages
|
||||||
|
│ ├── formActions.tsx # Save / Cancel action bar used in forms
|
||||||
|
│ ├── creditCardVisual.tsx # Animated card visual for card-related pages
|
||||||
|
│ ├── tableButton.tsx # Small icon button used inside table rows
|
||||||
|
│ └── tableSearch.tsx # Standalone search input for tables
|
||||||
|
│
|
||||||
|
├── features/ # Feature-Sliced Design — one folder per domain
|
||||||
|
│ └── [feature]/
|
||||||
|
│ ├── api/ # Axios calls + TypeScript types/interfaces
|
||||||
|
│ ├── hooks/ # React Query hooks (useQuery + useMutation)
|
||||||
|
│ ├── components/ # Feature-specific shared components (e.g. *Form.tsx)
|
||||||
|
│ └── schemas/ # Zod schemas for form validation
|
||||||
|
│
|
||||||
|
├── layouts/
|
||||||
|
│ └── DashboardLayout.tsx # Sidebar + header + <Outlet /> for all auth'd pages
|
||||||
|
│
|
||||||
|
├── lib/
|
||||||
|
│ ├── api/
|
||||||
|
│ │ └── client.ts # Axios instance — auth header + 401/403 interceptors
|
||||||
|
│ ├── i18n/
|
||||||
|
│ │ ├── index.ts # i18next init — reads localStorage for saved locale
|
||||||
|
│ │ └── locales/
|
||||||
|
│ │ ├── en.json # English translations
|
||||||
|
│ │ ├── ru.json # Russian translations
|
||||||
|
│ │ └── tk.json # Turkmen translations
|
||||||
|
│ ├── hooks/
|
||||||
|
│ │ ├── useMobile.ts # Detects mobile viewport
|
||||||
|
│ │ └── useOutsideClick.ts
|
||||||
|
│ └── utils.ts # cn() — clsx + tailwind-merge helper
|
||||||
|
│
|
||||||
|
└── pages/ # Route-level page components (thin wrappers)
|
||||||
|
├── login/
|
||||||
|
├── dashboard/
|
||||||
|
├── loanDepartment/ # Loan orders, mobile loans, loan balance, certificates
|
||||||
|
├── cardDepartment/ # Card orders, transactions, requisites, balances, PINs
|
||||||
|
├── internationalPayments/ # Visa/Master, Sber payments
|
||||||
|
├── users/ # Operators, clients, all users
|
||||||
|
├── currencies/ # Currency rates, Visa/Master/Sber settings
|
||||||
|
├── onlinePaymentsHistory/
|
||||||
|
├── settings/
|
||||||
|
│ ├── users/ # Roles, Permissions
|
||||||
|
│ ├── loan/ # Loan types, Required documents
|
||||||
|
│ ├── card/ # Card reasons, Card types
|
||||||
|
│ └── location/ # Districts, Branches
|
||||||
|
└── notFoundPage/
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Architecture Overview
|
||||||
|
|
||||||
|
### Entry Point & Provider Tree
|
||||||
|
|
||||||
|
`main.tsx` composes the provider stack in this exact order (outermost → innermost):
|
||||||
|
|
||||||
|
```
|
||||||
|
GlobalErrorBoundary
|
||||||
|
└─ ThemeProvider (next-themes — manages <html class="dark">)
|
||||||
|
└─ QueryProvider (TanStack Query client with global error toasts)
|
||||||
|
└─ App (RouterProvider)
|
||||||
|
└─ Toaster (sonner — placed here so it is always mounted)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Why this order matters:**
|
||||||
|
- `GlobalErrorBoundary` catches JS crashes from _any_ child including providers.
|
||||||
|
- `ThemeProvider` must wrap everything so CSS variables resolve before first paint.
|
||||||
|
- `QueryProvider` creates the single shared `queryClient` with centralized `QueryCache` / `MutationCache` error handlers — so individual hooks do _not_ need their own `toast.error()`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Router
|
||||||
|
|
||||||
|
`src/app/router/index.tsx` uses `createBrowserRouter` (React Router v7).
|
||||||
|
|
||||||
|
**Guards (Outlet-based):**
|
||||||
|
|
||||||
|
| Guard | Behavior |
|
||||||
|
|---|---|
|
||||||
|
| `PublicGuard` | If already authenticated → redirect to `/dashboard` |
|
||||||
|
| `AuthGuard` | If not authenticated → redirect to `/login` |
|
||||||
|
|
||||||
|
**Lazy Loading:** Every page component is wrapped in `React.lazy()` + `<Suspense fallback={<PageLoader />}>`. This keeps the initial bundle tiny — only the login page is loaded on first visit.
|
||||||
|
|
||||||
|
**Error Element:** `<PageErrorFallback />` is set on all route levels so any render-time exception shows a recovery UI instead of a blank screen.
|
||||||
|
|
||||||
|
**Adding a new route:**
|
||||||
|
1. Create a `lazy()` import at the top of `router/index.tsx`.
|
||||||
|
2. Add the route object inside the `AuthGuard → DashboardLayout` children array.
|
||||||
|
3. Follow the pattern: list `/feature`, create `/feature/create`, view `/feature/:id`, edit `/feature/:id/edit`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Layouts
|
||||||
|
|
||||||
|
There is currently **one layout**: `DashboardLayout`.
|
||||||
|
|
||||||
|
`DashboardLayout` (`src/layouts/DashboardLayout.tsx`) renders:
|
||||||
|
- **`<AppSidebar />`** — collapsible 3-level navigation using shadcn `Sidebar` + Radix Collapsible. Auto-expands the active section based on `useLocation()`.
|
||||||
|
- **`<DashboardHeader />`** — breadcrumbs auto-generated from the URL path, language switcher (EN/RU/TK), theme toggle, and notifications bell.
|
||||||
|
- **`<Outlet />`** — the matched page is rendered here.
|
||||||
|
- **Footer** — copyright line.
|
||||||
|
|
||||||
|
The sidebar nav structure is a `NavGroup[]` array defined inside `AppSidebar`. When you add a new section, add it here alongside the route.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### State Management (Zustand)
|
||||||
|
|
||||||
|
All stores live in `src/app/store/` and use the `persist` middleware (localStorage).
|
||||||
|
|
||||||
|
| Store | Key | What it holds |
|
||||||
|
|---|---|---|
|
||||||
|
| `authStore` | `tbbank-auth` | `token`, `user`, `isAuthenticated`, `setAuth()`, `logout()`, `refreshToken()` |
|
||||||
|
| `themeStore` | `tbbank-theme` | `theme: 'light' \| 'dark'`, `setTheme()`, `toggleTheme()`. Applies class to `<html>` immediately on rehydration. |
|
||||||
|
| `i18nStore` | `tbbank-lang` | `language: 'en' \| 'ru' \| 'tk'`, `setLanguage()`. Calls `i18n.changeLanguage()` on change. |
|
||||||
|
|
||||||
|
> **Rule:** Zustand is for **global persistent UI state only**. Server data lives in React Query. Never put API responses into Zustand.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Data Fetching (React Query)
|
||||||
|
|
||||||
|
`QueryProvider` creates one shared `queryClient` with:
|
||||||
|
|
||||||
|
- **`staleTime`**: 5 minutes — data is considered fresh for 5 min after fetch.
|
||||||
|
- **`gcTime`**: 10 minutes — cached data is garbage-collected after 10 min of inactivity.
|
||||||
|
- **`refetchOnWindowFocus`**: `false` — no surprise refetches when the user alt-tabs.
|
||||||
|
- **Retry logic**: Retries once on failure, but _never_ retries on `401`, `403`, or `404` responses.
|
||||||
|
- **Global `QueryCache.onError`**: Shows `toast.error()` for all failed queries (unless `meta.silent = true`).
|
||||||
|
- **Global `MutationCache.onError`**: Same for mutations.
|
||||||
|
|
||||||
|
**Hook pattern** (every feature follows this):
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// features/[feature]/hooks/use[Feature]s.ts
|
||||||
|
|
||||||
|
export function use[Feature]s(params) {
|
||||||
|
return useQuery({ queryKey: [KEY, params], queryFn: () => fetch[Feature]s(params) })
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useCreate[Feature]() {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (payload) => create[Feature](payload),
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: [KEY] })
|
||||||
|
toast.success(t('...'))
|
||||||
|
},
|
||||||
|
// No onError needed — global MutationCache handles it
|
||||||
|
})
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Important:** Do **not** write `toast.error()` inside hooks — the global `MutationCache` already handles it. To suppress a toast for a specific query/mutation, pass `meta: { silent: true }`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### HTTP Client (Axios)
|
||||||
|
|
||||||
|
`src/lib/api/client.ts` exports a single Axios instance (`apiClient`).
|
||||||
|
|
||||||
|
**Request Interceptor:**
|
||||||
|
- Reads `token` from `authStore.getState()` on every request.
|
||||||
|
- Injects `Authorization: Bearer <token>` header.
|
||||||
|
|
||||||
|
**Response Interceptor (401 handling):**
|
||||||
|
1. Catches `401 Unauthorized`.
|
||||||
|
2. If a refresh is already in progress, queues the failed request.
|
||||||
|
3. Calls `authStore.getState().refreshToken()` — which POSTs to `/auth/refresh` using a _separate_ plain `axios` instance (avoids circular dependency with `apiClient`).
|
||||||
|
4. On success: replays all queued requests with the new token.
|
||||||
|
5. On failure: calls `logout()` and dispatches the `auth:unauthorized` window event (the router listens for this to redirect to `/login`).
|
||||||
|
|
||||||
|
**403 handling:** Dispatches `auth:forbidden` event. The app shows a toast but keeps the user on the page.
|
||||||
|
|
||||||
|
> When connecting to a real backend, ensure `/auth/refresh` accepts the current (expired) JWT in the `Authorization` header and returns `{ token: string }`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Internationalization (i18n)
|
||||||
|
|
||||||
|
- **Supported locales:** `en`, `ru`, `tk` (Turkmen)
|
||||||
|
- **Translation files:** `src/lib/i18n/locales/{en,ru,tk}.json`
|
||||||
|
- **Initialization:** `src/lib/i18n/index.ts` — reads the saved language from `localStorage` (`tbbank-lang` key) before initializing so there is no flash of the wrong language.
|
||||||
|
- **Usage in components:** `const { t } = useTranslation()` → `t('some.key')`
|
||||||
|
- **Changing language:** Call `useI18nStore().setLanguage('ru')` — it updates both i18next and Zustand.
|
||||||
|
|
||||||
|
> **Hard-coded strings in JSX are forbidden.** Every user-facing string must have an entry in all three locale files.
|
||||||
|
|
||||||
|
**Adding a new translation key:**
|
||||||
|
1. Add the key-value pair to `en.json`.
|
||||||
|
2. Add the same key with the translated value to `ru.json` and `tk.json`.
|
||||||
|
3. Use `t('your.key')` in the component.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Theming (Light / Dark)
|
||||||
|
|
||||||
|
- `ThemeProvider` wraps the app with `next-themes` (`attribute="class"`, `enableSystem={false}`).
|
||||||
|
- `themeStore` stores the user's preference and applies/removes the `dark` class on `<html>` immediately on store rehydration (no flash).
|
||||||
|
- All colors use Tailwind CSS semantic tokens (e.g. `bg-background`, `text-foreground`, `border-border`) defined as CSS custom properties in `index.css`. **Avoid raw color classes** like `bg-white` or `text-gray-900`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Error Handling
|
||||||
|
|
||||||
|
Two error boundary wrappers are exported from `src/app/providers/ErrorBoundary.tsx`:
|
||||||
|
|
||||||
|
| Component | Where used | Fallback |
|
||||||
|
|---|---|---|
|
||||||
|
| `GlobalErrorBoundary` | `main.tsx` — wraps the entire app | Full-screen error message + Reload button |
|
||||||
|
| `PageErrorBoundary` | Set as `errorElement` on each route | Same, but scoped to the content area |
|
||||||
|
|
||||||
|
> **Blank screens are forbidden.** Every boundary renders a meaningful fallback UI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Form Validation (Zod + RHF)
|
||||||
|
|
||||||
|
- Each feature's forms have a dedicated schema at `src/features/[feature]/schemas/[feature].schema.ts`.
|
||||||
|
- Schemas use `zod` and are connected to React Hook Form via `zodResolver`.
|
||||||
|
- Types are derived with `z.infer<typeof schema>` — **never** define a separate TypeScript interface for form data.
|
||||||
|
- Server validation errors are set with RHF's `setError()` on the relevant field.
|
||||||
|
- `if/else` manual validation is **forbidden**.
|
||||||
|
|
||||||
|
**Single-step forms** → use `<FormInput />` (`src/components/formInput.tsx`)
|
||||||
|
**Multi-step forms** → use `<StepBarV2 />` (`src/components/stepBarV2.tsx`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Feature Modules
|
||||||
|
|
||||||
|
Each feature lives under `src/features/[feature]/` with this internal structure:
|
||||||
|
|
||||||
|
```
|
||||||
|
[feature]/
|
||||||
|
├── api/
|
||||||
|
│ └── [feature]Api.ts # Types (interfaces), API functions (axios calls)
|
||||||
|
├── hooks/
|
||||||
|
│ └── use[Feature]s.ts # useQuery + useMutation wrappers
|
||||||
|
├── components/
|
||||||
|
│ └── [Feature]Form.tsx # Shared Create/Edit form (mode="create"|"edit")
|
||||||
|
└── schemas/
|
||||||
|
└── [feature].schema.ts # Zod validation schema
|
||||||
|
```
|
||||||
|
|
||||||
|
**Currently implemented features:**
|
||||||
|
|
||||||
|
| Feature | Module path |
|
||||||
|
|---|---|
|
||||||
|
| Authentication | `features/auth` |
|
||||||
|
| Loan Orders | `features/loanOrders` |
|
||||||
|
| Loan Order Mobiles | `features/loanOrderMobiles` |
|
||||||
|
| Loan Remaining | `features/loanRemaining` |
|
||||||
|
| Loan Paid-Off Letters | `features/loanPaidOffLetters` |
|
||||||
|
| Loan Types (Settings) | `features/loanTypes` |
|
||||||
|
| Required Documents (Settings) | `features/requiredDocuments` |
|
||||||
|
| Order New Card | `features/orderNewCard` |
|
||||||
|
| Card Transactions | `features/cardTransactions` |
|
||||||
|
| Card Requisites | `features/cardRequisites` |
|
||||||
|
| Card Balance | `features/cardBalance` |
|
||||||
|
| Card Pins | `features/cardPins` |
|
||||||
|
| Card Reasons (Settings) | `features/cardReasons` |
|
||||||
|
| Card Types (Settings) | `features/cardTypes` |
|
||||||
|
| Visa/Master Payments | `features/visaMasterPayments` |
|
||||||
|
| Sber Payments | `features/sberPayments` |
|
||||||
|
| Visa/Master/Sber Settings | `features/visaMasterSberSettings` |
|
||||||
|
| Operators | `features/operators` |
|
||||||
|
| All Users | `features/allUsers` |
|
||||||
|
| Clients | `features/clients` |
|
||||||
|
| Currency Rates | `features/currencyRates` |
|
||||||
|
| Online Payment History | `features/onlinePaymentHistory` |
|
||||||
|
| Roles (Settings) | `features/roles` |
|
||||||
|
| Permissions (Settings) | `features/permissions` |
|
||||||
|
| Districts (Settings) | `features/districts` |
|
||||||
|
| Branches (Settings) | `features/branches` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Shared Components
|
||||||
|
|
||||||
|
### `DataTable` (`src/components/dataTable.tsx`)
|
||||||
|
Generic paginated table built on TanStack React Table v8. Accepts `ColumnDef[]`, `data[]`, loading state, column visibility/order, pagination controls.
|
||||||
|
|
||||||
|
### `DataTableToolbar` (`src/components/dataTableToolbar.tsx`)
|
||||||
|
Toolbar placed above `DataTable`. Provides: search input, dynamic filter dropdowns, column visibility toggle, column drag-to-reorder, per-page selector, and an action button (usually "Create").
|
||||||
|
|
||||||
|
### `FormInput` (`src/components/formInput.tsx`)
|
||||||
|
Comprehensive single-step form builder. Renders `text`, `select`, `date`, `textarea`, `rich-text` (Tiptap), and `file-upload` fields from a config array. Always paired with RHF + Zod.
|
||||||
|
|
||||||
|
### `StepBarV2` (`src/components/stepBarV2.tsx`)
|
||||||
|
Multi-step form shell with a step indicator bar. Use this when a create/edit form has more than one logical group of fields (Progressive Disclosure).
|
||||||
|
|
||||||
|
### `ViewPageComponents` (`src/components/viewPageComponents.tsx`)
|
||||||
|
`<InfoRow label="...">value</InfoRow>` — the standard layout for detail/view pages. Renders a two-column label-value grid inside a `bg-card` container.
|
||||||
|
|
||||||
|
### `StatusBadge` (`src/components/ui/statusBadge.tsx`)
|
||||||
|
Colored pill badge. Variants: `success` | `warning` | `error` | `info`.
|
||||||
|
|
||||||
|
### `FormActions` (`src/components/formActions.tsx`)
|
||||||
|
Sticky Save / Cancel action bar. Handles the loading state of the submit button.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Route Map
|
||||||
|
|
||||||
|
All authenticated routes are nested under `DashboardLayout`. The full list:
|
||||||
|
|
||||||
|
```
|
||||||
|
/login Public
|
||||||
|
|
||||||
|
/dashboard
|
||||||
|
|
||||||
|
/loan-orders
|
||||||
|
/loan-orders/create
|
||||||
|
/loan-orders/:id
|
||||||
|
/loan-orders/:id/edit
|
||||||
|
|
||||||
|
/loan-order-mobiles
|
||||||
|
/loan-order-mobiles/create
|
||||||
|
/loan-order-mobiles/:id
|
||||||
|
/loan-order-mobiles/:id/edit
|
||||||
|
|
||||||
|
/loan-remaining
|
||||||
|
/loan-remaining/create
|
||||||
|
/loan-remaining/:id
|
||||||
|
/loan-remaining/:id/edit
|
||||||
|
|
||||||
|
/loan-paid-off-letters
|
||||||
|
|
||||||
|
/order-new-card
|
||||||
|
/order-new-card/create
|
||||||
|
/order-new-card/:id
|
||||||
|
/order-new-card/:id/edit
|
||||||
|
|
||||||
|
/card-transactions
|
||||||
|
/card-transactions/create
|
||||||
|
/card-transactions/:id
|
||||||
|
/card-transactions/:id/edit
|
||||||
|
|
||||||
|
/card-requisites
|
||||||
|
/card-requisites/create
|
||||||
|
/card-requisites/:id
|
||||||
|
/card-requisites/:id/edit
|
||||||
|
|
||||||
|
/card-balances
|
||||||
|
/card-balances/create
|
||||||
|
/card-balances/:id
|
||||||
|
/card-balances/:id/edit
|
||||||
|
|
||||||
|
/card-pins
|
||||||
|
/card-pins/create
|
||||||
|
/card-pins/:id
|
||||||
|
/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
|
||||||
|
|
||||||
|
/sber-payments
|
||||||
|
/sber-payments/create
|
||||||
|
/sber-payments/:id
|
||||||
|
/sber-payments/:id/edit
|
||||||
|
|
||||||
|
/operators
|
||||||
|
/operators/create
|
||||||
|
/operators/:id
|
||||||
|
/operators/:id/edit
|
||||||
|
|
||||||
|
/clients
|
||||||
|
/clients/create
|
||||||
|
/clients/:id
|
||||||
|
/clients/:id/edit
|
||||||
|
|
||||||
|
/all-users
|
||||||
|
/all-users/create
|
||||||
|
/all-users/:id
|
||||||
|
/all-users/:id/edit
|
||||||
|
|
||||||
|
/currency-rates
|
||||||
|
/currency-rates/create
|
||||||
|
/currency-rates/:id
|
||||||
|
/currency-rates/:id/edit
|
||||||
|
|
||||||
|
/visa-master-sber-settings
|
||||||
|
/visa-master-sber-settings/create
|
||||||
|
/visa-master-sber-settings/:id/edit (no view page)
|
||||||
|
|
||||||
|
/online-payments-history
|
||||||
|
/online-payments-history/:id
|
||||||
|
|
||||||
|
/settings/users/roles
|
||||||
|
/settings/users/roles/create
|
||||||
|
/settings/users/roles/:id
|
||||||
|
/settings/users/roles/:id/edit
|
||||||
|
|
||||||
|
/settings/users/permissions
|
||||||
|
/settings/users/permissions/create
|
||||||
|
/settings/users/permissions/:id
|
||||||
|
/settings/users/permissions/:id/edit
|
||||||
|
|
||||||
|
/settings/loan/loan-types
|
||||||
|
/settings/loan/loan-types/create
|
||||||
|
/settings/loan/loan-types/:id
|
||||||
|
/settings/loan/loan-types/:id/edit
|
||||||
|
|
||||||
|
/settings/loan/required-documents
|
||||||
|
/settings/loan/required-documents/create
|
||||||
|
/settings/loan/required-documents/:id
|
||||||
|
/settings/loan/required-documents/:id/edit
|
||||||
|
|
||||||
|
/settings/card/card-reasons
|
||||||
|
/settings/card/card-reasons/create
|
||||||
|
/settings/card/card-reasons/:id
|
||||||
|
/settings/card/card-reasons/:id/edit
|
||||||
|
|
||||||
|
/settings/card/card-types
|
||||||
|
/settings/card/card-types/create
|
||||||
|
/settings/card/card-types/:id
|
||||||
|
/settings/card/card-types/:id/edit
|
||||||
|
|
||||||
|
/settings/location/districts
|
||||||
|
/settings/location/districts/create
|
||||||
|
/settings/location/districts/:id
|
||||||
|
/settings/location/districts/:id/edit
|
||||||
|
|
||||||
|
/settings/location/branches
|
||||||
|
/settings/location/branches/create
|
||||||
|
/settings/location/branches/:id
|
||||||
|
/settings/location/branches/:id/edit
|
||||||
|
|
||||||
|
* → NotFoundPage
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Development Standards
|
||||||
|
|
||||||
|
> This section is the quick-reference summary of `PROJECT_STANDARDS.md`. Read that file for the full spec.
|
||||||
|
|
||||||
|
### Adding a new module — checklist
|
||||||
|
|
||||||
|
- [ ] Create `src/features/[feature]/api/[feature]Api.ts` — define types and async functions using `apiClient`.
|
||||||
|
- [ ] Create `src/features/[feature]/schemas/[feature].schema.ts` — Zod schema, export `z.infer<>` type.
|
||||||
|
- [ ] Create `src/features/[feature]/hooks/use[Feature]s.ts` — wrap in `useQuery` / `useMutation`.
|
||||||
|
- [ ] Create `src/features/[feature]/components/[Feature]Form.tsx` — shared create/edit form with `mode: 'create' | 'edit'` prop.
|
||||||
|
- [ ] Create thin page wrappers in `src/pages/[section]/[feature]{Create,View,Edit}/index.tsx`.
|
||||||
|
- [ ] Register all routes in `src/app/router/index.tsx`.
|
||||||
|
- [ ] Add sidebar nav entries in `DashboardLayout.tsx → navGroups`.
|
||||||
|
- [ ] Add all user-facing strings to `en.json`, `ru.json`, `tk.json`.
|
||||||
|
|
||||||
|
### Strict rules
|
||||||
|
|
||||||
|
| Rule | Detail |
|
||||||
|
|---|---|
|
||||||
|
| No `any` | Use `unknown` or define proper interfaces/types. |
|
||||||
|
| No hard-coded strings | Every text must go through `t('key')`. |
|
||||||
|
| No duplicate forms | Create/Edit pages must share one `[Feature]Form` component. |
|
||||||
|
| No bare `try/catch` that swallows errors | Always `console.error` or rethrow. |
|
||||||
|
| No `toast.error()` in hooks | Global `MutationCache.onError` handles it. Use `meta: { silent: true }` to opt out. |
|
||||||
|
| Always show loading states | Use `<Spinner />` or `<Skeleton />` while data loads. |
|
||||||
|
| Disable buttons during mutation | `disabled={mutation.isPending}` on submit buttons. |
|
||||||
|
| `PageErrorBoundary` on every route | Already set via `errorElement` in the router. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Known Issues & Gaps
|
||||||
|
|
||||||
|
These items exist in the sidebar nav or codebase but are **not yet implemented** — good starting points for the next developer:
|
||||||
|
|
||||||
|
| Item | Status | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| **`/settings/language/locale-manager`** | ❌ No route or page | Sidebar entry exists but leads nowhere |
|
||||||
|
| **`/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 |
|
||||||
|
| **`useLoanOrders` toast duplication** | ⚠️ | The hook calls `toast.error()` inside `onError` while the global `MutationCache` also does — results in double toasts. Other features may have the same pattern. |
|
||||||
|
| **`DashboardLayout` sidebar strings** | ⚠️ | Nav item titles use `t("English", "Fallback")` instead of proper i18n keys — inconsistent with the project standard |
|
||||||
|
| **`AuthLayout`** | ❌ Missing | No dedicated layout for the login page; it renders without a wrapper layout |
|
||||||
|
| **Mock data** | ⚠️ | All API functions currently return **mock in-memory data**. When connecting a real backend, replace the functions in `[feature]Api.ts` with real `apiClient.get/post/put/delete()` calls. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Connecting a Real Backend
|
||||||
|
|
||||||
|
All API logic is isolated in `src/features/[feature]/api/[feature]Api.ts`. To go live:
|
||||||
|
|
||||||
|
1. Set `VITE_API_BASE_URL` in your `.env` file.
|
||||||
|
2. Open each `[feature]Api.ts`.
|
||||||
|
3. Replace the mock functions with real Axios calls, for example:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Before (mock)
|
||||||
|
export async function fetchLoanOrders(params: LoanOrdersParams) {
|
||||||
|
await delay(600)
|
||||||
|
return { data: mockStore, total: mockStore.length, page: 1, perPage: 25 }
|
||||||
|
}
|
||||||
|
|
||||||
|
// After (real)
|
||||||
|
export async function fetchLoanOrders(params: LoanOrdersParams) {
|
||||||
|
const { data } = await apiClient.get<LoanOrdersResponse>('/loan-orders', { params })
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Adjust the response shape to match what your backend returns. Update the TypeScript interfaces in the same file accordingly.
|
||||||
|
5. Make sure the backend's `/auth/refresh` endpoint returns `{ token: string }` — that is what `authStore.refreshToken()` expects.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Last updated: 2026-05-15 — TBBank Admin v2.0*
|
||||||
Generated
+27
-24
@@ -100,6 +100,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz",
|
||||||
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
|
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.29.0",
|
"@babel/code-frame": "^7.29.0",
|
||||||
"@babel/generator": "^7.29.0",
|
"@babel/generator": "^7.29.0",
|
||||||
@@ -661,29 +662,6 @@
|
|||||||
"@noble/ciphers": "^1.0.0"
|
"@noble/ciphers": "^1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@emnapi/core": {
|
|
||||||
"version": "1.10.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
|
|
||||||
"integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@emnapi/wasi-threads": "1.2.1",
|
|
||||||
"tslib": "^2.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@emnapi/runtime": {
|
|
||||||
"version": "1.10.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
|
|
||||||
"integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
|
||||||
"tslib": "^2.4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@emnapi/wasi-threads": {
|
"node_modules/@emnapi/wasi-threads": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
|
||||||
@@ -837,6 +815,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.6.tgz",
|
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.6.tgz",
|
||||||
"integrity": "sha512-9gZSAI5XM36880PPMm//9dfiEngYoC6Am2izES1FF406YFsjvyBMmeJ2g4SAju3xWwtuynNRFL2s9hgxpLI5SQ==",
|
"integrity": "sha512-9gZSAI5XM36880PPMm//9dfiEngYoC6Am2izES1FF406YFsjvyBMmeJ2g4SAju3xWwtuynNRFL2s9hgxpLI5SQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@floating-ui/core": "^1.7.5",
|
"@floating-ui/core": "^1.7.5",
|
||||||
"@floating-ui/utils": "^0.2.11"
|
"@floating-ui/utils": "^0.2.11"
|
||||||
@@ -1205,6 +1184,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz",
|
||||||
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
|
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^14.21.3 || >=16"
|
"node": "^14.21.3 || >=16"
|
||||||
},
|
},
|
||||||
@@ -3478,6 +3458,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.23.2.tgz",
|
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.23.2.tgz",
|
||||||
"integrity": "sha512-yjv2N7gaQMbIVfsSZHBMscLoybgetcTraXsSMrELAerl/jfRipg5S1dBXMFvgRy8Kh48+TGoH+5nqshxdOEGoQ==",
|
"integrity": "sha512-yjv2N7gaQMbIVfsSZHBMscLoybgetcTraXsSMrELAerl/jfRipg5S1dBXMFvgRy8Kh48+TGoH+5nqshxdOEGoQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "github",
|
"type": "github",
|
||||||
"url": "https://github.com/sponsors/ueberdosis"
|
"url": "https://github.com/sponsors/ueberdosis"
|
||||||
@@ -3700,6 +3681,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.23.2.tgz",
|
"resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.23.2.tgz",
|
||||||
"integrity": "sha512-tRbbjpOPrY4ApIHtn3ctnKIhkkioewMsZa5gJzqVB47LJFNyzLXLo/aID4sJRKTIMi1wd1fA9TiBKPe6KqczPA==",
|
"integrity": "sha512-tRbbjpOPrY4ApIHtn3ctnKIhkkioewMsZa5gJzqVB47LJFNyzLXLo/aID4sJRKTIMi1wd1fA9TiBKPe6KqczPA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "github",
|
"type": "github",
|
||||||
"url": "https://github.com/sponsors/ueberdosis"
|
"url": "https://github.com/sponsors/ueberdosis"
|
||||||
@@ -3805,6 +3787,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.23.2.tgz",
|
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.23.2.tgz",
|
||||||
"integrity": "sha512-kRHQ3nSbAfkFdxj9FtDdr4hpREndGgWFA6ZEAwlLeGUxf8QYTpuF9zb2yxdBPBlTc5+JsbPcskNt+u1PazGKYw==",
|
"integrity": "sha512-kRHQ3nSbAfkFdxj9FtDdr4hpREndGgWFA6ZEAwlLeGUxf8QYTpuF9zb2yxdBPBlTc5+JsbPcskNt+u1PazGKYw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "github",
|
"type": "github",
|
||||||
"url": "https://github.com/sponsors/ueberdosis"
|
"url": "https://github.com/sponsors/ueberdosis"
|
||||||
@@ -3819,6 +3802,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.23.2.tgz",
|
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.23.2.tgz",
|
||||||
"integrity": "sha512-1kvsBqGNu2ZJ0P/lkxN0pAMqSyUcpkMIzE4xwGUIyAiD0pZV6dr+OCMwGWOTLllSyrn91xI5K7OLk3pYeCPKqA==",
|
"integrity": "sha512-1kvsBqGNu2ZJ0P/lkxN0pAMqSyUcpkMIzE4xwGUIyAiD0pZV6dr+OCMwGWOTLllSyrn91xI5K7OLk3pYeCPKqA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"prosemirror-changeset": "^2.3.0",
|
"prosemirror-changeset": "^2.3.0",
|
||||||
"prosemirror-commands": "^1.6.2",
|
"prosemirror-commands": "^1.6.2",
|
||||||
@@ -4012,6 +3996,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.2.tgz",
|
||||||
"integrity": "sha512-A1sre26ke7HDIuY/M23nd9gfB+nrmhtYyMINbjI1zHJxYteKR6qSMX56FsmjMcDb3SMcjJg5BiRRgOCC/yBD0g==",
|
"integrity": "sha512-A1sre26ke7HDIuY/M23nd9gfB+nrmhtYyMINbjI1zHJxYteKR6qSMX56FsmjMcDb3SMcjJg5BiRRgOCC/yBD0g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~7.16.0"
|
"undici-types": "~7.16.0"
|
||||||
}
|
}
|
||||||
@@ -4021,6 +4006,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
||||||
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.2.2"
|
"csstype": "^3.2.2"
|
||||||
}
|
}
|
||||||
@@ -4030,6 +4016,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz",
|
||||||
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
|
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": "^19.2.0"
|
"@types/react": "^19.2.0"
|
||||||
}
|
}
|
||||||
@@ -4106,6 +4093,7 @@
|
|||||||
"integrity": "sha512-HDQH9O/47Dxi1ceDhBXdaldtf/WV9yRYMjbjCuNk3qnaTD564qwv61Y7+gTxwxRKzSrgO5uhtw584igXVuuZkA==",
|
"integrity": "sha512-HDQH9O/47Dxi1ceDhBXdaldtf/WV9yRYMjbjCuNk3qnaTD564qwv61Y7+gTxwxRKzSrgO5uhtw584igXVuuZkA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.59.1",
|
"@typescript-eslint/scope-manager": "8.59.1",
|
||||||
"@typescript-eslint/types": "8.59.1",
|
"@typescript-eslint/types": "8.59.1",
|
||||||
@@ -4349,6 +4337,7 @@
|
|||||||
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -4630,6 +4619,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.10.12",
|
"baseline-browser-mapping": "^2.10.12",
|
||||||
"caniuse-lite": "^1.0.30001782",
|
"caniuse-lite": "^1.0.30001782",
|
||||||
@@ -5489,6 +5479,7 @@
|
|||||||
"integrity": "sha512-XbEXaRva5cF0ZQB8w6MluHA0kZZfV2DuCMJ3ozyEOHLwDpZX2Lmm/7Pp0xdJmI0GL1W05VH5VwIFHEm1Vcw2gw==",
|
"integrity": "sha512-XbEXaRva5cF0ZQB8w6MluHA0kZZfV2DuCMJ3ozyEOHLwDpZX2Lmm/7Pp0xdJmI0GL1W05VH5VwIFHEm1Vcw2gw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.8.0",
|
"@eslint-community/eslint-utils": "^4.8.0",
|
||||||
"@eslint-community/regexpp": "^4.12.2",
|
"@eslint-community/regexpp": "^4.12.2",
|
||||||
@@ -5745,6 +5736,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
|
||||||
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
|
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"accepts": "^2.0.0",
|
"accepts": "^2.0.0",
|
||||||
"body-parser": "^2.2.1",
|
"body-parser": "^2.2.1",
|
||||||
@@ -6419,6 +6411,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.16.tgz",
|
"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.16.tgz",
|
||||||
"integrity": "sha512-jN0ZewiNAWSe5khM3EyCmBb250+b40wWbwNILNfEvq84VREWwOIkuUsFONk/3i3nqkz7Oe1PcpM2mwQEK2L9Kg==",
|
"integrity": "sha512-jN0ZewiNAWSe5khM3EyCmBb250+b40wWbwNILNfEvq84VREWwOIkuUsFONk/3i3nqkz7Oe1PcpM2mwQEK2L9Kg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
}
|
}
|
||||||
@@ -6493,6 +6486,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5 || ^6"
|
"typescript": "^5 || ^6"
|
||||||
},
|
},
|
||||||
@@ -7902,6 +7896,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nanoid": "^3.3.11",
|
"nanoid": "^3.3.11",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
@@ -8292,6 +8287,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.5.tgz",
|
||||||
"integrity": "sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA==",
|
"integrity": "sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@@ -8323,6 +8319,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.5.tgz",
|
||||||
"integrity": "sha512-J5bAZz+DXMMwW/wV3xzKke59Af6CHY7G4uYLN1OvBcKEsWOs4pQExj86BBKamxl/Ik5bx9whOrvBlSDfWzgSag==",
|
"integrity": "sha512-J5bAZz+DXMMwW/wV3xzKke59Af6CHY7G4uYLN1OvBcKEsWOs4pQExj86BBKamxl/Ik5bx9whOrvBlSDfWzgSag==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "^0.27.0"
|
"scheduler": "^0.27.0"
|
||||||
},
|
},
|
||||||
@@ -8335,6 +8332,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.75.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.75.0.tgz",
|
||||||
"integrity": "sha512-Ovv94H+0p3sJ7B9B5QxPuCP1u8V/cHuVGyH55cSwodYDtoJwK+fqk3vjfIgSX59I2U/bU4z0nRJ9HMLpNiWEmw==",
|
"integrity": "sha512-Ovv94H+0p3sJ7B9B5QxPuCP1u8V/cHuVGyH55cSwodYDtoJwK+fqk3vjfIgSX59I2U/bU4z0nRJ9HMLpNiWEmw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
},
|
},
|
||||||
@@ -8385,6 +8383,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
|
||||||
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
|
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/use-sync-external-store": "^0.0.6",
|
"@types/use-sync-external-store": "^0.0.6",
|
||||||
"use-sync-external-store": "^1.4.0"
|
"use-sync-external-store": "^1.4.0"
|
||||||
@@ -8579,7 +8578,8 @@
|
|||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
|
||||||
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
|
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"peer": true
|
||||||
},
|
},
|
||||||
"node_modules/redux-thunk": {
|
"node_modules/redux-thunk": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
@@ -9351,6 +9351,7 @@
|
|||||||
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
@@ -9585,6 +9586,7 @@
|
|||||||
"integrity": "sha512-rZuUu9j6J5uotLDs+cAA4O5H4K1SfPliUlQwqa6YEwSrWDZzP4rhm00oJR5snMewjxF5V/K3D4kctsUTsIU9Mw==",
|
"integrity": "sha512-rZuUu9j6J5uotLDs+cAA4O5H4K1SfPliUlQwqa6YEwSrWDZzP4rhm00oJR5snMewjxF5V/K3D4kctsUTsIU9Mw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lightningcss": "^1.32.0",
|
"lightningcss": "^1.32.0",
|
||||||
"picomatch": "^4.0.4",
|
"picomatch": "^4.0.4",
|
||||||
@@ -9914,6 +9916,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
|
||||||
"integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
|
"integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/colinhacks"
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
}
|
}
|
||||||
|
|||||||
+28
@@ -1,7 +1,35 @@
|
|||||||
|
import { useEffect } from 'react'
|
||||||
import { RouterProvider } from 'react-router-dom'
|
import { RouterProvider } from 'react-router-dom'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
import i18next from 'i18next'
|
||||||
import { router } from '@/app/router'
|
import { router } from '@/app/router'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
useEffect(() => {
|
||||||
|
// Fired by the Axios response interceptor (client.ts) when a 401 is received
|
||||||
|
// and the refresh token attempt also fails — the user must re-authenticate.
|
||||||
|
const handleUnauthorized = () => {
|
||||||
|
router.navigate('/login', { replace: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fired by the Axios response interceptor (client.ts) on 403 Forbidden.
|
||||||
|
// The user stays on the current page but receives a toast notification.
|
||||||
|
const handleForbidden = () => {
|
||||||
|
toast.error(
|
||||||
|
i18next.t('errors.forbidden', 'You do not have permission to perform this action.'),
|
||||||
|
{ id: 'auth-forbidden' },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('auth:unauthorized', handleUnauthorized)
|
||||||
|
window.addEventListener('auth:forbidden', handleForbidden)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('auth:unauthorized', handleUnauthorized)
|
||||||
|
window.removeEventListener('auth:forbidden', handleForbidden)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
return <RouterProvider router={router} />
|
return <RouterProvider router={router} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { ThemeProvider as NextThemesProvider } from 'next-themes'
|
|
||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
interface ThemeProviderProps {
|
interface ThemeProviderProps {
|
||||||
@@ -6,9 +5,7 @@ interface ThemeProviderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ThemeProvider({ children }: ThemeProviderProps) {
|
export function ThemeProvider({ children }: ThemeProviderProps) {
|
||||||
return (
|
// Theme is managed by useThemeStore in src/app/store/themeStore.ts
|
||||||
<NextThemesProvider attribute="class" defaultTheme="light" enableSystem={false}>
|
// next-themes was removed to avoid conflicts and double persistence issues.
|
||||||
{children}
|
return <>{children}</>
|
||||||
</NextThemesProvider>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import { createBrowserRouter, Navigate, Outlet } from "react-router-dom";
|
|||||||
import { useAuthStore } from "../store/authStore";
|
import { useAuthStore } from "../store/authStore";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
import { DashboardLayout } from "@/layouts/DashboardLayout";
|
import { DashboardLayout } from "@/layouts/DashboardLayout";
|
||||||
|
import { AuthLayout } from "@/layouts/AuthLayout";
|
||||||
import { PageErrorFallback } from "@/app/providers/ErrorBoundary";
|
import { PageErrorFallback } from "@/app/providers/ErrorBoundary";
|
||||||
import NotFoundPage from "@/pages/notFoundPage";
|
import NotFoundPage from "@/pages/notFoundPage";
|
||||||
|
|
||||||
@@ -150,12 +151,19 @@ export const router = createBrowserRouter([
|
|||||||
errorElement: <PageErrorFallback />,
|
errorElement: <PageErrorFallback />,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/login",
|
// AuthLayout: semantic wrapper for all public/unauthenticated pages.
|
||||||
element: (
|
// Login manages its own full-screen layout internally.
|
||||||
<Suspense fallback={<PageLoader />}>
|
element: <AuthLayout />,
|
||||||
<LoginPage />
|
children: [
|
||||||
</Suspense>
|
{
|
||||||
),
|
path: "/login",
|
||||||
|
element: (
|
||||||
|
<Suspense fallback={<PageLoader />}>
|
||||||
|
<LoginPage />
|
||||||
|
</Suspense>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useTheme } from "next-themes"
|
import { useThemeStore } from "@/app/store/themeStore"
|
||||||
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
||||||
import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
|
import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
|
||||||
|
|
||||||
const Toaster = ({ ...props }: ToasterProps) => {
|
const Toaster = ({ ...props }: ToasterProps) => {
|
||||||
const { theme = "system" } = useTheme()
|
const { theme } = useThemeStore()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sonner
|
<Sonner
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { Outlet } from 'react-router-dom'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AuthLayout — a thin semantic wrapper for all unauthenticated pages
|
||||||
|
* (login, register, reset-password, 2FA, etc.).
|
||||||
|
*
|
||||||
|
* The login page manages its own full-screen layout internally,
|
||||||
|
* so this component simply renders <Outlet /> without adding any
|
||||||
|
* visual chrome. The value of this layout is architectural:
|
||||||
|
* - Clear separation between public and private route trees.
|
||||||
|
* - Any future auth page added here inherits the same guard and error boundary.
|
||||||
|
* - Consistent with the DashboardLayout pattern used for auth'd routes.
|
||||||
|
*/
|
||||||
|
export function AuthLayout() {
|
||||||
|
return <Outlet />
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { Download, Trash2, Pencil, DownloadCloud } from "lucide-react";
|
import { Download, Trash2, Pencil, DownloadCloud } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
|
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||||
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -23,24 +25,35 @@ import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequ
|
|||||||
import { InfoRow } from "@/components/viewPageComponents";
|
import { InfoRow } from "@/components/viewPageComponents";
|
||||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_BADGE: Record<
|
const STATUS_CONFIG = {
|
||||||
CardRequisiteStatus,
|
|
||||||
{ label: string; className: string }
|
|
||||||
> = {
|
|
||||||
pending: {
|
pending: {
|
||||||
label: "GARAŞYLÝAR",
|
label: "Garaşylýar",
|
||||||
className: "bg-yellow-500/20 text-yellow-400 border border-yellow-500/30",
|
variant: "warning" as StatusBadgeVariant,
|
||||||
|
icon: AlertCircle,
|
||||||
},
|
},
|
||||||
approved: {
|
approved: {
|
||||||
label: "TASSYKLANAN",
|
label: "Tassyklanan",
|
||||||
className:
|
variant: "success" as StatusBadgeVariant,
|
||||||
"bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",
|
icon: CheckCircle2,
|
||||||
},
|
},
|
||||||
rejected: {
|
rejected: {
|
||||||
label: "RET EDILEN",
|
label: "Ret edilen",
|
||||||
className: "bg-red-500/20 text-red-400 border border-red-500/30",
|
variant: "error" as StatusBadgeVariant,
|
||||||
|
icon: XCircle,
|
||||||
},
|
},
|
||||||
};
|
} satisfies Record<
|
||||||
|
CardRequisiteStatus,
|
||||||
|
{ label: string; variant: StatusBadgeVariant; icon: React.ElementType }
|
||||||
|
>;
|
||||||
|
|
||||||
|
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||||
|
const cfg = STATUS_CONFIG[status];
|
||||||
|
if (!cfg)
|
||||||
|
return <span className="text-xs text-muted-foreground">{String(status)}</span>;
|
||||||
|
return (
|
||||||
|
<StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Section header ───────────────────────────────────────────────────────────
|
// ─── Section header ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -119,7 +132,6 @@ export default function CardRequisiteViewPage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusCfg = STATUS_BADGE[data.status] ?? STATUS_BADGE.pending;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-0">
|
<div className="space-y-0">
|
||||||
@@ -160,11 +172,7 @@ export default function CardRequisiteViewPage() {
|
|||||||
{data.created_at}
|
{data.created_at}
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t("Status", "Status")}>
|
<InfoRow label={t("Status", "Status")}>
|
||||||
<span
|
<CardRequisiteStatusBadge status={data.status} />
|
||||||
className={`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold ${statusCfg.className}`}
|
|
||||||
>
|
|
||||||
{statusCfg.label}
|
|
||||||
</span>
|
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
<InfoRow label={t("Note", "Bellik")}>{data.note || "—"}</InfoRow>
|
<InfoRow label={t("Note", "Bellik")}>{data.note || "—"}</InfoRow>
|
||||||
<InfoRow label={t("Requested by", "Sargyt eden:")}>
|
<InfoRow label={t("Requested by", "Sargyt eden:")}>
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export default function UsersListPage() {
|
|||||||
row.original.isActive ? (
|
row.original.isActive ? (
|
||||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||||
) : (
|
) : (
|
||||||
<XCircle size={18} className="text-muted-foreground/40" />
|
<XCircle size={18} className="text-destructive" />
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Trash2, Eye, Pencil } from 'lucide-react'
|
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from 'lucide-react'
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -82,17 +82,9 @@ export default function ClientsPage() {
|
|||||||
header: t('clients.fields.isActive', 'IŞJEŇ'),
|
header: t('clients.fields.isActive', 'IŞJEŇ'),
|
||||||
cell: ({ row }) =>
|
cell: ({ row }) =>
|
||||||
row.original.isActive ? (
|
row.original.isActive ? (
|
||||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
|
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
||||||
<path d="M2 6l3 3 5-5" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
) : (
|
) : (
|
||||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-destructive text-destructive">
|
<XCircle size={18} className="text-destructive" />
|
||||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
||||||
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" />
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
),
|
),
|
||||||
size: 80,
|
size: 80,
|
||||||
},
|
},
|
||||||
|
|||||||
+120
-128
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from "react";
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { Trash2, Eye, Pencil } from 'lucide-react'
|
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -11,30 +11,33 @@ import {
|
|||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from "@/components/ui/alert-dialog";
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from "@/components/ui/button";
|
||||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { useOperators, useDeleteOperator } from '@/features/operators/hooks/useOperators'
|
import {
|
||||||
import type { Operator } from '@/features/operators/api/operatorsApi'
|
useOperators,
|
||||||
|
useDeleteOperator,
|
||||||
|
} from "@/features/operators/hooks/useOperators";
|
||||||
|
import type { Operator } from "@/features/operators/api/operatorsApi";
|
||||||
|
|
||||||
// ─── OperatorsPage ────────────────────────────────────────────────────────────
|
// ─── OperatorsPage ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export default function OperatorsPage() {
|
export default function OperatorsPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const deleteMutation = useDeleteOperator()
|
const deleteMutation = useDeleteOperator();
|
||||||
|
|
||||||
// ── Table state ─────────────────────────────────────────────────────────────
|
// ── Table state ─────────────────────────────────────────────────────────────
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1);
|
||||||
const [perPage, setPerPage] = useState(25)
|
const [perPage, setPerPage] = useState(25);
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState("");
|
||||||
const [isActiveFilter, setIsActiveFilter] = useState('')
|
const [isActiveFilter, setIsActiveFilter] = useState("");
|
||||||
const [columnVisibility, setColumnVisibility] = useState({})
|
const [columnVisibility, setColumnVisibility] = useState({});
|
||||||
const [columnOrder, setColumnOrder] = useState<string[]>([])
|
const [columnOrder, setColumnOrder] = useState<string[]>([]);
|
||||||
|
|
||||||
// ── Delete dialog ────────────────────────────────────────────────────────────
|
// ── Delete dialog ────────────────────────────────────────────────────────────
|
||||||
const [deleteTarget, setDeleteTarget] = useState<Operator | null>(null)
|
const [deleteTarget, setDeleteTarget] = useState<Operator | null>(null);
|
||||||
|
|
||||||
// ── Query ────────────────────────────────────────────────────────────────────
|
// ── Query ────────────────────────────────────────────────────────────────────
|
||||||
const { data, isLoading } = useOperators({
|
const { data, isLoading } = useOperators({
|
||||||
@@ -42,17 +45,17 @@ export default function OperatorsPage() {
|
|||||||
perPage,
|
perPage,
|
||||||
search: search || undefined,
|
search: search || undefined,
|
||||||
isActive: isActiveFilter || undefined,
|
isActive: isActiveFilter || undefined,
|
||||||
})
|
});
|
||||||
|
|
||||||
const operators = data?.data ?? []
|
const operators = data?.data ?? [];
|
||||||
const totalPages = data?.meta.totalPages ?? 1
|
const totalPages = data?.meta.totalPages ?? 1;
|
||||||
const totalCount = data?.meta.totalCount ?? 0
|
const totalCount = data?.meta.totalCount ?? 0;
|
||||||
|
|
||||||
// ── Columns ──────────────────────────────────────────────────────────────────
|
// ── Columns ──────────────────────────────────────────────────────────────────
|
||||||
const columns: ColumnDef<Operator>[] = [
|
const columns: ColumnDef<Operator>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'id',
|
accessorKey: "id",
|
||||||
header: 'ID',
|
header: "ID",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<span
|
<span
|
||||||
className="text-primary font-semibold cursor-pointer hover:underline text-sm"
|
className="text-primary font-semibold cursor-pointer hover:underline text-sm"
|
||||||
@@ -64,70 +67,51 @@ export default function OperatorsPage() {
|
|||||||
size: 80,
|
size: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'username',
|
accessorKey: "username",
|
||||||
header: t('operators.fields.username', 'ULANYJY ADY'),
|
header: t("operators.fields.username", "ULANYJY ADY"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<span className="text-sm text-foreground">{row.original.username}</span>
|
<span className="text-sm text-foreground">{row.original.username}</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'name',
|
accessorKey: "name",
|
||||||
header: t('operators.fields.name', 'ADY'),
|
header: t("operators.fields.name", "ADY"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<span className="text-sm text-foreground">{row.original.name}</span>
|
<span className="text-sm text-foreground">{row.original.name}</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'phone',
|
accessorKey: "phone",
|
||||||
header: t('operators.fields.phone', 'TELEFON'),
|
header: t("operators.fields.phone", "TELEFON"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<span className="text-sm text-foreground">
|
<span className="text-sm text-foreground">
|
||||||
{row.original.phone ?? '—'}
|
{row.original.phone ?? "—"}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'email',
|
accessorKey: "email",
|
||||||
header: t('operators.fields.email', 'E-POÇTA'),
|
header: t("operators.fields.email", "E-POÇTA"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<span className="text-sm text-foreground">
|
<span className="text-sm text-foreground">
|
||||||
{row.original.email ?? '—'}
|
{row.original.email ?? "—"}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'isActive',
|
accessorKey: "isActive",
|
||||||
header: t('operators.fields.isActive', 'IŞJEŇ'),
|
header: t("operators.fields.isActive", "IŞJEŇ"),
|
||||||
cell: ({ row }) =>
|
cell: ({ row }) =>
|
||||||
row.original.isActive ? (
|
row.original.isActive ? (
|
||||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-primary text-primary">
|
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
||||||
<path
|
|
||||||
d="M2 6l3 3 5-5"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="1.8"
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
) : (
|
) : (
|
||||||
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full border-2 border-destructive text-destructive">
|
<XCircle size={18} className="text-destructive" />
|
||||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
||||||
<path
|
|
||||||
d="M3 3l6 6M9 3l-6 6"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="1.8"
|
|
||||||
strokeLinecap="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
),
|
),
|
||||||
size: 80,
|
size: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'actions',
|
id: "actions",
|
||||||
header: '',
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<div className="flex items-center gap-1 justify-end">
|
||||||
<Button
|
<Button
|
||||||
@@ -159,17 +143,17 @@ export default function OperatorsPage() {
|
|||||||
size: 120,
|
size: 120,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
|
|
||||||
const columnMetas = columns
|
const columnMetas = columns
|
||||||
.filter((c) => 'accessorKey' in c && c.accessorKey)
|
.filter((c) => "accessorKey" in c && c.accessorKey)
|
||||||
.map((c) => ({
|
.map((c) => ({
|
||||||
id: ('accessorKey' in c ? String(c.accessorKey) : c.id) as string,
|
id: ("accessorKey" in c ? String(c.accessorKey) : c.id) as string,
|
||||||
label:
|
label:
|
||||||
typeof c.header === 'string'
|
typeof c.header === "string"
|
||||||
? c.header
|
? c.header
|
||||||
: ('accessorKey' in c ? String(c.accessorKey) : '') ?? '',
|
: (("accessorKey" in c ? String(c.accessorKey) : "") ?? ""),
|
||||||
}))
|
}));
|
||||||
|
|
||||||
// ── Render ───────────────────────────────────────────────────────────────────
|
// ── Render ───────────────────────────────────────────────────────────────────
|
||||||
return (
|
return (
|
||||||
@@ -177,61 +161,69 @@ export default function OperatorsPage() {
|
|||||||
{/* Page header */}
|
{/* Page header */}
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h1 className="text-2xl font-semibold text-foreground">
|
<h1 className="text-2xl font-semibold text-foreground">
|
||||||
{t('operators.title', 'Operatorlar')}
|
{t("operators.title", "Operatorlar")}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-card border border-border rounded-xl p-4">
|
<div className="bg-card border border-border rounded-xl p-4">
|
||||||
|
{/* Toolbar */}
|
||||||
|
<DataTableToolbar
|
||||||
|
searchValue={search}
|
||||||
|
onSearchChange={(v) => {
|
||||||
|
setSearch(v);
|
||||||
|
setPage(1);
|
||||||
|
}}
|
||||||
|
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||||
|
columns={columnMetas}
|
||||||
|
columnVisibility={columnVisibility}
|
||||||
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
|
columnOrder={columnOrder}
|
||||||
|
onColumnOrderChange={setColumnOrder}
|
||||||
|
filterFields={[
|
||||||
|
{
|
||||||
|
id: "isActive",
|
||||||
|
label: t("operators.fields.isActive", "Işjeň"),
|
||||||
|
options: [
|
||||||
|
{ value: "true", label: t("common.active", "Işjeň") },
|
||||||
|
{ value: "false", label: t("common.inactive", "Işjeň däl") },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
activeFilters={[{ fieldId: "isActive", value: isActiveFilter }]}
|
||||||
|
onFilterChange={(fieldId, value) => {
|
||||||
|
if (fieldId === "isActive") setIsActiveFilter(value);
|
||||||
|
setPage(1);
|
||||||
|
}}
|
||||||
|
onFilterReset={() => {
|
||||||
|
setIsActiveFilter("");
|
||||||
|
setPage(1);
|
||||||
|
}}
|
||||||
|
perPageOptions={[10, 25, 50, 100]}
|
||||||
|
perPage={perPage}
|
||||||
|
onPerPageChange={(v) => {
|
||||||
|
setPerPage(v);
|
||||||
|
setPage(1);
|
||||||
|
}}
|
||||||
|
actionLabel={t("operators.createBtn", "Operator döredin")}
|
||||||
|
onAction={() => navigate("/operators/create")}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Toolbar */}
|
{/* Table */}
|
||||||
<DataTableToolbar
|
<DataTable
|
||||||
searchValue={search}
|
columns={columns}
|
||||||
onSearchChange={(v) => { setSearch(v); setPage(1) }}
|
data={operators}
|
||||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
isLoading={isLoading}
|
||||||
columns={columnMetas}
|
columnVisibility={columnVisibility}
|
||||||
columnVisibility={columnVisibility}
|
onColumnVisibilityChange={setColumnVisibility}
|
||||||
onColumnVisibilityChange={setColumnVisibility}
|
columnOrder={columnOrder}
|
||||||
columnOrder={columnOrder}
|
onColumnOrderChange={setColumnOrder}
|
||||||
onColumnOrderChange={setColumnOrder}
|
getRowId={(row) => String(row.id)}
|
||||||
filterFields={[
|
currentPage={page}
|
||||||
{
|
totalPages={totalPages}
|
||||||
id: 'isActive',
|
totalCount={totalCount}
|
||||||
label: t('operators.fields.isActive', 'Işjeň'),
|
onPageChange={setPage}
|
||||||
options: [
|
enableRowSelection
|
||||||
{ value: 'true', label: t('common.active', 'Işjeň') },
|
/>
|
||||||
{ value: 'false', label: t('common.inactive', 'Işjeň däl') },
|
</div>
|
||||||
],
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
activeFilters={[{ fieldId: 'isActive', value: isActiveFilter }]}
|
|
||||||
onFilterChange={(fieldId, value) => {
|
|
||||||
if (fieldId === 'isActive') setIsActiveFilter(value)
|
|
||||||
setPage(1)
|
|
||||||
}}
|
|
||||||
onFilterReset={() => { setIsActiveFilter(''); setPage(1) }}
|
|
||||||
perPageOptions={[10, 25, 50, 100]}
|
|
||||||
perPage={perPage}
|
|
||||||
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
|
|
||||||
actionLabel={t('operators.createBtn', 'Operator döredin')}
|
|
||||||
onAction={() => navigate('/operators/create')}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Table */}
|
|
||||||
<DataTable
|
|
||||||
columns={columns}
|
|
||||||
data={operators}
|
|
||||||
isLoading={isLoading}
|
|
||||||
columnVisibility={columnVisibility}
|
|
||||||
onColumnVisibilityChange={setColumnVisibility}
|
|
||||||
columnOrder={columnOrder}
|
|
||||||
onColumnOrderChange={setColumnOrder}
|
|
||||||
getRowId={(row) => String(row.id)}
|
|
||||||
currentPage={page}
|
|
||||||
totalPages={totalPages}
|
|
||||||
totalCount={totalCount}
|
|
||||||
onPageChange={setPage}
|
|
||||||
enableRowSelection
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Delete dialog */}
|
{/* Delete dialog */}
|
||||||
<AlertDialog
|
<AlertDialog
|
||||||
@@ -241,33 +233,33 @@ export default function OperatorsPage() {
|
|||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
{t('operators.deleteTitle', 'Operatory pozmak')}
|
{t("operators.deleteTitle", "Operatory pozmak")}
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{t(
|
{t(
|
||||||
'operators.deleteConfirm',
|
"operators.deleteConfirm",
|
||||||
'{{name}} operatoryny pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.',
|
"{{name}} operatoryny pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.",
|
||||||
{ name: deleteTarget?.name ?? '' },
|
{ name: deleteTarget?.name ?? "" },
|
||||||
)}
|
)}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (deleteTarget) {
|
if (deleteTarget) {
|
||||||
deleteMutation.mutate(deleteTarget.id, {
|
deleteMutation.mutate(deleteTarget.id, {
|
||||||
onSuccess: () => setDeleteTarget(null),
|
onSuccess: () => setDeleteTarget(null),
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('common.delete', 'Poz')}
|
{t("common.delete", "Poz")}
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user