Compare commits
10
Commits
b83f350c6b
...
0ca218505d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ca218505d | ||
|
|
b990b59698 | ||
|
|
e550eff090 | ||
|
|
84c5ff4153 | ||
|
|
ef9d6201eb | ||
|
|
2ba061b76c | ||
|
|
26057e1fac | ||
|
|
f57ccd187d | ||
|
|
0946d32273 | ||
|
|
54afadab4a |
No files matched your search
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"*.{js,jsx,ts,tsx}": [
|
||||
"eslint --fix",
|
||||
"prettier --write"
|
||||
],
|
||||
"*.{css,scss,md,json,html}": [
|
||||
|
||||
+21
-11
@@ -61,6 +61,9 @@ src/
|
||||
│ ├── api/ # Feature'a özel axios istek fonksiyonları
|
||||
│ ├── hooks/ # Feature'a özel React Query hook'ları (useQuery, useMutation)
|
||||
│ └── components/# Feature'a özel bileşenler
|
||||
│ └── shared/ # 2+ feature'da kullanılan paylaşımlı API'ler ve hook'lar
|
||||
│ ├── api/ # sharedApi.ts — ortak endpoint'ler + TypeScript tipleri
|
||||
│ └── hooks/ # useShared[Resource].ts — ortak React Query hook'ları
|
||||
├── hooks/ # Global custom hook'lar
|
||||
├── layouts/ # Sayfa düzenleri (DashboardLayout, AuthLayout vb.)
|
||||
├── lib/ # API client, i18n ayarları ve utils (yardımcı fonksiyonlar)
|
||||
@@ -96,17 +99,17 @@ src/
|
||||
[Feature]EditPage.tsx ← id fetch → <[Feature]Form mode="edit" initialData={data} loanOrderId={id} />
|
||||
```
|
||||
8. **Hata Yönetimi Kuralları:**
|
||||
- Custom hook'lar veya API istekleri yazarken, hatalar zaten merkezi QueryCache ve MutationCache tarafından yakalandığı için hook içinde tekrar toast.error() yazma (kod tekrarını önle).
|
||||
- İstisnai olarak, bir hatanın ekrana toast basmasını istemiyorsan, query veya mutation tanımına meta: { silent: true } parametresini geç.
|
||||
- Kod bloklarında asla ham try-catch kullanarak hataları yutma (catch (e) { } boş bırakılamaz). Hata yutulacaksa bile konsola console.error ile basılmalı veya log servisine yönlendirilmelidir.
|
||||
- Custom hook'lar veya API istekleri yazarken, hatalar zaten merkezi QueryCache ve MutationCache tarafından yakalandığı için hook içinde tekrar toast.error() yazma (kod tekrarını önle).
|
||||
- İstisnai olarak, bir hatanın ekrana toast basmasını istemiyorsan, query veya mutation tanımına meta: { silent: true } parametresini geç.
|
||||
- Kod bloklarında asla ham try-catch kullanarak hataları yutma (catch (e) { } boş bırakılamaz). Hata yutulacaksa bile konsola console.error ile basılmalı veya log servisine yönlendirilmelidir.
|
||||
9. **Senior Authentication (Refresh Token & Session) Kuralları:**
|
||||
- **Giriş (Login):** API'den dönen `token` ve `user` verilerini `authStore.setAuth()` ile zustand state'ine kaydet.
|
||||
- **İstekler (Requests):** `axios` client'ı otomatik olarak zustand'dan token çeker ve `Authorization: Bearer <token>` header'ını ekler.
|
||||
- **401 Unauthorized:** Kullanıcı başka bir yerde oturum açar veya token süresi solar ve istek 401 dönerse:
|
||||
1. **Otomatik Yenileme (Auto-Refresh):** Interceptor, durumu yakalar ve gizlice yeni token almaya çalışır.
|
||||
2. **Çakışma Önleme:** Aynı anda birden fazla 401 gelirse, `isRefreshing` bayrağı ile diğer istekler beklemede tutulur.
|
||||
- **Başarısız Refresh:** Yeni token alınamazsa (`refreshToken` hata dönerse), sistem kullanıcıyı otomatik olarak çıkışa zorlar (`logout()`) ve kullanıcıyı Login sayfasına yönlendirir.
|
||||
- **403 Forbidden:** Kullanıcının o sayfaya erişim izni yoksa (Rol yetkisi eksik), toast ile uyarı verilir ancak kullanıcı aynı sayfada kalır (Kritik sayfadan atılmaz).
|
||||
- **Giriş (Login):** API'den dönen `token` ve `user` verilerini `authStore.setAuth()` ile zustand state'ine kaydet.
|
||||
- **İstekler (Requests):** `axios` client'ı otomatik olarak zustand'dan token çeker ve `Authorization: Bearer <token>` header'ını ekler.
|
||||
- **401 Unauthorized:** Kullanıcı başka bir yerde oturum açar veya token süresi solar ve istek 401 dönerse:
|
||||
1. **Otomatik Yenileme (Auto-Refresh):** Interceptor, durumu yakalar ve gizlice yeni token almaya çalışır.
|
||||
2. **Çakışma Önleme:** Aynı anda birden fazla 401 gelirse, `isRefreshing` bayrağı ile diğer istekler beklemede tutulur.
|
||||
- **Başarısız Refresh:** Yeni token alınamazsa (`refreshToken` hata dönerse), sistem kullanıcıyı otomatik olarak çıkışa zorlar (`logout()`) ve kullanıcıyı Login sayfasına yönlendirir.
|
||||
- **403 Forbidden:** Kullanıcının o sayfaya erişim izni yoksa (Rol yetkisi eksik), toast ile uyarı verilir ancak kullanıcı aynı sayfada kalır (Kritik sayfadan atılmaz).
|
||||
10. **Error Boundary Kuralları:**
|
||||
- Her sayfa route'u `PageErrorBoundary` ile sarılır.
|
||||
- App kökü `GlobalErrorBoundary` ile sarılır.
|
||||
@@ -116,4 +119,11 @@ src/
|
||||
- Manuel `if/else` validation **kesinlikle yasaktır**.
|
||||
- `zodResolver` dışında resolver kullanılamaz.
|
||||
- Server hataları `setError()` ile ilgili field'a atanır.
|
||||
- `z.infer<typeof schema>` ile tip üretilir; ayrıca tip yazmak **yasaktır**.
|
||||
- `z.infer<typeof schema>` ile tip üretilir; ayrıca tip yazmak **yasaktır**.
|
||||
12. **Paylaşımlı (Shared) API Kuralları:**
|
||||
- Bir API endpoint'i yalnızca tek bir feature tarafından kullanılıyorsa o feature'ın kendi `api/` klasörüne yazılır.
|
||||
- Aynı endpoint 2 veya daha fazla feature tarafından kullanılıyorsa `src/features/shared/api/sharedApi.ts` içine taşınır.
|
||||
- `src/lib/api/` dizinine asla business logic veya endpoint fonksiyonu yazılmaz; bu dizin yalnızca axios instance ve interceptor içindir.
|
||||
- Her shared endpoint fonksiyonu için `src/features/shared/hooks/useShared[Resource].ts` adında bir React Query hook'u oluşturulur.
|
||||
- Shared hook'larda `staleTime` mutlaka belirtilmelidir (dropdown/lookup verileri için minimum 5 dakika önerilir).
|
||||
- Aynı `queryKey` ile çağrılan hook TanStack Query tarafından otomatik olarak dedup edilir; aynı hook'u birden fazla component'te çağırmak ekstra network isteği oluşturmaz.
|
||||
@@ -32,25 +32,25 @@ A full-featured internal banking administration panel built with **React 19 + Vi
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
---
|
||||
|
||||
@@ -147,6 +147,9 @@ src/
|
||||
│ └── tableSearch.tsx # Standalone search input for tables
|
||||
│
|
||||
├── features/ # Feature-Sliced Design — one folder per domain
|
||||
│ ├── shared/ # APIs and hooks used by 2+ features
|
||||
│ │ ├── api/ # sharedApi.ts — shared endpoints + TypeScript types
|
||||
│ │ └── hooks/ # useShared[Resource].ts — shared React Query hooks
|
||||
│ └── [feature]/
|
||||
│ ├── api/ # Axios calls + TypeScript types/interfaces
|
||||
│ ├── hooks/ # React Query hooks (useQuery + useMutation)
|
||||
@@ -204,6 +207,7 @@ GlobalErrorBoundary
|
||||
```
|
||||
|
||||
**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()`.
|
||||
@@ -216,16 +220,17 @@ GlobalErrorBoundary
|
||||
|
||||
**Guards (Outlet-based):**
|
||||
|
||||
| Guard | Behavior |
|
||||
|---|---|
|
||||
| Guard | Behavior |
|
||||
| ------------- | --------------------------------------------------- |
|
||||
| `PublicGuard` | If already authenticated → redirect to `/dashboard` |
|
||||
| `AuthGuard` | If not authenticated → redirect to `/login` |
|
||||
| `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`.
|
||||
@@ -237,6 +242,7 @@ GlobalErrorBoundary
|
||||
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.
|
||||
@@ -250,11 +256,11 @@ The sidebar nav structure is a `NavGroup[]` array defined inside `AppSidebar`. W
|
||||
|
||||
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()` |
|
||||
| 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. |
|
||||
| `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.
|
||||
|
||||
@@ -302,10 +308,12 @@ export function useCreate[Feature]() {
|
||||
`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`).
|
||||
@@ -329,6 +337,7 @@ export function useCreate[Feature]() {
|
||||
> **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.
|
||||
@@ -347,10 +356,10 @@ export function useCreate[Feature]() {
|
||||
|
||||
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 |
|
||||
| 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.
|
||||
|
||||
@@ -387,58 +396,65 @@ Each feature lives under `src/features/[feature]/` with this internal structure:
|
||||
|
||||
**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` |
|
||||
| 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.
|
||||
|
||||
---
|
||||
@@ -590,19 +606,21 @@ All authenticated routes are nested under `DashboardLayout`. The full list:
|
||||
- [ ] 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`.
|
||||
- [ ] If the API endpoint is used by 2+ features, move it to `src/features/shared/api/sharedApi.ts` and create a `useShared[Resource].ts` hook instead of duplicating it.
|
||||
|
||||
### 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. |
|
||||
| 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. |
|
||||
| No duplicate API calls | If an endpoint is used by 2+ features, it belongs in `src/features/shared/` — never copy-paste API functions across feature folders. |
|
||||
|
||||
---
|
||||
|
||||
@@ -610,19 +628,16 @@ All authenticated routes are nested under `DashboardLayout`. The full list:
|
||||
|
||||
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 |
|
||||
| **`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. |
|
||||
| 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 |
|
||||
| **`/logs`** | ❌ No route or page | Sidebar entry exists |
|
||||
| **`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 |
|
||||
| **`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. |
|
||||
|
||||
---
|
||||
|
||||
@@ -637,14 +652,14 @@ All API logic is isolated in `src/features/[feature]/api/[feature]Api.ts`. To go
|
||||
```ts
|
||||
// Before (mock)
|
||||
export async function fetchLoanOrders(params: LoanOrdersParams) {
|
||||
await delay(600)
|
||||
return { data: mockStore, total: mockStore.length, page: 1, perPage: 25 }
|
||||
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
|
||||
const { data } = await apiClient.get<LoanOrdersResponse>("/loan-orders", { params });
|
||||
return data;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -653,4 +668,4 @@ export async function fetchLoanOrders(params: LoanOrdersParams) {
|
||||
|
||||
---
|
||||
|
||||
*Last updated: 2026-05-15 — TBBank Admin v2.0*
|
||||
_Last updated: 2026-05-15 — TBBank Admin v2.0_
|
||||
Generated
+78
-78
@@ -759,9 +759,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-helpers": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.5.5.tgz",
|
||||
"integrity": "sha512-eIJYKTCECbP/nsKaaruF6LW967mtbQbsw4JTtSVkUQc9MneSkbrgPJAbKl9nWr0ZeowV8BfsarBmPpBzGelA2w==",
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.6.0.tgz",
|
||||
"integrity": "sha512-ii6Bw9jJ2zi2cWA2Z+9/QZ/+3DX6kwaV5Q986D/CdP3Lap3w/pgQZ373FV7byY/i7L4IRH/G43I5dz1ClsCbpA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -816,9 +816,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/plugin-kit": {
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.1.tgz",
|
||||
"integrity": "sha512-rZAP3aVgB9ds9KOeUSL+zZ21hPmo8dh6fnIFwRQj5EAZl9gzR7wxYbYXYysAM8CTqGmUGyp2S4kUdV17MnGuWQ==",
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.7.2.tgz",
|
||||
"integrity": "sha512-+CNAzxglkrpNf/kKywqQfk74QjtceuOE7Qm+AF8miRvPF/wmmK5+OJOgVh3AVTT3RP2mH3+FOaxlE5v72owk0A==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
@@ -4036,9 +4036,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
|
||||
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
|
||||
"integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
@@ -4104,17 +4104,17 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.59.1.tgz",
|
||||
"integrity": "sha512-BOziFIfE+6osHO9FoJG4zjoHUcvI7fTNBSpdAwrNH0/TLvzjsk2oo8XSSOT2HhqUyhZPfHv4UOffoJ9oEEQ7Ag==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.60.1.tgz",
|
||||
"integrity": "sha512-JQ4S5GB0tfjO8BuJ4fcX+HodkzJjYBV+7OJ+wLygaX7OGQ7FudyHL4NSCA6ob+w3Yn+5MkKIozOwQhXeM7opVg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.12.2",
|
||||
"@typescript-eslint/scope-manager": "8.59.1",
|
||||
"@typescript-eslint/type-utils": "8.59.1",
|
||||
"@typescript-eslint/utils": "8.59.1",
|
||||
"@typescript-eslint/visitor-keys": "8.59.1",
|
||||
"@typescript-eslint/scope-manager": "8.60.1",
|
||||
"@typescript-eslint/type-utils": "8.60.1",
|
||||
"@typescript-eslint/utils": "8.60.1",
|
||||
"@typescript-eslint/visitor-keys": "8.60.1",
|
||||
"ignore": "^7.0.5",
|
||||
"natural-compare": "^1.4.0",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
@@ -4127,7 +4127,7 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^8.59.1",
|
||||
"@typescript-eslint/parser": "^8.60.1",
|
||||
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
||||
"typescript": ">=4.8.4 <6.1.0"
|
||||
}
|
||||
@@ -4143,16 +4143,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.59.1.tgz",
|
||||
"integrity": "sha512-HDQH9O/47Dxi1ceDhBXdaldtf/WV9yRYMjbjCuNk3qnaTD564qwv61Y7+gTxwxRKzSrgO5uhtw584igXVuuZkA==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.60.1.tgz",
|
||||
"integrity": "sha512-A0M6ua6H252bVjPvvtSgl2QA4+ET9S5Mtkb2GDyTxIhH/C4qDItT7RQNO5PhMC6NXGYXOR9dIalcDDgBKT7oFA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.59.1",
|
||||
"@typescript-eslint/types": "8.59.1",
|
||||
"@typescript-eslint/typescript-estree": "8.59.1",
|
||||
"@typescript-eslint/visitor-keys": "8.59.1",
|
||||
"@typescript-eslint/scope-manager": "8.60.1",
|
||||
"@typescript-eslint/types": "8.60.1",
|
||||
"@typescript-eslint/typescript-estree": "8.60.1",
|
||||
"@typescript-eslint/visitor-keys": "8.60.1",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -4168,14 +4168,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.59.1.tgz",
|
||||
"integrity": "sha512-+MuHQlHiEr00Of/IQbE/MmEoi44znZHbR/Pz7Opq4HryUOlRi+/44dro9Ycy8Fyo+/024IWtw8m4JUMCGTYxDg==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.60.1.tgz",
|
||||
"integrity": "sha512-eXkTH2bxmXlqD1RnOPmLZ9ZM9D3VwSx04JOwBnP9RQ+yUA5a2Mu7SfW8uaV2Aon53NJzZlZYuX7tn91Izf+xaw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/tsconfig-utils": "^8.59.1",
|
||||
"@typescript-eslint/types": "^8.59.1",
|
||||
"@typescript-eslint/tsconfig-utils": "^8.60.1",
|
||||
"@typescript-eslint/types": "^8.60.1",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -4190,14 +4190,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.59.1.tgz",
|
||||
"integrity": "sha512-LwuHQI4pDOYVKvmH2dkaJo6YZCSgouVgnS/z7yBPKBMvgtBvyLqiLy9Z6b7+m/TRcX1NFYUqZetI5Y+aT4GEfg==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.60.1.tgz",
|
||||
"integrity": "sha512-gvI5OQoptnxQnchOirukCuQ55svJSTuD/4k5+pC267xyBtYry748R9/c3tYUzb/iE6RZfllRz2lVulLCHkTm4w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.59.1",
|
||||
"@typescript-eslint/visitor-keys": "8.59.1"
|
||||
"@typescript-eslint/types": "8.60.1",
|
||||
"@typescript-eslint/visitor-keys": "8.60.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -4208,9 +4208,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.59.1.tgz",
|
||||
"integrity": "sha512-/0nEyPbX7gRsk0Uwfe4ALwwgxuA66d/l2mhRDNlAvaj4U3juhUtJNq0DsY8M2AYwwb9rEq2hrC3IcIcEt++iJA==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.60.1.tgz",
|
||||
"integrity": "sha512-nh8w4qAteiKuZu3pSSzG/yGKpw0OlkrKnzFmbVRenKaD4qc+7i1GrmZaLVkr8rk4uipiPGMOW4YsM6WmKZ5CvA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -4225,15 +4225,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.59.1.tgz",
|
||||
"integrity": "sha512-klWPBR2ciQHS3f++ug/mVnWKPjBUo7icEL3FAO1lhAR1Z1i5NQYZ1EannMSRYcq5qCv5wNALlXr6fksRHyYl7w==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.60.1.tgz",
|
||||
"integrity": "sha512-sdwTrpjosW7ANQYJ39ZBF1ZyEMEGVB2UsikrserVM/30a/F1dTLnu9bGxEdosugyu5caigjLrR2qiD11asjI1A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.59.1",
|
||||
"@typescript-eslint/typescript-estree": "8.59.1",
|
||||
"@typescript-eslint/utils": "8.59.1",
|
||||
"@typescript-eslint/types": "8.60.1",
|
||||
"@typescript-eslint/typescript-estree": "8.60.1",
|
||||
"@typescript-eslint/utils": "8.60.1",
|
||||
"debug": "^4.4.3",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
},
|
||||
@@ -4250,9 +4250,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.59.1.tgz",
|
||||
"integrity": "sha512-ZDCjgccSdYPw5Bxh+my4Z0lJU96ZDN7jbBzvmEn0FZx3RtU1C7VWl6NbDx94bwY3V5YsgwRzJPOgeY2Q/nLG8A==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.60.1.tgz",
|
||||
"integrity": "sha512-4h0tY8ppCkdCzcrl2YM5M3my0xsE1Tf8om3owEu5oPWmXwkKRmk0j0LGDzYBGUcAlesEbxBhazqu/K4cu3Ug7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -4264,16 +4264,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.59.1.tgz",
|
||||
"integrity": "sha512-OUd+vJS05sSkOip+BkZ/2NS8RMxrAAJemsC6vU3kmfLyeaJT0TftHkV9mcx2107MmsBVXXexhVu4F0TZXyMl4g==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.60.1.tgz",
|
||||
"integrity": "sha512-alpRkfG8hlVE5kdJW2GkfgDgXxold3e8e4l6EnmhRmRLbekgAPCCGDVD++sABy9FcgPFroq+uFcCSM1vR57Cew==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.59.1",
|
||||
"@typescript-eslint/tsconfig-utils": "8.59.1",
|
||||
"@typescript-eslint/types": "8.59.1",
|
||||
"@typescript-eslint/visitor-keys": "8.59.1",
|
||||
"@typescript-eslint/project-service": "8.60.1",
|
||||
"@typescript-eslint/tsconfig-utils": "8.60.1",
|
||||
"@typescript-eslint/types": "8.60.1",
|
||||
"@typescript-eslint/visitor-keys": "8.60.1",
|
||||
"debug": "^4.4.3",
|
||||
"minimatch": "^10.2.2",
|
||||
"semver": "^7.7.3",
|
||||
@@ -4292,9 +4292,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||
"version": "7.7.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
|
||||
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
|
||||
"version": "7.8.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz",
|
||||
"integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
@@ -4305,16 +4305,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.59.1.tgz",
|
||||
"integrity": "sha512-3pIeoXhCeYH9FSCBI8P3iNwJlGuzPlYKkTlen2O9T1DSeeg8UG8jstq6BLk+Mda0qup7mgk4z4XL4OzRaxZ8LA==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.60.1.tgz",
|
||||
"integrity": "sha512-h2MPBLoNtjc3qZWfY3Tl51yPorQ2McHn8pJfcMNTcIvrrZrr90Ykffit0yjrPFWQcRcUxzH20+6OcVdW4yHtUg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.9.1",
|
||||
"@typescript-eslint/scope-manager": "8.59.1",
|
||||
"@typescript-eslint/types": "8.59.1",
|
||||
"@typescript-eslint/typescript-estree": "8.59.1"
|
||||
"@typescript-eslint/scope-manager": "8.60.1",
|
||||
"@typescript-eslint/types": "8.60.1",
|
||||
"@typescript-eslint/typescript-estree": "8.60.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -4329,13 +4329,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.59.1.tgz",
|
||||
"integrity": "sha512-LdDNl6C5iJExcM0Yh0PwAIBb9PrSiCsWamF/JyEZawm3kFDnRoaq3LGE4bpyRao/fWeGKKyw7icx0YxrLFC5Cg==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.60.1.tgz",
|
||||
"integrity": "sha512-EbGRQg4FhrmwLodl+t3JNAnXHWVr9Vp+Zl1QBZVPY4ByfkzIT8cX3K6QWODHtkIZqqJVEWvhHSx3v5PDHsaQag==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.59.1",
|
||||
"@typescript-eslint/types": "8.60.1",
|
||||
"eslint-visitor-keys": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -5622,18 +5622,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "10.3.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.3.0.tgz",
|
||||
"integrity": "sha512-XbEXaRva5cF0ZQB8w6MluHA0kZZfV2DuCMJ3ozyEOHLwDpZX2Lmm/7Pp0xdJmI0GL1W05VH5VwIFHEm1Vcw2gw==",
|
||||
"version": "10.4.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.4.1.tgz",
|
||||
"integrity": "sha512-AyIKhnOBuOAdueD7RB3xB+YeAWScb9jHsJBgH2Hcde8InP5JYhqrRR6iTMHyTEwgENK54Cp44e4v8BwNhsuHuw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.8.0",
|
||||
"@eslint-community/regexpp": "^4.12.2",
|
||||
"@eslint/config-array": "^0.23.5",
|
||||
"@eslint/config-helpers": "^0.5.5",
|
||||
"@eslint/config-helpers": "^0.6.0",
|
||||
"@eslint/core": "^1.2.1",
|
||||
"@eslint/plugin-kit": "^0.7.1",
|
||||
"@eslint/plugin-kit": "^0.7.2",
|
||||
"@humanfs/node": "^0.16.6",
|
||||
"@humanwhocodes/module-importer": "^1.0.1",
|
||||
"@humanwhocodes/retry": "^0.4.2",
|
||||
@@ -9775,16 +9775,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.59.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.59.1.tgz",
|
||||
"integrity": "sha512-xqDcFVBmlrltH64lklOVp1wYxgJr6LVdg3NamBgH2OOQDLFdTKfIZXF5PfghrnXQKXZGTQs8tr1vL7fJvq8CTQ==",
|
||||
"version": "8.60.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.60.1.tgz",
|
||||
"integrity": "sha512-6m5hkkRAp8lKvhVpcprAIn5KkehQEh+47oHH2VGnExEh7dhNxXlg6GPAOIu6TxbVQxhebrJDvjl3020ooiWCMA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "8.59.1",
|
||||
"@typescript-eslint/parser": "8.59.1",
|
||||
"@typescript-eslint/typescript-estree": "8.59.1",
|
||||
"@typescript-eslint/utils": "8.59.1"
|
||||
"@typescript-eslint/eslint-plugin": "8.60.1",
|
||||
"@typescript-eslint/parser": "8.60.1",
|
||||
"@typescript-eslint/typescript-estree": "8.60.1",
|
||||
"@typescript-eslint/utils": "8.60.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
||||
+7
-7
@@ -54,18 +54,18 @@
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"autoprefixer": "^10.5.0",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.5.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.4.0",
|
||||
"postcss": "^8.5.13",
|
||||
"prettier": "^3.8.3",
|
||||
"tailwindcss": "^4.2.4",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"vite": "^8.0.10"
|
||||
"vite": "^8.0.10",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.5.0",
|
||||
"typescript-eslint": "^8.58.2"
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,7 @@ const BackupsPage = lazy(() => import("@/pages/backups"));
|
||||
const BranchCreatePage = lazy(() => import("@/pages/settings/location/branchesCreate"));
|
||||
const BranchesViewPage = lazy(() => import("@/pages/settings/location/branchesView"));
|
||||
const BranchEditPage = lazy(() => import("@/pages/settings/location/branchesEdit"));
|
||||
const ProfilePage = lazy(() => import("@/pages/profile"));
|
||||
|
||||
// ─── Guards ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -145,8 +146,6 @@ type AppRoute = Omit<RouteObject, "handle" | "children"> & {
|
||||
children?: AppRoute[];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
// Wraps a lazy page in Suspense — keeps route definitions clean
|
||||
@@ -178,9 +177,7 @@ const routes: AppRoute[] = [
|
||||
children: [
|
||||
{
|
||||
element: <AuthLayout />,
|
||||
children: [
|
||||
{ path: "/login", element: page(LoginPage) },
|
||||
],
|
||||
children: [{ path: "/login", element: page(LoginPage) }],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -576,6 +573,13 @@ const routes: AppRoute[] = [
|
||||
],
|
||||
},
|
||||
|
||||
// ── PROFIL ────────────────────────────────────────────────────────
|
||||
{
|
||||
path: "/profile",
|
||||
handle: { title: (t) => t("profile.title", "Meniň profilim") },
|
||||
element: page(ProfilePage),
|
||||
},
|
||||
|
||||
// ── BEKAPLAR ──────────────────────────────────────────────────────
|
||||
{
|
||||
path: "/backups",
|
||||
@@ -775,4 +779,4 @@ const routes: AppRoute[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const router = createBrowserRouter(routes as RouteObject[]);
|
||||
export const router = createBrowserRouter(routes as RouteObject[]);
|
||||
+33
-39
@@ -1,23 +1,23 @@
|
||||
import { create } from 'zustand'
|
||||
import { persist } from 'zustand/middleware'
|
||||
import axios from 'axios'
|
||||
import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import axios from "axios";
|
||||
|
||||
export interface AuthUser {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
role: 'admin' | 'manager' | 'viewer'
|
||||
avatar?: string
|
||||
id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
role: "admin" | "manager" | "viewer";
|
||||
avatar?: string;
|
||||
}
|
||||
|
||||
interface AuthState {
|
||||
token: string | null
|
||||
user: AuthUser | null
|
||||
isAuthenticated: boolean
|
||||
setAuth: (token: string, user: AuthUser) => void
|
||||
clearAuth: () => void
|
||||
logout: () => void // Eklendi
|
||||
refreshToken: () => Promise<string> // Eklendi
|
||||
token: string | null;
|
||||
user: AuthUser | null;
|
||||
isAuthenticated: boolean;
|
||||
setAuth: (token: string, user: AuthUser) => void;
|
||||
clearAuth: () => void;
|
||||
logout: () => void;
|
||||
refreshToken: () => Promise<string>;
|
||||
}
|
||||
|
||||
export const useAuthStore = create<AuthState>()(
|
||||
@@ -26,44 +26,38 @@ export const useAuthStore = create<AuthState>()(
|
||||
token: null,
|
||||
user: null,
|
||||
isAuthenticated: false,
|
||||
|
||||
setAuth: (token, user) =>
|
||||
set({ token, user, isAuthenticated: true }),
|
||||
|
||||
clearAuth: () =>
|
||||
set({ token: null, user: null, isAuthenticated: false }),
|
||||
|
||||
|
||||
setAuth: (token, user) => set({ token, user, isAuthenticated: true }),
|
||||
|
||||
clearAuth: () => set({ token: null, user: null, isAuthenticated: false }),
|
||||
|
||||
logout: () => {
|
||||
// Çıkış yapıldığında hem local state'i temizle hem de gerekirse API'ye logout isteği at
|
||||
get().clearAuth()
|
||||
get().clearAuth();
|
||||
},
|
||||
|
||||
refreshToken: async () => {
|
||||
try {
|
||||
// Interceptor dairesel bağımlılığı bozmasın diye doğrudan bağımsız axios çağrısı yapıyoruz
|
||||
const response = await axios.post<{ token: string }>(
|
||||
`${import.meta.env.VITE_API_BASE_URL}/auth/refresh`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${get().token}`, // Mevcut süresi dolmuş token'ı gönderiyoruz
|
||||
Authorization: `Bearer ${get().token}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const newToken = response.data.token
|
||||
// Yeni token'ı store'a kaydet
|
||||
set((state) => ({ ...state, token: newToken }))
|
||||
return newToken
|
||||
},
|
||||
);
|
||||
|
||||
const newToken = response.data.token;
|
||||
set((state) => ({ ...state, token: newToken }));
|
||||
return newToken;
|
||||
} catch (error) {
|
||||
// Eğer refresh token da patlarsa her şeyi sıfırla
|
||||
get().clearAuth()
|
||||
throw error
|
||||
get().clearAuth();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: 'tbbank-auth',
|
||||
name: "tbbank-auth",
|
||||
},
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -245,7 +245,6 @@ function FilterDropdown({
|
||||
<div key={field.id} className="space-y-1">
|
||||
<label className="block text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">{field.label}</label>
|
||||
|
||||
{/* MonthSelect ile aynı pattern: manuel span + sentinel */}
|
||||
<div className="flex items-center gap-1">
|
||||
<Select value={current || "__all__"} onValueChange={(val) => onFilterChange(field.id, val === "__all__" ? "" : val)}>
|
||||
<SelectTrigger
|
||||
@@ -254,7 +253,6 @@ function FilterDropdown({
|
||||
isFieldActive ? "border-primary text-primary [&>svg:last-child]:text-primary" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{/* SelectValue kullanmıyoruz — MonthSelect gibi manuel */}
|
||||
<span className="flex-1 text-left truncate">
|
||||
{isFieldActive ? field.options.find((o) => o.value === current)?.label : "—"}
|
||||
</span>
|
||||
@@ -271,7 +269,6 @@ function FilterDropdown({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{/* Field bazlı temizle — MonthSelect'teki X butonu ile aynı */}
|
||||
{isFieldActive && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -306,7 +303,6 @@ function FilterDropdown({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Reset — tüm filtreler, sadece aktif filter varsa göster */}
|
||||
{hasActive && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -534,7 +534,6 @@ function FileInput({
|
||||
const [dragOver, setDragOver] = useState(false);
|
||||
const [preview, setPreview] = useState<string | null>(null);
|
||||
|
||||
// fileValue prop'u değişince preview'i güncelle + memory leak önle
|
||||
useEffect(() => {
|
||||
let url: string | null = null;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
@@ -552,7 +551,6 @@ function FileInput({
|
||||
};
|
||||
}, [fileValue]);
|
||||
|
||||
// handleFile sadece onFileChange'i çağırıyor — preview useEffect hallediyor
|
||||
const handleFile = (file: File | null) => {
|
||||
onFileChange?.(file);
|
||||
};
|
||||
|
||||
@@ -3,16 +3,11 @@ import { Download, Eye, ChevronDown, Inbox } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
// ─── BentoGrid ────────────────────────────────────────────────────────────────
|
||||
|
||||
export function BentoGrid({
|
||||
cols = 2,
|
||||
children,
|
||||
}: {
|
||||
cols?: 1 | 2 | 3 | 4;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
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",
|
||||
@@ -31,30 +26,14 @@ interface BentoCardProps {
|
||||
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"
|
||||
: "";
|
||||
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 (
|
||||
<div
|
||||
className={`bg-card border border-border rounded-xl overflow-hidden min-w-0 ${spanClass}`}
|
||||
>
|
||||
<div className={`bg-card border border-border rounded-xl overflow-hidden min-w-0 ${spanClass}`}>
|
||||
{title && (
|
||||
<div className="px-4 py-2.5 border-b border-border">
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide truncate">
|
||||
{title}
|
||||
</p>
|
||||
<p className="text-xs font-semibold text-muted-foreground uppercase tracking-wide truncate">{title}</p>
|
||||
</div>
|
||||
)}
|
||||
{noPadding ? <div>{children}</div> : children}
|
||||
@@ -69,23 +48,35 @@ export interface InfoRowProps {
|
||||
value?: string | number | null;
|
||||
children?: React.ReactNode;
|
||||
isLink?: boolean;
|
||||
href?: string;
|
||||
}
|
||||
|
||||
export function InfoRow({ label, value, children, isLink }: InfoRowProps) {
|
||||
export function InfoRow({ label, value, children, isLink, href }: InfoRowProps) {
|
||||
const content = children ?? (value != null ? String(value) : null);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start sm:items-center py-2.5 px-4 border-b border-border last:border-0 gap-0.5 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">
|
||||
{label}
|
||||
</span>
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug">{label}</span>
|
||||
{content != null && content !== "" ? (
|
||||
typeof content === "string" ? (
|
||||
<span
|
||||
className={`text-sm break-words min-w-0 ${isLink ? "text-primary font-medium" : "text-foreground"}`}
|
||||
>
|
||||
{content}
|
||||
</span>
|
||||
isLink && href ? (
|
||||
href.startsWith("http") ? (
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm wrap-break-words min-w-0 text-[#2bbae6] font-medium cursor-pointer hover:underline"
|
||||
>
|
||||
{content}
|
||||
</a>
|
||||
) : (
|
||||
<Link to={href} className="text-sm wrap-break-words min-w-0 text-[#2bbae6] font-medium cursor-pointer hover:underline">
|
||||
{content}
|
||||
</Link>
|
||||
)
|
||||
) : (
|
||||
<span className={`text-sm wrap-break-words min-w-0 ${isLink ? "text-primary font-medium" : "text-foreground"}`}>{content}</span>
|
||||
)
|
||||
) : (
|
||||
<div className="text-sm min-w-0">{content}</div>
|
||||
)
|
||||
@@ -116,9 +107,7 @@ export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:grid sm:grid-cols-[minmax(0,42%)_minmax(0,58%)] items-start py-2.5 px-4 border-b border-border last:border-0 gap-1 sm:gap-0">
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug pt-1">
|
||||
{label}
|
||||
</span>
|
||||
<span className="text-xs sm:text-sm text-muted-foreground leading-snug pt-1">{label}</span>
|
||||
<div className="w-full min-w-0 flex flex-col gap-1.5 py-0.5">
|
||||
{langs.map((l) =>
|
||||
l.val ? (
|
||||
@@ -126,9 +115,7 @@ export function MultiLangRow({ label, value }: MultiLangRowProps) {
|
||||
<span className="inline-flex items-center justify-center border border-border bg-muted/50 text-muted-foreground text-[9px] font-bold px-1.5 py-0.5 rounded min-w-[22px] mt-0.5 select-none">
|
||||
{l.code}
|
||||
</span>
|
||||
<span className="text-sm text-foreground break-words flex-1 min-w-0">
|
||||
{l.val}
|
||||
</span>
|
||||
<span className="text-sm text-foreground break-words flex-1 min-w-0">{l.val}</span>
|
||||
</div>
|
||||
) : null,
|
||||
)}
|
||||
@@ -148,14 +135,8 @@ export interface SectionProps {
|
||||
export function Section({ title, children }: SectionProps) {
|
||||
return (
|
||||
<div className="mb-6">
|
||||
{title ? (
|
||||
<h2 className="text-base font-semibold text-foreground mb-2">
|
||||
{title}
|
||||
</h2>
|
||||
) : null}
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{children}
|
||||
</div>
|
||||
{title ? <h2 className="text-base font-semibold text-foreground mb-2">{title}</h2> : null}
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -172,21 +153,11 @@ export function CollapsibleSection({ title, children }: CollapsibleSectionProps)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="flex items-center gap-2 mb-2 cursor-pointer select-none w-fit"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-2 cursor-pointer select-none w-fit" onClick={() => setOpen((v) => !v)}>
|
||||
<h2 className="text-base font-semibold text-foreground">{title}</h2>
|
||||
<ChevronDown
|
||||
size={15}
|
||||
className={`text-muted-foreground transition-transform duration-200 ${open ? "" : "-rotate-90"}`}
|
||||
/>
|
||||
<ChevronDown size={15} className={`text-muted-foreground transition-transform duration-200 ${open ? "" : "-rotate-90"}`} />
|
||||
</div>
|
||||
{open && (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
{open && <div className="bg-card border border-border rounded-xl overflow-hidden p-4 space-y-3">{children}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -208,11 +179,7 @@ export function PassportImage({ label, src, url }: PassportImageProps) {
|
||||
<span className="text-xs sm:text-sm text-muted-foreground">{label}</span>
|
||||
<div className="flex flex-col gap-2">
|
||||
{imageSrc ? (
|
||||
<img
|
||||
src={imageSrc}
|
||||
alt={label}
|
||||
className="w-28 h-20 object-cover rounded-md border border-border"
|
||||
/>
|
||||
<img src={imageSrc} alt={label} className="w-28 h-20 object-cover rounded-md border border-border" />
|
||||
) : (
|
||||
<div className="w-28 h-20 bg-muted rounded-md border border-border flex items-center justify-center">
|
||||
<span className="text-xs text-muted-foreground">—</span>
|
||||
@@ -264,9 +231,7 @@ export function StatusBadge({ status }: { status: string }) {
|
||||
|
||||
// ─── useAuditColumns ──────────────────────────────────────────────────────────
|
||||
|
||||
export function useAuditColumns(
|
||||
onView?: (log: AuditRowProps) => void,
|
||||
): ColumnDef<AuditRowProps>[] {
|
||||
export function useAuditColumns(onView?: (log: AuditRowProps) => void): ColumnDef<AuditRowProps>[] {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMemo(
|
||||
@@ -274,35 +239,23 @@ export function useAuditColumns(
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("audit.columns.id", "ID"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-xs font-mono text-muted-foreground">
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-xs font-mono text-muted-foreground">{row.original.id}</span>,
|
||||
size: 130,
|
||||
},
|
||||
{
|
||||
accessorKey: "action",
|
||||
header: t("audit.columns.action", "AMALYŇ ADY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm font-medium text-primary">
|
||||
{row.original.action}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm font-medium text-primary">{row.original.action}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "by",
|
||||
header: t("audit.columns.by", "KIM TARAPYNDAN"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.by}</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.by}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "target",
|
||||
header: t("audit.columns.target", "AMALYŇ NYŞANY"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.target}</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.target}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
@@ -313,11 +266,7 @@ export function useAuditColumns(
|
||||
{
|
||||
accessorKey: "date",
|
||||
header: t("audit.columns.date", "SENE"),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground whitespace-nowrap">
|
||||
{row.original.date}
|
||||
</span>
|
||||
),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground whitespace-nowrap">{row.original.date}</span>,
|
||||
size: 160,
|
||||
},
|
||||
{
|
||||
@@ -374,15 +323,7 @@ export function EmptyState({ label }: EmptyStateProps) {
|
||||
|
||||
// ─── AuditLog ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export function AuditLog({
|
||||
logs,
|
||||
currentPage,
|
||||
totalPages,
|
||||
totalCount,
|
||||
onPageChange,
|
||||
isLoading,
|
||||
onView,
|
||||
}: AuditLogProps) {
|
||||
export function AuditLog({ logs, currentPage, totalPages, totalCount, onPageChange, isLoading, onView }: AuditLogProps) {
|
||||
const columns = useAuditColumns(onView);
|
||||
|
||||
return (
|
||||
|
||||
@@ -10,6 +10,10 @@ export interface LoanOrderMobile {
|
||||
createdAt: string;
|
||||
region: string;
|
||||
branch: string;
|
||||
branchId?: number | string;
|
||||
loanTypeId?: number | string;
|
||||
workCityId?: number | string;
|
||||
createdById?: number | string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
phone: string;
|
||||
@@ -148,6 +152,10 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
createdAt: "2025-01-15 09:42",
|
||||
region: "Aşgabat",
|
||||
branch: "Merkezi şahamça",
|
||||
branchId: 1,
|
||||
loanTypeId: 1,
|
||||
workCityId: 1,
|
||||
createdById: "U-1001",
|
||||
firstName: "Oraz",
|
||||
lastName: "Annaýew",
|
||||
phone: "+99361123456",
|
||||
@@ -196,6 +204,10 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
createdAt: "2025-01-18 11:05",
|
||||
region: "Ahal",
|
||||
branch: "Änew şahamçasy",
|
||||
branchId: 2,
|
||||
loanTypeId: 2,
|
||||
workCityId: 2,
|
||||
createdById: "U-1002",
|
||||
firstName: "Merjen",
|
||||
lastName: "Hudaýewa",
|
||||
phone: "+99362234567",
|
||||
@@ -237,6 +249,10 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
createdAt: "2025-01-20 14:30",
|
||||
region: "Balkan",
|
||||
branch: "Balkanabat şahamçasy",
|
||||
branchId: 3,
|
||||
loanTypeId: 3,
|
||||
workCityId: 7,
|
||||
createdById: "U-1003",
|
||||
firstName: "Serdar",
|
||||
lastName: "Durdyýew",
|
||||
phone: "+99363345678",
|
||||
|
||||
@@ -1,369 +1,364 @@
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export type LoanOrderStatus =
|
||||
| 'GARAŞYLÝAR'
|
||||
| 'KANAGATLANDYRYLAN'
|
||||
| 'RED_EDILDI'
|
||||
| 'IŞLENÝÄR'
|
||||
export type LoanOrderStatus = "GARAŞYLÝAR" | "KANAGATLANDYRYLAN" | "RED_EDILDI" | "IŞLENÝÄR";
|
||||
|
||||
export interface LoanOrder {
|
||||
id: string
|
||||
loanType: string
|
||||
createdAt: string
|
||||
region: string
|
||||
branch: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
phone: string
|
||||
status: LoanOrderStatus
|
||||
note?: string | null
|
||||
id: string;
|
||||
loanType: string;
|
||||
createdAt: string;
|
||||
region: string;
|
||||
branch: string;
|
||||
branchId?: number | string;
|
||||
loanTypeId?: number | string;
|
||||
workCityId?: number | string;
|
||||
createdById?: number | string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
phone: string;
|
||||
status: LoanOrderStatus;
|
||||
note?: string | null;
|
||||
|
||||
loanAmount?: number | null
|
||||
loanHistory?: string | null
|
||||
patronicName?: string | null
|
||||
education?: string | null
|
||||
marriageStatus?: string | null
|
||||
dateOfBirth?: string | null
|
||||
residence?: string | null
|
||||
currentResidence?: string | null
|
||||
loanAmount?: number | null;
|
||||
loanHistory?: string | null;
|
||||
patronicName?: string | null;
|
||||
education?: string | null;
|
||||
marriageStatus?: string | null;
|
||||
dateOfBirth?: string | null;
|
||||
residence?: string | null;
|
||||
currentResidence?: string | null;
|
||||
|
||||
passportSerie?: string | null
|
||||
passportNumber?: string | null
|
||||
passportDateOfIssue?: string | null
|
||||
passportGivenBy?: string | null
|
||||
bornPlace?: string | null
|
||||
passportPage1Url?: string | null
|
||||
passportPage23Url?: string | null
|
||||
passportPage89Url?: string | null
|
||||
passportPage32Url?: string | null
|
||||
passportSerie?: string | null;
|
||||
passportNumber?: string | null;
|
||||
passportDateOfIssue?: string | null;
|
||||
passportGivenBy?: string | null;
|
||||
bornPlace?: string | null;
|
||||
passportPage1Url?: string | null;
|
||||
passportPage23Url?: string | null;
|
||||
passportPage89Url?: string | null;
|
||||
passportPage32Url?: string | null;
|
||||
|
||||
email?: string | null
|
||||
phoneAdditional?: string | null
|
||||
homePhone?: string | null
|
||||
email?: string | null;
|
||||
phoneAdditional?: string | null;
|
||||
homePhone?: string | null;
|
||||
|
||||
workCompany?: string | null
|
||||
workHrPhone?: string | null
|
||||
workRegion?: string | null
|
||||
workProvince?: string | null
|
||||
position?: string | null
|
||||
salary?: number | null
|
||||
workStartedAt?: string | null
|
||||
workCompany?: string | null;
|
||||
workHrPhone?: string | null;
|
||||
workRegion?: string | null;
|
||||
workProvince?: string | null;
|
||||
position?: string | null;
|
||||
salary?: number | null;
|
||||
workStartedAt?: string | null;
|
||||
|
||||
cardNumber?: string | null
|
||||
cardName?: string | null
|
||||
cardExpMonth?: string | null
|
||||
cardExpYear?: string | null
|
||||
cardNumber?: string | null;
|
||||
cardName?: string | null;
|
||||
cardExpMonth?: string | null;
|
||||
cardExpYear?: string | null;
|
||||
|
||||
guarantor1Name?: string | null
|
||||
guarantor1Surname?: string | null
|
||||
guarantor1Patronic?: string | null
|
||||
guarantor1PassportSerie?: string | null
|
||||
guarantor1PassportNumber?: string | null
|
||||
guarantor1CardNumber?: string | null
|
||||
guarantor1CardName?: string | null
|
||||
guarantor1CardExpMonth?: string | null
|
||||
guarantor1CardExpYear?: string | null
|
||||
guarantor1Salary?: number | null
|
||||
guarantor1Name?: string | null;
|
||||
guarantor1Surname?: string | null;
|
||||
guarantor1Patronic?: string | null;
|
||||
guarantor1PassportSerie?: string | null;
|
||||
guarantor1PassportNumber?: string | null;
|
||||
guarantor1CardNumber?: string | null;
|
||||
guarantor1CardName?: string | null;
|
||||
guarantor1CardExpMonth?: string | null;
|
||||
guarantor1CardExpYear?: string | null;
|
||||
guarantor1Salary?: number | null;
|
||||
|
||||
amount?: number | null
|
||||
createdBy?: string | null
|
||||
fullName?: string | null
|
||||
maritalStatus?: string | null
|
||||
birthDate?: string | null
|
||||
registeredAddress?: string | null
|
||||
currentAddress?: string | null
|
||||
phoneAlt?: string | null
|
||||
employer?: string | null
|
||||
deptPhone?: string | null
|
||||
workCity?: string | null
|
||||
employedSince?: string | null
|
||||
passportIssuedBy?: string | null
|
||||
passportBirthPlace?: string | null
|
||||
amount?: number | null;
|
||||
createdBy?: string | null;
|
||||
fullName?: string | null;
|
||||
maritalStatus?: string | null;
|
||||
birthDate?: string | null;
|
||||
registeredAddress?: string | null;
|
||||
currentAddress?: string | null;
|
||||
phoneAlt?: string | null;
|
||||
employer?: string | null;
|
||||
deptPhone?: string | null;
|
||||
workCity?: string | null;
|
||||
employedSince?: string | null;
|
||||
passportIssuedBy?: string | null;
|
||||
passportBirthPlace?: string | null;
|
||||
}
|
||||
|
||||
export interface LoanOrdersParams {
|
||||
search?: string
|
||||
region?: string
|
||||
status?: LoanOrderStatus | ''
|
||||
branch?: string
|
||||
archived?: string
|
||||
page?: number
|
||||
perPage?: number
|
||||
search?: string;
|
||||
region?: string;
|
||||
status?: LoanOrderStatus | "";
|
||||
branch?: string;
|
||||
archived?: string;
|
||||
page?: number;
|
||||
perPage?: number;
|
||||
}
|
||||
|
||||
export interface LoanOrdersResponse {
|
||||
data: LoanOrder[]
|
||||
total: number
|
||||
page: number
|
||||
perPage: number
|
||||
data: LoanOrder[];
|
||||
total: number;
|
||||
page: number;
|
||||
perPage: number;
|
||||
}
|
||||
|
||||
export interface LoanOrderPayload {
|
||||
status: string
|
||||
loanType: string
|
||||
region: string
|
||||
branch: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
patronicName?: string
|
||||
education: string
|
||||
marriageStatus: string
|
||||
dateOfBirth: string
|
||||
residence: string
|
||||
currentResidence?: string
|
||||
passportSerie: string
|
||||
passportNumber: string
|
||||
passportDateOfIssue: string
|
||||
passportGivenBy: string
|
||||
bornPlace?: string
|
||||
email?: string
|
||||
phone: string
|
||||
phoneAdditional?: string
|
||||
homePhone?: string
|
||||
workCompany: string
|
||||
workHrPhone?: string
|
||||
workRegion?: string
|
||||
workProvince?: string
|
||||
position: string
|
||||
salary: number
|
||||
workStartedAt: string
|
||||
status: string;
|
||||
loanType: string;
|
||||
region: string;
|
||||
branch: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
patronicName?: string;
|
||||
education: string;
|
||||
marriageStatus: string;
|
||||
dateOfBirth: string;
|
||||
residence: string;
|
||||
currentResidence?: string;
|
||||
passportSerie: string;
|
||||
passportNumber: string;
|
||||
passportDateOfIssue: string;
|
||||
passportGivenBy: string;
|
||||
bornPlace?: string;
|
||||
email?: string;
|
||||
phone: string;
|
||||
phoneAdditional?: string;
|
||||
homePhone?: string;
|
||||
workCompany: string;
|
||||
workHrPhone?: string;
|
||||
workRegion?: string;
|
||||
workProvince?: string;
|
||||
position: string;
|
||||
salary: number;
|
||||
workStartedAt: string;
|
||||
|
||||
note?: string
|
||||
loanAmount?: number
|
||||
loanHistory?: string
|
||||
note?: string;
|
||||
loanAmount?: number;
|
||||
loanHistory?: string;
|
||||
|
||||
cardNumber?: string
|
||||
cardName?: string
|
||||
cardExpMonth?: string
|
||||
cardExpYear?: string
|
||||
cardNumber?: string;
|
||||
cardName?: string;
|
||||
cardExpMonth?: string;
|
||||
cardExpYear?: string;
|
||||
|
||||
guarantor1Name?: string
|
||||
guarantor1Surname?: string
|
||||
guarantor1Patronic?: string
|
||||
guarantor1PassportSerie?: string
|
||||
guarantor1PassportNumber?: string
|
||||
guarantor1CardNumber?: string
|
||||
guarantor1CardName?: string
|
||||
guarantor1CardExpMonth?: string
|
||||
guarantor1CardExpYear?: string
|
||||
guarantor1Salary?: number
|
||||
guarantor1Name?: string;
|
||||
guarantor1Surname?: string;
|
||||
guarantor1Patronic?: string;
|
||||
guarantor1PassportSerie?: string;
|
||||
guarantor1PassportNumber?: string;
|
||||
guarantor1CardNumber?: string;
|
||||
guarantor1CardName?: string;
|
||||
guarantor1CardExpMonth?: string;
|
||||
guarantor1CardExpYear?: string;
|
||||
guarantor1Salary?: number;
|
||||
}
|
||||
|
||||
// ─── Mock ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
const MOCK_DATA: LoanOrder[] = [
|
||||
{
|
||||
id: 'L-1001',
|
||||
loanType: 'Ipoteka karzy',
|
||||
createdAt: '2024-03-20 10:30',
|
||||
region: 'Aşgabat',
|
||||
branch: 'Merkezi şahamça',
|
||||
firstName: 'Aman',
|
||||
lastName: 'Amanow',
|
||||
phone: '+993 65 112233',
|
||||
status: 'GARAŞYLÝAR',
|
||||
note: 'Müşderi dokumentleri tassyklamady',
|
||||
id: "L-1001",
|
||||
loanType: "Ipoteka karzy",
|
||||
createdAt: "2024-03-20 10:30",
|
||||
region: "Aşgabat",
|
||||
branch: "Merkezi şahamça",
|
||||
createdBy: "Nurtuwak",
|
||||
branchId: 1,
|
||||
loanTypeId: 1,
|
||||
workCityId: 1,
|
||||
createdById: "5970",
|
||||
firstName: "Aman",
|
||||
lastName: "Amanow",
|
||||
phone: "+993 65 112233",
|
||||
status: "GARAŞYLÝAR",
|
||||
note: "Müşderi dokumentleri tassyklamady",
|
||||
loanAmount: 50000,
|
||||
loanHistory: 'positive',
|
||||
patronicName: 'Myradowiç',
|
||||
education: 'high',
|
||||
marriageStatus: 'MARRIED',
|
||||
dateOfBirth: '1990-05-15',
|
||||
residence: 'Aşgabat, Bitarap Türkmenistan şaýoly, 15',
|
||||
currentResidence: 'Aşgabat, Garaşsyzlyk köçesi, 5',
|
||||
passportSerie: 'I',
|
||||
passportNumber: '123456',
|
||||
passportDateOfIssue: '2015-03-10',
|
||||
passportGivenBy: 'Aşgabat şäheriniň Içeri işler müdirligi',
|
||||
bornPlace: 'Aşgabat şäheri',
|
||||
email: 'aman.amanow@email.com',
|
||||
phoneAdditional: '+993 65 334455',
|
||||
homePhone: '+993 12 456789',
|
||||
workCompany: 'Türkmennebit',
|
||||
workHrPhone: '+993 12 987654',
|
||||
workRegion: 'Aşgabat',
|
||||
workProvince: 'Büzmeýin etraby',
|
||||
position: 'Inžener',
|
||||
loanHistory: "positive",
|
||||
patronicName: "Myradowiç",
|
||||
education: "high",
|
||||
marriageStatus: "MARRIED",
|
||||
dateOfBirth: "1990-05-15",
|
||||
residence: "Aşgabat, Bitarap Türkmenistan şaýoly, 15",
|
||||
currentResidence: "Aşgabat, Garaşsyzlyk köçesi, 5",
|
||||
passportSerie: "I",
|
||||
passportNumber: "123456",
|
||||
passportDateOfIssue: "2015-03-10",
|
||||
passportGivenBy: "Aşgabat şäheriniň Içeri işler müdirligi",
|
||||
bornPlace: "Aşgabat şäheri",
|
||||
email: "aman.amanow@email.com",
|
||||
phoneAdditional: "+993 65 334455",
|
||||
homePhone: "+993 12 456789",
|
||||
workCompany: "Türkmennebit",
|
||||
workHrPhone: "+993 12 987654",
|
||||
workRegion: "Aşgabat",
|
||||
workProvince: "Büzmeýin etraby",
|
||||
position: "Inžener",
|
||||
salary: 2500,
|
||||
workStartedAt: '2018-06-01',
|
||||
cardNumber: '4111111111111111',
|
||||
cardName: 'AMAN AMANOW',
|
||||
cardExpMonth: '12',
|
||||
cardExpYear: '2027',
|
||||
guarantor1Name: 'Berdi',
|
||||
guarantor1Surname: 'Berdiýew',
|
||||
guarantor1Patronic: 'Annagulyýewiç',
|
||||
guarantor1PassportSerie: 'II',
|
||||
guarantor1PassportNumber: '654321',
|
||||
guarantor1CardNumber: '4222222222222222',
|
||||
guarantor1CardName: 'BERDI BERDIÝEW',
|
||||
guarantor1CardExpMonth: '06',
|
||||
guarantor1CardExpYear: '2026',
|
||||
workStartedAt: "2018-06-01",
|
||||
cardNumber: "4111111111111111",
|
||||
cardName: "AMAN AMANOW",
|
||||
cardExpMonth: "12",
|
||||
cardExpYear: "2027",
|
||||
guarantor1Name: "Berdi",
|
||||
guarantor1Surname: "Berdiýew",
|
||||
guarantor1Patronic: "Annagulyýewiç",
|
||||
guarantor1PassportSerie: "II",
|
||||
guarantor1PassportNumber: "654321",
|
||||
guarantor1CardNumber: "4222222222222222",
|
||||
guarantor1CardName: "BERDI BERDIÝEW",
|
||||
guarantor1CardExpMonth: "06",
|
||||
guarantor1CardExpYear: "2026",
|
||||
guarantor1Salary: 3000,
|
||||
},
|
||||
{
|
||||
id: 'L-1002',
|
||||
loanType: 'Sarp ediş karzy',
|
||||
createdAt: '2024-03-19 14:15',
|
||||
region: 'Mary',
|
||||
branch: 'Mary-1 şahamçasy',
|
||||
firstName: 'Oguljan',
|
||||
lastName: 'Berdiýewa',
|
||||
phone: '+993 61 445566',
|
||||
status: 'IŞLENÝÄR',
|
||||
id: "L-1002",
|
||||
loanType: "Sarp ediş karzy",
|
||||
createdAt: "2024-03-19 14:15",
|
||||
region: "Mary",
|
||||
branch: "Mary-1 şahamçasy",
|
||||
branchId: 2,
|
||||
loanTypeId: 2,
|
||||
workCityId: 5,
|
||||
createdById: "U-1002",
|
||||
firstName: "Oguljan",
|
||||
lastName: "Berdiýewa",
|
||||
phone: "+993 61 445566",
|
||||
status: "IŞLENÝÄR",
|
||||
note: null,
|
||||
loanAmount: 10000,
|
||||
loanHistory: 'new',
|
||||
patronicName: 'Myratowna',
|
||||
education: 'masters',
|
||||
marriageStatus: 'SINGLE',
|
||||
dateOfBirth: '1995-11-20',
|
||||
residence: 'Mary şäher, Gurbansoltan eje köçesi, 10',
|
||||
currentResidence: 'Mary şäher, Gurbansoltan eje köçesi, 10',
|
||||
passportSerie: 'I',
|
||||
passportNumber: '789012',
|
||||
passportDateOfIssue: '2018-07-22',
|
||||
passportGivenBy: 'Mary şäheriniň Içeri işler müdirligi',
|
||||
bornPlace: 'Mary şäheri',
|
||||
email: 'oguljan.berdiýewa@email.com',
|
||||
loanHistory: "new",
|
||||
patronicName: "Myratowna",
|
||||
education: "masters",
|
||||
marriageStatus: "SINGLE",
|
||||
dateOfBirth: "1995-11-20",
|
||||
residence: "Mary şäher, Gurbansoltan eje köçesi, 10",
|
||||
currentResidence: "Mary şäher, Gurbansoltan eje köçesi, 10",
|
||||
passportSerie: "I",
|
||||
passportNumber: "789012",
|
||||
passportDateOfIssue: "2018-07-22",
|
||||
passportGivenBy: "Mary şäheriniň Içeri işler müdirligi",
|
||||
bornPlace: "Mary şäheri",
|
||||
email: "oguljan.berdiýewa@email.com",
|
||||
phoneAdditional: null,
|
||||
homePhone: null,
|
||||
workCompany: 'Mary ýangyn söndüriş bölümi',
|
||||
workHrPhone: '+993 55 112233',
|
||||
workRegion: 'Mary',
|
||||
workProvince: 'Mary şäher',
|
||||
position: 'Hasapçy',
|
||||
workCompany: "Mary ýangyn söndüriş bölümi",
|
||||
workHrPhone: "+993 55 112233",
|
||||
workRegion: "Mary",
|
||||
workProvince: "Mary şäher",
|
||||
position: "Hasapçy",
|
||||
salary: 1800,
|
||||
workStartedAt: '2019-03-15',
|
||||
cardNumber: '4333333333333333',
|
||||
cardName: 'OGULJAN BERDIÝEWA',
|
||||
cardExpMonth: '09',
|
||||
cardExpYear: '2028',
|
||||
guarantor1Name: 'Merdan',
|
||||
guarantor1Surname: 'Merdanow',
|
||||
guarantor1Patronic: 'Amanowiç',
|
||||
guarantor1PassportSerie: 'I',
|
||||
guarantor1PassportNumber: '345678',
|
||||
guarantor1CardNumber: '4444444444444444',
|
||||
guarantor1CardName: 'MERDAN MERDANOW',
|
||||
guarantor1CardExpMonth: '03',
|
||||
guarantor1CardExpYear: '2025',
|
||||
workStartedAt: "2019-03-15",
|
||||
cardNumber: "4333333333333333",
|
||||
cardName: "OGULJAN BERDIÝEWA",
|
||||
cardExpMonth: "09",
|
||||
cardExpYear: "2028",
|
||||
guarantor1Name: "Merdan",
|
||||
guarantor1Surname: "Merdanow",
|
||||
guarantor1Patronic: "Amanowiç",
|
||||
guarantor1PassportSerie: "I",
|
||||
guarantor1PassportNumber: "345678",
|
||||
guarantor1CardNumber: "4444444444444444",
|
||||
guarantor1CardName: "MERDAN MERDANOW",
|
||||
guarantor1CardExpMonth: "03",
|
||||
guarantor1CardExpYear: "2025",
|
||||
guarantor1Salary: 2200,
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
let mockStore = [...MOCK_DATA]
|
||||
let nextId = 1003
|
||||
let mockStore = [...MOCK_DATA];
|
||||
let nextId = 1003;
|
||||
|
||||
const delay = (ms = 300) => new Promise((r) => setTimeout(r, ms))
|
||||
const delay = (ms = 300) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
// ─── API Functions ────────────────────────────────────────────────────────────
|
||||
|
||||
export async function fetchLoanOrders(
|
||||
params: LoanOrdersParams
|
||||
): Promise<LoanOrdersResponse> {
|
||||
await delay(600)
|
||||
const page = params.page || 1
|
||||
const perPage = params.perPage || 25
|
||||
export async function fetchLoanOrders(params: LoanOrdersParams): Promise<LoanOrdersResponse> {
|
||||
await delay(600);
|
||||
const page = params.page || 1;
|
||||
const perPage = params.perPage || 25;
|
||||
|
||||
let filtered = mockStore.filter((item) => {
|
||||
const matchSearch =
|
||||
!params.search ||
|
||||
`${item.firstName} ${item.lastName}`.toLowerCase().includes(params.search.toLowerCase()) ||
|
||||
item.id.toLowerCase().includes(params.search.toLowerCase()) ||
|
||||
item.phone.includes(params.search)
|
||||
const matchStatus =
|
||||
!params.status
|
||||
? true
|
||||
: item.status === params.status
|
||||
const matchRegion =
|
||||
!params.region ? true : item.region === params.region
|
||||
const matchBranch =
|
||||
!params.branch ? true : item.branch === params.branch
|
||||
return matchSearch && matchStatus && matchRegion && matchBranch
|
||||
})
|
||||
item.phone.includes(params.search);
|
||||
const matchStatus = !params.status ? true : item.status === params.status;
|
||||
const matchRegion = !params.region ? true : item.region === params.region;
|
||||
const matchBranch = !params.branch ? true : item.branch === params.branch;
|
||||
return matchSearch && matchStatus && matchRegion && matchBranch;
|
||||
});
|
||||
|
||||
filtered = [...filtered].sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
||||
const total = filtered.length
|
||||
const start = (page - 1) * perPage
|
||||
const data = filtered.slice(start, start + perPage)
|
||||
filtered = [...filtered].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
||||
const total = filtered.length;
|
||||
const start = (page - 1) * perPage;
|
||||
const data = filtered.slice(start, start + perPage);
|
||||
|
||||
return { data, total, page, perPage }
|
||||
return { data, total, page, perPage };
|
||||
}
|
||||
|
||||
export async function getLoanOrderById(id: string): Promise<LoanOrder> {
|
||||
await delay(300)
|
||||
const item = mockStore.find((o) => o.id === id)
|
||||
if (!item) throw new Error('Not found')
|
||||
return { ...item }
|
||||
await delay(300);
|
||||
const item = mockStore.find((o) => o.id === id);
|
||||
if (!item) throw new Error("Not found");
|
||||
return { ...item };
|
||||
}
|
||||
|
||||
export async function createLoanOrder(
|
||||
payload: LoanOrderPayload
|
||||
): Promise<LoanOrder> {
|
||||
await delay(500)
|
||||
export async function createLoanOrder(payload: LoanOrderPayload): Promise<LoanOrder> {
|
||||
await delay(500);
|
||||
const newItem = {
|
||||
id: `L-${nextId++}`,
|
||||
createdAt: new Date().toISOString().slice(0, 16).replace('T', ' '),
|
||||
createdAt: new Date().toISOString().slice(0, 16).replace("T", " "),
|
||||
...payload,
|
||||
} as LoanOrder
|
||||
mockStore = [newItem, ...mockStore]
|
||||
return newItem
|
||||
} as LoanOrder;
|
||||
mockStore = [newItem, ...mockStore];
|
||||
return newItem;
|
||||
}
|
||||
|
||||
export async function updateLoanOrder(
|
||||
id: string,
|
||||
payload: Partial<LoanOrderPayload>
|
||||
): Promise<LoanOrder> {
|
||||
await delay(500)
|
||||
const idx = mockStore.findIndex((o) => o.id === id)
|
||||
if (idx === -1) throw new Error('Not found')
|
||||
const updated = { ...mockStore[idx], ...payload } as LoanOrder
|
||||
mockStore = mockStore.map((o) => (o.id === id ? updated : o))
|
||||
return updated
|
||||
export async function updateLoanOrder(id: string, payload: Partial<LoanOrderPayload>): Promise<LoanOrder> {
|
||||
await delay(500);
|
||||
const idx = mockStore.findIndex((o) => o.id === id);
|
||||
if (idx === -1) throw new Error("Not found");
|
||||
const updated = { ...mockStore[idx], ...payload } as LoanOrder;
|
||||
mockStore = mockStore.map((o) => (o.id === id ? updated : o));
|
||||
return updated;
|
||||
}
|
||||
|
||||
export async function deleteLoanOrder(id: string): Promise<void> {
|
||||
await delay(300)
|
||||
mockStore = mockStore.filter((o) => o.id !== id)
|
||||
await delay(300);
|
||||
mockStore = mockStore.filter((o) => o.id !== id);
|
||||
}
|
||||
|
||||
// ─── Branch options by region ─────────────────────────────────────────────────
|
||||
|
||||
export const BRANCHES_BY_REGION: Record<string, { value: string; label: string }[]> = {
|
||||
'Aşgabat': [
|
||||
{ value: 'Merkezi şahamça', label: 'Merkezi şahamça' },
|
||||
{ value: 'Garaşsyzlyk şahamçasy', label: 'Garaşsyzlyk şahamçasy' },
|
||||
{ value: 'Bitarap şahamça', label: 'Bitarap şahamça' },
|
||||
{ value: 'Aşgabat-1 şahamçasy', label: 'Aşgabat-1 şahamçasy' },
|
||||
{ value: 'Aşgabat-2 şahamçasy', label: 'Aşgabat-2 şahamçasy' },
|
||||
Aşgabat: [
|
||||
{ value: "Merkezi şahamça", label: "Merkezi şahamça" },
|
||||
{ value: "Garaşsyzlyk şahamçasy", label: "Garaşsyzlyk şahamçasy" },
|
||||
{ value: "Bitarap şahamça", label: "Bitarap şahamça" },
|
||||
{ value: "Aşgabat-1 şahamçasy", label: "Aşgabat-1 şahamçasy" },
|
||||
{ value: "Aşgabat-2 şahamçasy", label: "Aşgabat-2 şahamçasy" },
|
||||
],
|
||||
'Ahal': [
|
||||
{ value: 'Änew şahamçasy', label: 'Änew şahamçasy' },
|
||||
{ value: 'Gökdepe şahamçasy', label: 'Gökdepe şahamçasy' },
|
||||
{ value: 'Tejen şahamçasy', label: 'Tejen şahamçasy' },
|
||||
Ahal: [
|
||||
{ value: "Änew şahamçasy", label: "Änew şahamçasy" },
|
||||
{ value: "Gökdepe şahamçasy", label: "Gökdepe şahamçasy" },
|
||||
{ value: "Tejen şahamçasy", label: "Tejen şahamçasy" },
|
||||
],
|
||||
'Balkan': [
|
||||
{ value: 'Balkanabat şahamçasy', label: 'Balkanabat şahamçasy' },
|
||||
{ value: 'Türkmenbaşy şahamçasy', label: 'Türkmenbaşy şahamçasy' },
|
||||
{ value: 'Bereket şahamçasy', label: 'Bereket şahamçasy' },
|
||||
Balkan: [
|
||||
{ value: "Balkanabat şahamçasy", label: "Balkanabat şahamçasy" },
|
||||
{ value: "Türkmenbaşy şahamçasy", label: "Türkmenbaşy şahamçasy" },
|
||||
{ value: "Bereket şahamçasy", label: "Bereket şahamçasy" },
|
||||
],
|
||||
'Daşoguz': [
|
||||
{ value: 'Daşoguz şahamçasy', label: 'Daşoguz şahamçasy' },
|
||||
{ value: 'Akdepe şahamçasy', label: 'Akdepe şahamçasy' },
|
||||
{ value: 'Boldumsaz şahamçasy', label: 'Boldumsaz şahamçasy' },
|
||||
Daşoguz: [
|
||||
{ value: "Daşoguz şahamçasy", label: "Daşoguz şahamçasy" },
|
||||
{ value: "Akdepe şahamçasy", label: "Akdepe şahamçasy" },
|
||||
{ value: "Boldumsaz şahamçasy", label: "Boldumsaz şahamçasy" },
|
||||
],
|
||||
'Lebap': [
|
||||
{ value: 'Türkmenabat şahamçasy', label: 'Türkmenabat şahamçasy' },
|
||||
{ value: 'Seýdi şahamçasy', label: 'Seýdi şahamçasy' },
|
||||
{ value: 'Kerki şahamçasy', label: 'Kerki şahamçasy' },
|
||||
Lebap: [
|
||||
{ value: "Türkmenabat şahamçasy", label: "Türkmenabat şahamçasy" },
|
||||
{ value: "Seýdi şahamçasy", label: "Seýdi şahamçasy" },
|
||||
{ value: "Kerki şahamçasy", label: "Kerki şahamçasy" },
|
||||
],
|
||||
'Mary': [
|
||||
{ value: 'Mary-1 şahamçasy', label: 'Mary-1 şahamçasy' },
|
||||
{ value: 'Mary-2 şahamçasy', label: 'Mary-2 şahamçasy' },
|
||||
{ value: 'Baýramaly şahamçasy', label: 'Baýramaly şahamçasy' },
|
||||
Mary: [
|
||||
{ value: "Mary-1 şahamçasy", label: "Mary-1 şahamçasy" },
|
||||
{ value: "Mary-2 şahamçasy", label: "Mary-2 şahamçasy" },
|
||||
{ value: "Baýramaly şahamçasy", label: "Baýramaly şahamçasy" },
|
||||
],
|
||||
'Arkadag': [
|
||||
{ value: 'Arkadag şahamçasy', label: 'Arkadag şahamçasy' },
|
||||
],
|
||||
}
|
||||
Arkadag: [{ value: "Arkadag şahamçasy", label: "Arkadag şahamçasy" }],
|
||||
};
|
||||
@@ -1,206 +1,218 @@
|
||||
|
||||
|
||||
// ─── Sber Payment Order Types ─────────────────────────────────────────────────
|
||||
|
||||
export type PaymentStatus = 'GARASYLYYAR' | 'KANAGATLANDYRYLAN' | 'RET_EDILEN'
|
||||
export type PaymentPaidStatus = 'Tolenmedik' | 'Tolendi'
|
||||
export type PaymentStatus = "GARASYLYYAR" | "KANAGATLANDYRYLAN" | "RET_EDILEN";
|
||||
export type PaymentPaidStatus = "Tolenmedik" | "Tolendi";
|
||||
|
||||
export interface SberPaymentOrder {
|
||||
id: string
|
||||
createdAt: string
|
||||
welayat: string
|
||||
sahamca: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
phone: string
|
||||
email: string
|
||||
address: string
|
||||
status: PaymentStatus
|
||||
paidStatus: PaymentPaidStatus
|
||||
bellik: string
|
||||
|
||||
id: string;
|
||||
createdAt: string;
|
||||
welayat: string;
|
||||
sahamca: string;
|
||||
sahamcaId?: number | string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
address: string;
|
||||
status: PaymentStatus;
|
||||
paidStatus: PaymentPaidStatus;
|
||||
bellik: string;
|
||||
|
||||
// Payment info
|
||||
accountNumber: string
|
||||
passportSeries: string
|
||||
passportNumber: string
|
||||
fullName: string
|
||||
|
||||
accountNumber: string;
|
||||
passportSeries: string;
|
||||
passportNumber: string;
|
||||
fullName: string;
|
||||
|
||||
// Documents
|
||||
documents: SberDocument[]
|
||||
|
||||
documents: SberDocument[];
|
||||
|
||||
// Payment history
|
||||
paymentHistory: PaymentHistoryItem[]
|
||||
|
||||
paymentHistory: PaymentHistoryItem[];
|
||||
|
||||
// Activity log
|
||||
activityLog: ActivityLogItem[]
|
||||
activityLog: ActivityLogItem[];
|
||||
}
|
||||
|
||||
export interface SberDocument {
|
||||
id: string
|
||||
name: string
|
||||
label: string
|
||||
fileUrl: string | null
|
||||
fileType: 'image' | 'pdf' | null
|
||||
id: string;
|
||||
name: string;
|
||||
label: string;
|
||||
fileUrl: string | null;
|
||||
fileType: "image" | "pdf" | null;
|
||||
}
|
||||
|
||||
export interface PaymentHistoryItem {
|
||||
id: string
|
||||
date: string
|
||||
amount: number
|
||||
status: 'completed' | 'pending' | 'failed'
|
||||
id: string;
|
||||
date: string;
|
||||
amount: number;
|
||||
status: "completed" | "pending" | "failed";
|
||||
}
|
||||
|
||||
export interface ActivityLogItem {
|
||||
id: string
|
||||
analysisName: string
|
||||
createdBy: string
|
||||
target: string
|
||||
status: 'FINISHED' | 'PENDING' | 'FAILED'
|
||||
createdAt: string
|
||||
id: string;
|
||||
analysisName: string;
|
||||
createdBy: string;
|
||||
target: string;
|
||||
status: "FINISHED" | "PENDING" | "FAILED";
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
// ─── API Types ────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface SberPaymentOrdersResponse {
|
||||
data: SberPaymentOrder[]
|
||||
data: SberPaymentOrder[];
|
||||
pagination: {
|
||||
currentPage: number
|
||||
totalPages: number
|
||||
totalCount: number
|
||||
perPage: number
|
||||
}
|
||||
currentPage: number;
|
||||
totalPages: number;
|
||||
totalCount: number;
|
||||
perPage: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface CreateSberPaymentPayload {
|
||||
welayat: string
|
||||
sahamca: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
phone: string
|
||||
email: string
|
||||
address: string
|
||||
status: PaymentStatus
|
||||
bellik: string
|
||||
accountNumber: string
|
||||
passportSeries: string
|
||||
passportNumber: string
|
||||
fullName: string
|
||||
welayat: string;
|
||||
sahamca: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
address: string;
|
||||
status: PaymentStatus;
|
||||
bellik: string;
|
||||
accountNumber: string;
|
||||
passportSeries: string;
|
||||
passportNumber: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
export interface UpdateSberPaymentPayload extends CreateSberPaymentPayload {
|
||||
id: string
|
||||
id: string;
|
||||
}
|
||||
|
||||
// ─── Form Types ───────────────────────────────────────────────────────────────
|
||||
|
||||
export interface SberPaymentFormData {
|
||||
welayat: string
|
||||
sahamca: string
|
||||
firstName: string
|
||||
lastName: string
|
||||
phone: string
|
||||
email: string
|
||||
address: string
|
||||
status: PaymentStatus
|
||||
bellik: string
|
||||
accountNumber: string
|
||||
passportSeries: string
|
||||
passportNumber: string
|
||||
fullName: string
|
||||
welayat: string;
|
||||
sahamca: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
address: string;
|
||||
status: PaymentStatus;
|
||||
bellik: string;
|
||||
accountNumber: string;
|
||||
passportSeries: string;
|
||||
passportNumber: string;
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
// ─── Filter Types ─────────────────────────────────────────────────────────────
|
||||
|
||||
export interface SberPaymentFilters {
|
||||
search: string
|
||||
welayat: string
|
||||
sahamca: string
|
||||
status: string
|
||||
paidStatus: string
|
||||
search: string;
|
||||
welayat: string;
|
||||
sahamca: string;
|
||||
status: string;
|
||||
paidStatus: string;
|
||||
}
|
||||
|
||||
|
||||
// ─── Mock Data ────────────────────────────────────────────────────────────────
|
||||
|
||||
const turkmenNames = [
|
||||
{ first: 'Lale', last: 'Agayewa' },
|
||||
{ first: 'Agamyrat', last: 'Hydyrow' },
|
||||
{ first: 'Rusdem', last: 'Jorayew' },
|
||||
{ first: 'Agajan', last: 'Rejepow' },
|
||||
{ first: 'Cemen', last: 'Mamedowa' },
|
||||
{ first: 'Ussman', last: 'Saberdiyew' },
|
||||
{ first: 'Ogultagan', last: 'Amanowa' },
|
||||
{ first: 'Bahargul', last: 'Dowranowa' },
|
||||
{ first: 'Muhabet', last: 'Hojakulyyewa' },
|
||||
{ first: 'Yusupbay', last: 'Orunow' },
|
||||
{ first: 'Jumagul', last: 'Hasanowa' },
|
||||
{ first: 'Arazgul', last: 'Akmedowa' },
|
||||
{ first: 'Samsat', last: 'Mamedowa' },
|
||||
{ first: 'Anzela', last: 'Metkumyan' },
|
||||
{ first: 'Durmys', last: 'Bahadurow' },
|
||||
{ first: 'Serdar', last: 'Nuryyew' },
|
||||
{ first: 'Kseniya', last: 'Hemrayewa' },
|
||||
{ first: 'Orazgul', last: 'Dowletowa' },
|
||||
{ first: 'Salidahan', last: 'Kazyyewa' },
|
||||
{ first: 'Babamurad', last: 'Abdyraimow' },
|
||||
{ first: 'Ogulnar', last: 'Babakulyyewa' },
|
||||
{ first: 'Derman', last: 'Hudaynazarow' },
|
||||
{ first: 'Hasan', last: 'Tasow' },
|
||||
{ first: 'Yusupjan', last: 'Tasow' },
|
||||
{ first: 'Begnazar', last: 'Weliyew' },
|
||||
]
|
||||
{ first: "Lale", last: "Agayewa" },
|
||||
{ first: "Agamyrat", last: "Hydyrow" },
|
||||
{ first: "Rusdem", last: "Jorayew" },
|
||||
{ first: "Agajan", last: "Rejepow" },
|
||||
{ first: "Cemen", last: "Mamedowa" },
|
||||
{ first: "Ussman", last: "Saberdiyew" },
|
||||
{ first: "Ogultagan", last: "Amanowa" },
|
||||
{ first: "Bahargul", last: "Dowranowa" },
|
||||
{ first: "Muhabet", last: "Hojakulyyewa" },
|
||||
{ first: "Yusupbay", last: "Orunow" },
|
||||
{ first: "Jumagul", last: "Hasanowa" },
|
||||
{ first: "Arazgul", last: "Akmedowa" },
|
||||
{ first: "Samsat", last: "Mamedowa" },
|
||||
{ first: "Anzela", last: "Metkumyan" },
|
||||
{ first: "Durmys", last: "Bahadurow" },
|
||||
{ first: "Serdar", last: "Nuryyew" },
|
||||
{ first: "Kseniya", last: "Hemrayewa" },
|
||||
{ first: "Orazgul", last: "Dowletowa" },
|
||||
{ first: "Salidahan", last: "Kazyyewa" },
|
||||
{ first: "Babamurad", last: "Abdyraimow" },
|
||||
{ first: "Ogulnar", last: "Babakulyyewa" },
|
||||
{ first: "Derman", last: "Hudaynazarow" },
|
||||
{ first: "Hasan", last: "Tasow" },
|
||||
{ first: "Yusupjan", last: "Tasow" },
|
||||
{ first: "Begnazar", last: "Weliyew" },
|
||||
];
|
||||
|
||||
const welayatlar = ['Mary', 'Lebap', 'Asgabat', 'Dashoguz', 'Balkan']
|
||||
const welayatlar = ["Mary", "Lebap", "Asgabat", "Dashoguz", "Balkan"];
|
||||
|
||||
const sahamcalar: Record<string, string[]> = {
|
||||
Mary: ['Bayramaly', 'Mary saheri', 'Sakarçäge'],
|
||||
Lebap: ['Turkmenabat', 'Garlyk', 'Seydi', 'Buzmeyin'],
|
||||
Asgabat: ['Buzmeyin', 'Berkararlyk', 'Köpetdag'],
|
||||
Dashoguz: ['Dashoguz saheri', 'Gubadag', 'Köneurgench'],
|
||||
Balkan: ['Balkanabat', 'Turkmenbasy', 'Serdar'],
|
||||
}
|
||||
Mary: ["Bayramaly", "Mary saheri", "Sakarçäge"],
|
||||
Lebap: ["Turkmenabat", "Garlyk", "Seydi", "Buzmeyin"],
|
||||
Asgabat: ["Buzmeyin", "Berkararlyk", "Köpetdag"],
|
||||
Dashoguz: ["Dashoguz saheri", "Gubadag", "Köneurgench"],
|
||||
Balkan: ["Balkanabat", "Turkmenbasy", "Serdar"],
|
||||
};
|
||||
|
||||
const statuses: Array<'GARASYLYYAR' | 'KANAGATLANDYRYLAN' | 'RET_EDILEN'> = [
|
||||
'GARASYLYYAR',
|
||||
'KANAGATLANDYRYLAN',
|
||||
'RET_EDILEN',
|
||||
]
|
||||
const statuses: Array<"GARASYLYYAR" | "KANAGATLANDYRYLAN" | "RET_EDILEN"> = ["GARASYLYYAR", "KANAGATLANDYRYLAN", "RET_EDILEN"];
|
||||
|
||||
const documentLabels = [
|
||||
{ id: 'rekvezit', name: 'Rekvezit.jpg', label: 'Talyba degisli walýuta "SBERBANK" kartyň rekwizitleri' },
|
||||
{ id: 'sprawka', name: 'sprawka-2026.jpg', label: 'Talybýň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwanamasy' },
|
||||
{ id: 'bildirish', name: 'bildirish.jpg', label: 'Talybýň bildirisli göcürmesi' },
|
||||
{ id: 'passport-copy', name: 'Tkm-pas-Agayewa-Mahllan-(1).jpg', label: 'Talyba degisli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi' },
|
||||
{ id: 'zagran-1', name: 'Zagran-(1).jpg', label: 'Talybýň Türkmenistandan çykmak we Türkmenistana girmek üçin (zagran) pasportynyň göçürmesi' },
|
||||
{ id: 'zagran-2', name: 'Zagran-(2).jpg', label: 'Talybýň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportyndaky daşary ýurda çykmak üçin tälynjädägy baradaky beriim miiletti hereket edijan rughsatnamasyniyň (wizasynyň) bellenen sahypasynyň göçürmesi' },
|
||||
]
|
||||
{ id: "rekvezit", name: "Rekvezit.jpg", label: 'Talyba degisli walýuta "SBERBANK" kartyň rekwizitleri' },
|
||||
{
|
||||
id: "sprawka",
|
||||
name: "sprawka-2026.jpg",
|
||||
label: "Talybýň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwanamasy",
|
||||
},
|
||||
{ id: "bildirish", name: "bildirish.jpg", label: "Talybýň bildirisli göcürmesi" },
|
||||
{
|
||||
id: "passport-copy",
|
||||
name: "Tkm-pas-Agayewa-Mahllan-(1).jpg",
|
||||
label: "Talyba degisli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi",
|
||||
},
|
||||
{
|
||||
id: "zagran-1",
|
||||
name: "Zagran-(1).jpg",
|
||||
label: "Talybýň Türkmenistandan çykmak we Türkmenistana girmek üçin (zagran) pasportynyň göçürmesi",
|
||||
},
|
||||
{
|
||||
id: "zagran-2",
|
||||
name: "Zagran-(2).jpg",
|
||||
label:
|
||||
"Talybýň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportyndaky daşary ýurda çykmak üçin tälynjädägy baradaky beriim miiletti hereket edijan rughsatnamasyniyň (wizasynyň) bellenen sahypasynyň göçürmesi",
|
||||
},
|
||||
];
|
||||
|
||||
function generateMockPaymentOrder(index: number): SberPaymentOrder {
|
||||
const name = turkmenNames[index % turkmenNames.length]
|
||||
const welayat = welayatlar[index % welayatlar.length]
|
||||
const sahamcaList = sahamcalar[welayat]
|
||||
const sahamca = sahamcaList[index % sahamcaList.length]
|
||||
const status = statuses[index % statuses.length]
|
||||
|
||||
const baseDate = new Date(2026, 4, 7) // May 7, 2026
|
||||
const orderDate = new Date(baseDate.getTime() - index * 3 * 60 * 1000) // 3 min apart
|
||||
|
||||
const idPrefix = ['TB7369', 'TB8319', 'TB8318', 'TB8311', 'TB1308'][index % 5]
|
||||
const idNumber = 8137 - index
|
||||
|
||||
const name = turkmenNames[index % turkmenNames.length];
|
||||
const welayat = welayatlar[index % welayatlar.length];
|
||||
const sahamcaList = sahamcalar[welayat];
|
||||
const sahamca = sahamcaList[index % sahamcaList.length];
|
||||
const status = statuses[index % statuses.length];
|
||||
|
||||
const baseDate = new Date(2026, 4, 7); // May 7, 2026
|
||||
const orderDate = new Date(baseDate.getTime() - index * 3 * 60 * 1000); // 3 min apart
|
||||
|
||||
const idPrefix = ["TB7369", "TB8319", "TB8318", "TB8311", "TB1308"][index % 5];
|
||||
const idNumber = 8137 - index;
|
||||
|
||||
return {
|
||||
id: `${idPrefix}-${idNumber}`,
|
||||
createdAt: orderDate.toISOString(),
|
||||
welayat,
|
||||
sahamca,
|
||||
sahamcaId: (index % 3) + 1,
|
||||
firstName: name.first,
|
||||
lastName: name.last,
|
||||
phone: `+993-${60 + (index % 5)}${index % 10}-${(42 + index) % 99}-${(28 + index * 2) % 99}-${(13 + index * 3) % 99}`,
|
||||
email: `${name.first.toLowerCase()}.${name.last.toLowerCase()}@mail.tm`,
|
||||
address: `Bayramaly saher 1-nji jay toolumy jay1 oy1`,
|
||||
status,
|
||||
paidStatus: index % 3 === 0 ? 'Tolendi' : 'Tolenmedik',
|
||||
bellik: '',
|
||||
paidStatus: index % 3 === 0 ? "Tolendi" : "Tolenmedik",
|
||||
bellik: "",
|
||||
accountNumber: `232080100002850`,
|
||||
passportSeries: `II-M${String.fromCharCode(65 + (index % 8))}`,
|
||||
passportNumber: String(100000 + index * 1234),
|
||||
@@ -210,72 +222,70 @@ function generateMockPaymentOrder(index: number): SberPaymentOrder {
|
||||
name: doc.name,
|
||||
label: doc.label,
|
||||
fileUrl: index % 2 === 0 ? `/uploads/${doc.name}` : null,
|
||||
fileType: doc.name.endsWith('.pdf') ? 'pdf' : 'image',
|
||||
fileType: doc.name.endsWith(".pdf") ? "pdf" : "image",
|
||||
})),
|
||||
paymentHistory: [],
|
||||
activityLog: [
|
||||
{
|
||||
id: `activity-${index}-1`,
|
||||
analysisName: 'Gospmak',
|
||||
analysisName: "Gospmak",
|
||||
createdBy: `Agayewa ${name.first} Sadurdyyewna`,
|
||||
target: `Sber töleg (talyplar üçin): ${idPrefix}-${idNumber}`,
|
||||
status: 'FINISHED',
|
||||
status: "FINISHED",
|
||||
createdAt: orderDate.toISOString(),
|
||||
},
|
||||
],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Generate 100 mock records
|
||||
const mockPaymentOrders: SberPaymentOrder[] = Array.from({ length: 100 }, (_, i) =>
|
||||
generateMockPaymentOrder(i)
|
||||
)
|
||||
const mockPaymentOrders: SberPaymentOrder[] = Array.from({ length: 100 }, (_, i) => generateMockPaymentOrder(i));
|
||||
|
||||
// ─── API Functions ────────────────────────────────────────────────────────────
|
||||
|
||||
export async function getSberPaymentOrders(params: {
|
||||
page?: number
|
||||
perPage?: number
|
||||
search?: string
|
||||
welayat?: string
|
||||
sahamca?: string
|
||||
status?: string
|
||||
page?: number;
|
||||
perPage?: number;
|
||||
search?: string;
|
||||
welayat?: string;
|
||||
sahamca?: string;
|
||||
status?: string;
|
||||
}): Promise<SberPaymentOrdersResponse> {
|
||||
// Simulate network delay
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
|
||||
let filtered = [...mockPaymentOrders]
|
||||
let filtered = [...mockPaymentOrders];
|
||||
|
||||
// Apply filters
|
||||
if (params.search) {
|
||||
const q = params.search.toLowerCase()
|
||||
const q = params.search.toLowerCase();
|
||||
filtered = filtered.filter(
|
||||
(o) =>
|
||||
o.id.toLowerCase().includes(q) ||
|
||||
o.firstName.toLowerCase().includes(q) ||
|
||||
o.lastName.toLowerCase().includes(q) ||
|
||||
o.phone.includes(q)
|
||||
)
|
||||
o.phone.includes(q),
|
||||
);
|
||||
}
|
||||
|
||||
if (params.welayat) {
|
||||
filtered = filtered.filter((o) => o.welayat === params.welayat)
|
||||
filtered = filtered.filter((o) => o.welayat === params.welayat);
|
||||
}
|
||||
|
||||
if (params.sahamca) {
|
||||
filtered = filtered.filter((o) => o.sahamca === params.sahamca)
|
||||
filtered = filtered.filter((o) => o.sahamca === params.sahamca);
|
||||
}
|
||||
|
||||
if (params.status) {
|
||||
filtered = filtered.filter((o) => o.status === params.status)
|
||||
filtered = filtered.filter((o) => o.status === params.status);
|
||||
}
|
||||
|
||||
const page = params.page ?? 1
|
||||
const perPage = params.perPage ?? 25
|
||||
const totalCount = filtered.length
|
||||
const totalPages = Math.ceil(totalCount / perPage)
|
||||
const start = (page - 1) * perPage
|
||||
const data = filtered.slice(start, start + perPage)
|
||||
const page = params.page ?? 1;
|
||||
const perPage = params.perPage ?? 25;
|
||||
const totalCount = filtered.length;
|
||||
const totalPages = Math.ceil(totalCount / perPage);
|
||||
const start = (page - 1) * perPage;
|
||||
const data = filtered.slice(start, start + perPage);
|
||||
|
||||
return {
|
||||
data,
|
||||
@@ -285,65 +295,61 @@ export async function getSberPaymentOrders(params: {
|
||||
totalCount,
|
||||
perPage,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function getSberPaymentOrderById(id: string): Promise<SberPaymentOrder | null> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 200))
|
||||
return mockPaymentOrders.find((o) => o.id === id) ?? null
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
return mockPaymentOrders.find((o) => o.id === id) ?? null;
|
||||
}
|
||||
|
||||
export async function createSberPaymentOrder(
|
||||
payload: CreateSberPaymentPayload
|
||||
): Promise<SberPaymentOrder> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 400))
|
||||
export async function createSberPaymentOrder(payload: CreateSberPaymentPayload): Promise<SberPaymentOrder> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
|
||||
const newOrder: SberPaymentOrder = {
|
||||
id: `TB${Math.floor(1000 + Math.random() * 9000)}-${Math.floor(1000 + Math.random() * 9000)}`,
|
||||
createdAt: new Date().toISOString(),
|
||||
...payload,
|
||||
paidStatus: 'Tolenmedik',
|
||||
paidStatus: "Tolenmedik",
|
||||
documents: [],
|
||||
paymentHistory: [],
|
||||
activityLog: [],
|
||||
}
|
||||
};
|
||||
|
||||
mockPaymentOrders.unshift(newOrder)
|
||||
return newOrder
|
||||
mockPaymentOrders.unshift(newOrder);
|
||||
return newOrder;
|
||||
}
|
||||
|
||||
export async function updateSberPaymentOrder(
|
||||
payload: UpdateSberPaymentPayload
|
||||
): Promise<SberPaymentOrder> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 400))
|
||||
export async function updateSberPaymentOrder(payload: UpdateSberPaymentPayload): Promise<SberPaymentOrder> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
|
||||
const index = mockPaymentOrders.findIndex((o) => o.id === payload.id)
|
||||
const index = mockPaymentOrders.findIndex((o) => o.id === payload.id);
|
||||
if (index === -1) {
|
||||
throw new Error('Payment order not found')
|
||||
throw new Error("Payment order not found");
|
||||
}
|
||||
|
||||
const updated = {
|
||||
...mockPaymentOrders[index],
|
||||
...payload,
|
||||
}
|
||||
mockPaymentOrders[index] = updated
|
||||
return updated
|
||||
};
|
||||
mockPaymentOrders[index] = updated;
|
||||
return updated;
|
||||
}
|
||||
|
||||
export async function deleteSberPaymentOrder(id: string): Promise<void> {
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
const index = mockPaymentOrders.findIndex((o) => o.id === id)
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
const index = mockPaymentOrders.findIndex((o) => o.id === id);
|
||||
if (index !== -1) {
|
||||
mockPaymentOrders.splice(index, 1)
|
||||
mockPaymentOrders.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Constants for dropdowns ──────────────────────────────────────────────────
|
||||
|
||||
export const WELAYATLAR = welayatlar
|
||||
export const SAHAMCALAR = sahamcalar
|
||||
export const WELAYATLAR = welayatlar;
|
||||
export const SAHAMCALAR = sahamcalar;
|
||||
export const STATUSES = [
|
||||
{ value: 'GARASYLYYAR', label: 'Garasylyyar' },
|
||||
{ value: 'KANAGATLANDYRYLAN', label: 'Kanagatlandyrylan' },
|
||||
{ value: 'RET_EDILEN', label: 'Ret edilen' },
|
||||
]
|
||||
{ value: "GARASYLYYAR", label: "Garasylyyar" },
|
||||
{ value: "KANAGATLANDYRYLAN", label: "Kanagatlandyrylan" },
|
||||
{ value: "RET_EDILEN", label: "Ret edilen" },
|
||||
];
|
||||
@@ -86,9 +86,11 @@ function NavSubGroup({ subItem, pathname }: { subItem: NavSubItem; pathname: str
|
||||
const active = subItem.items?.some((s) => pathname === s.url) ?? false;
|
||||
const [open, setOpen] = useState(active);
|
||||
|
||||
useEffect(() => {
|
||||
const [prevActive, setPrevActive] = useState(active);
|
||||
if (active !== prevActive) {
|
||||
setPrevActive(active);
|
||||
if (active) setOpen(true);
|
||||
}, [active]);
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapsible open={open} onOpenChange={setOpen}>
|
||||
@@ -139,9 +141,13 @@ function NavGroupItem({ item }: { item: NavItem }) {
|
||||
const active = isActiveItem(item, pathname);
|
||||
const [open, setOpen] = useState(active);
|
||||
|
||||
useEffect(() => {
|
||||
const [prevActive, setPrevActive] = useState(active);
|
||||
const [prevCollapsed, setPrevCollapsed] = useState(collapsed);
|
||||
if (active !== prevActive || collapsed !== prevCollapsed) {
|
||||
setPrevActive(active);
|
||||
setPrevCollapsed(collapsed);
|
||||
if (active && !collapsed) setOpen(true);
|
||||
}, [active, collapsed]);
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapsible open={!collapsed && open} onOpenChange={(v) => !collapsed && setOpen(v)}>
|
||||
@@ -468,17 +474,19 @@ function AppSidebar() {
|
||||
{/* Footer — user block */}
|
||||
<SidebarFooter className="border-t border-sidebar-border p-2">
|
||||
<Collapsible>
|
||||
{/* Items — trigger'dan ÖNCE render edilir, yukarı doğru açılır */}
|
||||
<CollapsibleContent className="overflow-hidden data-[state=open]:animate-collapsible-down data-[state=closed]:animate-collapsible-up">
|
||||
<div className="mb-1 rounded-lg py-1 group-data-[collapsible=icon]:hidden">
|
||||
<div className="px-3 py-2 border-b border-sidebar-border/50 mb-1">
|
||||
<p className="truncate text-xs font-medium text-sidebar-foreground">{user?.name ?? "Admin"}</p>
|
||||
<p className="truncate text-[11px] text-sidebar-foreground/40">{user?.email ?? ""}</p>
|
||||
</div>
|
||||
<button className="flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-foreground hover:bg-sidebar-accent/10 transition-colors">
|
||||
<Link
|
||||
to="/profile"
|
||||
className="flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-foreground hover:bg-sidebar-accent/10 transition-colors"
|
||||
>
|
||||
<User size={14} />
|
||||
<span>My profile</span>
|
||||
</button>
|
||||
<span>{t("profile.title", "Meniň profilim")}</span>
|
||||
</Link>
|
||||
<button
|
||||
onClick={logout}
|
||||
className="flex w-full items-center gap-2 rounded-md px-3 py-1.5 text-sm text-destructive hover:bg-destructive/10 transition-colors"
|
||||
@@ -489,7 +497,6 @@ function AppSidebar() {
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
|
||||
{/* Trigger — profil butonu */}
|
||||
<CollapsibleTrigger asChild>
|
||||
<SidebarMenuButton
|
||||
size="lg"
|
||||
@@ -566,8 +573,6 @@ function DashboardHeader() {
|
||||
};
|
||||
});
|
||||
|
||||
// DashboardHeader içindeki breadcrumb render kısmı
|
||||
|
||||
const generateBreadcrumbs = () => {
|
||||
if (breadcrumbs.length === 0) return null;
|
||||
|
||||
@@ -693,14 +698,14 @@ export function DashboardLayout() {
|
||||
<div className="flex w-full text-foreground ">
|
||||
<AppSidebar />
|
||||
|
||||
<div className="flex-1 p-2 flex bg-sidebar flex-col min-w-0">
|
||||
<div className="flex-1 p-0 md:p-2 flex bg-sidebar flex-col min-w-0">
|
||||
<DashboardHeader />
|
||||
|
||||
<main className="flex-1 p-4 rounded-b-md mb-1 bg-background">
|
||||
<Outlet />
|
||||
</main>
|
||||
|
||||
<div className="text-center text-[11px] text-muted-foreground/30 py-3 ">© 2026 TBBANK.GOV.TM</div>
|
||||
<div className="text-center text-[11px] text-muted-foreground/30 py-3">© {new Date().getFullYear()} TBBANK.GOV.TM</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
|
||||
+12
-16
@@ -17,23 +17,23 @@ const processQueue = (error: any, token: string | null = null) => {
|
||||
failedQueue = [];
|
||||
};
|
||||
|
||||
// Request Interceptor (Token ekleme)
|
||||
apiClient.interceptors.request.use((config) => {
|
||||
const token = useAuthStore.getState().token;
|
||||
if (token && config.headers) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
}, (error) => Promise.reject(error));
|
||||
apiClient.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = useAuthStore.getState().token;
|
||||
if (token && config.headers) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
);
|
||||
|
||||
// Response Interceptor (Senior Hata Yönetimi)
|
||||
apiClient.interceptors.response.use(
|
||||
(response) => response,
|
||||
async (error) => {
|
||||
const originalRequest = error.config;
|
||||
const status = error.response?.status;
|
||||
|
||||
// 1. 401 Unauthorized & Refresh Token Yönetimi
|
||||
if (status === 401 && !originalRequest._retry) {
|
||||
if (isRefreshing) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -50,16 +50,13 @@ apiClient.interceptors.response.use(
|
||||
isRefreshing = true;
|
||||
|
||||
try {
|
||||
// Sessizce yeni token almayı dene (Zustand içindeki refresh action'ı)
|
||||
const newToken = await useAuthStore.getState().refreshToken();
|
||||
processQueue(null, newToken);
|
||||
originalRequest.headers.Authorization = `Bearer ${newToken}`;
|
||||
return apiClient(originalRequest);
|
||||
} catch (refreshError) {
|
||||
processQueue(refreshError, null);
|
||||
// Refresh de patladıysa kullanıcıyı temizce çıkışa zorla
|
||||
useAuthStore.getState().logout();
|
||||
// SPA dostu yönlendirme: Sayfa yenilemeden custom bir event veya global history ile
|
||||
window.dispatchEvent(new Event("auth:unauthorized"));
|
||||
return Promise.reject(refreshError);
|
||||
} finally {
|
||||
@@ -67,13 +64,12 @@ apiClient.interceptors.response.use(
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 403 Forbidden Yönetimi (Kullanıcıyı haberdar et, akışı durdur)
|
||||
if (status === 403) {
|
||||
window.dispatchEvent(new Event("auth:forbidden"));
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default apiClient;
|
||||
export default apiClient;
|
||||
+18
-17
@@ -1,27 +1,28 @@
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
import en from './locales/en.json'
|
||||
import ru from './locales/ru.json'
|
||||
import tk from './locales/tk.json'
|
||||
import en from "./locales/en.json";
|
||||
import ru from "./locales/ru.json";
|
||||
import tk from "./locales/tk.json";
|
||||
|
||||
export const SUPPORTED_LANGUAGES = ['en', 'ru', 'tk'] as const
|
||||
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number]
|
||||
export const SUPPORTED_LANGUAGES = ["en", "ru", "tk"] as const;
|
||||
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
|
||||
|
||||
const savedStorage = localStorage.getItem('tbbank-lang')
|
||||
let savedLang: string | null = null
|
||||
const savedStorage = localStorage.getItem("tbbank-lang");
|
||||
let savedLang: string | null = null;
|
||||
|
||||
if (savedStorage) {
|
||||
try {
|
||||
const parsed = JSON.parse(savedStorage)
|
||||
savedLang = parsed.state?.language
|
||||
const parsed = JSON.parse(savedStorage);
|
||||
savedLang = parsed.state?.language;
|
||||
} catch {
|
||||
savedLang = savedStorage
|
||||
savedLang = savedStorage;
|
||||
}
|
||||
}
|
||||
|
||||
const defaultLang: SupportedLanguage =
|
||||
SUPPORTED_LANGUAGES.includes(savedLang as SupportedLanguage) ? (savedLang as SupportedLanguage) : 'en'
|
||||
const defaultLang: SupportedLanguage = SUPPORTED_LANGUAGES.includes(savedLang as SupportedLanguage)
|
||||
? (savedLang as SupportedLanguage)
|
||||
: "en";
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
resources: {
|
||||
@@ -30,10 +31,10 @@ i18n.use(initReactI18next).init({
|
||||
tk: { translation: tk },
|
||||
},
|
||||
lng: defaultLang,
|
||||
fallbackLng: 'en',
|
||||
fallbackLng: "tk",
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
export default i18n
|
||||
export default i18n;
|
||||
@@ -1215,5 +1215,6 @@
|
||||
"visaMasterSberSettings.createTitle": "Create setting",
|
||||
"visaMasterSberSettings.editTitle": "Edit setting",
|
||||
"onlinePayments.viewTitle": "Payment detail",
|
||||
"cardTypes.viewTitle": "Card type detail"
|
||||
"cardTypes.viewTitle": "Card type detail",
|
||||
"profile.title": "My Profile"
|
||||
}
|
||||
@@ -1216,5 +1216,6 @@
|
||||
"visaMasterSberSettings.createTitle": "Создать настройку",
|
||||
"visaMasterSberSettings.editTitle": "Редактировать настройку",
|
||||
"onlinePayments.viewTitle": "Детали платежа",
|
||||
"cardTypes.viewTitle": "Детали типа карты"
|
||||
"cardTypes.viewTitle": "Детали типа карты",
|
||||
"profile.title": "Мой профиль"
|
||||
}
|
||||
@@ -1214,5 +1214,6 @@
|
||||
"visaMasterSberSettings.createTitle": "Sazlama döretmek",
|
||||
"visaMasterSberSettings.editTitle": "Sazlama üýtgetmek",
|
||||
"onlinePayments.viewTitle": "Töleg giňišleýin",
|
||||
"cardTypes.viewTitle": "Kart görnüşi giňişleýin"
|
||||
"cardTypes.viewTitle": "Kart görnüşi giňişleýin",
|
||||
"profile.title": "Meniň profilim"
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
useCardPin,
|
||||
useDeleteCardPin,
|
||||
} from "@/features/cardPins/hooks/useCardPins";
|
||||
import { useCardPin, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import type { CardPinStatus } from "@/features/cardPins/api/cardPinApi";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -18,33 +15,30 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<CardPinStatus, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
}
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<CardPinStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
}
|
||||
};
|
||||
|
||||
function CardPinStatusBadge({ status }: { status: CardPinStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const variant = STATUS_VARIANT[status]
|
||||
const Icon = STATUS_ICON[status]
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={t(`cardPin.status.${status}`)} variant={variant} icon={Icon} />
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`cardPin.status.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -64,34 +58,29 @@ function CardPinViewSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardPinViewPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data, isLoading, isError } = useCardPin(id!)
|
||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin()
|
||||
const { data, isLoading, isError } = useCardPin(id!);
|
||||
const { mutate: deletePin, isPending: isDeleting } = useDeleteCardPin();
|
||||
|
||||
if (isLoading) {
|
||||
return <CardPinViewSkeleton />
|
||||
return <CardPinViewSkeleton />;
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
)
|
||||
return <div className="flex items-center justify-center py-24 text-muted-foreground">{t("common.notFound", "Maglumat tapylmady")}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-start justify-between">
|
||||
<h1 className="text-xl font-bold text-foreground">
|
||||
@@ -100,28 +89,19 @@ export default function CardPinViewPage() {
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertDialog>
|
||||
<AlertDialogTitle asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10">
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("cardPin.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t("cardPin.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardPin.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")}{" "}
|
||||
{data.id}
|
||||
{t("cardPin.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} {data.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>
|
||||
{t("common.cancel", "Ýatyr")}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={isDeleting}>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
@@ -133,12 +113,7 @@ export default function CardPinViewPage() {
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8"
|
||||
onClick={() => navigate(`/card-pins/${id}/edit`)}
|
||||
>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8" onClick={() => navigate(`/card-pins/${id}/edit`)}>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -147,97 +122,56 @@ export default function CardPinViewPage() {
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardPin.metaSection", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")}>
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")}>
|
||||
{data.created_at}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
<InfoRow label={t("cardPin.createdAt", "Döredilen wagty")} value={data.created_at} />
|
||||
<InfoRow label={t("cardPin.status", "Status")}>
|
||||
<CardPinStatusBadge status={data.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.note", "Bellik")}>
|
||||
{data.note || "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{data.created_by_label}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.note", "Bellik")} value={data.note || undefined} />
|
||||
<InfoRow label={t("cardPin.createdBy", "Sargyt eden")} value={data.created_by_label} isLink />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPin.cardSection", "Kart")}>
|
||||
<InfoRow label={t("cardPin.cardNumber", "Kart belgisi")}>
|
||||
<span className="font-mono tracking-wider">{data.card_number}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.cardExpireMonth", "Kart Möhleti (aý)")}>
|
||||
—
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.cardExpireYear", "Kart Möhleti (ýyl)")}>
|
||||
—
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.cardNumber", "Kart belgisi")} value={data.card_number} />
|
||||
<InfoRow label={t("cardPin.cardExpireMonth", "Kart Möhleti (aý)")} value={null} />
|
||||
<InfoRow label={t("cardPin.cardExpireYear", "Kart Möhleti (ýyl)")} value={null} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPin.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardPin.province", "Welaýat")}>
|
||||
{data.province_label}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.branch", "Şahamça")}>
|
||||
<span className="text-primary font-medium">{data.branch_label}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.province", "Welaýat")} value={data.province_label} />
|
||||
<InfoRow label={t("cardPin.branch", "Şahamça")} value={data.branch_label} isLink />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy + Pasport maglumatlary ─────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("cardPin.personalSection", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("cardPin.fullName", "Doly ady")}>
|
||||
{`${data.last_name} ${data.first_name} ${data.father_name}`}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.birthDate", "Doglan güni")}>
|
||||
{data.birth_date}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.phone", "Telefon")}>
|
||||
+{data.phone}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.fullName", "Doly ady")} value={`${data.last_name} ${data.first_name} ${data.father_name}`} />
|
||||
<InfoRow label={t("cardPin.birthDate", "Doglan güni")} value={data.birth_date} />
|
||||
<InfoRow label={t("cardPin.phone", "Telefon")} value={`+${data.phone}`} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPin.passportSection", "Pasport")}>
|
||||
<InfoRow label={t("cardPin.passportSeries", "Pasport seriýasy")}>
|
||||
{data.passport_series}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.passportNumber", "Pasport belgisi")}>
|
||||
{data.passport_number}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardPin.passportSeries", "Pasport seriýasy")} value={data.passport_series} />
|
||||
<InfoRow label={t("cardPin.passportNumber", "Pasport belgisi")} value={data.passport_number} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("cardPin.passportFile1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile1", "Pasport (sahypa 1)")}
|
||||
url={data.passport_file_1}
|
||||
/>
|
||||
<PassportImage label={t("cardPin.passportFile1", "Pasport (sahypa 1)")} url={data.passport_file_1} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardPin.passportFile2", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile2", "Pasport (2-3-nji sahypa)")}
|
||||
url={data.passport_file_2}
|
||||
/>
|
||||
<PassportImage label={t("cardPin.passportFile2", "Pasport (2-3-nji sahypa)")} url={data.passport_file_2} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardPin.passportFile3", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile3", "Pasport (8-9 sahypa)")}
|
||||
url={data.passport_file_3}
|
||||
/>
|
||||
<PassportImage label={t("cardPin.passportFile3", "Pasport (8-9 sahypa)")} url={data.passport_file_3} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardPin.passportFile4", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t("cardPin.passportFile4", "Pasport (32-nji sahypa)")}
|
||||
url={data.passport_file_4}
|
||||
/>
|
||||
<PassportImage label={t("cardPin.passportFile4", "Pasport (32-nji sahypa)")} url={data.passport_file_4} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Download } from "lucide-react";
|
||||
import { Download, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||
@@ -11,29 +11,20 @@ import { TableActions } from "@/components/tableActions";
|
||||
import type { VisibilityState } from "@tanstack/react-table";
|
||||
import { useCardRequisites, useDeleteCardRequisite, useDownloadCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisite, CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_BADGE: Record<CardRequisiteStatus, { label: string; className: string }> = {
|
||||
pending: {
|
||||
label: "Garaşylýar",
|
||||
className: "bg-yellow-500/15 text-yellow-500 border-yellow-500/20",
|
||||
},
|
||||
approved: {
|
||||
label: "Tassyklanan",
|
||||
className: "bg-emerald-500/15 text-emerald-500 border-emerald-500/20",
|
||||
},
|
||||
rejected: {
|
||||
label: "Ret edilen",
|
||||
className: "bg-red-500/15 text-red-500 border-red-500/20",
|
||||
},
|
||||
const STATUS_CONFIG: Record<CardRequisiteStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
pending: { label: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
approved: { label: "Tassyklanan", variant: "success", icon: CheckCircle2 },
|
||||
rejected: { label: "Ret edilen", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function StatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const cfg = STATUS_BADGE[status] ?? STATUS_BADGE.pending;
|
||||
return (
|
||||
<span className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${cfg.className}`}>{cfg.label}</span>
|
||||
);
|
||||
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -115,7 +106,7 @@ export default function CardRequisitesPage() {
|
||||
id: "status",
|
||||
accessorKey: "status",
|
||||
header: t("Status", "STATUS"),
|
||||
cell: ({ row }) => <StatusBadge status={row.original.status} />,
|
||||
cell: ({ row }) => <CardRequisiteStatusBadge status={row.original.status} />,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
useCardRequisite,
|
||||
useDeleteCardRequisite,
|
||||
useDownloadCardRequisite,
|
||||
} from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import { useCardRequisite, useDeleteCardRequisite, useDownloadCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||
import type { CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -19,33 +15,30 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<CardRequisiteStatus, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
}
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<CardRequisiteStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
}
|
||||
};
|
||||
|
||||
function CardRequisiteStatusBadge({ status }: { status: CardRequisiteStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const variant = STATUS_VARIANT[status]
|
||||
const Icon = STATUS_ICON[status]
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`cardRequisite.status.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -65,35 +58,30 @@ function CardRequisiteViewSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardRequisiteViewPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { data, isLoading, isError } = useCardRequisite(id ?? "")
|
||||
const deleteMutation = useDeleteCardRequisite()
|
||||
const downloadMutation = useDownloadCardRequisite()
|
||||
const { data, isLoading, isError } = useCardRequisite(id ?? "");
|
||||
const deleteMutation = useDeleteCardRequisite();
|
||||
const downloadMutation = useDownloadCardRequisite();
|
||||
|
||||
if (isLoading) {
|
||||
return <CardRequisiteViewSkeleton />
|
||||
return <CardRequisiteViewSkeleton />;
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
)
|
||||
return <div className="flex items-center justify-center py-24 text-muted-foreground">{t("common.notFound", "Maglumat tapylmady")}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-start justify-between">
|
||||
<h1 className="text-xl font-bold text-foreground">
|
||||
@@ -101,7 +89,8 @@ export default function CardRequisiteViewPage() {
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
size="icon" variant="ghost"
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8"
|
||||
onClick={() => downloadMutation.mutate(data.id)}
|
||||
disabled={downloadMutation.isPending}
|
||||
@@ -110,27 +99,19 @@ export default function CardRequisiteViewPage() {
|
||||
</Button>
|
||||
<AlertDialog>
|
||||
<AlertDialogTitle asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10">
|
||||
<Trash2 size={15} />
|
||||
</Button>
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t("cardRequisite.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardRequisite.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} {data.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteMutation.isPending}>
|
||||
{t("common.cancel", "Ýatyr")}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={deleteMutation.isPending}>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
@@ -142,10 +123,7 @@ export default function CardRequisiteViewPage() {
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
<Button
|
||||
size="icon" variant="ghost" className="h-8 w-8"
|
||||
onClick={() => navigate(`/card-requisites/${id}/edit`)}
|
||||
>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8" onClick={() => navigate(`/card-requisites/${id}/edit`)}>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -154,101 +132,63 @@ export default function CardRequisiteViewPage() {
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ────────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardRequisite.metaSection", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")}>
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.createdAt", "Döredilen wagty")}>
|
||||
{data.created_at}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
<InfoRow label={t("cardRequisite.createdAt", "Döredilen wagty")} value={data.created_at} />
|
||||
<InfoRow label={t("cardRequisite.status", "Status")}>
|
||||
<CardRequisiteStatusBadge status={data.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.note", "Bellik")}>
|
||||
{data.note || "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.createdBy", "Sargyt eden")}>
|
||||
{data.first_name && data.last_name ? (
|
||||
<span className="text-primary font-medium">
|
||||
{data.last_name}_{data.first_name}
|
||||
</span>
|
||||
) : "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.note", "Bellik")} value={data.note || undefined} />
|
||||
<InfoRow
|
||||
label={t("cardRequisite.createdBy", "Sargyt eden")}
|
||||
value={data.first_name && data.last_name ? `${data.last_name}_${data.first_name}` : undefined}
|
||||
isLink
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardRequisite.cardSection", "Kart")}>
|
||||
<InfoRow label={t("cardRequisite.cardNumber", "Kart belgisi")}>
|
||||
<span className="font-mono tracking-wider">{data.card_number}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.cardExpireMonth", "Kart Möhleti (aý)")}>
|
||||
{data.card_expiry_month}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.cardExpireYear", "Kart Möhleti (ýyl)")}>
|
||||
{data.card_expiry_year}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.cardNumber", "Kart belgisi")} value={data.card_number} />
|
||||
<InfoRow label={t("cardRequisite.cardExpireMonth", "Kart Möhleti (aý)")} value={data.card_expiry_month} />
|
||||
<InfoRow label={t("cardRequisite.cardExpireYear", "Kart Möhleti (ýyl)")} value={data.card_expiry_year} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardRequisite.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardRequisite.province", "Welaýat")}>
|
||||
{data.province_name ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.branch", "Şahamça")}>
|
||||
<span className="text-primary font-medium">{data.branch_name ?? "—"}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.province", "Welaýat")} value={data.province_name ?? undefined} />
|
||||
<InfoRow label={t("cardRequisite.branch", "Şahamça")} value={data.branch_name ?? undefined} isLink />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy + Pasport maglumatlary ──────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("cardRequisite.personalSection", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("cardRequisite.fullName", "Doly ady")}>
|
||||
{[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(" ")}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.birthDate", "Doglan güni")}>
|
||||
{data.birth_date}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.phone", "Telefon")}>
|
||||
{data.phone}
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("cardRequisite.fullName", "Doly ady")}
|
||||
value={[data.first_name, data.last_name, data.middle_name].filter(Boolean).join(" ")}
|
||||
/>
|
||||
<InfoRow label={t("cardRequisite.birthDate", "Doglan güni")} value={data.birth_date} />
|
||||
<InfoRow label={t("cardRequisite.phone", "Telefon")} value={data.phone} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardRequisite.passportSection", "Pasport")}>
|
||||
<InfoRow label={t("cardRequisite.passportSeries", "Pasport seriýasy")}>
|
||||
{data.passport_series}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.passportNumber", "Pasport belgisi")}>
|
||||
{data.passport_number}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardRequisite.passportSeries", "Pasport seriýasy")} value={data.passport_series} />
|
||||
<InfoRow label={t("cardRequisite.passportNumber", "Pasport belgisi")} value={data.passport_number} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Passport images ────────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("cardRequisite.passportFile1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("cardRequisite.passportFile1", "Pasport (sahypa 1)")}
|
||||
src={data.passport_page1_url}
|
||||
/>
|
||||
<PassportImage label={t("cardRequisite.passportFile1", "Pasport (sahypa 1)")} src={data.passport_page1_url} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardRequisite.passportFile2", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t("cardRequisite.passportFile2", "Pasport (2-3-nji sahypa)")}
|
||||
src={data.passport_page2_3_url}
|
||||
/>
|
||||
<PassportImage label={t("cardRequisite.passportFile2", "Pasport (2-3-nji sahypa)")} src={data.passport_page2_3_url} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardRequisite.passportFile3", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("cardRequisite.passportFile3", "Pasport (8-9 sahypa)")}
|
||||
src={data.passport_page8_9_url}
|
||||
/>
|
||||
<PassportImage label={t("cardRequisite.passportFile3", "Pasport (8-9 sahypa)")} src={data.passport_page8_9_url} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardRequisite.passportFile4", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t("cardRequisite.passportFile4", "Pasport (32-nji sahypa)")}
|
||||
src={data.passport_page32_url}
|
||||
/>
|
||||
<PassportImage label={t("cardRequisite.passportFile4", "Pasport (32-nji sahypa)")} src={data.passport_page32_url} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Printer, Download, Trash2, Pencil } from "lucide-react";
|
||||
import { Printer, Download, Trash2, Pencil, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
@@ -14,30 +14,24 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
useCardOrderById,
|
||||
useDeleteCardOrder,
|
||||
} from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import { useCardOrderById, useDeleteCardOrder } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import type { CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_STYLE: Record<CardOrderStatus, { className: string; icon: string }> = {
|
||||
PENDING: { icon: "⏳", className: "bg-amber-500/10 text-amber-400 border border-amber-500/20" },
|
||||
APPROVED: { icon: "✓", className: "bg-emerald-500/10 text-emerald-400 border border-emerald-500/20" },
|
||||
REJECTED: { icon: "✕", className: "bg-red-500/10 text-red-400 border border-red-500/20" },
|
||||
}
|
||||
const STATUS_CONFIG: Record<CardOrderStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
PENDING: { label: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
APPROVED: { label: "Tassyklandy", variant: "success", icon: CheckCircle2 },
|
||||
REJECTED: { label: "Ýatyryldy", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function StatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const cfg = STATUS_STYLE[status]
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-bold tracking-wide ${cfg.className}`}>
|
||||
<span className="text-[10px]">{cfg.icon}</span>
|
||||
{t(`cardOrder.status.${status.toLowerCase()}`)}
|
||||
</span>
|
||||
)
|
||||
function CardOrderStatusBadge({ status }: { status: CardOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`cardOrder.status.${status.toLowerCase()}`)} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -57,43 +51,36 @@ function DetailSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function CardOrderDetailPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? "")
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? "");
|
||||
const deleteMutation = useDeleteCardOrder();
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!id) return
|
||||
await deleteMutation.mutateAsync(id)
|
||||
navigate("/order-new-card")
|
||||
}
|
||||
if (!id) return;
|
||||
await deleteMutation.mutateAsync(id);
|
||||
navigate("/order-new-card");
|
||||
};
|
||||
|
||||
if (isLoading) return <DetailSkeleton />
|
||||
if (!order)
|
||||
return (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</p>
|
||||
)
|
||||
if (isLoading) return <DetailSkeleton />;
|
||||
if (!order) return <p className="text-muted-foreground text-sm">{t("common.notFound", "Tapylmady")}</p>;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}:{" "}
|
||||
<span className="text-primary font-mono">{order.id}</span>
|
||||
{t("cardOrder.detailTitle", "Kart sargyt giriş üçin")}: <span className="text-primary font-mono">{order.id}</span>
|
||||
</h1>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
@@ -124,103 +111,66 @@ export default function CardOrderDetailPage() {
|
||||
{/* ── Row 1: Meta + Kart + Lokasiýa ───────────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("cardOrder.section.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")}>{order.id}</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")}>
|
||||
{order.createdAt}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow label={t("cardOrder.field.createdAt", "Döredilen wagty")} value={order.createdAt} />
|
||||
<InfoRow label={t("cardOrder.field.status", "Status")}>
|
||||
<StatusBadge status={order.status} />
|
||||
<CardOrderStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.isPaid", "Tölenen")}>
|
||||
<span className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold ${order.isPaid ? "bg-emerald-500/15 text-emerald-400" : "bg-red-500/15 text-red-400"}`}>
|
||||
<span
|
||||
className={`inline-flex items-center justify-center w-5 h-5 rounded-full text-xs font-bold ${order.isPaid ? "bg-emerald-500/15 text-emerald-400" : "bg-red-500/15 text-red-400"}`}
|
||||
>
|
||||
{order.isPaid ? "✓" : "✕"}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")}>
|
||||
{order.note ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.createdBy", "Sargyt eden")}>
|
||||
<span className="text-primary font-medium">{order.createdBy}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.note", "Bellik")} value={order.note ?? undefined} />
|
||||
<InfoRow label={t("cardOrder.field.createdBy", "Sargyt eden")} value={order.createdBy} isLink />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.card", "Kart")}>
|
||||
<InfoRow label={t("cardOrder.field.issuanceReason", "Kartyň çykarylmagynyň sebäbi")}>
|
||||
<span className="text-primary font-medium">{order.issuanceReasonName}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.cardType", "Kart görnüşi")}>
|
||||
<span className="text-cyan-400 font-medium">{order.cardTypeName}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.issuanceReason", "Kartyň çykarylmagynyň sebäbi")} value={order.issuanceReasonName} isLink />
|
||||
<InfoRow label={t("cardOrder.field.cardType", "Kart görnüşi")} value={order.cardTypeName} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("cardOrder.field.province", "Welaýat")}>
|
||||
{order.provinceName}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.branch", "Şahamça")}>
|
||||
<span className="text-cyan-400 font-medium">{order.branchName}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.province", "Welaýat")} value={order.provinceName} />
|
||||
<InfoRow label={t("cardOrder.field.branch", "Şahamça")} value={order.branchName} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy maglumatlar (full width — many fields) ─────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("cardOrder.section.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("cardOrder.field.fullName", "Doly ady")}>
|
||||
{[order.lastName, order.firstName, order.middleName].filter(Boolean).join(" ")}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")}>
|
||||
{order.birthDate}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")}>
|
||||
{order.citizenship}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.registeredAddress", "Ýazgy edilen salgy")}>
|
||||
{order.registeredAddress}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.currentAddress", "Häzirki ýaşaýyş ýeri")}>
|
||||
{order.currentAddress}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.workplace", "Işleýän ýeri we wezipesi")}>
|
||||
{order.workplace}
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("cardOrder.field.fullName", "Doly ady")}
|
||||
value={[order.lastName, order.firstName, order.middleName].filter(Boolean).join(" ")}
|
||||
/>
|
||||
<InfoRow label={t("cardOrder.field.birthDate", "Doglan güni")} value={order.birthDate} />
|
||||
<InfoRow label={t("cardOrder.field.citizenship", "Raýatlyk")} value={order.citizenship} />
|
||||
<InfoRow label={t("cardOrder.field.registeredAddress", "Ýazgy edilen salgy")} value={order.registeredAddress} />
|
||||
<InfoRow label={t("cardOrder.field.currentAddress", "Häzirki ýaşaýyş ýeri")} value={order.currentAddress} />
|
||||
<InfoRow label={t("cardOrder.field.workplace", "Işleýän ýeri we wezipesi")} value={order.workplace} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardOrder.section.contacts", "Kontakt")}>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")}>
|
||||
{order.phone}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")}>
|
||||
{order.phoneExtra ?? "—"}
|
||||
</InfoRow>
|
||||
<InfoRow label={t("cardOrder.field.phone", "Telefon")} value={order.phone} />
|
||||
<InfoRow label={t("cardOrder.field.phoneExtra", "Telefon goşmaça")} value={order.phoneExtra ?? undefined} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("cardOrder.field.passportPage1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")}
|
||||
url={order.passportFiles.page1}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage1", "Pasport (sahypa 1)")} url={order.passportFiles.page1} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage23", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage23", "Pasport (2-3-nji sahypa)")}
|
||||
url={order.passportFiles.page23}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage23", "Pasport (2-3-nji sahypa)")} url={order.passportFiles.page23} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage89", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")}
|
||||
url={order.passportFiles.page89}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage89", "Pasport (8-9 sahypa)")} url={order.passportFiles.page89} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("cardOrder.field.passportPage32", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
url={order.passportFiles.page32}
|
||||
/>
|
||||
<PassportImage label={t("cardOrder.field.passportPage32", "Pasport (32-nji sahypa)")} url={order.passportFiles.page32} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
@@ -228,27 +178,19 @@ export default function CardOrderDetailPage() {
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t("cardOrder.deleteTitle", "Pozmak isleýärsiňizmi?")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("cardOrder.deleteDescription", "Bu kart sargyt hemişelik pozular. Bu işi yzyna gaýtaryp bolmaz.")}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDelete}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending
|
||||
? t("common.deleting", "Pozulýar...")
|
||||
: t("common.delete", "Pozmak")}
|
||||
<AlertDialogAction onClick={handleDelete} className="bg-destructive text-destructive-foreground hover:bg-destructive/90">
|
||||
{deleteMutation.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Pozmak")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
+113
-95
@@ -7,36 +7,16 @@ import {
|
||||
Users,
|
||||
DollarSign,
|
||||
Activity,
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
AreaChart,
|
||||
Area,
|
||||
BarChart,
|
||||
Bar,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
PieChart,
|
||||
Pie,
|
||||
Cell,
|
||||
} from "recharts";
|
||||
import {
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
ChartLegend,
|
||||
ChartLegendContent,
|
||||
} from "@/components/ui/chart";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { AreaChart, Area, BarChart, Bar, XAxis, YAxis, CartesianGrid, PieChart, Pie, Cell } from "recharts";
|
||||
import { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent } from "@/components/ui/chart";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
// ─── Mock data ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -67,17 +47,17 @@ const barData = [
|
||||
|
||||
const pieData = [
|
||||
{ name: "Kanagatlandyrylan", value: 6746, key: "approved" },
|
||||
{ name: "Garaşylýar", value: 208, key: "pending" },
|
||||
{ name: "Işlenilýär", value: 157, key: "processing" },
|
||||
{ name: "Ýatyrylan", value: 245, key: "rejected" },
|
||||
{ name: "Bellige alyndy", value: 450, key: "registered" },
|
||||
{ name: "Garaşylýar", value: 208, key: "pending" },
|
||||
{ name: "Işlenilýär", value: 157, key: "processing" },
|
||||
{ name: "Ýatyrylan", value: 245, key: "rejected" },
|
||||
{ name: "Bellige alyndy", value: 450, key: "registered" },
|
||||
];
|
||||
|
||||
const recentActivity = [
|
||||
{ id: "#KS-2841", name: "Serdar Annagurban", amount: "12 500 TMT", status: "approved", time: "2 min öň" },
|
||||
{ id: "#KS-2840", name: "Aýgül Myradowa", amount: "8 000 TMT", status: "pending", time: "14 min öň" },
|
||||
{ id: "#KS-2839", name: "Kakajan Durdyýew", amount: "25 000 TMT", status: "approved", time: "31 min öň" },
|
||||
{ id: "#KS-2838", name: "Ogulgerek Sähedowa", amount: "5 500 TMT", status: "rejected", time: "1 sa öň" },
|
||||
{ id: "#KS-2841", name: "Serdar Annagurban", amount: "12 500 TMT", status: "approved", time: "2 min öň" },
|
||||
{ id: "#KS-2840", name: "Aýgül Myradowa", amount: "8 000 TMT", status: "pending", time: "14 min öň" },
|
||||
{ id: "#KS-2839", name: "Kakajan Durdyýew", amount: "25 000 TMT", status: "approved", time: "31 min öň" },
|
||||
{ id: "#KS-2838", name: "Ogulgerek Sähedowa", amount: "5 500 TMT", status: "rejected", time: "1 sa öň" },
|
||||
{ id: "#KS-2837", name: "Merdan Hojamyradow", amount: "18 000 TMT", status: "approved", time: "2 sa öň" },
|
||||
];
|
||||
|
||||
@@ -90,27 +70,31 @@ const areaConfig = {
|
||||
|
||||
const barConfig = {
|
||||
approved: { label: "Tassyklanan", color: "var(--chart-1)" },
|
||||
rejected: { label: "Ýatyryldy", color: "var(--chart-5)" },
|
||||
rejected: { label: "Ýatyryldy", color: "var(--chart-5)" },
|
||||
} satisfies Record<string, { label: string; color: string }>;
|
||||
|
||||
const pieConfig = {
|
||||
approved: { label: "Kanagatlandyrylan", color: "var(--chart-2)" },
|
||||
pending: { label: "Garaşylýar", color: "var(--chart-4)" },
|
||||
processing: { label: "Işlenilýär", color: "var(--chart-1)" },
|
||||
rejected: { label: "Ýatyrylan", color: "var(--chart-5)" },
|
||||
registered: { label: "Bellige alyndy", color: "var(--chart-3)" },
|
||||
approved: { label: "Kanagatlandyrylan", color: "var(--chart-2)" },
|
||||
pending: { label: "Garaşylýar", color: "var(--chart-4)" },
|
||||
processing: { label: "Işlenilýär", color: "var(--chart-1)" },
|
||||
rejected: { label: "Ýatyrylan", color: "var(--chart-5)" },
|
||||
registered: { label: "Bellige alyndy", color: "var(--chart-3)" },
|
||||
} satisfies Record<string, { label: string; color: string }>;
|
||||
|
||||
// ─── Stat card ────────────────────────────────────────────────────────────────
|
||||
|
||||
function StatCard({
|
||||
title, value, change, icon: Icon, accent,
|
||||
title,
|
||||
value,
|
||||
change,
|
||||
icon: Icon,
|
||||
accent,
|
||||
}: {
|
||||
title: string
|
||||
value: string
|
||||
change: number
|
||||
icon: React.ElementType
|
||||
accent: string
|
||||
title: string;
|
||||
value: string;
|
||||
change: number;
|
||||
icon: React.ElementType;
|
||||
accent: string;
|
||||
}) {
|
||||
const positive = change >= 0;
|
||||
return (
|
||||
@@ -123,10 +107,12 @@ function StatCard({
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-3xl font-semibold tracking-tight">{value}</p>
|
||||
<p className={cn(
|
||||
"mt-1 flex items-center gap-1 text-xs font-medium",
|
||||
positive ? "text-emerald-600 dark:text-emerald-400" : "text-destructive",
|
||||
)}>
|
||||
<p
|
||||
className={cn(
|
||||
"mt-1 flex items-center gap-1 text-xs font-medium",
|
||||
positive ? "text-emerald-600 dark:text-emerald-400" : "text-destructive",
|
||||
)}
|
||||
>
|
||||
{positive ? <ArrowUpRight size={13} /> : <ArrowDownRight size={13} />}
|
||||
{Math.abs(change)}% geçen aýa garanyňda
|
||||
</p>
|
||||
@@ -152,22 +138,16 @@ function StatCardSkeleton() {
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
function StatusBadge({ status }: { status: string }) {
|
||||
const styles: Record<string, string> = {
|
||||
approved: "bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400 hover:bg-emerald-100",
|
||||
pending: "bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-400 hover:bg-amber-100",
|
||||
rejected: "bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-400 hover:bg-red-100",
|
||||
};
|
||||
const labels: Record<string, string> = {
|
||||
approved: "Tassyklandy",
|
||||
pending: "Garaşylýar",
|
||||
rejected: "Ýatyryldy",
|
||||
};
|
||||
return (
|
||||
<Badge variant="secondary" className={cn("text-[10px] px-1.5 py-0", styles[status])}>
|
||||
{labels[status]}
|
||||
</Badge>
|
||||
);
|
||||
const STATUS_CONFIG: Record<string, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }> = {
|
||||
approved: { label: "Tassyklandy", variant: "success", icon: CheckCircle2 },
|
||||
pending: { label: "Garaşylýar", variant: "warning", icon: AlertCircle },
|
||||
rejected: { label: "Ýatyryldy", variant: "error", icon: XCircle },
|
||||
};
|
||||
|
||||
function DashboardStatusBadge({ status }: { status: string }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
@@ -185,7 +165,9 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{[...Array(4)].map((_, i) => <StatCardSkeleton key={i} />)}
|
||||
{[...Array(4)].map((_, i) => (
|
||||
<StatCardSkeleton key={i} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
@@ -198,13 +180,17 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardContent>
|
||||
<div className="h-[220px] w-full flex flex-col justify-end relative">
|
||||
<div className="absolute left-0 top-0 h-full flex flex-col justify-between pb-6">
|
||||
{[...Array(5)].map((_, i) => <Skeleton key={i} className="h-2.5 w-6" />)}
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-6" />
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 flex-1 relative overflow-hidden rounded-md">
|
||||
<Skeleton className="absolute inset-0" />
|
||||
</div>
|
||||
<div className="ml-8 mt-2 flex justify-between">
|
||||
{[...Array(12)].map((_, i) => <Skeleton key={i} className="h-2.5 w-6" />)}
|
||||
{[...Array(12)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-6" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
@@ -256,7 +242,9 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardContent>
|
||||
<div className="h-[180px] w-full flex flex-col justify-end relative">
|
||||
<div className="absolute left-0 top-0 h-full flex flex-col justify-between pb-6">
|
||||
{[...Array(4)].map((_, i) => <Skeleton key={i} className="h-2.5 w-6" />)}
|
||||
{[...Array(4)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-6" />
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 flex items-end justify-between gap-1.5 h-[148px]">
|
||||
{[65, 85, 50, 95, 75, 40, 30].map((h, i) => (
|
||||
@@ -267,7 +255,9 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
))}
|
||||
</div>
|
||||
<div className="ml-8 mt-2 flex justify-between">
|
||||
{[...Array(7)].map((_, i) => <Skeleton key={i} className="h-2.5 w-4" />)}
|
||||
{[...Array(7)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-2.5 w-4" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
@@ -317,20 +307,40 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<div className="w-full space-y-6">
|
||||
{/* Header */}
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">
|
||||
{t("Dashboard", "Baş sahypa")}
|
||||
</h1>
|
||||
<p className="text-sm text-muted-foreground mt-0.5">
|
||||
{t("Overview of all operations", "Ähli amallaryň gysgaça görünüşi")}
|
||||
</p>
|
||||
<h1 className="text-2xl font-semibold tracking-tight">{t("Dashboard", "Baş sahypa")}</h1>
|
||||
<p className="text-sm text-muted-foreground mt-0.5">{t("Overview of all operations", "Ähli amallaryň gysgaça görünüşi")}</p>
|
||||
</div>
|
||||
|
||||
{/* Stat cards */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<StatCard title={t("Loan orders", "Karz sargytlary")} value="2 841" change={12.4} icon={FileText} accent="bg-blue-100 text-blue-600 dark:bg-blue-950 dark:text-blue-400" />
|
||||
<StatCard title={t("Active cards", "Işjeň kartlar")} value="6 968" change={5.1} icon={CreditCard} accent="bg-violet-100 text-violet-600 dark:bg-violet-950 dark:text-violet-400" />
|
||||
<StatCard title={t("Active clients", "Işjeň müşderiler")} value="1 204" change={-3.2} icon={Users} accent="bg-amber-100 text-amber-600 dark:bg-amber-950 dark:text-amber-400" />
|
||||
<StatCard title={t("Online payments", "Onlaýn tölegler")} value="438" change={18.7} icon={DollarSign} accent="bg-emerald-100 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400" />
|
||||
<StatCard
|
||||
title={t("Loan orders", "Karz sargytlary")}
|
||||
value="2 841"
|
||||
change={12.4}
|
||||
icon={FileText}
|
||||
accent="bg-blue-100 text-blue-600 dark:bg-blue-950 dark:text-blue-400"
|
||||
/>
|
||||
<StatCard
|
||||
title={t("Active cards", "Işjeň kartlar")}
|
||||
value="6 968"
|
||||
change={5.1}
|
||||
icon={CreditCard}
|
||||
accent="bg-violet-100 text-violet-600 dark:bg-violet-950 dark:text-violet-400"
|
||||
/>
|
||||
<StatCard
|
||||
title={t("Active clients", "Işjeň müşderiler")}
|
||||
value="1 204"
|
||||
change={-3.2}
|
||||
icon={Users}
|
||||
accent="bg-amber-100 text-amber-600 dark:bg-amber-950 dark:text-amber-400"
|
||||
/>
|
||||
<StatCard
|
||||
title={t("Online payments", "Onlaýn tölegler")}
|
||||
value="438"
|
||||
change={18.7}
|
||||
icon={DollarSign}
|
||||
accent="bg-emerald-100 text-emerald-600 dark:bg-emerald-950 dark:text-emerald-400"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Area chart + Pie chart */}
|
||||
@@ -345,11 +355,11 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<AreaChart data={areaData} margin={{ top: 4, right: 4, left: -24, bottom: 0 }}>
|
||||
<defs>
|
||||
<linearGradient id="fillLoans" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="5%" stopColor="var(--color-loans)" stopOpacity={0.2} />
|
||||
<stop offset="5%" stopColor="var(--color-loans)" stopOpacity={0.2} />
|
||||
<stop offset="95%" stopColor="var(--color-loans)" stopOpacity={0} />
|
||||
</linearGradient>
|
||||
<linearGradient id="fillCards" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="5%" stopColor="var(--color-cards)" stopOpacity={0.2} />
|
||||
<stop offset="5%" stopColor="var(--color-cards)" stopOpacity={0.2} />
|
||||
<stop offset="95%" stopColor="var(--color-cards)" stopOpacity={0} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
@@ -373,7 +383,17 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardContent>
|
||||
<ChartContainer config={pieConfig} className="h-[160px] w-full">
|
||||
<PieChart>
|
||||
<Pie data={pieData} cx="50%" cy="50%" innerRadius={48} outerRadius={72} paddingAngle={2} dataKey="value" nameKey="name" strokeWidth={0}>
|
||||
<Pie
|
||||
data={pieData}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
innerRadius={48}
|
||||
outerRadius={72}
|
||||
paddingAngle={2}
|
||||
dataKey="value"
|
||||
nameKey="name"
|
||||
strokeWidth={0}
|
||||
>
|
||||
{pieData.map((entry, i) => (
|
||||
<Cell key={i} fill={`var(--color-${entry.key})`} />
|
||||
))}
|
||||
@@ -388,9 +408,7 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<span className="h-1.5 w-1.5 rounded-full flex-shrink-0" style={{ background: `var(--color-${d.key})` }} />
|
||||
{d.name}
|
||||
</span>
|
||||
<span className="font-medium tabular-nums">
|
||||
{((d.value / total) * 100).toFixed(0)}%
|
||||
</span>
|
||||
<span className="font-medium tabular-nums">{((d.value / total) * 100).toFixed(0)}%</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -413,7 +431,7 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<YAxis tickLine={false} axisLine={false} tick={{ fontSize: 11, fill: "var(--muted-foreground)" }} />
|
||||
<ChartTooltip content={<ChartTooltipContent />} />
|
||||
<Bar dataKey="approved" fill="var(--color-approved)" radius={[4, 4, 0, 0]} maxBarSize={20} />
|
||||
<Bar dataKey="rejected" fill="var(--color-rejected)" radius={[4, 4, 0, 0]} maxBarSize={20} />
|
||||
<Bar dataKey="rejected" fill="var(--color-rejected)" radius={[4, 4, 0, 0]} maxBarSize={20} />
|
||||
<ChartLegend content={<ChartLegendContent />} />
|
||||
</BarChart>
|
||||
</ChartContainer>
|
||||
@@ -424,9 +442,7 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-3">
|
||||
<div>
|
||||
<CardTitle>{t("Recent activity", "Soňky hereketler")}</CardTitle>
|
||||
<CardDescription className="mt-0.5">
|
||||
{t("Latest loan orders", "Iň soňky karz sargytlary")}
|
||||
</CardDescription>
|
||||
<CardDescription className="mt-0.5">{t("Latest loan orders", "Iň soňky karz sargytlary")}</CardDescription>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 text-xs text-muted-foreground">
|
||||
<Activity size={12} />
|
||||
@@ -442,11 +458,13 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium truncate">{item.name}</p>
|
||||
<p className="text-xs text-muted-foreground">{item.id} · {item.time}</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{item.id} · {item.time}
|
||||
</p>
|
||||
</div>
|
||||
<div className="text-right shrink-0 space-y-0.5">
|
||||
<p className="text-sm font-medium tabular-nums">{item.amount}</p>
|
||||
<StatusBadge status={item.status} />
|
||||
<DashboardStatusBadge status={item.status} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -456,4 +474,4 @@ export default function DashboardPage({ isLoading = false }: { isLoading?: boole
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,77 @@
|
||||
import { format } from 'date-fns'
|
||||
import { Trash2, Edit, Search, Download, XCircle, CheckCircle2, AlertCircle } from 'lucide-react'
|
||||
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 { 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'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { format } from "date-fns";
|
||||
import { Trash2, Edit, Search, Download, XCircle, CheckCircle2, AlertCircle } from "lucide-react";
|
||||
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 { 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";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<PaymentStatus, StatusBadgeVariant> = {
|
||||
GARASYLYYAR: 'warning',
|
||||
KANAGATLANDYRYLAN: 'success',
|
||||
RET_EDILEN: 'error',
|
||||
}
|
||||
GARASYLYYAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RET_EDILEN: "error",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<PaymentStatus, React.ElementType> = {
|
||||
GARASYLYYAR: AlertCircle,
|
||||
GARASYLYYAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RET_EDILEN: XCircle,
|
||||
}
|
||||
RET_EDILEN: XCircle,
|
||||
};
|
||||
|
||||
const STATUS_KEY_MAP: Record<PaymentStatus, string> = {
|
||||
GARASYLYYAR: 'pending',
|
||||
KANAGATLANDYRYLAN: 'approved',
|
||||
RET_EDILEN: 'rejected',
|
||||
}
|
||||
GARASYLYYAR: "pending",
|
||||
KANAGATLANDYRYLAN: "approved",
|
||||
RET_EDILEN: "rejected",
|
||||
};
|
||||
|
||||
const PAID_STATUS_VARIANT: Record<PaymentPaidStatus, StatusBadgeVariant> = {
|
||||
Tolenmedik: 'error',
|
||||
Tolendi: 'success',
|
||||
}
|
||||
Tolenmedik: "error",
|
||||
Tolendi: "success",
|
||||
};
|
||||
|
||||
const PAID_STATUS_ICON: Record<PaymentPaidStatus, React.ElementType> = {
|
||||
Tolenmedik: XCircle,
|
||||
Tolendi: CheckCircle2,
|
||||
}
|
||||
Tolendi: CheckCircle2,
|
||||
};
|
||||
|
||||
const PAID_STATUS_KEY_MAP: Record<PaymentPaidStatus, string> = {
|
||||
Tolenmedik: 'unpaid',
|
||||
Tolendi: 'paid',
|
||||
}
|
||||
Tolenmedik: "unpaid",
|
||||
Tolendi: "paid",
|
||||
};
|
||||
|
||||
function PaymentStatusBadge({ status }: { status: PaymentStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const variant = STATUS_VARIANT[status]
|
||||
const Icon = STATUS_ICON[status]
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={t(`sberPayments.status.${STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`sberPayments.status.${STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
function PaymentPaidStatusBadge({ status }: { status: PaymentPaidStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const variant = PAID_STATUS_VARIANT[status]
|
||||
const Icon = PAID_STATUS_ICON[status]
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={t(`sberPayments.paidStatus.${PAID_STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />
|
||||
const { t } = useTranslation();
|
||||
const variant = PAID_STATUS_VARIANT[status];
|
||||
const Icon = PAID_STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`sberPayments.paidStatus.${PAID_STATUS_KEY_MAP[status]}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Document row ─────────────────────────────────────────────────────────────
|
||||
|
||||
function DocumentRow({
|
||||
label,
|
||||
fileName,
|
||||
fileUrl,
|
||||
}: {
|
||||
label: string
|
||||
fileName: string | null
|
||||
fileUrl: string | null
|
||||
}) {
|
||||
if (!fileUrl) return (
|
||||
<InfoRow label={label}>
|
||||
<span className="text-muted-foreground/50">—</span>
|
||||
</InfoRow>
|
||||
)
|
||||
function DocumentRow({ label, fileName, fileUrl }: { label: string; fileName: string | null; fileUrl: string | null }) {
|
||||
if (!fileUrl)
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
<span className="text-muted-foreground/50">—</span>
|
||||
</InfoRow>
|
||||
);
|
||||
|
||||
const name = fileName ?? fileUrl.split('/').pop() ?? 'faýl'
|
||||
const name = fileName ?? fileUrl.split("/").pop() ?? "faýl";
|
||||
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
@@ -96,7 +89,7 @@ function DocumentRow({
|
||||
</a>
|
||||
</div>
|
||||
</InfoRow>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -116,69 +109,69 @@ function SberPaymentViewSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function SberPaymentViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const [historySearch, setHistorySearch] = useState('')
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const [historySearch, setHistorySearch] = useState("");
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id!)
|
||||
const deleteMutation = useDeleteSberPayment()
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id!);
|
||||
const deleteMutation = useDeleteSberPayment();
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(id!)
|
||||
navigate('/sber-payments')
|
||||
}
|
||||
await deleteMutation.mutateAsync(id!);
|
||||
navigate("/sber-payments");
|
||||
};
|
||||
|
||||
if (isLoading) return <SberPaymentViewSkeleton />
|
||||
if (isLoading) return <SberPaymentViewSkeleton />;
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t('sberPayments.notFound', 'Töleg tapylmady')}
|
||||
{t("sberPayments.notFound", "Töleg tapylmady")}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const kabulDocs = order.documents?.slice(0, 6) ?? []
|
||||
const ugradDocs = order.documents?.slice(6) ?? []
|
||||
const kabulDocs = order.documents?.slice(0, 6) ?? [];
|
||||
const ugradDocs = order.documents?.slice(6) ?? [];
|
||||
|
||||
const auditLogs: AuditRowProps[] = order.activityLog?.map((log) => ({
|
||||
id: log.id.split('-')[1] ?? log.id,
|
||||
action: log.analysisName,
|
||||
by: log.createdBy,
|
||||
target: log.target,
|
||||
status: log.status,
|
||||
date: format(new Date(log.createdAt), 'dd/MM/yyyy, HH:mm:ss') + ' GMT+5',
|
||||
})) ?? []
|
||||
const auditLogs: AuditRowProps[] =
|
||||
order.activityLog?.map((log) => ({
|
||||
id: log.id.split("-")[1] ?? log.id,
|
||||
action: log.analysisName,
|
||||
by: log.createdBy,
|
||||
target: log.target,
|
||||
status: log.status,
|
||||
date: format(new Date(log.createdAt), "dd/MM/yyyy, HH:mm:ss") + " GMT+5",
|
||||
})) ?? [];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('sberPayments.viewTitle', 'Sberbank töleg')}: {order.id}
|
||||
{t("sberPayments.viewTitle", "Sberbank töleg")}: {order.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t('common.delete', 'Poz')}
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/sber-payments/${id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.edit', 'Redaktirle')}
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Edit size={16} />
|
||||
</button>
|
||||
@@ -187,80 +180,79 @@ export default function SberPaymentViewPage() {
|
||||
|
||||
{/* ── Row 1: Meta + Lokasiýa ────────────────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t('sberPayments.view.sections.main', 'Esasy maglumatlar')}>
|
||||
<InfoRow label={t('common.id', 'ID')} value={order.id} />
|
||||
<InfoRow label={t('Status', 'Status')}>
|
||||
<BentoCard title={t("sberPayments.view.sections.main", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow label={t("Status", "Status")}>
|
||||
<PaymentStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t('sberPayments.columns.paidStatus', 'Tölenen (şul aý)')}>
|
||||
<InfoRow label={t("sberPayments.columns.paidStatus", "Tölenen (şul aý)")}>
|
||||
<PaymentPaidStatusBadge status={order.paidStatus} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t('sberPayments.cards.bellik', 'Bellik')} value={order.bellik} />
|
||||
<InfoRow label={t("sberPayments.cards.bellik", "Bellik")} value={order.bellik} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t('sberPayments.view.sections.location', 'Lokasiýa')}>
|
||||
<InfoRow label={t('sberPayments.fields.welayat', 'Welaýat')} value={order.welayat} />
|
||||
<InfoRow label={t('sberPayments.fields.sahamca', 'Şahamça')} value={order.sahamca} isLink />
|
||||
<BentoCard title={t("sberPayments.view.sections.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("sberPayments.fields.welayat", "Welaýat")} value={order.welayat} />
|
||||
<InfoRow
|
||||
label={t("sberPayments.fields.sahamca", "Şahamça")}
|
||||
value={order.sahamca}
|
||||
isLink
|
||||
href={order.sahamcaId ? `/settings/location/branches/${order.sahamcaId}` : "/settings/location/branches"}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy maglumatlar + Töleg ─────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t('sberPayments.view.sections.personal', 'Şahsy maglumatlar')}>
|
||||
<InfoRow label={t('sberPayments.fields.firstName', 'Pasportdaky ady')} value={order.firstName} />
|
||||
<InfoRow label={t('sberPayments.fields.lastName', 'Pasportdaky familiýa')} value={order.lastName} />
|
||||
<InfoRow label={t('sberPayments.fields.phone', 'Telefon')} value={order.phone} />
|
||||
<InfoRow label={t('sberPayments.fields.email', 'E-poçta')} value={order.email} />
|
||||
<InfoRow label={t('sberPayments.fields.address', 'Salgy')} value={order.address} />
|
||||
<BentoCard title={t("sberPayments.view.sections.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("sberPayments.fields.firstName", "Pasportdaky ady")} value={order.firstName} />
|
||||
<InfoRow label={t("sberPayments.fields.lastName", "Pasportdaky familiýa")} value={order.lastName} />
|
||||
<InfoRow label={t("sberPayments.fields.phone", "Telefon")} value={order.phone} />
|
||||
<InfoRow label={t("sberPayments.fields.email", "E-poçta")} value={order.email} />
|
||||
<InfoRow label={t("sberPayments.fields.address", "Salgy")} value={order.address} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t('sberPayments.view.sections.payment', 'Töleg')}>
|
||||
<BentoCard title={t("sberPayments.view.sections.payment", "Töleg")}>
|
||||
<InfoRow
|
||||
label={t('sberPayments.payerInfo', 'Töleg ugradyjynyň maglumatlary')}
|
||||
value={`I-M${order.passportNumber?.slice(0, 2) ?? 'XX'}-${order.passportNumber ?? ''} ${order.fullName}`}
|
||||
label={t("sberPayments.payerInfo", "Töleg ugradyjynyň maglumatlary")}
|
||||
value={`I-M${order.passportNumber?.slice(0, 2) ?? "XX"}-${order.passportNumber ?? ""} ${order.fullName}`}
|
||||
/>
|
||||
<InfoRow label={t('sberPayments.fields.accountNumber', 'Goýum hasaby')} value={order.accountNumber} />
|
||||
<InfoRow label={t('sberPayments.fields.passportSeries', 'Pasport seriýasy')} value={order.passportSeries} />
|
||||
<InfoRow label={t('sberPayments.fields.passportNumber', 'Pasport nomeri')} value={order.passportNumber} />
|
||||
<InfoRow label={t('sberPayments.fields.fullName', 'Ady Familiýasy Atasynyň ady')} value={order.fullName} />
|
||||
<InfoRow label={t("sberPayments.fields.accountNumber", "Goýum hasaby")} value={order.accountNumber} />
|
||||
<InfoRow label={t("sberPayments.fields.passportSeries", "Pasport seriýasy")} value={order.passportSeries} />
|
||||
<InfoRow label={t("sberPayments.fields.passportNumber", "Pasport nomeri")} value={order.passportNumber} />
|
||||
<InfoRow label={t("sberPayments.fields.fullName", "Ady Familiýasy Atasynyň ady")} value={order.fullName} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Kabul ediji resminamalary ─────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t('sberPayments.view.sections.acceptedDocs', 'Kabul ediji talyp boýunça resminamalary')}>
|
||||
{kabulDocs.length > 0
|
||||
? kabulDocs.map((doc) => (
|
||||
<DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />
|
||||
))
|
||||
: (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
{t('sberPayments.view.noDocuments', 'Resminamalar ýok')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<BentoCard title={t("sberPayments.view.sections.acceptedDocs", "Kabul ediji talyp boýunça resminamalary")}>
|
||||
{kabulDocs.length > 0 ? (
|
||||
kabulDocs.map((doc) => <DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />)
|
||||
) : (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
{t("sberPayments.view.noDocuments", "Resminamalar ýok")}
|
||||
</div>
|
||||
)}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 4: Ugradyjy resminamalary ────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t('sberPayments.view.sections.sentDocs', 'Ugradyjy boýunça resminamalary')}>
|
||||
{ugradDocs.length > 0
|
||||
? ugradDocs.map((doc) => (
|
||||
<DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />
|
||||
))
|
||||
: (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
{t('sberPayments.view.noDocuments', 'Resminamalar ýok')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<BentoCard title={t("sberPayments.view.sections.sentDocs", "Ugradyjy boýunça resminamalary")}>
|
||||
{ugradDocs.length > 0 ? (
|
||||
ugradDocs.map((doc) => <DocumentRow key={doc.id} label={doc.label} fileName={doc.name} fileUrl={doc.fileUrl} />)
|
||||
) : (
|
||||
<div className="px-4 py-8 text-center text-sm text-muted-foreground">
|
||||
{t("sberPayments.view.noDocuments", "Resminamalar ýok")}
|
||||
</div>
|
||||
)}
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 5: Töleg taryhy ───────────────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t('sberPayments.view.sections.paymentHistory', 'Töleg taryhy')}>
|
||||
<BentoCard title={t("sberPayments.view.sections.paymentHistory", "Töleg taryhy")}>
|
||||
<div className="p-4">
|
||||
<div className="relative max-w-xs mb-4">
|
||||
<Search size={13} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" />
|
||||
@@ -268,7 +260,7 @@ export default function SberPaymentViewPage() {
|
||||
type="text"
|
||||
value={historySearch}
|
||||
onChange={(e) => setHistorySearch(e.target.value)}
|
||||
placeholder={t('common.search', 'Gözlemek')}
|
||||
placeholder={t("common.search", "Gözlemek")}
|
||||
className="h-9 w-full pl-9 pr-3 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
|
||||
/>
|
||||
</div>
|
||||
@@ -281,7 +273,7 @@ export default function SberPaymentViewPage() {
|
||||
<line x1="9" y1="21" x2="9" y2="9" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm">{t('sberPayments.view.noPaymentHistory', 'Berlen kriteriýalara Töleg gabat gelmedi.')}</p>
|
||||
<p className="text-sm">{t("sberPayments.view.noPaymentHistory", "Berlen kriteriýalara Töleg gabat gelmedi.")}</p>
|
||||
</div>
|
||||
</div>
|
||||
</BentoCard>
|
||||
@@ -293,11 +285,11 @@ export default function SberPaymentViewPage() {
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t('sberPayments.deleteDialog.title', 'Bu tölegi pozmak isleýärsiňizmi?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
title={t("sberPayments.deleteDialog.title", "Bu tölegi pozmak isleýärsiňizmi?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,46 +1,47 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, Download, Search, AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { BentoGrid, BentoCard, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useIntlPayment, useDeleteIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
||||
import type { IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||
import { useState } from "react";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, Download, Search, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { useIntlPayment, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||
import type { IntlPaymentStatus } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<IntlPaymentStatus, StatusBadgeVariant> = {
|
||||
pending: 'warning',
|
||||
approved: 'success',
|
||||
rejected: 'error',
|
||||
}
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<IntlPaymentStatus, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
}
|
||||
};
|
||||
|
||||
function PaymentStatusBadge({ status }: { status: IntlPaymentStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const variant = STATUS_VARIANT[status] ?? STATUS_VARIANT.pending
|
||||
const Icon = STATUS_ICON[status] ?? STATUS_ICON.pending
|
||||
return <StatusBadge label={t(`intlPayment.status.${status}`)} variant={variant} icon={Icon} />
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status] ?? STATUS_VARIANT.pending;
|
||||
const Icon = STATUS_ICON[status] ?? STATUS_ICON.pending;
|
||||
return <StatusBadge label={t(`intlPayment.status.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── DocFile row ──────────────────────────────────────────────────────────────
|
||||
|
||||
function DocFileRow({ label, url }: { label: string; url: string | null }) {
|
||||
if (!url) return (
|
||||
<InfoRow label={label}>
|
||||
<span className="text-muted-foreground/50">—</span>
|
||||
</InfoRow>
|
||||
)
|
||||
if (!url)
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
<span className="text-muted-foreground/50">—</span>
|
||||
</InfoRow>
|
||||
);
|
||||
|
||||
const filename = url.split('/').pop() ?? 'faýl'
|
||||
const isImage = /\.(jpg|jpeg|png|gif|webp)$/i.test(url)
|
||||
const filename = url.split("/").pop() ?? "faýl";
|
||||
const isImage = /\.(jpg|jpeg|png|gif|webp)$/i.test(url);
|
||||
|
||||
return (
|
||||
<InfoRow label={label}>
|
||||
@@ -66,7 +67,7 @@ function DocFileRow({ label, url }: { label: string; url: string | null }) {
|
||||
</a>
|
||||
</div>
|
||||
</InfoRow>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -86,68 +87,92 @@ function IntlPaymentViewSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function IntlPaymentViewPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const [historySearch, setHistorySearch] = useState('')
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const [historySearch, setHistorySearch] = useState("");
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
const { data, isLoading, isError } = useIntlPayment(id!)
|
||||
const { mutate: deletePayment, isPending: isDeleting } = useDeleteIntlPayment()
|
||||
const { data, isLoading, isError } = useIntlPayment(id!);
|
||||
const { mutate: deletePayment, isPending: isDeleting } = useDeleteIntlPayment();
|
||||
|
||||
const confirmDelete = () => {
|
||||
deletePayment(data!.id, { onSuccess: () => navigate('/intl-payments/visa-master') })
|
||||
}
|
||||
deletePayment(data!.id, { onSuccess: () => navigate("/intl-payments/visa-master") });
|
||||
};
|
||||
|
||||
if (isLoading) return <IntlPaymentViewSkeleton />
|
||||
if (isLoading) return <IntlPaymentViewSkeleton />;
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t('common.notFound', 'Maglumat tapylmady')}
|
||||
{t("common.notFound", "Maglumat tapylmady")}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const KABUL_DOCS = [
|
||||
{ label: 'Talypyň degişli welaýata "SBERBANK" kartyň rekwizitleri', url: data.doc_sberbank_account },
|
||||
{ label: 'Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy', url: data.doc_school_enrollment },
|
||||
{ label: 'Talypyň bilendiriň göçürmesi', url: data.doc_summons },
|
||||
{ label: 'Talypyň degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi', url: data.doc_passport_tm },
|
||||
{ label: 'Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi', url: data.doc_foreign_passport },
|
||||
{ label: 'Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurtda galan döwründe bakýan döwleti baradaky bellenen sahypasynyň göçürmesi', url: data.doc_foreign_passport_copy },
|
||||
{ label: 'Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň dowletiniň girmesiz baradaky bellenen sahypasynyň göçürmesi', url: data.doc_exit_permission },
|
||||
{ label: 'Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy barada maglumatlary daşary ýurt döwletiniň ýokary okuw mekdebinden haty', url: data.doc_school_foreign_info },
|
||||
{ label: 'Talypyň daşary ýurt döwletinde okaýandygy baradaky güwänamany daşary ýurt döwletiniň ýokary okuw mekdebinden haty', url: data.doc_school_departure_info },
|
||||
]
|
||||
{ label: 'Talypyň degişli welaýata "SBERBANK" kartyň rekwizitleri', url: data.doc_sberbank_account },
|
||||
{ label: "Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy", url: data.doc_school_enrollment },
|
||||
{ label: "Talypyň bilendiriň göçürmesi", url: data.doc_summons },
|
||||
{ label: "Talypyň degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi", url: data.doc_passport_tm },
|
||||
{ label: "Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi", url: data.doc_foreign_passport },
|
||||
{
|
||||
label:
|
||||
"Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurtda galan döwründe bakýan döwleti baradaky bellenen sahypasynyň göçürmesi",
|
||||
url: data.doc_foreign_passport_copy,
|
||||
},
|
||||
{
|
||||
label:
|
||||
"Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň dowletiniň girmesiz baradaky bellenen sahypasynyň göçürmesi",
|
||||
url: data.doc_exit_permission,
|
||||
},
|
||||
{
|
||||
label:
|
||||
"Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy barada maglumatlary daşary ýurt döwletiniň ýokary okuw mekdebinden haty",
|
||||
url: data.doc_school_foreign_info,
|
||||
},
|
||||
{
|
||||
label: "Talypyň daşary ýurt döwletinde okaýandygy baradaky güwänamany daşary ýurt döwletiniň ýokary okuw mekdebinden haty",
|
||||
url: data.doc_school_departure_info,
|
||||
},
|
||||
];
|
||||
|
||||
const UPGRAD_DOCS = [
|
||||
{ label: 'Upgradyý degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi', url: data.upd_doc_passport_tm },
|
||||
{ label: 'Upgradyý degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi', url: data.upd_doc_foreign_passport },
|
||||
{ label: 'Upgradyý Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurt döwletinde galýandygy baradaky şaýmynyň bellenen sahypasynyň göçürmesi', url: data.upd_doc_visa },
|
||||
{ label: 'Upgradyýyň we kabul edijiniň resminamalarynyň göçürmesi', url: data.upd_doc_acceptance_letter },
|
||||
{ label: 'Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky maglumatlary', url: data.upd_doc_passport_biometric },
|
||||
{ label: 'Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky göwnamasy', url: data.upd_doc_passport_old },
|
||||
]
|
||||
{ label: "Upgradyý degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi", url: data.upd_doc_passport_tm },
|
||||
{
|
||||
label: "Upgradyý degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi",
|
||||
url: data.upd_doc_foreign_passport,
|
||||
},
|
||||
{
|
||||
label:
|
||||
"Upgradyý Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurt döwletinde galýandygy baradaky şaýmynyň bellenen sahypasynyň göçürmesi",
|
||||
url: data.upd_doc_visa,
|
||||
},
|
||||
{ label: "Upgradyýyň we kabul edijiniň resminamalarynyň göçürmesi", url: data.upd_doc_acceptance_letter },
|
||||
{
|
||||
label: "Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky maglumatlary",
|
||||
url: data.upd_doc_passport_biometric,
|
||||
},
|
||||
{ label: "Upgradyý we kabul ediji täze 2015-nji ýyldan soňra pasportynyň seriýasy baradaky göwnamasy", url: data.upd_doc_passport_old },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('intlPayment.viewTitle', 'Halkara töleg')}: {data.id}
|
||||
{t("intlPayment.viewTitle", "Halkara töleg")}: {data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t('common.delete', 'Poz')}
|
||||
title={t("common.delete", "Poz")}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
@@ -156,7 +181,7 @@ export default function IntlPaymentViewPage() {
|
||||
<button
|
||||
onClick={() => navigate(`/intl-payments/visa-master/${id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.edit', 'Redaktirle')}
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
@@ -165,55 +190,47 @@ export default function IntlPaymentViewPage() {
|
||||
|
||||
{/* ── Row 1: Meta + Ýüztuman + Lokasiýa ───────────────────────────── */}
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t('intlPayment.statusSection', 'Esasy maglumatlar')}>
|
||||
<InfoRow label={t('intlPayment.client', 'Ulanyjy')}>
|
||||
<span className="text-primary font-medium">{data.client_label}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("common.id", "ID")}>
|
||||
<span className="font-mono">{data.id}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('intlPayment.status', 'Status')}>
|
||||
<BentoCard title={t("intlPayment.statusSection", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("intlPayment.client", "Ulanyjy")} value={data.client_label} isLink />
|
||||
<InfoRow label={t("common.id", "ID")} value={data.id} />
|
||||
<InfoRow label={t("intlPayment.status", "Status")}>
|
||||
<PaymentStatusBadge status={data.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t('intlPayment.tilowanMonth', 'Tölewan (Aý/aý)')} value={data.created_at} />
|
||||
<InfoRow label={t('intlPayment.note', 'Bellik')} value={data.note} />
|
||||
<InfoRow label={t("intlPayment.tilowanMonth", "Tölewan (Aý/aý)")} value={data.created_at} />
|
||||
<InfoRow label={t("intlPayment.note", "Bellik")} value={data.note} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t('intlPayment.currencySection', 'Ýüztumanyň görnüşi')}>
|
||||
<InfoRow label={t('intlPayment.currencyType', 'Görnüşi')} value={data.currency_type_label} />
|
||||
<BentoCard title={t("intlPayment.currencySection", "Ýüztumanyň görnüşi")}>
|
||||
<InfoRow label={t("intlPayment.currencyType", "Görnüşi")} value={data.currency_type_label} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t('intlPayment.locationSection', 'Lokasiýa')}>
|
||||
<InfoRow label={t('intlPayment.province', 'Welaýat')} value={data.province_label} />
|
||||
<InfoRow label={t('intlPayment.branch', 'Şahamça')}>
|
||||
<span className="text-primary font-medium">{data.branch_label}</span>
|
||||
</InfoRow>
|
||||
<BentoCard title={t("intlPayment.locationSection", "Lokasiýa")}>
|
||||
<InfoRow label={t("intlPayment.province", "Welaýat")} value={data.province_label} />
|
||||
<InfoRow label={t("intlPayment.branch", "Şahamça")} value={data.branch_label} isLink />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 2: Şahsy maglumatlar + Töleg ─────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t('intlPayment.personalSection', 'Şahsy maglumatlar')}>
|
||||
<InfoRow label={t('intlPayment.passportFirstName', 'Pasportdaky ady')} value={data.passport_first_name} />
|
||||
<InfoRow label={t('intlPayment.passportLastName', 'Pasportdaky familiýa')} value={data.passport_last_name} />
|
||||
<InfoRow label={t('intlPayment.phone', 'Telefon')}>
|
||||
<span>+{data.phone}</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('intlPayment.email', 'E-poçta')} value={data.email} />
|
||||
<InfoRow label={t('intlPayment.homeAddress', 'Häzirki ýaşyş ýeri')} value={data.home_address} />
|
||||
<BentoCard title={t("intlPayment.personalSection", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("intlPayment.passportFirstName", "Pasportdaky ady")} value={data.passport_first_name} />
|
||||
<InfoRow label={t("intlPayment.passportLastName", "Pasportdaky familiýa")} value={data.passport_last_name} />
|
||||
<InfoRow label={t("intlPayment.phone", "Telefon")} value={`+${data.phone}`} />
|
||||
<InfoRow label={t("intlPayment.email", "E-poçta")} value={data.email} />
|
||||
<InfoRow label={t("intlPayment.homeAddress", "Häzirki ýaşyş ýeri")} value={data.home_address} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t('intlPayment.paymentSection', 'Töleg')}>
|
||||
<InfoRow label={t('intlPayment.payerFullName', 'Töleg upgradyjynyň maglumatlary')} value={data.payer_full_name} />
|
||||
<InfoRow label={t('intlPayment.payerAccount', 'Töleg upgradyjynyň goşun hasaby')} value={data.payer_account_number} />
|
||||
<InfoRow label={t('intlPayment.passportSeries', 'Pasport seriýasy')} value={data.passport_series} />
|
||||
<InfoRow label={t('intlPayment.passportNumber', 'Pasport nomeri')} value={data.passport_number} />
|
||||
<BentoCard title={t("intlPayment.paymentSection", "Töleg")}>
|
||||
<InfoRow label={t("intlPayment.payerFullName", "Töleg upgradyjynyň maglumatlary")} value={data.payer_full_name} />
|
||||
<InfoRow label={t("intlPayment.payerAccount", "Töleg upgradyjynyň goşun hasaby")} value={data.payer_account_number} />
|
||||
<InfoRow label={t("intlPayment.passportSeries", "Pasport seriýasy")} value={data.passport_series} />
|
||||
<InfoRow label={t("intlPayment.passportNumber", "Pasport nomeri")} value={data.passport_number} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 3: Kabul ediji resminamalar ──────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t('intlPayment.kabulDocsSection', 'Kabul ediji talyp boyunca resminamalar')}>
|
||||
<BentoCard title={t("intlPayment.kabulDocsSection", "Kabul ediji talyp boyunca resminamalar")}>
|
||||
{KABUL_DOCS.map((doc, i) => (
|
||||
<DocFileRow key={i} label={doc.label} url={doc.url} />
|
||||
))}
|
||||
@@ -222,7 +239,7 @@ export default function IntlPaymentViewPage() {
|
||||
|
||||
{/* ── Row 4: Upgradyý resminamalar ─────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t('intlPayment.upgradDocsSection', 'Upgradyý boyunca resminamalar')}>
|
||||
<BentoCard title={t("intlPayment.upgradDocsSection", "Upgradyý boyunca resminamalar")}>
|
||||
{UPGRAD_DOCS.map((doc, i) => (
|
||||
<DocFileRow key={i} label={doc.label} url={doc.url} />
|
||||
))}
|
||||
@@ -231,7 +248,7 @@ export default function IntlPaymentViewPage() {
|
||||
|
||||
{/* ── Row 5: Töleg taryhy ───────────────────────────────────────────── */}
|
||||
<BentoGrid cols={1}>
|
||||
<BentoCard title={t('intlPayment.paymentHistory', 'Töleg taryhy')}>
|
||||
<BentoCard title={t("intlPayment.paymentHistory", "Töleg taryhy")}>
|
||||
<div className="p-4">
|
||||
<div className="relative max-w-xs mb-4">
|
||||
<Search size={13} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" />
|
||||
@@ -239,7 +256,7 @@ export default function IntlPaymentViewPage() {
|
||||
type="text"
|
||||
value={historySearch}
|
||||
onChange={(e) => setHistorySearch(e.target.value)}
|
||||
placeholder={t('intlPayment.search', 'Gözlemek')}
|
||||
placeholder={t("intlPayment.search", "Gözlemek")}
|
||||
className="h-9 w-full pl-9 pr-3 rounded-md border border-border bg-background text-sm focus:outline-none focus:ring-2 focus:ring-ring"
|
||||
/>
|
||||
</div>
|
||||
@@ -252,7 +269,7 @@ export default function IntlPaymentViewPage() {
|
||||
<line x1="9" y1="9" x2="9" y2="21" />
|
||||
</svg>
|
||||
</div>
|
||||
<p className="text-sm">{t('intlPayment.noHistory', 'Beriilen kriteriýalara Töleg gabat gelmedi')}</p>
|
||||
<p className="text-sm">{t("intlPayment.noHistory", "Beriilen kriteriýalara Töleg gabat gelmedi")}</p>
|
||||
</div>
|
||||
</div>
|
||||
</BentoCard>
|
||||
@@ -261,12 +278,12 @@ export default function IntlPaymentViewPage() {
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}
|
||||
description={`${t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} ${data?.id}`}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
title={t("intlPayment.deleteTitle", "Pozmak isleýärsiňizmi?")}
|
||||
description={`${t("intlPayment.deleteDesc", "Bu amal yzyna dolanyp bolmaz.")} ${data?.id}`}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={isDeleting}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2,50 +2,37 @@ import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import {
|
||||
useLoanOrderMobileById,
|
||||
useDeleteLoanOrderMobile,
|
||||
} from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import { useLoanOrderMobileById, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
BentoGrid,
|
||||
BentoCard,
|
||||
InfoRow,
|
||||
PassportImage,
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
}
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
}
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const { t } = useTranslation()
|
||||
const variant = STATUS_VARIANT[status]
|
||||
const Icon = STATUS_ICON[status]
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -65,57 +52,52 @@ function LoanOrderMobilesViewSkeleton() {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function LoanOrderMobilesViewPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const deleteMutation = useDeleteLoanOrderMobile()
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanOrderMobile();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: order, isLoading } = useLoanOrderMobileById(id!)
|
||||
const { data: order, isLoading } = useLoanOrderMobileById(id!);
|
||||
|
||||
const handleDelete = () => {
|
||||
setShowDeleteDialog(true)
|
||||
}
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => navigate("/loan-order-mobiles"),
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanOrderMobilesViewSkeleton />
|
||||
if (isLoading) return <LoanOrderMobilesViewSkeleton />;
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</div>
|
||||
)
|
||||
return <div className="flex items-center justify-center h-64 text-muted-foreground text-sm">{t("common.notFound", "Tapylmady")}</div>;
|
||||
}
|
||||
|
||||
const auditLogs: AuditRowProps[] = [
|
||||
{
|
||||
id: "44548",
|
||||
id: "44548",
|
||||
action: t("audit.actions.view", "Görmek"),
|
||||
by: order.createdBy ?? "",
|
||||
by: order.createdBy ?? "",
|
||||
target: `${t("loanOrderMobiles.title", "Karz sargyt")}: ${order.id}`,
|
||||
status: "FINISHED",
|
||||
date: order.createdAt ?? "",
|
||||
date: order.createdAt ?? "",
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
const hasCard = !!(order.cardNumber || order.cardName)
|
||||
const hasGuarantor = !!(order.guarantor1Name || order.guarantor1CardNumber)
|
||||
const hasCard = !!(order.cardNumber || order.cardName);
|
||||
const hasGuarantor = !!(order.guarantor1Name || order.guarantor1CardNumber);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
|
||||
{/* ── Page header ──────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
@@ -144,24 +126,13 @@ export default function LoanOrderMobilesViewPage() {
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.status", "Status")}
|
||||
>
|
||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||
value={order.createdAt}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||
value={order.branch}
|
||||
isLink
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.note", "Bellik")}
|
||||
value={order.note || undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={order.createdAt} />
|
||||
|
||||
<InfoRow label={t("loanOrders.fields.note", "Bellik")} value={order.note || undefined} />
|
||||
<InfoRow label={t("loanOrders.columns.createdBy", "Döreden")} value={order.createdBy} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("loanOrders.sections.loan", "Karz")}>
|
||||
@@ -169,6 +140,7 @@ export default function LoanOrderMobilesViewPage() {
|
||||
label={t("loanOrders.columns.loanType", "Karz görnüşi")}
|
||||
value={order.loanType}
|
||||
isLink
|
||||
href={order.loanTypeId ? `/settings/loan/loan-types/${order.loanTypeId}` : "/settings/loan/loan-types"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.loanAmount", "Karz möçberi")}
|
||||
@@ -177,9 +149,12 @@ export default function LoanOrderMobilesViewPage() {
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("loanOrders.sections.location", "Lokasiýa")}>
|
||||
<InfoRow label={t("loanOrders.columns.region", "Welaýat")} value={order.region} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.region", "Welaýat")}
|
||||
value={order.region}
|
||||
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||
value={order.branch}
|
||||
isLink
|
||||
href={order.branchId ? `/settings/location/branches/${order.branchId}` : "/settings/location/branches"}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
@@ -197,14 +172,8 @@ export default function LoanOrderMobilesViewPage() {
|
||||
variant="primary"
|
||||
/>
|
||||
</div>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.cardNumber", "Kart belgisi")}
|
||||
value={order.cardNumber}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.cardName", "Kartdaky ady")}
|
||||
value={order.cardName}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.cardNumber", "Kart belgisi")} value={order.cardNumber} />
|
||||
<InfoRow label={t("loanOrders.fields.cardName", "Kartdaky ady")} value={order.cardName} />
|
||||
</BentoCard>
|
||||
|
||||
{/* Guarantor card — shown side-by-side with main card when both exist */}
|
||||
@@ -245,110 +214,50 @@ export default function LoanOrderMobilesViewPage() {
|
||||
label={t("loanOrders.fields.fullName", "Doly ady")}
|
||||
value={`${order.firstName} ${order.lastName} ${order.patronicName || ""}`.trim()}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.education", "Bilimi")}
|
||||
value={order.education ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")}
|
||||
value={order.marriageStatus ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.birthDate", "Doglan güni")}
|
||||
value={order.dateOfBirth ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")}
|
||||
value={order.residence ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")}
|
||||
value={order.currentResidence ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.loanHistory", "Karz taryhy")}
|
||||
value={order.loanHistory ?? undefined}
|
||||
isLink
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.education", "Bilimi")} value={order.education ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")} value={order.marriageStatus ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.birthDate", "Doglan güni")} value={order.dateOfBirth ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")} value={order.residence ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")} value={order.currentResidence ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.loanHistory", "Karz taryhy")} value={order.loanHistory ?? undefined} isLink />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("loanOrders.sections.contacts", "Habarlaşmak")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.email", "E-poçta")}
|
||||
value={order.email ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.phone", "Telefon")}
|
||||
value={order.phone}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")}
|
||||
value={order.phoneAdditional ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.homePhone", "Öý telefony")}
|
||||
value={order.homePhone ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.email", "E-poçta")} value={order.email ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.columns.phone", "Telefon")} value={order.phone} />
|
||||
<InfoRow label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")} value={order.phoneAdditional ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.homePhone", "Öý telefony")} value={order.homePhone ?? undefined} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 4: Employment + Passport info ───────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrders.sections.employment", "Iş")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.employer", "Kärhananyň ady")}
|
||||
value={order.workCompany ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.deptPhone", "Işgärler bölüminiň belgisi")}
|
||||
value={order.workHrPhone ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.workRegion", "Işleýän welaýaty")}
|
||||
value={order.workRegion ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.employer", "Kärhananyň ady")} value={order.workCompany ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.deptPhone", "Işgärler bölüminiň belgisi")} value={order.workHrPhone ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.workRegion", "Işleýän welaýaty")} value={order.workRegion ?? undefined} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.workCity", "Işleýän etraby")}
|
||||
value={order.workProvince ?? undefined}
|
||||
isLink
|
||||
href={order.workCityId ? `/settings/location/districts/${order.workCityId}` : "/settings/location/districts"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.position", "Wezipe")}
|
||||
value={order.position ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.salary", "Zähmet haky")}
|
||||
value={order.salary ? String(order.salary) : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.employedSince", "Işe başlan wagty")}
|
||||
value={order.workStartedAt ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.position", "Wezipe")} value={order.position ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.salary", "Zähmet haky")} value={order.salary ? String(order.salary) : undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.employedSince", "Işe başlan wagty")} value={order.workStartedAt ?? undefined} />
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.passportNumber", "Pasport")}
|
||||
value={order.passportNumber ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")}
|
||||
value={order.passportGivenBy ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")}
|
||||
value={order.bornPlace ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport")} value={order.passportNumber ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportGivenBy ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")} value={order.bornPlace ?? undefined} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
{/* ── Row 5: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")}
|
||||
src={order.passportPage1Url ?? undefined}
|
||||
/>
|
||||
<PassportImage label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")} src={order.passportPage1Url ?? undefined} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage23", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
@@ -357,10 +266,7 @@ export default function LoanOrderMobilesViewPage() {
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage89", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t("loanOrders.fields.passportPage89", "Pasport (8-9 sahypa)")}
|
||||
src={order.passportPage89Url ?? undefined}
|
||||
/>
|
||||
<PassportImage label={t("loanOrders.fields.passportPage89", "Pasport (8-9 sahypa)")} src={order.passportPage89Url ?? undefined} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage32", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
@@ -413,5 +319,5 @@ export default function LoanOrderMobilesViewPage() {
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2,60 +2,36 @@ import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import {
|
||||
useLoanOrderById,
|
||||
useDeleteLoanOrder,
|
||||
} from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { useLoanOrderById, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
} from "@/components/ui/statusBadge";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import {
|
||||
BentoGrid,
|
||||
BentoCard,
|
||||
InfoRow,
|
||||
PassportImage,
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
const STATUS_VARIANT: Record<LoanOrderStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
const STATUS_ICON: Record<LoanOrderStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({
|
||||
status,
|
||||
}: {
|
||||
status: LoanOrderMobileStatus;
|
||||
}) {
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant)
|
||||
return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return (
|
||||
<StatusBadge
|
||||
label={t(`loanOrderStatus.${status}`)}
|
||||
variant={variant}
|
||||
icon={Icon}
|
||||
/>
|
||||
);
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
@@ -66,10 +42,7 @@ function LoanOrderViewSkeleton() {
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
{[...Array(6)].map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3"
|
||||
>
|
||||
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
<Skeleton className="h-3 w-24 mb-1" />
|
||||
{[...Array(3)].map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
@@ -105,11 +78,7 @@ export default function LoanOrderViewPage() {
|
||||
if (isLoading) return <LoanOrderViewSkeleton />;
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</div>
|
||||
);
|
||||
return <div className="flex items-center justify-center h-64 text-muted-foreground text-sm">{t("common.notFound", "Tapylmady")}</div>;
|
||||
}
|
||||
|
||||
const auditLogs: AuditRowProps[] = [
|
||||
@@ -154,21 +123,16 @@ export default function LoanOrderViewPage() {
|
||||
{/* Meta */}
|
||||
<BentoCard title={t("loanOrders.sections.meta", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={order.id} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.createdAt", "Döredilen wagty")}
|
||||
value={order.createdAt}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.columns.createdAt", "Döredilen wagty")} value={order.createdAt} />
|
||||
<InfoRow label={t("loanOrders.columns.status", "Status")}>
|
||||
<LoanOrderMobileStatusBadge status={order.status} />
|
||||
</InfoRow>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.amount", "Berlik")}
|
||||
value={order.amount ? String(order.amount) : undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.amount", "Berlik")} value={order.amount ? String(order.amount) : undefined} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.createdBy", "Sargyt eden")}
|
||||
value={order.createdBy ?? undefined}
|
||||
isLink
|
||||
href={order.createdById ? `/all-users/${order.createdById}` : "/all-users"}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
@@ -178,6 +142,7 @@ export default function LoanOrderViewPage() {
|
||||
label={t("loanOrders.columns.loanType", "Karz görnüşi")}
|
||||
value={order.loanType}
|
||||
isLink
|
||||
href={order.loanTypeId ? `/settings/loan/loan-types/${order.loanTypeId}` : "/settings/loan/loan-types"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.loanAmount", "Karz mukdary")}
|
||||
@@ -187,14 +152,12 @@ export default function LoanOrderViewPage() {
|
||||
|
||||
{/* Location */}
|
||||
<BentoCard title={t("loanOrders.sections.location", "Lokasiýa")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.region", "Welaýat")}
|
||||
value={order.region}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.columns.region", "Welaýat")} value={order.region} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.branch", "Şahamça")}
|
||||
value={order.branch}
|
||||
isLink
|
||||
href={order.branchId ? `/settings/location/branches/${order.branchId}` : "/settings/location/branches"}
|
||||
/>
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
@@ -202,59 +165,21 @@ export default function LoanOrderViewPage() {
|
||||
{/* ── Row 2: Personal + Contacts ──────────────────────────────────── */}
|
||||
<BentoGrid cols={2}>
|
||||
{/* Personal */}
|
||||
<BentoCard
|
||||
title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}
|
||||
>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.fullName", "Doly ady")}
|
||||
value={order.fullName ?? `${order.firstName} ${order.lastName}`}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.education", "Bilimi")}
|
||||
value={order.education ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")}
|
||||
value={order.maritalStatus ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.birthDate", "Doglan güni")}
|
||||
value={order.birthDate ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.registeredAddress",
|
||||
"Ýazgy edilen salgy",
|
||||
)}
|
||||
value={order.registeredAddress ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.currentAddress",
|
||||
"Häzirki ýaşaýyş ýeri",
|
||||
)}
|
||||
value={order.currentAddress ?? undefined}
|
||||
/>
|
||||
<BentoCard title={t("loanOrders.sections.personal", "Şahsy maglumatlar")}>
|
||||
<InfoRow label={t("loanOrders.fields.fullName", "Doly ady")} value={order.fullName ?? `${order.firstName} ${order.lastName}`} />
|
||||
<InfoRow label={t("loanOrders.fields.education", "Bilimi")} value={order.education ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.maritalStatus", "Maşgala ýagdaýy")} value={order.maritalStatus ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.birthDate", "Doglan güni")} value={order.birthDate ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.registeredAddress", "Ýazgy edilen salgy")} value={order.registeredAddress ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.currentAddress", "Häzirki ýaşaýyş ýeri")} value={order.currentAddress ?? undefined} />
|
||||
</BentoCard>
|
||||
|
||||
{/* Contacts */}
|
||||
<BentoCard title={t("loanOrders.sections.contacts", "Habarlaşmak")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.email", "E-poçta")}
|
||||
value={order.email ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.columns.phone", "Telefon")}
|
||||
value={order.phone}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")}
|
||||
value={order.phoneAlt ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.homePhone", "Öý telefony")}
|
||||
value={order.homePhone ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.email", "E-poçta")} value={order.email ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.columns.phone", "Telefon")} value={order.phone} />
|
||||
<InfoRow label={t("loanOrders.fields.phoneAlt", "Telefon goşmaça")} value={order.phoneAlt ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.homePhone", "Öý telefony")} value={order.homePhone ?? undefined} />
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
@@ -262,58 +187,26 @@ export default function LoanOrderViewPage() {
|
||||
<BentoGrid cols={2}>
|
||||
{/* Employment */}
|
||||
<BentoCard title={t("loanOrders.sections.employment", "Iş")}>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.employer", "Kärhananyň ady")}
|
||||
value={order.employer ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.deptPhone",
|
||||
"Işgärler bölüminiň belgisi",
|
||||
)}
|
||||
value={order.deptPhone ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.workRegion", "Işleýän welaýaty")}
|
||||
value={order.workRegion ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.employer", "Kärhananyň ady")} value={order.employer ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.deptPhone", "Işgärler bölüminiň belgisi")} value={order.deptPhone ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.workRegion", "Işleýän welaýaty")} value={order.workRegion ?? undefined} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.workCity", "Işleýän etraby")}
|
||||
value={order.workCity ?? undefined}
|
||||
isLink
|
||||
href={order.workCityId ? `/settings/location/districts/${order.workCityId}` : "/settings/location/districts"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.position", "Wezipe")}
|
||||
value={order.position ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.salary", "Zähmet haky")}
|
||||
value={order.salary ? String(order.salary) : undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.employedSince", "Işe başlan wagty")}
|
||||
value={order.employedSince ?? undefined}
|
||||
/>
|
||||
<InfoRow label={t("loanOrders.fields.position", "Wezipe")} value={order.position ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.salary", "Zähmet haky")} value={order.salary ? String(order.salary) : undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.employedSince", "Işe başlan wagty")} value={order.employedSince ?? undefined} />
|
||||
</BentoCard>
|
||||
|
||||
{/* Passport info */}
|
||||
<BentoCard title={t("loanOrders.sections.passport", "Pasport")}>
|
||||
<InfoRow label={t("loanOrders.fields.passportNumber", "Pasport")} value={order.passportNumber ?? undefined} />
|
||||
<InfoRow label={t("loanOrders.fields.passportIssuedBy", "Kim tarapyndan berildi")} value={order.passportIssuedBy ?? undefined} />
|
||||
<InfoRow
|
||||
label={t("loanOrders.fields.passportNumber", "Pasport")}
|
||||
value={order.passportNumber ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.passportIssuedBy",
|
||||
"Kim tarapyndan berildi",
|
||||
)}
|
||||
value={order.passportIssuedBy ?? undefined}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"loanOrders.fields.passportBirthPlace",
|
||||
"Doglan ýeri (pasport)",
|
||||
)}
|
||||
label={t("loanOrders.fields.passportBirthPlace", "Doglan ýeri (pasport)")}
|
||||
value={order.passportBirthPlace ?? undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -322,35 +215,20 @@ export default function LoanOrderViewPage() {
|
||||
{/* ── Row 4: Passport images ───────────────────────────────────────── */}
|
||||
<BentoGrid cols={4}>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage1", "Sahypa 1")}>
|
||||
<PassportImage
|
||||
label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")}
|
||||
src={order.passportPage1Url ?? undefined}
|
||||
/>
|
||||
<PassportImage label={t("loanOrders.fields.passportPage1", "Pasport (sahypa 1)")} src={order.passportPage1Url ?? undefined} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage23", "Sahypa 2-3")}>
|
||||
<PassportImage
|
||||
label={t(
|
||||
"loanOrders.fields.passportPage23",
|
||||
"Pasport (2-3-nji sahypa)",
|
||||
)}
|
||||
label={t("loanOrders.fields.passportPage23", "Pasport (2-3-nji sahypa)")}
|
||||
src={order.passportPage23Url ?? undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage89", "Sahypa 8-9")}>
|
||||
<PassportImage
|
||||
label={t(
|
||||
"loanOrders.fields.passportPage89",
|
||||
"Pasport (8-9 sahypa)",
|
||||
)}
|
||||
src={order.passportPage89Url ?? undefined}
|
||||
/>
|
||||
<PassportImage label={t("loanOrders.fields.passportPage89", "Pasport (8-9 sahypa)")} src={order.passportPage89Url ?? undefined} />
|
||||
</BentoCard>
|
||||
<BentoCard title={t("loanOrders.fields.passportPage32", "Sahypa 32")}>
|
||||
<PassportImage
|
||||
label={t(
|
||||
"loanOrders.fields.passportPage32",
|
||||
"Pasport (32-nji sahypa)",
|
||||
)}
|
||||
label={t("loanOrders.fields.passportPage32", "Pasport (32-nji sahypa)")}
|
||||
src={order.passportPage32Url ?? undefined}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// pages/OnlinePaymentDetailPage.tsx
|
||||
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Section, InfoRow } from "@/components/viewPageComponents";
|
||||
import { useGetOnlinePaymentById } from "@/features/onlinePaymentHistory/hooks/useOnlinePaymentsHistory";
|
||||
@@ -30,9 +30,7 @@ export default function OnlinePaymentDetailPage() {
|
||||
if (!payment) {
|
||||
return (
|
||||
<div className="p-6">
|
||||
<p className="text-muted-foreground">
|
||||
{t("onlinePayments.notFound", "Töleg tapylmady")}
|
||||
</p>
|
||||
<p className="text-muted-foreground">{t("onlinePayments.notFound", "Töleg tapylmady")}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -43,76 +41,35 @@ export default function OnlinePaymentDetailPage() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-xl font-semibold text-foreground mb-6 break-all">
|
||||
{title}
|
||||
</h1>
|
||||
<h1 className="text-xl font-semibold text-foreground mb-6 break-all">{title}</h1>
|
||||
|
||||
{/* Detail Card */}
|
||||
<Section>
|
||||
<InfoRow label={t("common.id", "ID")} value={payment.id} />
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.amount", "amount")}
|
||||
value={payment.amount}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.orderNumber", "orderNumber")}
|
||||
value={payment.orderNumber}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.apiClient", "Api Client")}
|
||||
value={payment.apiClient}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.description", "description")}
|
||||
value={payment.description}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.orderId", "orderId")}
|
||||
value={payment.orderId}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.formUrl", "formUrl")}
|
||||
isLink
|
||||
value={payment.formUrl}
|
||||
/>
|
||||
<InfoRow label={t("onlinePayments.fields.amount", "amount")} value={payment.amount} />
|
||||
<InfoRow label={t("onlinePayments.fields.orderNumber", "orderNumber")} value={payment.orderNumber} />
|
||||
<InfoRow label={t("onlinePayments.fields.apiClient", "Api Client")} value={payment.apiClient} />
|
||||
<InfoRow label={t("onlinePayments.fields.description", "description")} value={payment.description} />
|
||||
<InfoRow label={t("onlinePayments.fields.orderId", "orderId")} value={payment.orderId} />
|
||||
<InfoRow label={t("onlinePayments.fields.formUrl", "formUrl")} isLink href={payment.formUrl ?? undefined} value={payment.formUrl} />
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.successUrl", "successUrl")}
|
||||
isLink
|
||||
href={payment.successUrl ?? undefined}
|
||||
value={payment.successUrl}
|
||||
/>
|
||||
<InfoRow label={t("onlinePayments.fields.status", "Status")}>
|
||||
<PaymentStatusBadge status={payment.status} />
|
||||
</InfoRow>
|
||||
<InfoRow label={t("onlinePayments.fields.callbackStatus", "callbackStatus")} value={payment.callbackStatus ?? "—"} />
|
||||
<InfoRow label={t("onlinePayments.fields.username", "username")} value={payment.username} />
|
||||
<InfoRow label={t("onlinePayments.fields.onlinePaymantableId", "online_paymantable_id")} value={payment.onlinePaymantableId} />
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.callbackStatus", "callbackStatus")}
|
||||
value={payment.callbackStatus ?? "—"}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.username", "username")}
|
||||
value={payment.username}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"onlinePayments.fields.onlinePaymantableId",
|
||||
"online_paymantable_id",
|
||||
)}
|
||||
value={payment.onlinePaymantableId}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t(
|
||||
"onlinePayments.fields.onlinePaymantableType",
|
||||
"online_paymantable_type",
|
||||
)}
|
||||
label={t("onlinePayments.fields.onlinePaymantableType", "online_paymantable_type")}
|
||||
value={payment.onlinePaymantableType}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.createdAt", "Döredilen wagty")}
|
||||
value={formatDateTime(payment.createdAt)}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("onlinePayments.fields.updatedAt", "Updated at")}
|
||||
value={formatDateTime(payment.updatedAt)}
|
||||
/>
|
||||
<InfoRow label={t("onlinePayments.fields.createdAt", "Döredilen wagty")} value={formatDateTime(payment.createdAt)} />
|
||||
<InfoRow label={t("onlinePayments.fields.updatedAt", "Updated at")} value={formatDateTime(payment.updatedAt)} />
|
||||
</Section>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Pencil, CheckCircle2, Eye, Trash2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Section, InfoRow, CollapsibleSection, EmptyState, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { useAuthStore } from "@/app/store/authStore";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
interface RoleRow {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
guardName: string;
|
||||
}
|
||||
|
||||
// ─── Mock Data ────────────────────────────────────────────────────────────────
|
||||
|
||||
const MOCK_ROLES: RoleRow[] = [{ id: 2, code: "superadmin", name: "Superadmin", guardName: "web" }];
|
||||
|
||||
const MOCK_AUDIT: AuditRowProps[] = [
|
||||
{
|
||||
id: "9043",
|
||||
action: "Üýtgetmek",
|
||||
by: "Nurmuhammet Allanov",
|
||||
target: "Ulanyç: Nurmuhammet Allanov (nurmuhammet)",
|
||||
status: "success",
|
||||
date: "2026-06-04 10:23",
|
||||
},
|
||||
{
|
||||
id: "5869",
|
||||
action: "Üýtgetmek",
|
||||
by: "Nurmuhammet Allanov",
|
||||
target: "Ulanyç: Nurmuhammet Allanov (nurmuhammet)",
|
||||
status: "success",
|
||||
date: "2026-06-03 14:11",
|
||||
},
|
||||
];
|
||||
|
||||
// ─── ProfilePage ──────────────────────────────────────────────────────────────
|
||||
|
||||
export default function ProfilePage() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const user = useAuthStore((s) => s.user);
|
||||
|
||||
const [roleSearch, setRoleSearch] = useState("");
|
||||
const [permSearch, setPermSearch] = useState("");
|
||||
const [branchSearch, setBranchSearch] = useState("");
|
||||
const [roleColVisibility, setRoleColVisibility] = useState({});
|
||||
const [roleColOrder, setRoleColOrder] = useState<string[]>([]);
|
||||
|
||||
// ── Role table columns (ColumnDef for DataTable) ───────────────────────────
|
||||
|
||||
const roleColumns: ColumnDef<RoleRow>[] = useMemo(
|
||||
() => [
|
||||
{
|
||||
accessorKey: "id",
|
||||
header: t("common.id", "ID"),
|
||||
cell: ({ row }) => <span className="text-sm font-semibold text-primary">{row.original.id}</span>,
|
||||
size: 60,
|
||||
},
|
||||
{
|
||||
accessorKey: "code",
|
||||
header: t("roles.fields.code", "KOD"),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.code}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "name",
|
||||
header: t("roles.fields.name", "ADY"),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.name}</span>,
|
||||
},
|
||||
{
|
||||
accessorKey: "guardName",
|
||||
header: t("roles.fields.guardName", "GUARD NAME"),
|
||||
cell: ({ row }) => <span className="text-sm text-foreground">{row.original.guardName}</span>,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
header: "",
|
||||
enableHiding: false,
|
||||
size: 90,
|
||||
cell: () => (
|
||||
<div className="flex items-center justify-end gap-0.5">
|
||||
<button className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors">
|
||||
<Eye size={14} />
|
||||
</button>
|
||||
<button className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors">
|
||||
<Pencil size={14} />
|
||||
</button>
|
||||
<button className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-destructive/70 hover:text-destructive transition-colors">
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
// ── ColumnMeta for DataTableToolbar ───────────────────────────────────────
|
||||
|
||||
const roleColumnMeta: ColumnMeta[] = useMemo(
|
||||
() => [
|
||||
{ id: "id", label: t("common.id", "ID") },
|
||||
{ id: "code", label: t("roles.fields.code", "KOD") },
|
||||
{ id: "name", label: t("roles.fields.name", "ADY") },
|
||||
{ id: "guardName", label: t("roles.fields.guardName", "GUARD NAME") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
// ── Filtered roles ────────────────────────────────────────────────────────
|
||||
|
||||
const filteredRoles = useMemo(() => {
|
||||
const q = roleSearch.toLowerCase().trim();
|
||||
if (!q) return MOCK_ROLES;
|
||||
return MOCK_ROLES.filter(
|
||||
(r) => r.code.toLowerCase().includes(q) || r.name.toLowerCase().includes(q) || r.guardName.toLowerCase().includes(q),
|
||||
);
|
||||
}, [roleSearch]);
|
||||
|
||||
// ── Loading skeleton ──────────────────────────────────────────────────────
|
||||
|
||||
if (!user) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* ── Title + actions ──────────────────────────────────────────────── */}
|
||||
<div className="flex items-start justify-between">
|
||||
<h1 className="text-xl font-bold text-foreground leading-tight">
|
||||
{t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2 shrink-0 ml-4">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
onClick={() => navigate("/profile/edit")}
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Main info ────────────────────────────────────────────────────── */}
|
||||
<Section>
|
||||
<InfoRow label={t("common.id", "ID")} value={user.id} />
|
||||
<InfoRow label={t("users.fields.username", "Ulanyjy ady")} value={user.name} />
|
||||
<InfoRow label={t("users.fields.name", "Ady")} value={user.name} />
|
||||
<InfoRow label={t("users.fields.phone", "Telefon")} value={null} />
|
||||
<InfoRow label={t("users.fields.email", "E-poçta")} value={user.email} />
|
||||
<InfoRow label={t("users.fields.isActive", "İşjeň")}>
|
||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||
</InfoRow>
|
||||
</Section>
|
||||
|
||||
{/* ── Rollar ───────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection title={t("users.sections.roles", "Rollar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={roleSearch}
|
||||
onSearchChange={setRoleSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={roleColumnMeta}
|
||||
columnVisibility={roleColVisibility}
|
||||
onColumnVisibilityChange={setRoleColVisibility}
|
||||
columnOrder={roleColOrder}
|
||||
onColumnOrderChange={setRoleColOrder}
|
||||
actionLabel={t("users.actions.addRole", "Rol birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<DataTable
|
||||
columns={roleColumns}
|
||||
data={filteredRoles}
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={1}
|
||||
totalPages={1}
|
||||
totalCount={filteredRoles.length}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Rugsatlar ────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection title={t("users.sections.permissions", "Rugsatlar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={permSearch}
|
||||
onSearchChange={setPermSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("users.actions.addPermission", "Rugsat birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t("users.empty.permissions", "Berlen kriteriýalara Rugsat gabat gelmedi.")} />
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Şahamçalar ───────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection title={t("users.sections.branches", "Şahamçalar")}>
|
||||
<DataTableToolbar
|
||||
searchValue={branchSearch}
|
||||
onSearchChange={setBranchSearch}
|
||||
searchPlaceholder={t("common.search", "Gözlemek")}
|
||||
columns={[]}
|
||||
columnVisibility={{}}
|
||||
onColumnVisibilityChange={() => {}}
|
||||
columnOrder={[]}
|
||||
onColumnOrderChange={() => {}}
|
||||
actionLabel={t("users.actions.addBranch", "Şahamça birikdiriň")}
|
||||
onAction={() => {}}
|
||||
/>
|
||||
<EmptyState label={t("users.empty.branches", "Berlen kriteriýalara Şahamça gabat gelmedi.")} />
|
||||
</CollapsibleSection>
|
||||
|
||||
{/* ── Ammallar ─────────────────────────────────────────────────────── */}
|
||||
<CollapsibleSection title={t("users.sections.audit", "Ammallar")}>
|
||||
<AuditLog logs={MOCK_AUDIT} currentPage={1} totalPages={1} totalCount={MOCK_AUDIT.length} />
|
||||
</CollapsibleSection>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user