added new pages

This commit is contained in:
@jcarymuhammedow
2026-05-04 19:06:18 +05:00
parent f834f29e53
commit 648ce5a172
35 changed files with 2857 additions and 177 deletions

96
package-lock.json generated
View File

@@ -14,11 +14,13 @@
"axios": "^1.15.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"i18next": "^26.0.8",
"lucide-react": "^1.14.0",
"next-themes": "^0.4.6",
"radix-ui": "^1.4.3",
"react": "^19.2.5",
"react-day-picker": "^9.14.0",
"react-dom": "^19.2.5",
"react-i18next": "^17.0.6",
"react-router-dom": "^7.14.2",
@@ -90,7 +92,6 @@
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz",
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.29.0",
"@babel/generator": "^7.29.0",
@@ -477,6 +478,12 @@
"node": ">=6.9.0"
}
},
"node_modules/@date-fns/tz": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/@date-fns/tz/-/tz-1.4.1.tgz",
"integrity": "sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA==",
"license": "MIT"
},
"node_modules/@dotenvx/dotenvx": {
"version": "1.64.0",
"resolved": "https://registry.npmjs.org/@dotenvx/dotenvx/-/dotenvx-1.64.0.tgz",
@@ -646,6 +653,29 @@
"@noble/ciphers": "^1.0.0"
}
},
"node_modules/@emnapi/core": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
"integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"@emnapi/wasi-threads": "1.2.1",
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
"integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@emnapi/wasi-threads": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
@@ -1146,7 +1176,6 @@
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz",
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
"license": "MIT",
"peer": true,
"engines": {
"node": "^14.21.3 || >=16"
},
@@ -3028,6 +3057,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@tabby_ai/hijri-converter": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@tabby_ai/hijri-converter/-/hijri-converter-1.0.5.tgz",
"integrity": "sha512-r5bClKrcIusDoo049dSL8CawnHR6mRdDwhlQuIgZRNty68q0x8k3Lf1BtPAMxRf/GgnHBnIO4ujd3+GQdLWzxQ==",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
},
"node_modules/@tailwindcss/node": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.2.4.tgz",
@@ -3406,7 +3444,6 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.2.tgz",
"integrity": "sha512-A1sre26ke7HDIuY/M23nd9gfB+nrmhtYyMINbjI1zHJxYteKR6qSMX56FsmjMcDb3SMcjJg5BiRRgOCC/yBD0g==",
"license": "MIT",
"peer": true,
"dependencies": {
"undici-types": "~7.16.0"
}
@@ -3417,7 +3454,6 @@
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
"devOptional": true,
"license": "MIT",
"peer": true,
"dependencies": {
"csstype": "^3.2.2"
}
@@ -3428,7 +3464,6 @@
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
"devOptional": true,
"license": "MIT",
"peer": true,
"peerDependencies": {
"@types/react": "^19.2.0"
}
@@ -3499,7 +3534,6 @@
"integrity": "sha512-HDQH9O/47Dxi1ceDhBXdaldtf/WV9yRYMjbjCuNk3qnaTD564qwv61Y7+gTxwxRKzSrgO5uhtw584igXVuuZkA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "8.59.1",
"@typescript-eslint/types": "8.59.1",
@@ -3743,7 +3777,6 @@
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -4025,7 +4058,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.10.12",
"caniuse-lite": "^1.0.30001782",
@@ -4422,6 +4454,22 @@
"node": ">= 12"
}
},
"node_modules/date-fns": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
"integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/date-fns-jalali": {
"version": "4.1.0-0",
"resolved": "https://registry.npmjs.org/date-fns-jalali/-/date-fns-jalali-4.1.0-0.tgz",
"integrity": "sha512-hTIP/z+t+qKwBDcmmsnmjWTduxCg+5KfdqWQvb2X/8C9+knYY6epN/pfxdDuyVlSVeFz0sM5eEfwIUQ70U4ckg==",
"license": "MIT"
},
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
@@ -4733,7 +4781,6 @@
"integrity": "sha512-XbEXaRva5cF0ZQB8w6MluHA0kZZfV2DuCMJ3ozyEOHLwDpZX2Lmm/7Pp0xdJmI0GL1W05VH5VwIFHEm1Vcw2gw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.2",
@@ -4984,7 +5031,6 @@
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
"license": "MIT",
"peer": true,
"dependencies": {
"accepts": "^2.0.0",
"body-parser": "^2.2.1",
@@ -5650,7 +5696,6 @@
"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.16.tgz",
"integrity": "sha512-jN0ZewiNAWSe5khM3EyCmBb250+b40wWbwNILNfEvq84VREWwOIkuUsFONk/3i3nqkz7Oe1PcpM2mwQEK2L9Kg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=16.9.0"
}
@@ -5725,7 +5770,6 @@
}
],
"license": "MIT",
"peer": true,
"peerDependencies": {
"typescript": "^5 || ^6"
},
@@ -7104,7 +7148,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
@@ -7366,17 +7409,37 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.2.5.tgz",
"integrity": "sha512-llUJLzz1zTUBrskt2pwZgLq59AemifIftw4aB7JxOqf1HY2FDaGDxgwpAPVzHU1kdWabH7FauP4i1oEeer2WCA==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/react-day-picker": {
"version": "9.14.0",
"resolved": "https://registry.npmjs.org/react-day-picker/-/react-day-picker-9.14.0.tgz",
"integrity": "sha512-tBaoDWjPwe0M5pGrum4H0SR6Lyk+BO9oHnp9JbKpGKW2mlraNPgP9BMfsg5pWpwrssARmeqk7YBl2oXutZTaHA==",
"license": "MIT",
"dependencies": {
"@date-fns/tz": "^1.4.1",
"@tabby_ai/hijri-converter": "1.0.5",
"date-fns": "^4.1.0",
"date-fns-jalali": "4.1.0-0"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "individual",
"url": "https://github.com/sponsors/gpbl"
},
"peerDependencies": {
"react": ">=16.8.0"
}
},
"node_modules/react-dom": {
"version": "19.2.5",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.5.tgz",
"integrity": "sha512-J5bAZz+DXMMwW/wV3xzKke59Af6CHY7G4uYLN1OvBcKEsWOs4pQExj86BBKamxl/Ik5bx9whOrvBlSDfWzgSag==",
"license": "MIT",
"peer": true,
"dependencies": {
"scheduler": "^0.27.0"
},
@@ -8302,7 +8365,6 @@
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
"devOptional": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -8515,7 +8577,6 @@
"integrity": "sha512-rZuUu9j6J5uotLDs+cAA4O5H4K1SfPliUlQwqa6YEwSrWDZzP4rhm00oJR5snMewjxF5V/K3D4kctsUTsIU9Mw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"lightningcss": "^1.32.0",
"picomatch": "^4.0.4",
@@ -8839,7 +8900,6 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-4.4.2.tgz",
"integrity": "sha512-IynmDyxsEsb9RKzO3J9+4SxXnl2FTFSzNBaKKaMV6tsSk0rw9gYw9gs+JFCq/qk2LCZ78KDwyj+Z289TijSkUw==",
"license": "MIT",
"peer": true,
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}

View File

@@ -16,11 +16,13 @@
"axios": "^1.15.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"i18next": "^26.0.8",
"lucide-react": "^1.14.0",
"next-themes": "^0.4.6",
"radix-ui": "^1.4.3",
"react": "^19.2.5",
"react-day-picker": "^9.14.0",
"react-dom": "^19.2.5",
"react-i18next": "^17.0.6",
"react-router-dom": "^7.14.2",

View File

@@ -4,13 +4,14 @@ import { useAuthStore } from "../store/authStore";
import { Spinner } from "@/components/ui/spinner";
import { DashboardLayout } from "@/layouts/DashboardLayout";
const LoginPage = lazy(() => import("@/pages/login"));
const DashboardPage = lazy(() => import("@/pages/dashboard"));
const LoanOrdersPage = lazy(() => import("@/pages/loanOrders"));
const LoanOrderMobilesPage = lazy(() => import("@/pages/loanOrderMobiles"));
const LoanRemainingPage = lazy(() => import("@/pages/loanRemaining"));
const LoanPaidOffLettersPage = lazy(() => import("@/pages/loanPaidOffLetters"));
const LoanOrderCreatePage = lazy(() => import("@/pages/loanOrderCreate"));
const LoanOrderViewPage = lazy(() => import("@/pages/loanOrderView"));
function AuthGuard() {
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
@@ -65,7 +66,7 @@ export const router = createBrowserRouter([
// ── KARZ BÖLÜMI ──────────────────────────────────────────────────
{
path: "/resources/loan-orders",
path: "/loan-orders",
element: (
<Suspense fallback={<PageLoader />}>
<LoanOrdersPage />
@@ -73,8 +74,24 @@ export const router = createBrowserRouter([
),
},
{
// Sidebar: /resources/loan-order-mobiles
path: "/resources/loan-order-mobiles",
path: "/loan-orders/:id",
element: (
<Suspense fallback={<PageLoader />}>
<LoanOrderViewPage />
</Suspense>
),
},
{
path: "/loan-orders/create",
element: (
<Suspense fallback={<PageLoader />}>
<LoanOrderCreatePage />
</Suspense>
),
},
{
// Sidebar: /loan-order-mobiles
path: "/loan-order-mobiles",
element: (
<Suspense fallback={<PageLoader />}>
<LoanOrderMobilesPage />
@@ -82,8 +99,8 @@ export const router = createBrowserRouter([
),
},
{
// Sidebar: /resources/loan-remaining
path: "/resources/loan-remaining",
// Sidebar: /loan-remaining
path: "/loan-remaining",
element: (
<Suspense fallback={<PageLoader />}>
<LoanRemainingPage />
@@ -91,8 +108,8 @@ export const router = createBrowserRouter([
),
},
{
// Sidebar: /resources/loan-paid-off-letters
path: "/resources/loan-paid-off-letters",
// Sidebar: /loan-paid-off-letters
path: "/loan-paid-off-letters",
element: (
<Suspense fallback={<PageLoader />}>
<LoanPaidOffLettersPage />

View File

@@ -10,7 +10,7 @@ interface I18nState {
export const useI18nStore = create<I18nState>()(
persist(
(set) => ({
language: (localStorage.getItem('tbbank-lang') as SupportedLanguage) ?? 'en',
language: i18n.language as SupportedLanguage,
setLanguage: (language) => {
i18n.changeLanguage(language)
set({ language })

View File

@@ -161,7 +161,7 @@ function SelectAllDropdown({
</button>
{open && (
<div className="absolute top-10 left-0 z-50 w-52 bg-card border border-border rounded-lg shadow-lg py-1">
<div className="absolute top-10 left-0 z-50 w-52 bg-card border border-border rounded-md shadow-lg py-1">
<button
onClick={() => {
onSelectPage(true)
@@ -370,7 +370,7 @@ export function DataTable<TData>({
<div
className={cn(
'border border-border overflow-hidden',
showBanner ? 'rounded-b-lg rounded-t-none' : 'rounded-lg'
showBanner ? 'rounded-b-lg rounded-t-none' : 'rounded-md'
)}
>
<Table>

View File

@@ -133,7 +133,7 @@ function ToggleColumnsDropdown({
<button
onClick={() => setOpen((v) => !v)}
className={cn(
'flex items-center gap-1.5 h-9 px-3 rounded-md border border-border',
'flex items-center gap-1.5 h-9 px-3 rounded-md border border-border cursor-pointer',
'text-sm text-muted-foreground bg-background',
'hover:bg-muted/50 hover:text-foreground transition-colors',
open && 'bg-muted/50 text-foreground border-ring'
@@ -144,7 +144,7 @@ function ToggleColumnsDropdown({
</button>
{open && (
<div className="absolute right-0 mt-1.5 w-52 bg-card border border-border rounded-lg shadow-lg z-50 py-2">
<div className="absolute right-0 mt-1.5 w-52 bg-card border border-border rounded-md shadow-lg z-50 py-2">
<p className="px-3 pb-1.5 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">
{t('table.toggleColumns', 'Toggle Columns')}
</p>
@@ -193,7 +193,7 @@ function DateFilterButton() {
return (
<button
className={cn(
'flex items-center h-9 px-3 rounded-md border border-border',
'flex items-center h-9 px-3 rounded-md border border-border cursor-pointer',
'text-muted-foreground bg-background',
'hover:bg-muted/50 hover:text-foreground transition-colors'
)}
@@ -240,7 +240,7 @@ function FilterDropdown({
<button
onClick={() => setOpen((v) => !v)}
className={cn(
'flex items-center gap-1.5 h-9 px-3 rounded-md border border-border',
'flex items-center gap-1.5 h-9 px-3 rounded-md border border-border cursor-pointer',
'text-muted-foreground bg-background',
'hover:bg-muted/50 hover:text-foreground transition-colors',
open && 'bg-muted/50 text-foreground border-ring',
@@ -258,7 +258,7 @@ function FilterDropdown({
</button>
{open && (
<div className="absolute right-0 mt-1.5 w-64 bg-card border border-border rounded-lg shadow-lg z-50 py-3">
<div className="absolute right-0 mt-1.5 w-64 bg-card border border-border rounded-md shadow-lg z-50 py-3">
<div className="flex items-center justify-between px-3 pb-2 border-b border-border mb-2">
<p className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">
{t('table.filters', 'Filters')}

View File

@@ -0,0 +1,655 @@
import { useState, useRef } from 'react'
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible'
import { Check, ChevronsUpDown, Search, X, Eye, EyeOff, Upload, Hash } from 'lucide-react'
import { cn } from '@/lib/utils'
import { Input } from '@/components/ui/input'
import { Textarea } from '@/components/ui/textarea'
import { Button } from '@/components/ui/button'
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
import { Calendar } from '@/components/ui/calendar'
import { format, parse, isValid } from 'date-fns'
import { CalendarIcon } from 'lucide-react'
// ─── Collapsible aliases ──────────────────────────────────────────────────────
const Collapsible = CollapsiblePrimitive.Root
const CollapsibleTrigger = CollapsiblePrimitive.Trigger
const CollapsibleContent = CollapsiblePrimitive.Content
// ─── Types ────────────────────────────────────────────────────────────────────
export type FormInputType =
| 'text'
| 'number'
| 'phone'
| 'email'
| 'password'
| 'date'
| 'select'
| 'searchable-select'
| 'file'
| 'textarea'
export interface SelectOption {
value: string
label: string
}
export interface FormInputProps {
type?: FormInputType
label?: string
value?: string
onChange?: (value: string) => void
placeholder?: string
error?: string
required?: boolean
disabled?: boolean
options?: SelectOption[]
accept?: string
onFileChange?: (file: File | null) => void
fileValue?: File | null
className?: string
phonePrefix?: string
rows?: number
name?: string
readOnly?: boolean
}
// ─── FieldLabel ───────────────────────────────────────────────────────────────
function FieldLabel({ label, required }: { label?: string; required?: boolean }) {
if (!label) return null
return (
<label className="block text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-1.5 select-none">
{label}
{required && <span className="text-destructive ml-0.5">*</span>}
</label>
)
}
// ─── ErrorMsg ─────────────────────────────────────────────────────────────────
function ErrorMsg({ error }: { error?: string }) {
if (!error) return null
return (
<p className="mt-1.5 text-xs text-destructive font-medium flex items-center gap-1.5">
<span className="inline-block w-1 h-1 rounded-full bg-destructive shrink-0" />
{error}
</p>
)
}
// ─── error border helper ──────────────────────────────────────────────────────
const withError = (error?: string) =>
error ? 'border-destructive focus-visible:ring-destructive/30' : ''
// ─── TextInput ────────────────────────────────────────────────────────────────
function TextInput({
type = 'text',
value = '',
onChange,
placeholder,
error,
disabled,
required,
label,
className,
name,
readOnly,
rows = 3,
}: FormInputProps) {
const [showPass, setShowPass] = useState(false)
const isPassword = type === 'password'
const isTextarea = type === 'textarea'
const isNumber = type === 'number'
return (
<div className={className}>
<FieldLabel label={label} required={required} />
<div className="relative">
{isTextarea ? (
<Textarea
name={name}
value={value}
onChange={(e) => onChange?.(e.target.value)}
placeholder={placeholder}
disabled={disabled}
readOnly={readOnly}
rows={rows}
className={cn('resize-none', withError(error))}
/>
) : (
<Input
name={name}
type={
isPassword ? (showPass ? 'text' : 'password')
: isNumber ? 'number'
: type === 'email' ? 'email'
: 'text'
}
min={isNumber ? 0 : undefined}
value={value}
onChange={(e) => {
if (isNumber) {
const num = e.target.value
if (num === '' || Number(num) >= 0) onChange?.(num)
} else {
onChange?.(e.target.value)
}
}}
placeholder={placeholder}
disabled={disabled}
readOnly={readOnly}
className={cn(
isPassword && 'pr-10',
isNumber && 'pr-10',
withError(error),
)}
/>
)}
{isPassword && (
<button
type="button"
tabIndex={-1}
onClick={() => setShowPass((v) => !v)}
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors"
>
{showPass ? <EyeOff size={15} /> : <Eye size={15} />}
</button>
)}
{isNumber && (
<Hash
size={14}
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"
/>
)}
</div>
<ErrorMsg error={error} />
</div>
)
}
// ─── PhoneInput ───────────────────────────────────────────────────────────────
function PhoneInput({
value = '',
onChange,
placeholder = '61 097 651',
error,
disabled,
required,
label,
className,
phonePrefix = '+993',
}: FormInputProps) {
return (
<div className={className}>
<FieldLabel label={label} required={required} />
<div
className={cn(
'flex h-8 w-full rounded-md border bg-background overflow-hidden',
'ring-offset-background transition-colors duration-150',
'focus-within:outline-none focus-within:ring-1 focus-within:ring-ring focus-within:ring-offset-0',
error ? 'border-destructive focus-within:ring-destructive/30' : 'border-input',
disabled && 'opacity-50 cursor-not-allowed',
)}
>
<div className="flex items-center px-3 bg-muted/50 border-r border-input text-sm font-medium text-muted-foreground shrink-0 select-none">
{phonePrefix}
</div>
<input
type="tel"
value={value}
onChange={(e) => onChange?.(e.target.value.replace(/[^\d\s-]/g, ''))}
placeholder={placeholder}
disabled={disabled}
className="flex-1 h-full px-3 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none disabled:cursor-not-allowed"
/>
</div>
<ErrorMsg error={error} />
</div>
)
}
// ─── DateInput (shadcn Popover + Calendar) ───────────────────────────────────
function DateInput({
value = '',
onChange,
error,
disabled,
required,
label,
className,
placeholder = 'Sene saýlaň',
}: FormInputProps) {
const [open, setOpen] = useState(false)
// value is stored as 'yyyy-MM-dd' string
const parsed = value ? parse(value, 'yyyy-MM-dd', new Date()) : undefined
const selected = parsed && isValid(parsed) ? parsed : undefined
const handleSelect = (day: Date | undefined) => {
onChange?.(day ? format(day, 'yyyy-MM-dd') : '')
setOpen(false)
}
return (
<div className={className}>
<FieldLabel label={label} required={required} />
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<button
type="button"
disabled={disabled}
className={cn(
'flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2',
'text-sm ring-offset-background transition-colors duration-150',
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0',
'disabled:cursor-not-allowed disabled:opacity-50',
error ? 'border-destructive' : 'border-input',
!selected && 'text-muted-foreground/60',
)}
>
<span>{selected ? format(selected, 'dd.MM.yyyy') : placeholder}</span>
<CalendarIcon size={15} className="text-muted-foreground shrink-0" />
</button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
mode="single"
selected={selected}
onSelect={handleSelect}
initialFocus
captionLayout="dropdown"
fromYear={1940}
toYear={new Date().getFullYear()}
/>
</PopoverContent>
</Popover>
<ErrorMsg error={error} />
</div>
)
}
// ─── SelectInput ──────────────────────────────────────────────────────────────
// ─── SelectInput ──────────────────────────────────────────────────────────────
// Artık Collapsible tabanlı — SearchableSelect ile aynı mekanizma
function SelectInput({
value = '',
onChange,
options = [],
placeholder = '—',
error,
disabled,
required,
label,
className,
}: FormInputProps) {
const [open, setOpen] = useState(false)
const selected = options.find((o) => o.value === value)
const handleSelect = (val: string) => {
onChange?.(val)
setOpen(false)
}
return (
<div className={cn('relative', className)}>
<FieldLabel label={label} required={required} />
<Collapsible
open={open}
onOpenChange={(next) => {
if (!disabled) setOpen(next)
}}
>
<CollapsibleTrigger asChild>
<button
type="button"
disabled={disabled}
className={cn(
'flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2',
'text-sm ring-offset-background transition-colors duration-150',
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0',
'disabled:cursor-not-allowed disabled:opacity-50',
error ? 'border-destructive' : 'border-input',
open && !error && 'ring-2 ring-ring ring-offset-0 border-transparent',
)}
>
<span className={cn('truncate text-left', !selected && 'text-muted-foreground/60')}>
{selected ? selected.label : placeholder}
</span>
<ChevronsUpDown
size={14}
className={cn(
'text-muted-foreground transition-transform duration-200 shrink-0',
open && 'text-foreground',
)}
/>
</button>
</CollapsibleTrigger>
<CollapsibleContent className="mt-1 rounded-md border border-border bg-card shadow-lg overflow-hidden">
<div className="max-h-52 overflow-y-auto py-1">
{options.map((opt) => {
const isSelected = opt.value === value
return (
<button
key={opt.value}
type="button"
onMouseDown={(e) => { e.preventDefault(); handleSelect(opt.value) }}
className={cn(
'flex items-center justify-between w-full text-left px-3 py-2 text-sm transition-colors',
'hover:bg-accent hover:text-accent-foreground',
isSelected && 'text-primary font-medium bg-primary/10',
)}
>
<span>{opt.label}</span>
{isSelected && <Check size={13} className="text-primary shrink-0" />}
</button>
)
})}
</div>
</CollapsibleContent>
</Collapsible>
<ErrorMsg error={error} />
</div>
)
}
// ─── SearchableSelect ─────────────────────────────────────────────────────────
// Uses Radix Collapsible — no portal, no z-index issues, natural document flow.
// onMouseDown (not onClick) on options prevents the trigger's onBlur from
// firing before the selection is registered.
function SearchableSelect({
value = '',
onChange,
options = [],
placeholder = 'Saýlamak üçin basyň',
error,
disabled,
required,
label,
className,
}: FormInputProps) {
const [open, setOpen] = useState(false)
const [query, setQuery] = useState('')
const searchRef = useRef<HTMLInputElement>(null)
const selected = options.find((o) => o.value === value)
const filtered = query.trim()
? options.filter((o) => o.label.toLowerCase().includes(query.toLowerCase()))
: options
const openDropdown = () => {
setOpen(true)
// Focus search after Collapsible animation frame
requestAnimationFrame(() => searchRef.current?.focus())
}
const closeDropdown = () => {
setOpen(false)
setQuery('')
}
const handleSelect = (val: string) => {
onChange?.(val)
closeDropdown()
}
const handleClear = (e: React.MouseEvent) => {
e.preventDefault()
e.stopPropagation()
onChange?.('')
}
return (
<div className={cn('relative', className)}>
<FieldLabel label={label} required={required} />
<Collapsible open={open} onOpenChange={(next) => { if (!disabled) { if (next) { openDropdown() } else { closeDropdown() } } }}>
{/* Trigger */}
<CollapsibleTrigger asChild>
<button
type="button"
disabled={disabled}
className={cn(
'flex h-8 w-full items-center justify-between rounded-md border bg-background px-3 py-2',
'text-sm ring-offset-background transition-colors duration-150',
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0',
'disabled:cursor-not-allowed disabled:opacity-50',
error ? 'border-destructive' : 'border-input',
open && !error && 'ring-2 ring-ring ring-offset-0 border-transparent',
)}
>
<span className={cn('truncate text-left', !selected && 'text-muted-foreground/60')}>
{selected ? selected.label : placeholder}
</span>
<div className="flex items-center gap-1 shrink-0 ml-2">
{selected && !disabled && (
<span
role="button"
tabIndex={-1}
onMouseDown={handleClear}
className="p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors"
>
<X size={12} />
</span>
)}
<ChevronsUpDown
size={14}
className={cn(
'text-muted-foreground transition-transform duration-200 shrink-0',
open && 'text-foreground',
)}
/>
</div>
</button>
</CollapsibleTrigger>
{/* Panel */}
<CollapsibleContent className="mt-1 rounded-md border border-border bg-card shadow-lg overflow-hidden">
{/* Search */}
<div className="flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/20">
<Search size={13} className="text-muted-foreground shrink-0" />
<input
ref={searchRef}
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Gözle..."
className="flex-1 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none"
/>
{query && (
<button
type="button"
tabIndex={-1}
onMouseDown={() => setQuery('')}
className="text-muted-foreground hover:text-foreground transition-colors"
>
<X size={12} />
</button>
)}
</div>
{/* Options */}
<div className="max-h-52 overflow-y-auto py-1">
{filtered.length === 0 ? (
<p className="px-3 py-4 text-sm text-muted-foreground text-center">
Netije tapylmady
</p>
) : (
filtered.map((opt) => {
const isSelected = opt.value === value
return (
<button
key={opt.value}
type="button"
onMouseDown={(e) => { e.preventDefault(); handleSelect(opt.value) }}
className={cn(
'flex items-center justify-between w-full text-left px-3 py-2 text-sm transition-colors',
'hover:bg-accent hover:text-accent-foreground',
isSelected && 'text-primary font-medium bg-primary/10',
)}
>
<span>{opt.label}</span>
{isSelected && <Check size={13} className="text-primary shrink-0" />}
</button>
)
})
)}
</div>
</CollapsibleContent>
</Collapsible>
<ErrorMsg error={error} />
</div>
)
}
// ─── FileInput ────────────────────────────────────────────────────────────────
function FileInput({
label,
required,
error,
disabled,
accept = 'image/*',
onFileChange,
fileValue,
className,
placeholder = 'Faýl saýlaň ýa-da salmak üçin basyň',
}: FormInputProps) {
const inputRef = useRef<HTMLInputElement>(null)
const [dragOver, setDragOver] = useState(false)
const [preview, setPreview] = useState<string | null>(null)
const handleFile = (file: File | null) => {
onFileChange?.(file)
if (file?.type.startsWith('image/')) {
setPreview(URL.createObjectURL(file))
} else {
setPreview(null)
}
}
const handleDrop = (e: React.DragEvent) => {
e.preventDefault()
setDragOver(false)
handleFile(e.dataTransfer.files[0] ?? null)
}
const isImage = fileValue?.type.startsWith('image/')
return (
<div className={className}>
<FieldLabel label={label} required={required} />
<div
role="button"
tabIndex={disabled ? -1 : 0}
onClick={() => !disabled && inputRef.current?.click()}
onKeyDown={(e) => e.key === 'Enter' && !disabled && inputRef.current?.click()}
onDragOver={(e) => { e.preventDefault(); setDragOver(true) }}
onDragLeave={() => setDragOver(false)}
onDrop={handleDrop}
className={cn(
'relative flex flex-col items-center justify-center',
'min-h-[88px] rounded-md border-2 border-dashed cursor-pointer select-none',
'transition-all duration-200',
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2',
dragOver && 'border-primary bg-primary/5 scale-[1.01]',
error ? 'border-destructive/60' : 'border-border',
!dragOver && !error && 'hover:border-primary/50 hover:bg-muted/20',
disabled && 'opacity-50 cursor-not-allowed pointer-events-none',
fileValue && isImage && '!border-solid !border-border p-0 overflow-hidden',
)}
>
{fileValue && isImage && preview ? (
<>
<img src={preview} alt="preview" className="w-full h-32 object-cover" />
<Button
type="button"
size="icon"
variant="secondary"
onClick={(e) => { e.stopPropagation(); handleFile(null) }}
className="absolute top-2 right-2 h-6 w-6 rounded-full border border-border shadow-sm"
>
<X size={11} />
</Button>
</>
) : fileValue ? (
<div className="flex flex-col items-center gap-1.5 p-4">
<div className="w-8 h-8 rounded-md bg-primary/10 flex items-center justify-center">
<Upload size={14} className="text-primary" />
</div>
<p className="text-xs font-medium text-foreground text-center truncate max-w-[180px]">
{fileValue.name}
</p>
<button
type="button"
onClick={(e) => { e.stopPropagation(); handleFile(null) }}
className="text-xs text-destructive hover:text-destructive/80 transition-colors"
>
Aýyr
</button>
</div>
) : (
<div className="flex flex-col items-center gap-1.5 p-4">
<div className="w-8 h-8 rounded-md bg-muted flex items-center justify-center">
<Upload size={14} className="text-muted-foreground" />
</div>
<p className="text-xs text-muted-foreground text-center leading-relaxed">
{placeholder}
</p>
</div>
)}
</div>
<input
ref={inputRef}
type="file"
accept={accept}
disabled={disabled}
onChange={(e) => handleFile(e.target.files?.[0] ?? null)}
className="hidden"
/>
<ErrorMsg error={error} />
</div>
)
}
// ─── FormInput (router) ───────────────────────────────────────────────────────
export function FormInput(props: FormInputProps) {
const { type = 'text' } = props
if (type === 'phone') return <PhoneInput {...props} />
if (type === 'date') return <DateInput {...props} />
if (type === 'select') return <SelectInput {...props} />
if (type === 'searchable-select') return <SearchableSelect {...props} />
if (type === 'file') return <FileInput {...props} />
if (type === 'textarea') return <TextInput {...props} type="textarea" />
return <TextInput {...props} />
}

View File

@@ -25,7 +25,7 @@ export function TableActionButton({
disabled={disabled}
variant={variant === 'destructive' ? 'destructive' : variant === 'secondary' ? 'secondary' : 'default'}
className={cn(
'font-medium text-sm h-9 px-4 transition-colors shadow-sm',
'font-medium text-sm h-9 px-4 transition-colors shadow-sm cursor-pointer',
className
)}
>

View File

@@ -31,7 +31,7 @@ export function TableSearchInput({
className={cn(
'h-9 w-64 rounded-md border border-border bg-background pl-9 pr-3',
'text-sm text-foreground placeholder:text-muted-foreground',
'focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent',
'focus:outline-none focus:ring-1 focus:ring-ring focus:border-transparent',
'transition-colors'
)}
/>

View File

@@ -40,7 +40,7 @@ function AccordionTrigger({
<AccordionPrimitive.Trigger
data-slot="accordion-trigger"
className={cn(
"group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring disabled:pointer-events-none disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",
"group/accordion-trigger relative flex flex-1 items-start justify-between rounded-md border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring disabled:pointer-events-none disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",
className
)}
{...props}

View File

@@ -1,9 +1,45 @@
import * as React from "react"
import { type VariantProps } from "class-variance-authority"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"
import { cn } from "@/lib/utils"
import { buttonVariants } from "./button-variants"
const buttonVariants = cva(
"group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
outline:
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
ghost:
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
destructive:
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default:
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
icon: "size-8",
"icon-xs":
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
"icon-sm":
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-md",
"icon-lg": "size-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Button({
className,
@@ -28,4 +64,4 @@ function Button({
)
}
export { Button }
export { Button, buttonVariants }

View File

@@ -0,0 +1,220 @@
import * as React from "react"
import {
DayPicker,
getDefaultClassNames,
type DayButton,
type Locale,
} from "react-day-picker"
import { cn } from "@/lib/utils"
import { Button, buttonVariants } from "@/components/ui/button"
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
function Calendar({
className,
classNames,
showOutsideDays = true,
captionLayout = "label",
buttonVariant = "ghost",
locale,
formatters,
components,
...props
}: React.ComponentProps<typeof DayPicker> & {
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
}) {
const defaultClassNames = getDefaultClassNames()
return (
<DayPicker
showOutsideDays={showOutsideDays}
className={cn(
"group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent",
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
className
)}
captionLayout={captionLayout}
locale={locale}
formatters={{
formatMonthDropdown: (date) =>
date.toLocaleString(locale?.code, { month: "short" }),
...formatters,
}}
classNames={{
root: cn("w-fit", defaultClassNames.root),
months: cn(
"relative flex flex-col gap-4 md:flex-row",
defaultClassNames.months
),
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
nav: cn(
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
defaultClassNames.nav
),
button_previous: cn(
buttonVariants({ variant: buttonVariant }),
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
defaultClassNames.button_previous
),
button_next: cn(
buttonVariants({ variant: buttonVariant }),
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
defaultClassNames.button_next
),
month_caption: cn(
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
defaultClassNames.month_caption
),
dropdowns: cn(
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
defaultClassNames.dropdowns
),
dropdown_root: cn(
"relative rounded-(--cell-radius)",
defaultClassNames.dropdown_root
),
dropdown: cn(
"absolute inset-0 bg-popover opacity-0",
defaultClassNames.dropdown
),
caption_label: cn(
"font-medium select-none",
captionLayout === "label"
? "text-sm"
: "flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
defaultClassNames.caption_label
),
table: "w-full border-collapse",
weekdays: cn("flex", defaultClassNames.weekdays),
weekday: cn(
"flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none",
defaultClassNames.weekday
),
week: cn("mt-2 flex w-full", defaultClassNames.week),
week_number_header: cn(
"w-(--cell-size) select-none",
defaultClassNames.week_number_header
),
week_number: cn(
"text-[0.8rem] text-muted-foreground select-none",
defaultClassNames.week_number
),
day: cn(
"group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)",
props.showWeekNumber
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
: "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
defaultClassNames.day
),
range_start: cn(
"relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted",
defaultClassNames.range_start
),
range_middle: cn("rounded-none", defaultClassNames.range_middle),
range_end: cn(
"relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted",
defaultClassNames.range_end
),
today: cn(
"rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none",
defaultClassNames.today
),
outside: cn(
"text-muted-foreground aria-selected:text-muted-foreground",
defaultClassNames.outside
),
disabled: cn(
"text-muted-foreground opacity-50",
defaultClassNames.disabled
),
hidden: cn("invisible", defaultClassNames.hidden),
...classNames,
}}
components={{
Root: ({ className, rootRef, ...props }) => {
return (
<div
data-slot="calendar"
ref={rootRef}
className={cn(className)}
{...props}
/>
)
},
Chevron: ({ className, orientation, ...props }) => {
if (orientation === "left") {
return (
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
)
}
if (orientation === "right") {
return (
<ChevronRightIcon className={cn("size-4", className)} {...props} />
)
}
return (
<ChevronDownIcon className={cn("size-4", className)} {...props} />
)
},
DayButton: ({ ...props }) => (
<CalendarDayButton locale={locale} {...props} />
),
WeekNumber: ({ children, ...props }) => {
return (
<td {...props}>
<div className="flex size-(--cell-size) items-center justify-center text-center">
{children}
</div>
</td>
)
},
...components,
}}
{...props}
/>
)
}
function CalendarDayButton({
className,
day,
modifiers,
locale,
...props
}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
const defaultClassNames = getDefaultClassNames()
const ref = React.useRef<HTMLButtonElement>(null)
React.useEffect(() => {
if (modifiers.focused) ref.current?.focus()
}, [modifiers.focused])
return (
<Button
ref={ref}
variant="ghost"
size="icon"
data-day={day.date.toLocaleDateString(locale?.code)}
data-selected-single={
modifiers.selected &&
!modifiers.range_start &&
!modifiers.range_end &&
!modifiers.range_middle
}
data-range-start={modifiers.range_start}
data-range-end={modifiers.range_end}
data-range-middle={modifiers.range_middle}
className={cn(
"relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70",
defaultClassNames.day,
className
)}
{...props}
/>
)
}
export { Calendar, CalendarDayButton }

View File

@@ -12,7 +12,7 @@ function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
data-slot="input-group"
role="group"
className={cn(
"group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
"group/input-group relative flex h-8 w-full min-w-0 items-center rounded-md border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
className
)}
{...props}

View File

@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
type={type}
data-slot="input"
className={cn(
"h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
"h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
className
)}
{...props}

View File

@@ -0,0 +1,87 @@
import * as React from "react"
import { Popover as PopoverPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Popover({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
return <PopoverPrimitive.Root data-slot="popover" {...props} />
}
function PopoverTrigger({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
}
function PopoverContent({
className,
align = "center",
sideOffset = 4,
...props
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
return (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
data-slot="popover-content"
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-md bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
className
)}
{...props}
/>
</PopoverPrimitive.Portal>
)
}
function PopoverAnchor({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
}
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="popover-header"
className={cn("flex flex-col gap-0.5 text-sm", className)}
{...props}
/>
)
}
function PopoverTitle({ className, ...props }: React.ComponentProps<"h2">) {
return (
<div
data-slot="popover-title"
className={cn("font-medium", className)}
{...props}
/>
)
}
function PopoverDescription({
className,
...props
}: React.ComponentProps<"p">) {
return (
<p
data-slot="popover-description"
className={cn("text-muted-foreground", className)}
{...props}
/>
)
}
export {
Popover,
PopoverAnchor,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
}

View File

@@ -0,0 +1,190 @@
import * as React from "react"
import { Select as SelectPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
function Select({
...props
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
return <SelectPrimitive.Root data-slot="select" {...props} />
}
function SelectGroup({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
return (
<SelectPrimitive.Group
data-slot="select-group"
className={cn("scroll-my-1 p-1", className)}
{...props}
/>
)
}
function SelectValue({
...props
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
return <SelectPrimitive.Value data-slot="select-value" {...props} />
}
function SelectTrigger({
className,
size = "default",
children,
...props
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
size?: "sm" | "default"
}) {
return (
<SelectPrimitive.Trigger
data-slot="select-trigger"
data-size={size}
className={cn(
"flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
>
{children}
<SelectPrimitive.Icon asChild>
<ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
)
}
function SelectContent({
className,
children,
position = "item-aligned",
align = "center",
...props
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
return (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
data-slot="select-content"
data-align-trigger={position === "item-aligned"}
className={cn("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", position ==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className )}
position={position}
align={align}
{...props}
>
<SelectScrollUpButton />
<SelectPrimitive.Viewport
data-position={position}
className={cn(
"data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)",
position === "popper" && ""
)}
>
{children}
</SelectPrimitive.Viewport>
<SelectScrollDownButton />
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
)
}
function SelectLabel({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
return (
<SelectPrimitive.Label
data-slot="select-label"
className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
{...props}
/>
)
}
function SelectItem({
className,
children,
...props
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
return (
<SelectPrimitive.Item
data-slot="select-item"
className={cn(
"relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
className
)}
{...props}
>
<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<CheckIcon className="pointer-events-none" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
)
}
function SelectSeparator({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
return (
<SelectPrimitive.Separator
data-slot="select-separator"
className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
{...props}
/>
)
}
function SelectScrollUpButton({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
return (
<SelectPrimitive.ScrollUpButton
data-slot="select-scroll-up-button"
className={cn(
"z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
>
<ChevronUpIcon
/>
</SelectPrimitive.ScrollUpButton>
)
}
function SelectScrollDownButton({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
return (
<SelectPrimitive.ScrollDownButton
data-slot="select-scroll-down-button"
className={cn(
"z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
>
<ChevronDownIcon
/>
</SelectPrimitive.ScrollDownButton>
)
}
export {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectScrollDownButton,
SelectScrollUpButton,
SelectSeparator,
SelectTrigger,
SelectValue,
}

View File

@@ -241,7 +241,7 @@ function Sidebar({
<div
data-sidebar="sidebar"
data-slot="sidebar-inner"
className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-md group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
>
{children}
</div>

View File

@@ -7,7 +7,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
<textarea
data-slot="textarea"
className={cn(
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
className
)}
{...props}

View File

@@ -22,39 +22,6 @@ const MOCK_DATA: LoanOrder[] = [
lastName: 'Berdiýewa',
phone: '+993 61 445566',
status: 'IŞLENÝÄR',
},
{
id: 'L-1003',
loanType: 'Biznes karzy',
createdAt: '2024-03-18 09:00',
region: 'Lebap',
branch: 'Türkmenabat şahamçasy',
firstName: 'Myrat',
lastName: 'Hallyýew',
phone: '+993 64 778899',
status: 'KANAGATLANDYRYLAN',
},
{
id: 'L-1004',
loanType: 'Talyp karzy',
createdAt: '2024-03-17 16:45',
region: 'Balkan',
branch: 'Türkmenbaşy şahamçasy',
firstName: 'Jeren',
lastName: 'Saparowa',
phone: '+993 62 001122',
status: 'RED_EDILDI',
},
{
id: 'L-1005',
loanType: 'Awtoulag karzy',
createdAt: '2024-03-16 11:20',
region: 'Daşoguz',
branch: 'Daşoguz-2 şahamçasy',
firstName: 'Döwlet',
lastName: 'Meredow',
phone: '+993 63 334455',
status: 'GARAŞYLÝAR',
}
];
@@ -104,6 +71,39 @@ export interface CreateLoanOrderPayload {
phone: string
}
// Add this to your existing loanOrdersApi.ts
export interface LoanOrderCreatePayload {
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
}
// ─── API Functions ────────────────────────────────────────────────────────────
export async function fetchLoanOrders(
@@ -112,6 +112,9 @@ export async function fetchLoanOrders(
// Hakyky API ýok wagty simulator (800ms garaşdyrýar)
await new Promise((resolve) => setTimeout(resolve, 800));
const page = params.page || 1;
const perPage = params.perPage || 25;
// Gözleg (search) logic-ni simulirlemek (optional)
const filtered = MOCK_DATA.filter(item =>
!params.search ||
@@ -119,12 +122,18 @@ export async function fetchLoanOrders(
item.id.toLowerCase().includes(params.search.toLowerCase())
);
// Sayfalama mantığı (slice)
const start = (page - 1) * perPage;
const end = start + perPage;
const paginatedData = filtered.slice(start, end);
return {
data: filtered,
data: paginatedData,
total: filtered.length,
page: params.page || 1,
perPage: params.perPage || 25,
};}
page,
perPage,
};
}
// export async function fetchLoanOrders(
// params: LoanOrdersParams
@@ -159,4 +168,69 @@ export async function updateLoanOrder(
export async function deleteLoanOrder(id: string): Promise<void> {
await apiClient.delete(`/resources/loan-orders/${id}`)
}
// ─── Extend this into your existing loanOrdersApi.ts ─────────────────────────
// Add the fields below to your existing LoanOrder interface.
// The list page already uses: id, loanType, createdAt, region, branch,
// firstName, lastName, phone, status.
export interface LoanOrder {
// ── List fields (already exist) ──────────────────────────────────────────
id: string
loanType: string
createdAt: string
region: string
branch: string
firstName: string
lastName: string
phone: string
status: LoanOrderStatus
// ── Detail-only fields ────────────────────────────────────────────────────
amount?: string | null
loanAmount?: string | null
createdBy?: string | null
// Personal
fullName?: string | null
education?: string | null
maritalStatus?: string | null
birthDate?: string | null
registeredAddress?: string | null
currentAddress?: string | null
// Contacts
email?: string | null
phoneAlt?: string | null
homePhone?: string | null
// Employment
employer?: string | null
deptPhone?: string | null
workRegion?: string | null
workCity?: string | null
position?: string | null
salary?: string | null
employedSince?: string | null
// Passport
passportNumber?: string | null
passportIssuedBy?: string | null
passportBirthPlace?: string | null
passportPage1Url?: string | null
passportPage23Url?: string | null
passportPage89Url?: string | null
passportPage32Url?: string | null
}
// ─── Add this function to your existing loanOrdersApi.ts ──────────────────────
// import { apiClient } from '@/lib/api/client'
export async function getLoanOrderById(id: string): Promise<LoanOrder> {
const { data } = await apiClient.get<LoanOrder>(`/loan-orders/${id}`)
return data
}

View File

@@ -1,25 +1,39 @@
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from 'lucide-react'
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
import type { LoanOrderStatus } from '../api/loanOrdersApi'
interface LoanOrderStatusConfig {
label: string
variant: StatusBadgeVariant
icon: React.ElementType
}
const STATUS_CONFIG: Record<LoanOrderStatus, LoanOrderStatusConfig> = {
GARAŞYLÝAR: { label: 'GARAŞYLÝAR', variant: 'warning', icon: AlertCircle },
KANAGATLANDYRYLAN: { label: 'KANAGATLANDYRYLAN', variant: 'success', icon: CheckCircle2 },
RED_EDILDI: { label: 'RED EDILDI', variant: 'error', icon: XCircle },
IŞLENÝÄR: { label: 'IŞLENÝÄR', variant: 'info', icon: Loader2 },
}
interface LoanOrderStatusBadgeProps {
status: LoanOrderStatus
}
export function LoanOrderStatusBadge({ status }: LoanOrderStatusBadgeProps) {
const config = STATUS_CONFIG[status]
return <StatusBadge label={config.label} variant={config.variant} icon={config.icon} />
}
import { useTranslation } from 'react-i18next'
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from 'lucide-react'
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
import type { LoanOrderStatus } from '../api/loanOrdersApi'
interface LoanOrderStatusConfig {
labelKey: string
variant: StatusBadgeVariant
icon: React.ElementType
}
const STATUS_CONFIG: Record<LoanOrderStatus, LoanOrderStatusConfig> = {
GARAŞYLÝAR: { labelKey: 'loanOrderStatus.GARAŞYLÝAR', variant: 'warning', icon: AlertCircle },
KANAGATLANDYRYLAN: { labelKey: 'loanOrderStatus.KANAGATLANDYRYLAN', variant: 'success', icon: CheckCircle2 },
RED_EDILDI: { labelKey: 'loanOrderStatus.RED_EDILDI', variant: 'error', icon: XCircle },
IŞLENÝÄR: { labelKey: 'loanOrderStatus.IŞLENÝÄR', variant: 'info', icon: Loader2 },
}
interface LoanOrderStatusBadgeProps {
status: LoanOrderStatus
}
export function LoanOrderStatusBadge({ status }: LoanOrderStatusBadgeProps) {
const { t } = useTranslation()
const config = STATUS_CONFIG[status]
if (!config) {
console.warn(`[LoanOrderStatusBadge] Unknown status: ${status}`);
return (
<StatusBadge
label={status ? String(status) : t('common.unknown', 'Näbelli')}
variant="default"
icon={AlertCircle}
/>
)
}
return <StatusBadge label={t(config.labelKey)} variant={config.variant} icon={config.icon} />
}

View File

@@ -8,6 +8,7 @@ import {
deleteLoanOrder,
type LoanOrdersParams,
type CreateLoanOrderPayload,
getLoanOrderById,
} from '../api/loanOrdersApi'
const LOAN_ORDERS_KEY = 'loan-orders'
@@ -67,4 +68,12 @@ export function useDeleteLoanOrder() {
toast.error(t('loanOrders.deleteError', 'Karz sargyt pozmakda säwlik ýüze çykdy'))
},
})
}
export function useLoanOrderById(id: string) {
return useQuery({
queryKey: ['loanOrders', id],
queryFn: () => getLoanOrderById(id),
enabled: !!id,
})
}

View File

@@ -340,27 +340,27 @@ function AppSidebar() {
{
title: t('Loan department', 'KARZ BÖLÜMI'),
items: [
{ title: t('Loan orders', 'Karz sargytlary'), url: '/resources/loan-orders' },
{ title: t('Loan order (Mobile)', 'Karz sargyt (Mobile)'), url: '/resources/loan-order-mobiles' },
{ title: t('Loan balance', 'Karzyň galyndysy'), url: '/resources/loan-remaining' },
{ title: t('Certificates of loan repayment', 'Karzyň ýapylandygy barada güwanamalar'), url: '/resources/loan-paid-off-letters' },
{ title: t('Loan orders', 'Karz sargytlary'), url: '/loan-orders' },
{ title: t('Loan order (Mobile)', 'Karz sargyt (Mobile)'), url: '/loan-order-mobiles' },
{ title: t('Loan balance', 'Karzyň galyndysy'), url: '/loan-remaining' },
{ title: t('Certificates of loan repayment', 'Karzyň ýapylandygy barada güwanamalar'), url: '/loan-paid-off-letters' },
],
},
{
title: t('Card department', 'KART BÖLÜMI'),
items: [
{ title: t('Order new card', 'Täze kart açmak'), url: '/resources/card-new' },
{ title: t('Card transactions', 'Kart hereketleri'), url: '/resources/card-transactions' },
{ title: t('Card requisites', 'Kart rekwizitler'), url: '/resources/card-requisites' },
{ title: t('Card balances', 'Kart galyndylary'), url: '/resources/card-balances' },
{ title: t('Card pins', 'Kart pin bukjalar'), url: '/resources/card-pins' },
{ title: t('Order new card', 'Täze kart açmak'), url: '/card-new' },
{ title: t('Card transactions', 'Kart hereketleri'), url: '/card-transactions' },
{ title: t('Card requisites', 'Kart rekwizitler'), url: '/card-requisites' },
{ title: t('Card balances', 'Kart galyndylary'), url: '/card-balances' },
{ title: t('Card pins', 'Kart pin bukjalar'), url: '/card-pins' },
],
},
{
title: t('International payments', 'HALKARA TÖLEGLER'),
items: [
{ title: t('Visa/Master payments', 'Visa/Master tölegleri'), url: '/resources/intl-payments/visa-master' },
{ title: t('Sber payments', 'Sber tölegleri'), url: '/resources/intl-payments/sber' },
{ title: t('Visa/Master payments', 'Visa/Master tölegleri'), url: '/intl-payments/visa-master' },
{ title: t('Sber payments', 'Sber tölegleri'), url: '/intl-payments/sber' },
],
},
],
@@ -388,7 +388,7 @@ function AppSidebar() {
{
title: t('Loan', 'KARZ'),
items: [
{ title: t('Loan Types', 'Karz görnüşleri'), url: '/settings/loan/types' },
{ title: t('Loan types', 'Karz görnüşleri'), url: '/settings/loan/types' },
{ title: t('Required Documents', 'Karz gerekli resminamalary'), url: '/settings/loan/documents' },
],
},
@@ -396,13 +396,13 @@ function AppSidebar() {
title: t('Card', 'KART'),
items: [
{ title: t('Card Issuance Reasons', 'Kartyň çykarylmagynyň sebäpleri'), url: '/settings/card/reasons' },
{ title: t('Card Types', 'Kart görnüşleri'), url: '/settings/card/types' },
{ title: t('Card types', 'Kart görnüşleri'), url: '/settings/card/types' },
],
},
{
title: t('Location', 'LOKASIÝA'),
items: [
{ title: t('Districts', 'Etraplar'), url: '/settings/location/districts' },
{ title: t('Provinces', 'Etraplar'), url: '/settings/location/districts' },
{ title: t('Branches', 'Şahamçalar'), url: '/settings/location/branches' },
],
},
@@ -492,6 +492,10 @@ export function DashboardLayout() {
<main className="flex-1 p-6 overflow-auto">
<Outlet />
</main>
{/* Footer */}
<div className="text-center text-xs text-muted-foreground/40 pt-2 pb-6">
© 2026 TBBANK.GOV.TM.
</div>
</div>
</div>
</SidebarProvider>

View File

@@ -8,7 +8,18 @@ import tk from './locales/tk.json'
export const SUPPORTED_LANGUAGES = ['en', 'ru', 'tk'] as const
export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number]
const savedLang = localStorage.getItem('tbbank-lang') as SupportedLanguage | null
const savedStorage = localStorage.getItem('tbbank-lang')
let savedLang: string | null = null
if (savedStorage) {
try {
const parsed = JSON.parse(savedStorage)
savedLang = parsed.state?.language
} catch {
savedLang = savedStorage
}
}
const defaultLang: SupportedLanguage =
SUPPORTED_LANGUAGES.includes(savedLang as SupportedLanguage) ? (savedLang as SupportedLanguage) : 'en'

View File

@@ -131,13 +131,16 @@
"Loading": "Loading",
"Loan": "Loan",
"Loan Card": "Loan Card",
"Cancel": "Cancel",
"Loan department": "Loan department",
"Loan order": "Loan order",
"New Loan Order": "New Loan Order",
"Loan order created": "Loan order created",
"Loan order deleted": "Loan order deleted",
"Loan order required docs": "Loan order required docs",
"Loan order updated": "Loan order updated",
"Loan orders": "Loan orders",
"Loan order (Mobile)": "Loan order (Mobile)",
"Loan type": "Loan type",
"Loan types": "Loan types",
"Locale": "Locale",
@@ -355,5 +358,54 @@
"You are receiving this email because we received a password reset request for your account.": "You are receiving this email because we received a password reset request for your account.",
"Your password has been updated": "Your password has been updated",
"Enter your username to continue": "Enter your username to continue",
"Old surname (if changed)": "Old surname (if changed)"
"Old surname (if changed)": "Old surname (if changed)",
"common.view": "View",
"common.edit": "Edit",
"common.delete": "Delete",
"common.search": "Search",
"common.yes": "Yes",
"common.no": "No",
"loanOrderMobiles.title": "Loan Orders (Mobile)",
"loanOrderMobiles.searchPlaceholder": "Search...",
"loanOrderMobiles.createButton": "Create Loan Order",
"loanOrderMobiles.deleteConfirm": "Are you sure you want to delete this order?",
"loanOrderMobiles.columns.id": "ID",
"loanOrderMobiles.columns.loanType": "LOAN TYPE",
"loanOrderMobiles.columns.createdAt": "CREATED AT",
"loanOrderMobiles.columns.region": "REGION",
"loanOrderMobiles.columns.branch": "BRANCH",
"loanOrderMobiles.columns.firstName": "FIRST NAME",
"loanOrderMobiles.columns.lastName": "LAST NAME",
"loanOrderMobiles.columns.phone": "PHONE",
"loanOrderMobiles.columns.status": "STATUS",
"loanOrderMobiles.filters.region": "REGION",
"loanOrderMobiles.filters.status": "STATUS",
"loanOrderMobiles.filters.branch": "BRANCH",
"loanOrderMobiles.filters.archived": "ARCHIVED",
"loanPaidOffLetters.title": "Loan Paid Off Letters",
"loanPaidOffLetters.emptyMessage": "No records found matching the criteria.",
"loanPaidOffLetters.createButton": "Create Paid Off Letter",
"loanPaidOffLetters.deleteConfirm": "Are you sure you want to delete this record?",
"loanPaidOffLetters.columns.id": "ID",
"loanPaidOffLetters.columns.passportSeries": "PASSPORT SERIES",
"loanPaidOffLetters.columns.passportNumber": "PASSPORT NUMBER",
"loanPaidOffLetters.columns.loanAccount": "LOAN ACCOUNT",
"loanPaidOffLetters.columns.issuedAt": "ISSUED AT",
"loanRemaining.title": "Loan Remaining Balance",
"loanRemaining.createButton": "Create Loan Remaining Record",
"loanRemaining.deleteConfirm": "Are you sure you want to delete this record?",
"loanRemaining.columns.id": "ID",
"loanRemaining.columns.passportSeries": "PASSPORT SERIES",
"loanRemaining.columns.passportNumber": "PASSPORT NUMBER",
"loanRemaining.columns.loanAccount": "LOAN ACCOUNT",
"loanOrderStatus.GARAŞYLÝAR": "PENDING",
"loanOrderStatus.KANAGATLANDYRYLAN": "APPROVED",
"loanOrderStatus.RED_EDILDI": "REJECTED",
"loanOrderStatus.IŞLENÝÄR": "PROCESSING",
"Dashboards": "Dashboard",
"Card Issuance Reasons": "Card Issuance Reasons",
"Locale Manager": "Locale Manager",
"Resources": "Resources",
"Currency rates": "Currency rates",
"Loan balance": "Loan balance"
}

View File

@@ -31,6 +31,7 @@
"Branches": "Филиалы",
"Cancelled": "Отменено",
"Card": "Карта",
"Cancel": "Отменить",
"Card balance": "Баланс карты",
"Card balances": "Балансы карт",
"Card department": "Карточный отдел",
@@ -133,11 +134,13 @@
"Loan Card": "Кредитная карта",
"Loan department": "Кредитный отдел",
"Loan order": "Заявка на кредит",
"New Loan Order": "Новая заявка на кредит",
"Loan order created": "Заявка на кредит создана",
"Loan order deleted": "Заявка на кредит удалена",
"Loan order required docs": "Необходимые документы для кредита",
"Loan order updated": "Заявка на кредит обновлена",
"Loan orders": "Заявки на кредит",
"Loan order (Mobile)": "Заявка на кредит (Мобильный)",
"Loan type": "Тип кредита",
"Loan types": "Типы кредитов",
"Locale": "Языковой стандарт",
@@ -355,5 +358,54 @@
"You are receiving this email because we received a password reset request for your account.": "Вы получили это письмо, потому что мы получили запрос на сброс пароля для Вашей учётной записи.",
"Your password has been updated": "Ваш пароль был обновлён",
"Enter your username to continue": "Введите свое имя пользователя, чтобы продолжить",
"Old surname (if changed)": "Старая фамилия (если менялась)"
"Old surname (if changed)": "Старая фамилия (если менялась)",
"common.view": "Просмотр",
"common.edit": "Редактировать",
"common.delete": "Удалить",
"common.search": "Поиск",
"common.yes": "Да",
"common.no": "Нет",
"loanOrderMobiles.title": "Заявки на кредит (Мобильные)",
"loanOrderMobiles.searchPlaceholder": "Поиск...",
"loanOrderMobiles.createButton": "Создать заявку на кредит",
"loanOrderMobiles.deleteConfirm": "Вы уверены, что хотите удалить этот заказ?",
"loanOrderMobiles.columns.id": "ID",
"loanOrderMobiles.columns.loanType": "ТИП КРЕДИТА",
"loanOrderMobiles.columns.createdAt": "ДАТА СОЗДАНИЯ",
"loanOrderMobiles.columns.region": "ВЕЛАЯТ",
"loanOrderMobiles.columns.branch": "ФИЛИАЛ",
"loanOrderMobiles.columns.firstName": "ИМЯ",
"loanOrderMobiles.columns.lastName": "ФАМИЛИЯ",
"loanOrderMobiles.columns.phone": "ТЕЛЕФОН",
"loanOrderMobiles.columns.status": "СТАТУС",
"loanOrderMobiles.filters.region": "ВЕЛАЯТ",
"loanOrderMobiles.filters.status": "СТАТУС",
"loanOrderMobiles.filters.branch": "ФИЛИАЛ",
"loanOrderMobiles.filters.archived": "АРХИВИРОВАНО",
"loanPaidOffLetters.title": "Справки о погашении кредита",
"loanPaidOffLetters.emptyMessage": "Справки о погашении кредита не найдены.",
"loanPaidOffLetters.createButton": "Создать справку о погашении",
"loanPaidOffLetters.deleteConfirm": "Вы уверены, что хотите удалить эту запись?",
"loanPaidOffLetters.columns.id": "ID",
"loanPaidOffLetters.columns.passportSeries": "СЕРИЯ ПАСПОРТА",
"loanPaidOffLetters.columns.passportNumber": "НОМЕР ПАСПОРТА",
"loanPaidOffLetters.columns.loanAccount": "КРЕДИТНЫЙ СЧЕТ",
"loanPaidOffLetters.columns.issuedAt": "ДАТА ВЫДАЧИ",
"loanRemaining.title": "Остаток кредита",
"loanRemaining.createButton": "Создать запись об остатке кредита",
"loanRemaining.deleteConfirm": "Вы уверены, что хотите удалить эту запись?",
"loanRemaining.columns.id": "ID",
"loanRemaining.columns.passportSeries": "СЕРИЯ ПАСПОРТА",
"loanRemaining.columns.passportNumber": "НОМЕР ПАСПОРТА",
"loanRemaining.columns.loanAccount": "КРЕДИТНЫЙ СЧЕТ",
"loanOrderStatus.GARAŞYLÝAR": "В ОЖИДАНИИ",
"loanOrderStatus.KANAGATLANDYRYLAN": "ОДОБРЕНО",
"loanOrderStatus.RED_EDILDI": "ОТКЛОНЕНО",
"loanOrderStatus.IŞLENÝÄR": "В ПРОЦЕССЕ",
"Dashboards": "Панели управления",
"Card Issuance Reasons": "Причины выдачи карты",
"Locale Manager": "Управление локалью",
"Resources": "Ресурсы",
"Currency rates": "Курсы валют",
"Loan balance": "Остаток кредита"
}

View File

@@ -31,6 +31,7 @@
"Branches": "Şahamçalar",
"Cancelled": "Ýatyrylan",
"Card": "Kart",
"Cancel": "Ýatyrmak",
"Card balance": "Kart galyndysy",
"Card balances": "Kart galyndylary",
"Card department": "Kart bölümi",
@@ -133,11 +134,13 @@
"Loan Card": "Karz karty",
"Loan department": "Karz bölümi",
"Loan order": "Karz sargyt",
"New Loan Order": "Täze Karz Sargyt",
"Loan order created": "Karz sargydy döredildi",
"Loan order deleted": "Karz sargydy pozuldy",
"Loan order required docs": "Karz gerekli resminamalary",
"Loan order updated": "Karz sargydy üýtgedildi",
"Loan orders": "Karz sargytlary",
"Loan order (Mobile)": "Karz sargyt (Mobil)",
"Loan type": "Karz görnüşi",
"Loan types": "Karz görnüşleri",
"Locale": "Dil",
@@ -355,5 +358,55 @@
"You are receiving this email because we received a password reset request for your account.": "Bu e-poçta alýarsyňyz, sebäbi hasabyňyz üçin paroly täzeden düzmek haýyşyny aldyk.",
"Your password has been updated": "Siziň açar sözüňiz üýtgedildi",
"Enter your username to continue": "Dowam etmek üçin ulanyjy adyny giriziň",
"Old surname (if changed)": "Köne familiýaňyz (eger üýtgän bolsa)"
"Old surname (if changed)": "Köne familiýaňyz (eger üýtgän bolsa)",
"common.view": "Görmek",
"common.edit": "Üýtgetmek",
"common.delete": "Pozmak",
"common.search": "Gözlemek",
"common.yes": "Hawa",
"common.no": "Ýok",
"loanOrderMobiles.title": "Karz sargytlary",
"loanOrderMobiles.searchPlaceholder": "Gözlemek",
"loanOrderMobiles.createButton": "Karz sargyt dörediň",
"loanOrderMobiles.deleteConfirm": "Bu sargyt pozulsynmy?",
"loanOrderMobiles.columns.id": "ID",
"loanOrderMobiles.columns.loanType": "KARZ GÖRNÜŞI",
"loanOrderMobiles.columns.createdAt": "DÖREDILEN WAGTY",
"loanOrderMobiles.columns.region": "WELAÝAT",
"loanOrderMobiles.columns.branch": "ŞAHAMÇA",
"loanOrderMobiles.columns.firstName": "ADY",
"loanOrderMobiles.columns.lastName": "FAMILIÝASY",
"loanOrderMobiles.columns.phone": "TELEFON",
"loanOrderMobiles.columns.status": "STATUS",
"loanOrderMobiles.filters.region": "WELAÝAT",
"loanOrderMobiles.filters.status": "STATUS",
"loanOrderMobiles.filters.branch": "ŞAHAMÇA",
"loanOrderMobiles.filters.archived": "ARHIWLENEN",
"loanPaidOffLetters.title": "Karzyň ýapylandygy barada güwanamalar",
"loanPaidOffLetters.emptyMessage": "Berlen kriteriýalara Karzyň ýapylandygy barada güwanama almak gabat gelmedi.",
"loanPaidOffLetters.createButton": "Karzyň ýapylandygy barada güwanama almak dörediň",
"loanPaidOffLetters.deleteConfirm": "Bu ýazgy pozulsynmy?",
"loanPaidOffLetters.columns.id": "ID",
"loanPaidOffLetters.columns.passportSeries": "PASPORT SERIÝASY",
"loanPaidOffLetters.columns.passportNumber": "PASPORT BELGISI",
"loanPaidOffLetters.columns.loanAccount": "KARZ HASABY",
"loanPaidOffLetters.columns.issuedAt": "BERLEN WAGTY",
"loanRemaining.title": "Karzyň galyndysy",
"loanRemaining.createButton": "Karzyň galyndysy dörediň",
"loanRemaining.deleteConfirm": "Bu ýazgy pozulsynmy?",
"loanRemaining.columns.id": "ID",
"loanRemaining.columns.passportSeries": "PASPORT SERIÝASY",
"loanRemaining.columns.passportNumber": "PASPORT BELGISI",
"loanRemaining.columns.loanAccount": "KARZ HASABY",
"loanOrderStatus.GARAŞYLÝAR": "GARAŞYLÝAR",
"loanOrderStatus.KANAGATLANDYRYLAN": "KANAGATLANDYRYLAN",
"loanOrderStatus.RED_EDILDI": "RED EDILDI",
"loanOrderStatus.IŞLENÝÄR": "IŞLENÝÄR",
"Dashboards": "Dolandyryş panelleri",
"Card Issuance Reasons": "Kartyň çykarylmagynyň sebäpleri",
"Locale Manager": "Locale dolandyryjy",
"Resources": "Çeşmeler",
"Currency rates": "Walýuta kurslary",
"Loan balance": "Karzyň galyndysy"
}

View File

@@ -1,5 +1,6 @@
import { createRoot } from 'react-dom/client'
import { QueryProvider } from '@/app/providers/QueryProvider'
import { Toaster } from '@/components/ui/sonner'
import '@/lib/i18n'
import './index.css'
import App from './App.tsx'
@@ -7,5 +8,6 @@ import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<QueryProvider>
<App />
<Toaster />
</QueryProvider>
)

View File

@@ -13,7 +13,7 @@ export default function DashboardPage() {
<main className="grid gap-6">
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="p-6 bg-card rounded-lg border border-border shadow-sm flex flex-col relative overflow-hidden">
<div className="p-6 bg-card rounded-md border border-border shadow-sm flex flex-col relative overflow-hidden">
<div className="flex justify-between items-start mb-4">
<h3 className="font-medium text-muted-foreground">{t('Loan orders (all)', 'Karz sargytlary (ählisi)')}</h3>
<div className="bg-accent text-xs px-2 py-1 rounded text-muted-foreground">30 gün</div>
@@ -30,7 +30,7 @@ export default function DashboardPage() {
</div>
</div>
<div className="p-6 bg-card rounded-lg border border-border shadow-sm flex flex-col relative overflow-hidden">
<div className="p-6 bg-card rounded-md border border-border shadow-sm flex flex-col relative overflow-hidden">
<div className="flex justify-between items-start mb-4">
<h3 className="font-medium text-muted-foreground">{t('Loan orders (all)', 'Karz sargytlary (ählisi)')}</h3>
<div className="bg-accent text-xs px-2 py-1 rounded text-muted-foreground">30 gün</div>
@@ -48,7 +48,7 @@ export default function DashboardPage() {
</div>
</div>
<div className="p-6 bg-card rounded-lg border border-border shadow-sm flex flex-col">
<div className="p-6 bg-card rounded-md border border-border shadow-sm flex flex-col">
<div className="flex justify-between items-start mb-4">
<h3 className="font-medium text-muted-foreground">{t('Loan orders (all)', 'Karz sargytlary (ählisi)')}</h3>
<div className="text-xs text-muted-foreground">(6,968 jemi)</div>

View File

@@ -0,0 +1,733 @@
import { useState, useCallback } from 'react'
import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { FormInput } from '@/components/formInput'
import { Button } from '@/components/ui/button'
import { useCreateLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
import type { LoanOrderCreatePayload } from '@/features/loanOrders/api/loanOrdersApi'
import { cn } from '@/lib/utils'
// ─── Section Wrapper ──────────────────────────────────────────────────────────
function Section({ title, children, className }: {
title: string
children: React.ReactNode
className?: string
}) {
return (
<div className={cn('bg-card border border-border rounded-xl overflow-hidden', className)}>
<div className="px-5 py-3.5 border-b border-border">
<h2 className="text-sm font-semibold text-foreground">{title}</h2>
</div>
<div className="p-5">{children}</div>
</div>
)
}
// ─── Grid helpers ─────────────────────────────────────────────────────────────
const grid2 = 'grid grid-cols-1 sm:grid-cols-2 gap-6'
const grid3 = 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6'
const grid4 = 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6'
// ─── Static options ───────────────────────────────────────────────────────────
const REGION_OPTIONS = [
{ value: 'Aşgabat', label: 'Aşgabat' },
{ value: 'Ahal', label: 'Ahal' },
{ value: 'Balkan', label: 'Balkan' },
{ value: 'Daşoguz', label: 'Daşoguz' },
{ value: 'Lebap', label: 'Lebap' },
{ value: 'Mary', label: 'Mary' },
{ value: 'Arkadag', label: 'Arkadag' },
]
const EDUCATION_OPTIONS = [
{ value: 'high', label: 'Ýokary bilim' },
{ value: 'unfinished_high', label: 'Gutarylmadyk ýokary bilim' },
{ value: 'masters', label: 'Magistr' },
{ value: 'phd', label: 'Ylymlaryň doktory' },
{ value: 'middle', label: 'Orta mekdep' },
{ value: 'school', label: 'Orta bilim' },
{ value: 'school_dropout', label: 'Gutarylmadyk orta bilim' },
]
const MARRIAGE_OPTIONS = [
{ value: 'MARRIED', label: 'Öýlenen / Durmuşa çykan' },
{ value: 'SINGLE', label: 'Öýlenmedik / Durmuşa çykmadyk' },
{ value: 'DIVORCED', label: 'Aýrylşan' },
{ value: 'WIDOW', label: 'Adamsy ýa-da aýaly aradan çykan'},
{ value: 'LEGAL', label: 'Raýat nika' },
]
const STATUS_OPTIONS = [
{ value: 'GARAŞYLÝAR', label: 'Garaşylýar' },
{ value: 'IŞLENÝÄR', label: 'Işlenýär' },
{ value: 'KANAGATLANDYRYLAN', label: 'Kanagatlandyrylan' },
{ value: 'RED_EDILDI', label: 'Red edildi' },
]
const LOAN_TYPE_OPTIONS = [
{ value: 'consumer', label: 'Sarp ediş karzy' },
{ value: 'mortgage', label: 'Ipoteka' },
{ value: 'car', label: 'Awtoulag karzy' },
{ value: 'student', label: 'Talyplar üçin' },
{ value: 'business', label: 'Işewürlik karzy' },
]
const PASSPORT_SERIES_OPTIONS = [
{ value: 'I', label: 'I' },
{ value: 'II', label: 'II' },
]
// ─── Form State Types ─────────────────────────────────────────────────────────
interface FormState {
// Status & unique
status: string
uniqueCode: string
// Loan
loanType: string
// Location
region: string
branch: string
// Personal
firstName: string
lastName: string
patronicName: string
education: string
marriageStatus: string
dateOfBirth: string
residence: string
currentResidence: string
// Passport
passportSerie: string
passportNumber: string
passportDateOfIssue: string
passportGivenBy: string
bornPlace: string
// Contact
email: string
phone: string
phoneAdditional: string
homePhone: string
// Job
workCompany: string
workHrPhone: string
workRegion: string
workProvince: string
position: string
salary: string
workStartedAt: string
// Files
passportPage1: File | null
passportPage23: File | null
passportPage89: File | null
passportPage32: File | null
}
type FormErrors = Partial<Record<keyof FormState, string>>
const INITIAL_STATE: FormState = {
status: 'GARAŞYLÝAR',
uniqueCode: '',
loanType: '',
region: 'Aşgabat',
branch: '',
firstName: '',
lastName: '',
patronicName: '',
education: '',
marriageStatus: '',
dateOfBirth: '',
residence: '',
currentResidence: '',
passportSerie: '',
passportNumber: '',
passportDateOfIssue: '',
passportGivenBy: '',
bornPlace: '',
email: '',
phone: '',
phoneAdditional: '',
homePhone: '',
workCompany: '',
workHrPhone: '',
workRegion: 'Aşgabat',
workProvince: '',
position: '',
salary: '',
workStartedAt: '',
passportPage1: null,
passportPage23: null,
passportPage89: null,
passportPage32: null,
}
// ─── Validation ───────────────────────────────────────────────────────────────
function validate(form: FormState, t: (k: string) => string): FormErrors {
const errors: FormErrors = {}
const req = (key: keyof FormState, label: string) => {
const val = form[key]
if (!val || (typeof val === 'string' && !val.trim())) {
errors[key] = `${label} — ${t('required') || 'hökmany'}`
}
}
req('loanType', t('Loan type') || 'Karz görnüşi')
req('region', t('Region') || 'Welaýat')
req('branch', t('Branch') || 'Şahamça')
req('firstName', t('Name') || 'Ady')
req('lastName', t('Surname') || 'Familiýasy')
req('education', t('Education') || 'Bilimi')
req('marriageStatus', t('Marriage status') || 'Maşgala ýagdaýy')
req('dateOfBirth', t('Date of birth') || 'Doglan güni')
req('residence', t('Residence (passport)') || 'Ýazgy edilen salgy')
req('passportSerie', t('Passport serie') || 'Pasport seriýasy')
req('passportNumber', t('Passport number') || 'Pasport belgisi')
req('passportDateOfIssue', t('Passport date of issue') || 'Pasport berlen senesi')
req('passportGivenBy', t('Passport given by') || 'Kim tarapyndan berildi')
req('phone', t('Phone') || 'Telefon')
req('workCompany', t('Work company name') || 'Kärhananyň ady')
req('position', t('Position') || 'Wezipe')
req('salary', t('Salary') || 'Zähmet haky')
req('workStartedAt', t('Work started at') || 'Işe başlan wagty')
if (form.phone && form.phone.replace(/\D/g, '').length < 8) {
errors.phone = 'Telefon belgisi nädogry'
}
if (!form.passportPage1) errors.passportPage1 = 'Pasport (sahypa 1) hökmany'
if (!form.passportPage23) errors.passportPage23 = 'Pasport (sahypa 2-3) hökmany'
return errors
}
// ─── Page ─────────────────────────────────────────────────────────────────────
export default function LoanOrderCreatePage() {
const { t } = useTranslation()
const navigate = useNavigate()
const createMutation = useCreateLoanOrder()
const [form, setForm] = useState<FormState>(INITIAL_STATE)
const [errors, setErrors] = useState<FormErrors>({})
const [submitted, setSubmitted] = useState(false)
// Generic field updater
const set = useCallback(<K extends keyof FormState>(key: K, value: FormState[K]) => {
setForm((prev) => ({ ...prev, [key]: value }))
// Clear error on change
if (submitted) {
setErrors((prev) => ({ ...prev, [key]: undefined }))
}
}, [submitted])
const handleSubmit = () => {
setSubmitted(true)
const errs = validate(form, t)
if (Object.keys(errs).length > 0) {
setErrors(errs)
toast.error(t('Write a correct data please') || 'Dogry maglumat girizmegiňizi haýyş edýäris.')
// scroll to first error
const firstErrorKey = Object.keys(errs)[0]
document.getElementById(`field-${firstErrorKey}`)?.scrollIntoView({ behavior: 'smooth', block: 'center' })
return
}
const payload: LoanOrderCreatePayload = {
status: form.status,
loanType: form.loanType,
region: form.region,
branch: form.branch,
firstName: form.firstName,
lastName: form.lastName,
patronicName: form.patronicName,
education: form.education,
marriageStatus: form.marriageStatus,
dateOfBirth: form.dateOfBirth,
residence: form.residence,
currentResidence: form.currentResidence,
passportSerie: form.passportSerie,
passportNumber: form.passportNumber,
passportDateOfIssue: form.passportDateOfIssue,
passportGivenBy: form.passportGivenBy,
bornPlace: form.bornPlace,
email: form.email,
phone: form.phone,
phoneAdditional: form.phoneAdditional,
homePhone: form.homePhone,
workCompany: form.workCompany,
workHrPhone: form.workHrPhone,
workRegion: form.workRegion,
workProvince: form.workProvince,
position: form.position,
salary: Number(form.salary),
workStartedAt: form.workStartedAt,
}
createMutation.mutate(payload, {
onSuccess: () => {
toast.success(t('Loan order created') || 'Karz sargydy döredildi')
navigate('/resources/loan-orders')
},
onError: () => {
toast.error(t('Server Error') || 'Serwer ýalňyşlygy')
},
})
}
// ── Render ────────────────────────────────────────────────────────────────
return (
<div className="flex flex-col gap-5">
{/* Page title */}
<div>
<h1 className="text-xl font-semibold text-foreground">
{t('Loan order') || 'Karz sargyt döredüň'}
</h1>
</div>
{/* ── Status & Unique ──────────────────────────────────────────────── */}
<Section title={t('New Loan Order') || 'Täze Karz sargyt'}>
<div className={grid2}>
<div id="field-status">
<FormInput
type="select"
label={t('Status') || 'Status'}
required
value={form.status}
onChange={(v) => set('status', v)}
options={STATUS_OPTIONS}
error={errors.status}
placeholder="Saýlaň"
/>
</div>
<div id="field-uniqueCode">
<FormInput
type="text"
label={t('Unique code') || 'Unikal belgi'}
value={form.uniqueCode}
onChange={(v) => set('uniqueCode', v)}
placeholder={t('Unique code') || 'Bellik'}
error={errors.uniqueCode}
/>
</div>
</div>
</Section>
{/* ── Loan Type ────────────────────────────────────────────────────── */}
<Section title={t('Loan') || 'Karz'}>
<div id="field-loanType">
<FormInput
type="searchable-select"
label={t('Loan type') || 'Karz görnüşi'}
required
value={form.loanType}
onChange={(v) => set('loanType', v)}
options={LOAN_TYPE_OPTIONS}
placeholder="Saýlamak üçin basyň"
error={errors.loanType}
/>
</div>
</Section>
{/* ── Location ─────────────────────────────────────────────────────── */}
<Section title={t('Location') || 'Lokasiýa'}>
<div className={grid2}>
<div id="field-region">
<FormInput
type="searchable-select"
label={t('Region') || 'Welaýat'}
required
value={form.region}
onChange={(v) => set('region', v)}
options={REGION_OPTIONS}
placeholder="Saýlamak üçin basyň"
error={errors.region}
/>
</div>
<div id="field-branch">
<FormInput
type="searchable-select"
label={t('Branch') || 'Şahamça'}
required
value={form.branch}
onChange={(v) => set('branch', v)}
options={[]}
placeholder="Saýlamak üçin basyň"
error={errors.branch}
/>
</div>
</div>
</Section>
{/* ── Personal Data ─────────────────────────────────────────────────── */}
<Section title={t('Personal data') || 'Şahsy maglumatlar'}>
<div className="flex flex-col gap-6">
<div className={grid3}>
<div id="field-firstName">
<FormInput
type="text"
label={t('Name') || 'Ady'}
required
value={form.firstName}
onChange={(v) => set('firstName', v)}
placeholder={t('Name') || 'Ady'}
error={errors.firstName}
/>
</div>
<div id="field-lastName">
<FormInput
type="text"
label={t('Surname') || 'Familiýasy'}
required
value={form.lastName}
onChange={(v) => set('lastName', v)}
placeholder={t('Surname') || 'Familiýasy'}
error={errors.lastName}
/>
</div>
<div id="field-patronicName">
<FormInput
type="text"
label={t('Patronic name') || 'Atasynyň ady'}
value={form.patronicName}
onChange={(v) => set('patronicName', v)}
placeholder={t('Patronic name') || 'Atasynyň ady'}
/>
</div>
</div>
<div className={grid3}>
<div id="field-education">
<FormInput
type="select"
label={t('Education') || 'Bilimi'}
required
value={form.education}
onChange={(v) => set('education', v)}
options={EDUCATION_OPTIONS}
placeholder="Saýlaň"
error={errors.education}
/>
</div>
<div id="field-marriageStatus">
<FormInput
type="select"
label={t('Marriage status') || 'Maşgala ýagdaýy'}
required
value={form.marriageStatus}
onChange={(v) => set('marriageStatus', v)}
options={MARRIAGE_OPTIONS}
placeholder="Saýlaň"
error={errors.marriageStatus}
/>
</div>
<div id="field-dateOfBirth">
<FormInput
type="date"
label={t('Date of birth') || 'Doglan güni'}
required
value={form.dateOfBirth}
onChange={(v) => set('dateOfBirth', v)}
error={errors.dateOfBirth}
/>
</div>
</div>
<div className={grid2}>
<div id="field-residence">
<FormInput
type="text"
label={t('Residence (passport)') || 'Ýazgy edilen salgyňyz'}
required
value={form.residence}
onChange={(v) => set('residence', v)}
placeholder={t('Residence (passport)') || 'Ýazgy edilen salgyňyz'}
error={errors.residence}
/>
</div>
<div id="field-currentResidence">
<FormInput
type="text"
label={t('Current Residence') || 'Häzirki ýaşaýyş ýeri'}
value={form.currentResidence}
onChange={(v) => set('currentResidence', v)}
placeholder={t('Current Residence') || 'Häzirki ýaşaýyş ýeri'}
/>
</div>
</div>
</div>
</Section>
{/* ── Passport ──────────────────────────────────────────────────────── */}
<Section title={t('Passport') || 'Pasport'}>
<div className="flex flex-col gap-6">
<div className={grid3}>
<div id="field-passportSerie">
<FormInput
type="searchable-select"
label={t('Passport serie') || 'Pasport seriýasy'}
required
value={form.passportSerie}
onChange={(v) => set('passportSerie', v)}
options={PASSPORT_SERIES_OPTIONS}
placeholder="Saýlamak üçin basyň"
error={errors.passportSerie}
/>
</div>
<div id="field-passportNumber">
<FormInput
type="text"
label={t('Passport number') || 'Pasport belgisi'}
required
value={form.passportNumber}
onChange={(v) => set('passportNumber', v)}
placeholder={t('Passport number') || 'Pasport belgisi'}
error={errors.passportNumber}
/>
</div>
<div id="field-passportDateOfIssue">
<FormInput
type="date"
label={t('Passport date of issue') || 'Pasport berlen senesi'}
required
value={form.passportDateOfIssue}
onChange={(v) => set('passportDateOfIssue', v)}
error={errors.passportDateOfIssue}
/>
</div>
</div>
<div className={grid2}>
<div id="field-passportGivenBy">
<FormInput
type="text"
label={t('Passport given by') || 'Kim tarapyndan berildi'}
required
value={form.passportGivenBy}
onChange={(v) => set('passportGivenBy', v)}
placeholder={t('Passport given by') || 'Kim tarapyndan berildi'}
error={errors.passportGivenBy}
/>
</div>
<div id="field-bornPlace">
<FormInput
type="text"
label={t('Born place (passport)') || 'Doglan ýeri (pasport)'}
value={form.bornPlace}
onChange={(v) => set('bornPlace', v)}
placeholder={t('Born place (passport)') || 'Doglan ýeri (pasport)'}
/>
</div>
</div>
</div>
</Section>
{/* ── Contact ───────────────────────────────────────────────────────── */}
<Section title={t('Contact data') || 'Habarlaşmak üçin maglumatlar'}>
<div className={grid4}>
<div id="field-email">
<FormInput
type="email"
label={t('Email') || 'E-poçta'}
value={form.email}
onChange={(v) => set('email', v)}
placeholder="E-poçta"
/>
</div>
<div id="field-phone">
<FormInput
type="phone"
label={t('Phone') || 'Telefon'}
required
value={form.phone}
onChange={(v) => set('phone', v)}
placeholder="61 097 651"
error={errors.phone}
/>
</div>
<div id="field-phoneAdditional">
<FormInput
type="phone"
label={t('Phone Additional') || 'Telefon goşmaça'}
value={form.phoneAdditional}
onChange={(v) => set('phoneAdditional', v)}
placeholder="61 097 651"
/>
</div>
<div id="field-homePhone">
<FormInput
type="phone"
label={t('Home phone') || 'Öý telefony'}
value={form.homePhone}
onChange={(v) => set('homePhone', v)}
placeholder="61 097 651"
/>
</div>
</div>
</Section>
{/* ── Job ───────────────────────────────────────────────────────────── */}
<Section title={t('Job') || 'Iş'}>
<div className="flex flex-col gap-6">
<div className={grid2}>
<div id="field-workCompany">
<FormInput
type="text"
label={t('Work company name') || 'Işleýän edaranyň/kärhananyň ady'}
required
value={form.workCompany}
onChange={(v) => set('workCompany', v)}
placeholder={t('Work company name') || 'Işleýän edaranyň/kärhananyň ady'}
error={errors.workCompany}
/>
</div>
<div id="field-workHrPhone">
<FormInput
type="phone"
label={t('HR department work number') || 'Işgärler bölüminiň iş belgisi'}
value={form.workHrPhone}
onChange={(v) => set('workHrPhone', v)}
placeholder="61 097 651"
/>
</div>
</div>
<div className={grid2}>
<div id="field-workRegion">
<FormInput
type="searchable-select"
label={t('Work region') || 'Işleýän welaýatyňyz'}
value={form.workRegion}
onChange={(v) => set('workRegion', v)}
options={REGION_OPTIONS}
placeholder="Saýlamak üçin basyň"
/>
</div>
<div id="field-workProvince">
<FormInput
type="searchable-select"
label={t('Work province') || 'Işleýän etrabyňyz'}
value={form.workProvince}
onChange={(v) => set('workProvince', v)}
options={[]}
placeholder="Saýlamak üçin basyň"
/>
</div>
</div>
<div className={grid3}>
<div id="field-position">
<FormInput
type="text"
label={t('Position') || 'Wezipe'}
required
value={form.position}
onChange={(v) => set('position', v)}
placeholder={t('Position') || 'Wezipe'}
error={errors.position}
/>
</div>
<div id="field-salary">
<FormInput
type="number"
label={t('Salary') || 'Zähmet haky'}
required
value={form.salary}
onChange={(v) => set('salary', v)}
placeholder={t('Salary') || 'Zähmet haky'}
error={errors.salary}
/>
</div>
<div id="field-workStartedAt">
<FormInput
type="date"
label={t('Work started at') || 'Işe başlan wagtyňyz'}
required
value={form.workStartedAt}
onChange={(v) => set('workStartedAt', v)}
error={errors.workStartedAt}
/>
</div>
</div>
</div>
</Section>
{/* ── Passport Files ────────────────────────────────────────────────── */}
<Section title={t('Passport files') || 'Pasport faýýlar'}>
<div className={grid2}>
<div id="field-passportPage1">
<FormInput
type="file"
label={t('Passport (page 1)') || 'Pasport (sahypa 1)'}
required
accept="image/*"
fileValue={form.passportPage1}
onFileChange={(f) => set('passportPage1', f)}
placeholder="Faýl saýlaň ýa-da salmak üçin basyň"
error={errors.passportPage1}
/>
</div>
<div id="field-passportPage23">
<FormInput
type="file"
label={t('Passport (page 2-3)') || 'Pasport (2-3-nji sahypa)'}
required
accept="image/*"
fileValue={form.passportPage23}
onFileChange={(f) => set('passportPage23', f)}
placeholder="Faýl saýlaň ýa-da salmak üçin basyň"
error={errors.passportPage23}
/>
</div>
<div id="field-passportPage89">
<FormInput
type="file"
label={t('Passport (page 8-9)') || 'Pasport (8-9 sahypa)'}
accept="image/*"
fileValue={form.passportPage89}
onFileChange={(f) => set('passportPage89', f)}
placeholder="Faýl saýlaň ýa-da salmak üçin basyň"
/>
</div>
<div id="field-passportPage32">
<FormInput
type="file"
label={t('Passport (page 32)') || 'Pasport (32-nji sahypa)'}
accept="image/*"
fileValue={form.passportPage32}
onFileChange={(f) => set('passportPage32', f)}
placeholder="Faýl saýlaň ýa-da salmak üçin basyň"
/>
</div>
</div>
</Section>
{/* ── Footer Actions ────────────────────────────────────────────────── */}
<div className="flex items-center justify-end gap-3 pb-8">
<Button
type="button"
variant="outline"
onClick={() => navigate(-1)}
disabled={createMutation.isPending}
>
{t('Cancel') || 'Ýatyr'}
</Button>
<Button
type="button"
onClick={handleSubmit}
disabled={createMutation.isPending}
className="min-w-[160px]"
>
{createMutation.isPending
? (t('Loading') || 'Ýüklenilýär...')
: (t('loanOrderMobiles.createButton') || 'Karz sargyt döredüň')}
</Button>
</div>
</div>
)
}

View File

@@ -28,21 +28,9 @@ const COLUMN_IDS = [
// ─── Filter options ────────────────────────────────────────────────────────────
const REGION_OPTIONS = [
{ value: 'Balkan', label: 'Balkan' },
{ value: 'Ahal', label: 'Ahal' },
{ value: 'Daşoguz', label: 'Daşoguz' },
{ value: 'Lebap', label: 'Lebap' },
{ value: 'Mary', label: 'Mary' },
{ value: 'Aşgabat', label: 'Aşgabat' },
]
const STATUS_OPTIONS: { value: LoanOrderMobileStatus; label: string }[] = [
{ value: 'GARAŞYLÝAR', label: 'GARAŞYLÝAR' },
{ value: 'KANAGATLANDYRYLAN', label: 'KANAGATLANDYRYLAN' },
{ value: 'RED_EDILDI', label: 'RED EDILDI' },
{ value: 'IŞLENÝÄR', label: 'IŞLENÝÄR' },
]
// ─── Filter options (Internal keys/values) ───────────────────────────────────
const REGION_OPTIONS = ['Balkan', 'Ahal', 'Daşoguz', 'Lebap', 'Mary', 'Aşgabat']
const STATUS_OPTIONS: LoanOrderMobileStatus[] = ['GARAŞYLÝAR', 'KANAGATLANDYRYLAN', 'RED_EDILDI', 'IŞLENÝÄR']
// ─── Page Component ────────────────────────────────────────────────────────────
@@ -105,7 +93,7 @@ export default function LoanOrderMobilesPage() {
{
id: 'id',
accessorKey: 'id',
header: t('ID', 'ID'),
header: t('loanOrderMobiles.columns.id', 'ID'),
cell: ({ row }) => (
<span className="text-xs font-mono text-muted-foreground">{row.original.id}</span>
),
@@ -189,13 +177,13 @@ export default function LoanOrderMobilesPage() {
cell: ({ row }) => (
<div className="flex items-center gap-1.5 justify-end">
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t('common.view', 'Görmek')}
>
<Eye size={15} />
</button>
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t('common.edit', 'Üýtgetmek')}
>
<Pencil size={15} />
@@ -203,7 +191,7 @@ export default function LoanOrderMobilesPage() {
<button
onClick={() => handleDelete(row.original.id)}
disabled={deleteMutation.isPending}
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
className="p-1.5 cursor-pointer rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
title={t('common.delete', 'Pozmak')}
>
<Trash2 size={15} />
@@ -227,12 +215,12 @@ export default function LoanOrderMobilesPage() {
{
id: 'region',
label: t('loanOrderMobiles.filters.region', 'WELAÝAT'),
options: REGION_OPTIONS,
options: REGION_OPTIONS.map((v) => ({ value: v, label: t(v) })),
},
{
id: 'status',
label: t('loanOrderMobiles.filters.status', 'STATUS'),
options: STATUS_OPTIONS,
options: STATUS_OPTIONS.map((v) => ({ value: v, label: t(`loanOrderStatus.${v}`) })),
},
{
id: 'branch',
@@ -266,7 +254,7 @@ export default function LoanOrderMobilesPage() {
<DataTableToolbar
searchValue={search}
onSearchChange={(v) => { setSearch(v); setPage(1) }}
searchPlaceholder={t('loanOrderMobiles.searchPlaceholder', 'Gözlemek')}
searchPlaceholder={t('common.search', 'Gözlemek')}
columns={toggleableColumns}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}

View File

@@ -0,0 +1,412 @@
import { useNavigate, useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Trash2, Pencil, Download, ChevronRight, Eye } from 'lucide-react'
import { useLoanOrderById, useDeleteLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
import { LoanOrderStatusBadge } from '@/features/loanOrders/components/loanOrderStatusBadge'
import { Skeleton } from '@/components/ui/skeleton'
import { toast } from 'sonner'
// ─── Sub-component Types ──────────────────────────────────────────────────────
interface InfoRowProps {
label: string
value?: string | null
isLink?: boolean
}
interface SectionProps {
title: string
children: React.ReactNode
}
interface PassportImageProps {
label: string
src?: string | null
}
interface AuditRowProps {
id: string
action: string
by: string
target: string
status: string
date: string
}
// ─── InfoRow ─────────────────────────────────────────────────────────────────
function InfoRow({ label, value, isLink }: InfoRowProps) {
return (
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
<span className="text-sm text-muted-foreground">{label}</span>
{value ? (
<span className={`text-sm ${isLink ? 'text-primary font-medium' : 'text-foreground'}`}>
{value}
</span>
) : (
<span className="text-muted-foreground/40 text-sm">—</span>
)}
</div>
)
}
// ─── Section ─────────────────────────────────────────────────────────────────
function Section({ title, children }: SectionProps) {
return (
<div className="mb-6">
<h2 className="text-base font-semibold text-foreground mb-2">{title}</h2>
<div className="bg-card border border-border rounded-xl overflow-hidden">{children}</div>
</div>
)
}
// ─── PassportImage ────────────────────────────────────────────────────────────
function PassportImage({ label, src }: PassportImageProps) {
const { t } = useTranslation()
return (
<div className="grid grid-cols-[220px_1fr] items-start py-3 px-4 border-b border-border last:border-0">
<span className="text-sm text-muted-foreground pt-1">{label}</span>
<div className="flex flex-col gap-2">
{src ? (
<img
src={src}
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>
</div>
)}
<button className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit">
<Download size={12} />
{t('common.download', 'Göçürip al')}
</button>
</div>
</div>
)
}
// ─── AuditRow ─────────────────────────────────────────────────────────────────
function AuditRow({ id, action, by, target, status, date }: AuditRowProps) {
return (
<tr className="border-b border-border last:border-0 hover:bg-muted/30 transition-colors">
<td className="px-4 py-2.5 text-xs font-mono text-primary">{id}</td>
<td className="px-4 py-2.5 text-sm text-foreground">{action}</td>
<td className="px-4 py-2.5 text-sm text-foreground">{by}</td>
<td className="px-4 py-2.5 text-sm text-foreground">{target}</td>
<td className="px-4 py-2.5">
<span className="inline-flex items-center gap-1.5 text-xs font-medium text-emerald-400 bg-emerald-400/10 border border-emerald-400/30 px-2 py-0.5 rounded-full">
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
{status}
</span>
</td>
<td className="px-4 py-2.5 text-xs text-muted-foreground whitespace-nowrap">{date}</td>
<td className="px-4 py-2.5">
<button className="p-1 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors">
<Eye size={13} />
</button>
</td>
</tr>
)
}
// ─── Skeleton ─────────────────────────────────────────────────────────────────
function LoanOrderViewSkeleton() {
return (
<div className="flex flex-col gap-4">
<Skeleton className="h-7 w-64" />
{[...Array(5)].map((_, i) => (
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
<Skeleton className="h-4 w-32 mb-1" />
{[...Array(3)].map((_, j) => (
<Skeleton key={j} className="h-4 w-full" />
))}
</div>
))}
</div>
)
}
// ─── Page ─────────────────────────────────────────────────────────────────────
export default function LoanOrderViewPage() {
const { t } = useTranslation()
const navigate = useNavigate()
const { id } = useParams<{ id: string }>()
const deleteMutation = useDeleteLoanOrder()
const { data: order, isLoading } = useLoanOrderById(id!)
const handleDelete = () => {
if (!window.confirm(t('loanOrders.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
deleteMutation.mutate(id!, {
onSuccess: () => {
toast.success(t('loanOrders.deleteSuccess', 'Sargyt pozuldy'))
navigate('/loan-orders')
},
onError: () => {
toast.error(t('loanOrders.deleteError', 'Pozma wagty ýalňyşlyk ýüze çykdy'))
},
})
}
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>
)
}
// Replace with real audit data from API when available
const auditLogs: AuditRowProps[] = [
{
id: '44548',
action: t('audit.actions.view', 'Görmek'),
by: order.createdBy ?? '',
target: `${t('loanOrders.title', 'Karz sargyt')}: ${order.id}`,
status: 'FINISHED',
date: order.createdAt ?? '',
},
]
return (
<div className="flex flex-col">
{/* Page Header */}
<div className="flex items-center justify-between mb-5">
<h1 className="text-xl font-semibold text-foreground">
{t('loanOrders.view.title', 'Karz sargyt giriş')}: {order.id}
</h1>
<div className="flex items-center gap-1.5">
<button
onClick={handleDelete}
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')}
>
<Trash2 size={16} />
</button>
<button
onClick={() => navigate(`/loan-orders/${order.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')}
>
<Pencil size={16} />
</button>
</div>
</div>
{/* ── Basic Info ─────────────────────────────────────────────────────── */}
<div className="bg-card border border-border rounded-xl overflow-hidden mb-6">
<InfoRow label="ID" value={order.id} />
<InfoRow
label={t('loanOrders.columns.createdAt', 'Döredilen wagty')}
value={order.createdAt}
/>
{/* Status row — special render */}
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
<span className="text-sm text-muted-foreground">
{t('loanOrders.columns.status', 'Status')}
</span>
<LoanOrderStatusBadge status={order.status} />
</div>
<InfoRow
label={t('loanOrders.fields.amount', 'Berlik')}
value={order.amount ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.createdBy', 'Sargyt eden')}
value={order.createdBy ?? undefined}
isLink
/>
</div>
{/* ── Loan ───────────────────────────────────────────────────────────── */}
<Section title={t('loanOrders.sections.loan', 'Karz')}>
<InfoRow
label={t('loanOrders.columns.loanType', 'Karz görnüşi')}
value={order.loanType}
isLink
/>
<InfoRow
label={t('loanOrders.fields.loanAmount', 'Karz mukdary')}
value={order.loanAmount ?? undefined}
/>
</Section>
{/* ── Location ───────────────────────────────────────────────────────── */}
<Section title={t('loanOrders.sections.location', 'Lokasiýa')}>
<InfoRow label={t('loanOrders.columns.region', 'Welaýat')} value={order.region} />
<InfoRow
label={t('loanOrders.columns.branch', 'Şahamça')}
value={order.branch}
isLink
/>
</Section>
{/* ── Personal Info ──────────────────────────────────────────────────── */}
<Section 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ňyz')}
value={order.registeredAddress ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.currentAddress', 'Häzirki ýaşaýyş ýeri')}
value={order.currentAddress ?? undefined}
/>
</Section>
{/* ── Contacts ───────────────────────────────────────────────────────── */}
<Section title={t('loanOrders.sections.contacts', 'Habarlaşmak üçin maglumatlar')}>
<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}
/>
</Section>
{/* ── Employment ─────────────────────────────────────────────────────── */}
<Section title={t('loanOrders.sections.employment', 'Iş')}>
<InfoRow
label={t('loanOrders.fields.employer', 'Işleýän edaranyň/kärhananyn ady')}
value={order.employer ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.deptPhone', 'Işgärler bölüminiň iş belgisi')}
value={order.deptPhone ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.workRegion', 'Işleýän welaýatyňyz')}
value={order.workRegion ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.workCity', 'Işleýän etrabyňyz')}
value={order.workCity ?? undefined}
isLink
/>
<InfoRow
label={t('loanOrders.fields.position', 'Wezipe')}
value={order.position ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.salary', 'Zähmet haky')}
value={order.salary ?? undefined}
/>
<InfoRow
label={t('loanOrders.fields.employedSince', 'Işe başlan wagtyňyz')}
value={order.employedSince ?? undefined}
/>
</Section>
{/* ── Passport ───────────────────────────────────────────────────────── */}
<Section 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.passportBirthPlace', 'Doglan ýeri (pasport)')}
value={order.passportBirthPlace ?? undefined}
/>
<PassportImage
label={t('loanOrders.fields.passportPage1', 'Pasport (sahypa 1)')}
src={order.passportPage1Url ?? undefined}
/>
<PassportImage
label={t('loanOrders.fields.passportPage23', 'Pasport (2-3-nji sahypa)')}
src={order.passportPage23Url ?? undefined}
/>
<PassportImage
label={t('loanOrders.fields.passportPage89', 'Pasport (8-9 sahypa)')}
src={order.passportPage89Url ?? undefined}
/>
<PassportImage
label={t('loanOrders.fields.passportPage32', 'Pasport (32-nji sahypa)')}
src={order.passportPage32Url ?? undefined}
/>
</Section>
{/* ── Audit Log ──────────────────────────────────────────────────────── */}
<div className="mb-6">
<details open>
<summary className="text-base font-semibold text-foreground mb-2 cursor-pointer select-none list-none flex items-center gap-1.5 w-fit">
{t('loanOrders.sections.audit', 'Ammallar')}
<ChevronRight size={15} className="text-muted-foreground" />
</summary>
<div className="bg-card border border-border rounded-xl overflow-hidden mt-2">
<div className="overflow-x-auto">
<table className="w-full text-sm">
<thead>
<tr className="border-b border-border bg-muted/30">
{[
'ID',
t('audit.columns.action', 'AMALYŇ ADY'),
t('audit.columns.by', 'KIM TARAPYNDAN'),
t('audit.columns.target', 'AMALYŇ NYŞANY (TARIBESI)'),
t('audit.columns.status', 'AMALYŇ STATUSY'),
t('audit.columns.date', 'SENE'),
'',
].map((col, i) => (
<th
key={i}
className="px-4 py-2.5 text-left text-xs font-medium text-muted-foreground uppercase tracking-wide whitespace-nowrap"
>
{col}
</th>
))}
</tr>
</thead>
<tbody>
{auditLogs.map((log) => (
<AuditRow key={log.id} {...log} />
))}
</tbody>
</table>
</div>
<div className="flex items-center justify-between px-4 py-2.5 border-t border-border text-xs text-muted-foreground">
<span>{t('common.prev', 'Öňki')}</span>
<span>1–{auditLogs.length} / {auditLogs.length}</span>
<span>{t('common.next', 'Soňky')}</span>
</div>
</div>
</details>
</div>
</div>
)
}

View File

@@ -1,4 +1,5 @@
import { useState, useMemo, useCallback } from 'react'
import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Eye, Pencil, Trash2 } from 'lucide-react'
import type { ColumnDef, VisibilityState } from '@tanstack/react-table'
@@ -38,12 +39,13 @@ const STATUS_OPTIONS: { value: LoanOrderStatus; label: string }[] = [
export default function LoanOrdersPage() {
const { t } = useTranslation()
const navigate = useNavigate()
const deleteMutation = useDeleteLoanOrder()
// ── State ──────────────────────────────────────────────────────────────────
const [search, setSearch] = useState('')
const [page, setPage] = useState(1)
const [perPage, setPerPage] = useState(25)
const [perPage, setPerPage] = useState(10)
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({})
const [columnOrder, setColumnOrder] = useState<string[]>([...COLUMN_IDS])
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([
@@ -180,13 +182,14 @@ export default function LoanOrdersPage() {
cell: ({ row }) => (
<div className="flex items-center gap-1.5 justify-end">
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t('common.view', 'View')}
onClick={() => navigate(`/loan-orders/${row.original.id}`)}
>
<Eye size={15} />
</button>
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t('common.edit', 'Edit')}
>
<Pencil size={15} />
@@ -194,7 +197,7 @@ export default function LoanOrdersPage() {
<button
onClick={() => handleDelete(row.original.id)}
disabled={deleteMutation.isPending}
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
className="p-1.5 cursor-pointer rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
title={t('common.delete', 'Delete')}
>
<Trash2 size={15} />
@@ -272,7 +275,7 @@ export default function LoanOrdersPage() {
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
actionLabel={t('loanOrders.createButton', 'Karz sargyt dörediñ')}
onAction={() => {
// navigate to create page or open modal
navigate('/loan-orders/create')
}}
/>

View File

@@ -44,7 +44,7 @@ function EmptyState({ onCreate }: { onCreate: () => void }) {
</p>
<button
onClick={onCreate}
className="px-4 py-2 rounded-lg border border-border text-sm text-foreground hover:bg-muted/60 transition-colors"
className="px-4 py-2 rounded-md border border-border text-sm text-foreground hover:bg-muted/60 transition-colors"
>
{t(
"loanPaidOffLetters.createButton",
@@ -179,13 +179,13 @@ export default function LoanPaidOffLettersPage() {
cell: ({ row }) => (
<div className="flex items-center gap-1.5 justify-end">
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t("common.view", "Görmek")}
>
<Eye size={15} />
</button>
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t("common.edit", "Üýtgetmek")}
>
<Pencil size={15} />
@@ -193,7 +193,7 @@ export default function LoanPaidOffLettersPage() {
<button
onClick={() => handleDelete(row.original.id)}
disabled={deleteMutation.isPending}
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
className="p-1.5 cursor-pointer rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
title={t("common.delete", "Pozmak")}
>
<Trash2 size={15} />

View File

@@ -99,13 +99,13 @@ export default function LoanRemainingPage() {
cell: ({ row }) => (
<div className="flex items-center gap-1.5 justify-end">
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t('common.view', 'Görmek')}
>
<Eye size={15} />
</button>
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
title={t('common.edit', 'Üýtgetmek')}
>
<Pencil size={15} />
@@ -113,7 +113,7 @@ export default function LoanRemainingPage() {
<button
onClick={() => handleDelete(row.original.id)}
disabled={deleteMutation.isPending}
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
className="p-1.5 cursor-pointer rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
title={t('common.delete', 'Pozmak')}
>
<Trash2 size={15} />

View File

@@ -82,7 +82,7 @@ function FormInput({
<Input
value={value}
onChange={(e) => onChange(e.target.value)}
className="bg-background border-input focus-visible:ring-primary"
className="bg-background border-input focus-visible:ring-primary h-11"
{...props}
/>
</div>
@@ -106,8 +106,12 @@ export default function AuthPage() {
}
loginMutation.mutate({ email: username, password }, {
onError: () => {
toast.error(t("Server Error", "An error occurred during login"));
onSuccess: () => {
toast.success(t("Success login", "Login successful"));
},
onError: (error: any) => {
const message = error?.response?.data?.message || t("Server Error", "An error occurred during login");
toast.error(message);
}
});
};
@@ -124,7 +128,8 @@ export default function AuthPage() {
<LeftPanel />
<div className="w-full md:w-[45%] flex flex-col bg-background">
<div className="flex-1 flex flex-col justify-center px-8 sm:px-12 py-10 overflow-y-auto">
<div className="flex-1 flex flex-col justify-center items-center px-8 sm:px-12 py-10 overflow-y-auto">
<div className="w-full max-w-[400px]">
{view === "login" && (
<>
<h2 className="text-[22px] font-normal text-foreground text-center mb-2 tracking-wide uppercase">
@@ -154,14 +159,14 @@ export default function AuthPage() {
</span>
</div>
<div className="flex flex-col gap-3">
<Button onClick={handleLogin} disabled={loginMutation.isPending}>
{loginMutation.isPending ? t("Loading") + "..." : t("Login")}
</Button>
<Button variant="outline" onClick={() => setView("register")}>
{t("Register")}
</Button>
</div>
<div className="flex flex-col gap-3">
<Button onClick={handleLogin} disabled={loginMutation.isPending} className="h-11">
{loginMutation.isPending ? t("Loading") + "..." : t("Login")}
</Button>
<Button variant="outline" onClick={() => setView("register")} className="h-11">
{t("Register")}
</Button>
</div>
<div className="text-center mt-8">
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
@@ -203,10 +208,10 @@ export default function AuthPage() {
/>
<div className="flex flex-col gap-3 mt-4">
<Button onClick={handleOtherSubmit}>
<Button onClick={handleOtherSubmit} className="h-11">
{t("Register")}
</Button>
<Button variant="outline" onClick={() => setView("login")}>
<Button variant="outline" onClick={() => setView("login")} className="h-11">
{t("Go to login page")}
</Button>
</div>
@@ -233,10 +238,10 @@ export default function AuthPage() {
/>
<div className="mt-4 flex flex-col gap-3">
<Button onClick={handleOtherSubmit}>
<Button onClick={handleOtherSubmit} className="h-11">
{t("Submit")}
</Button>
<Button variant="outline" onClick={() => setView("login")}>
<Button variant="outline" onClick={() => setView("login")} className="h-11">
{t("Go to login page")}
</Button>
</div>
@@ -248,6 +253,7 @@ export default function AuthPage() {
</div>
</>
)}
</div>
</div>
</div>
</div>