refactored some code
This commit is contained in:
1 parent
caae941346
commit
b83f350c6b
33 files changed
+1031
-1402
No files matched your search
Generated
+66
-31
@@ -11,6 +11,7 @@
|
|||||||
"@fontsource-variable/geist": "^5.2.8",
|
"@fontsource-variable/geist": "^5.2.8",
|
||||||
"@fontsource-variable/inter": "^5.2.8",
|
"@fontsource-variable/inter": "^5.2.8",
|
||||||
"@hookform/resolvers": "^5.2.2",
|
"@hookform/resolvers": "^5.2.2",
|
||||||
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tanstack/react-query": "^5.100.8",
|
"@tanstack/react-query": "^5.100.8",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@tiptap/extension-link": "^3.23.2",
|
"@tiptap/extension-link": "^3.23.2",
|
||||||
@@ -3148,6 +3149,15 @@
|
|||||||
"node": ">=16.0.0"
|
"node": ">=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@tailwindcss/container-queries": {
|
||||||
|
"version": "0.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@tailwindcss/container-queries/-/container-queries-0.1.1.tgz",
|
||||||
|
"integrity": "sha512-p18dswChx6WnTSaJCSGx6lTmrGzNNvm2FtXmiO6AuA1V4U5REyoqwmT6kgAsIMdjo07QdAfYXHJ4hnMtfHzWgA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"tailwindcss": ">=3.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@tailwindcss/node": {
|
"node_modules/@tailwindcss/node": {
|
||||||
"version": "4.2.4",
|
"version": "4.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.2.4.tgz",
|
||||||
@@ -4580,16 +4590,42 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.15.2",
|
"version": "1.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.15.2.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.17.0.tgz",
|
||||||
"integrity": "sha512-wLrXxPtcrPTsNlJmKjkPnNPK2Ihe0hn0wGSaTEiHRPxwjvJwT3hKmXF4dpqxmPO9SoNb2FsYXj/xEo0gHN+D5A==",
|
"integrity": "sha512-J8SwNxprqqpbfenehxWYXE7CW+wM1BB4w3+N+g+/Wx40xM4rsLrfPmHHxSWIxJLYDgSY/HqlFPIYb2/S3rxafw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.11",
|
"follow-redirects": "^1.16.0",
|
||||||
"form-data": "^4.0.5",
|
"form-data": "^4.0.5",
|
||||||
|
"https-proxy-agent": "^5.0.1",
|
||||||
"proxy-from-env": "^2.1.0"
|
"proxy-from-env": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios/node_modules/agent-base": {
|
||||||
|
"version": "6.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||||
|
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"debug": "4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/axios/node_modules/https-proxy-agent": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"agent-base": "6",
|
||||||
|
"debug": "4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||||
@@ -4636,9 +4672,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "5.0.5",
|
"version": "5.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
||||||
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
|
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
@@ -5902,12 +5938,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/express-rate-limit": {
|
"node_modules/express-rate-limit": {
|
||||||
"version": "8.4.1",
|
"version": "8.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.2.tgz",
|
||||||
"integrity": "sha512-NGVYwQSAyEQgzxX1iCM978PP9AdO/hW93gMcF6ZwQCm+rFvLsBH6w4xcXWTcliS8La5EPRN3p9wzItqBwJrfNw==",
|
"integrity": "sha512-5Kb34ipNX694DH48vN9irak1Qx30nb0PLYHXfJgw4YEjiC3ZEmZJhwOp+VfiCYwFzvFTdB9QkArYS5kXa2cx2A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ip-address": "10.1.0"
|
"ip-address": "^10.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16"
|
||||||
@@ -5992,9 +6028,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fast-uri": {
|
"node_modules/fast-uri": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",
|
||||||
"integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==",
|
"integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@@ -6533,9 +6569,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hono": {
|
"node_modules/hono": {
|
||||||
"version": "4.12.16",
|
"version": "4.12.23",
|
||||||
"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.16.tgz",
|
"resolved": "https://registry.npmjs.org/hono/-/hono-4.12.23.tgz",
|
||||||
"integrity": "sha512-jN0ZewiNAWSe5khM3EyCmBb250+b40wWbwNILNfEvq84VREWwOIkuUsFONk/3i3nqkz7Oe1PcpM2mwQEK2L9Kg==",
|
"integrity": "sha512-eIaZ9qDgu7XV0pxOCrg7/WhnQ6Ivm22UcxhXx/A3dcbqbbYgBEkc6e/J/s7j2tS96zoB0S9VBdLwQNCWwUo4LA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
@@ -6713,9 +6749,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ip-address": {
|
"node_modules/ip-address": {
|
||||||
"version": "10.1.0",
|
"version": "10.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",
|
||||||
"integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==",
|
"integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 12"
|
"node": ">= 12"
|
||||||
@@ -8459,9 +8495,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.15.1",
|
"version": "6.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
||||||
"integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==",
|
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"side-channel": "^1.1.0"
|
"side-channel": "^1.1.0"
|
||||||
@@ -8758,9 +8794,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router": {
|
"node_modules/react-router": {
|
||||||
"version": "7.14.2",
|
"version": "7.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.16.0.tgz",
|
||||||
"integrity": "sha512-yCqNne6I8IB6rVCH7XUvlBK7/QKyqypBFGv+8dj4QBFJiiRX+FG7/nkdAvGElyvVZ/HQP5N19wzteuTARXi5Gw==",
|
"integrity": "sha512-wArC8lVyJb3+jM9OpDyW6hLCizACWkvQR/sSGqSs+o5uEXEtGlqdZ4v8hENR3Jad6i+LRkK93q/+bQAcvl6V1A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cookie": "^1.0.1",
|
"cookie": "^1.0.1",
|
||||||
@@ -8780,12 +8816,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router-dom": {
|
"node_modules/react-router-dom": {
|
||||||
"version": "7.14.2",
|
"version": "7.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.16.0.tgz",
|
||||||
"integrity": "sha512-YZcM5ES8jJSM+KrJ9BdvHHqlnGTg5tH3sC5ChFRj4inosKctdyzBDhOyyHdGk597q2OT6NTrCA1OvB/YDwfekQ==",
|
"integrity": "sha512-kMUAbimWB5FVbF4Bce4bJsiKJWLIUHq/mEG8+CFDnCSgltptBiG5nguducmsJeGKytlCvQud9Qhzpn49iduTlA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-router": "7.14.2"
|
"react-router": "7.16.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
@@ -9530,7 +9566,6 @@
|
|||||||
"version": "4.2.4",
|
"version": "4.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.4.tgz",
|
||||||
"integrity": "sha512-HhKppgO81FQof5m6TEnuBWCZGgfRAWbaeOaGT00KOy/Pf/j6oUihdvBpA7ltCeAvZpFhW3j0PTclkxsd4IXYDA==",
|
"integrity": "sha512-HhKppgO81FQof5m6TEnuBWCZGgfRAWbaeOaGT00KOy/Pf/j6oUihdvBpA7ltCeAvZpFhW3j0PTclkxsd4IXYDA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/tapable": {
|
"node_modules/tapable": {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"@fontsource-variable/geist": "^5.2.8",
|
"@fontsource-variable/geist": "^5.2.8",
|
||||||
"@fontsource-variable/inter": "^5.2.8",
|
"@fontsource-variable/inter": "^5.2.8",
|
||||||
"@hookform/resolvers": "^5.2.2",
|
"@hookform/resolvers": "^5.2.2",
|
||||||
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
"@tanstack/react-query": "^5.100.8",
|
"@tanstack/react-query": "^5.100.8",
|
||||||
"@tanstack/react-table": "^8.21.3",
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@tiptap/extension-link": "^3.23.2",
|
"@tiptap/extension-link": "^3.23.2",
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { Eye, Pencil, Trash2, type LucideIcon } from "lucide-react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
export interface TableAction {
|
||||||
|
icon: LucideIcon;
|
||||||
|
title: string;
|
||||||
|
onClick: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
destructive?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TableActionsProps {
|
||||||
|
onView?: () => void;
|
||||||
|
onEdit?: () => void;
|
||||||
|
onDelete?: () => void;
|
||||||
|
isDeleting?: boolean;
|
||||||
|
editIcon?: LucideIcon;
|
||||||
|
extraActions?: TableAction[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TableActions({ onView, onEdit, onDelete, isDeleting, editIcon: EditIcon = Pencil, extraActions }: TableActionsProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1.5 justify-end">
|
||||||
|
{extraActions?.map((action, i) => (
|
||||||
|
<button
|
||||||
|
key={i}
|
||||||
|
onClick={action.onClick}
|
||||||
|
disabled={action.disabled}
|
||||||
|
className={`p-1.5 cursor-pointer rounded transition-colors disabled:opacity-50 ${
|
||||||
|
action.destructive
|
||||||
|
? "hover:bg-destructive/10 text-muted-foreground hover:text-destructive"
|
||||||
|
: "hover:bg-muted/60 text-muted-foreground hover:text-foreground"
|
||||||
|
}`}
|
||||||
|
title={action.title}
|
||||||
|
>
|
||||||
|
<action.icon size={15} />
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{onView && (
|
||||||
|
<button
|
||||||
|
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={onView}
|
||||||
|
>
|
||||||
|
<Eye size={15} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{onEdit && (
|
||||||
|
<button
|
||||||
|
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||||
|
title={t("common.edit", "Edit")}
|
||||||
|
onClick={onEdit}
|
||||||
|
>
|
||||||
|
<EditIcon size={15} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{onDelete && (
|
||||||
|
<button
|
||||||
|
onClick={onDelete}
|
||||||
|
disabled={isDeleting}
|
||||||
|
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} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,314 +1,349 @@
|
|||||||
import { useState, useMemo, useCallback } from 'react'
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from "react-hook-form";
|
||||||
import { toast } from 'sonner'
|
import { toast } from "sonner";
|
||||||
import { User, MapPin, IdCard, CreditCard, Files } from 'lucide-react'
|
import { User, MapPin, IdCard, CreditCard, Files } from "lucide-react";
|
||||||
import type { LucideIcon } from 'lucide-react'
|
import type { LucideIcon } from "lucide-react";
|
||||||
|
|
||||||
import { FormInput } from '@/components/formInput'
|
import { FormInput } from "@/components/formInput";
|
||||||
import { FormActions } from '@/components/formActions'
|
import { FormActions } from "@/components/formActions";
|
||||||
import { StepBarCards, type StepCardItem } from '@/components/stepBarV2'
|
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||||
import { BentoGrid, BentoCard } from '@/components/bento'
|
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||||
import {
|
import { useCreateSberPayment, useUpdateSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||||
useCreateSberPayment,
|
import { WELAYATLAR, SAHAMCALAR, STATUSES, type SberPaymentOrder, type PaymentStatus } from "@/features/sberPayments/api/sberPaymentsApi";
|
||||||
useUpdateSberPayment,
|
|
||||||
} from '@/features/sberPayments/hooks/useSberPayments'
|
|
||||||
import {
|
|
||||||
WELAYATLAR,
|
|
||||||
SAHAMCALAR,
|
|
||||||
STATUSES,
|
|
||||||
type SberPaymentOrder,
|
|
||||||
type PaymentStatus,
|
|
||||||
} from '@/features/sberPayments/api/sberPaymentsApi'
|
|
||||||
import {
|
import {
|
||||||
validateStep,
|
validateStep,
|
||||||
DEFAULT_FORM_VALUES,
|
DEFAULT_FORM_VALUES,
|
||||||
buildPayload,
|
buildPayload,
|
||||||
type SberPaymentFormData,
|
type SberPaymentFormData,
|
||||||
} from '@/features/sberPayments/schemas/sberPayment.schema'
|
} from "@/features/sberPayments/schemas/sberPayment.schema";
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
interface SberPaymentFormProps {
|
interface SberPaymentFormProps {
|
||||||
mode: 'create' | 'edit'
|
mode: "create" | "edit";
|
||||||
initialData?: SberPaymentOrder | null
|
initialData?: SberPaymentOrder | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlatErrors = Partial<Record<keyof SberPaymentFormData, string>>
|
type FlatErrors = Partial<Record<keyof SberPaymentFormData, string>>;
|
||||||
|
|
||||||
// ─── Flatten RHF errors ──────────────────────────────────────────────────────
|
// ─── Flatten RHF errors ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
function flattenErrors(errors: Record<string, { message?: string } | undefined>): FlatErrors {
|
function flattenErrors(errors: Record<string, { message?: string } | undefined>): FlatErrors {
|
||||||
const result: FlatErrors = {}
|
const result: FlatErrors = {};
|
||||||
for (const key of Object.keys(errors)) {
|
for (const key of Object.keys(errors)) {
|
||||||
const msg = errors[key]?.message
|
const msg = errors[key]?.message;
|
||||||
if (msg) result[key as keyof SberPaymentFormData] = msg
|
if (msg) result[key as keyof SberPaymentFormData] = msg;
|
||||||
}
|
}
|
||||||
return result
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Document lists ───────────────────────────────────────────────────────────
|
// ─── Document lists ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
type AcceptedDocKey =
|
type AcceptedDocKey =
|
||||||
| 'acc_sberbank_card' | 'acc_enrollment' | 'acc_summons'
|
| "acc_sberbank_card"
|
||||||
| 'acc_passport_tm' | 'acc_zagran_passport' | 'acc_visa_page'
|
| "acc_enrollment"
|
||||||
| 'acc_entry_stamp' | 'acc_school_letter'
|
| "acc_summons"
|
||||||
|
| "acc_passport_tm"
|
||||||
|
| "acc_zagran_passport"
|
||||||
|
| "acc_visa_page"
|
||||||
|
| "acc_entry_stamp"
|
||||||
|
| "acc_school_letter";
|
||||||
|
|
||||||
type SentDocKey =
|
type SentDocKey =
|
||||||
| 'snt_passport_tm' | 'snt_zagran_passport' | 'snt_entry_stamp'
|
| "snt_passport_tm"
|
||||||
| 'snt_relation_doc' | 'snt_new_passport_series' | 'snt_old_passport_series'
|
| "snt_zagran_passport"
|
||||||
|
| "snt_entry_stamp"
|
||||||
|
| "snt_relation_doc"
|
||||||
|
| "snt_new_passport_series"
|
||||||
|
| "snt_old_passport_series";
|
||||||
|
|
||||||
const ACCEPTED_DOCS = (t: (key: string, fallback?: string) => string): { key: AcceptedDocKey; label: string }[] => [
|
const ACCEPTED_DOCS = (t: (key: string, fallback?: string) => string): { key: AcceptedDocKey; label: string }[] => [
|
||||||
{ key: 'acc_sberbank_card', label: t('sberPayments.documents.sberbankCard', 'Talýba degişli SBERBANK kartynyň rekwizitleri') },
|
{ key: "acc_sberbank_card", label: t("sberPayments.documents.sberbankCard", "Talýba degişli SBERBANK kartynyň rekwizitleri") },
|
||||||
{ key: 'acc_enrollment', label: t('sberPayments.documents.enrollment', 'Daşary ýurt ÝOM-da okaýandygy baradaky güwänamasy') },
|
{ key: "acc_enrollment", label: t("sberPayments.documents.enrollment", "Daşary ýurt ÝOM-da okaýandygy baradaky güwänamasy") },
|
||||||
{ key: 'acc_summons', label: t('sberPayments.documents.summons', 'Çagyrylma hatynyn göçürmesi') },
|
{ key: "acc_summons", label: t("sberPayments.documents.summons", "Çagyrylma hatynyn göçürmesi") },
|
||||||
{ key: 'acc_passport_tm', label: t('sberPayments.documents.passportTm', 'TM içki pasportynyň asyl görnüşi we göçürmesi') },
|
{ key: "acc_passport_tm", label: t("sberPayments.documents.passportTm", "TM içki pasportynyň asyl görnüşi we göçürmesi") },
|
||||||
{ key: 'acc_zagran_passport', label: t('sberPayments.documents.zagranPassport', 'Daşary ýurt (zagran) pasportynyň göçürmesi') },
|
{ key: "acc_zagran_passport", label: t("sberPayments.documents.zagranPassport", "Daşary ýurt (zagran) pasportynyň göçürmesi") },
|
||||||
{ key: 'acc_visa_page', label: t('sberPayments.documents.visaPage', 'Daşary ýurda rugsat (wizasy) bellenen sahypasynyň göçürmesi') },
|
{ key: "acc_visa_page", label: t("sberPayments.documents.visaPage", "Daşary ýurda rugsat (wizasy) bellenen sahypasynyň göçürmesi") },
|
||||||
{ key: 'acc_entry_stamp', label: t('sberPayments.documents.entryStamp', 'Daşary ýurt döwletine girenliği baradaky ştamply sahypasynyň göçürmesi') },
|
{
|
||||||
{ key: 'acc_school_letter', label: t('sberPayments.documents.schoolLetter', 'ÝOM-dan hat (daşary ýurt dilinde maglumatly)') },
|
key: "acc_entry_stamp",
|
||||||
]
|
label: t("sberPayments.documents.entryStamp", "Daşary ýurt döwletine girenliği baradaky ştamply sahypasynyň göçürmesi"),
|
||||||
|
},
|
||||||
|
{ key: "acc_school_letter", label: t("sberPayments.documents.schoolLetter", "ÝOM-dan hat (daşary ýurt dilinde maglumatly)") },
|
||||||
|
];
|
||||||
|
|
||||||
const SENT_DOCS = (t: (key: string, fallback?: string) => string): { key: SentDocKey; label: string }[] => [
|
const SENT_DOCS = (t: (key: string, fallback?: string) => string): { key: SentDocKey; label: string }[] => [
|
||||||
{ key: 'snt_passport_tm', label: t('sberPayments.documents.sentPassportTm', 'Ugradyjynyň TM içki pasportynyň asyl görnüşi we göçürmesi') },
|
{
|
||||||
{ key: 'snt_zagran_passport', label: t('sberPayments.documents.sentZagranPassport', 'Ugradyjynyň daşary ýurt pasportynyň asyl görnüşi we göçürmesi') },
|
key: "snt_passport_tm",
|
||||||
{ key: 'snt_entry_stamp', label: t('sberPayments.documents.sentEntryStamp', 'Ugradyjynyň daşary döwletine girenliği ştamply sahypasynyň göçürmesi') },
|
label: t("sberPayments.documents.sentPassportTm", "Ugradyjynyň TM içki pasportynyň asyl görnüşi we göçürmesi"),
|
||||||
{ key: 'snt_relation_doc', label: t('sberPayments.documents.sentRelationDoc', 'Ugradyjy we kabul edijiniň garyndaşlyk tassyklaýjy resminamasynyn göçürmesi') },
|
},
|
||||||
{ key: 'snt_new_passport_series', label: t('sberPayments.documents.sentNewPassportSeries', 'Ugradyjy/kabul ediji täze (2015+) pasport seriýasy maglumaty') },
|
{
|
||||||
{ key: 'snt_old_passport_series', label: t('sberPayments.documents.sentOldPassportSeries', 'Ugradyjy/kabul ediji köne pasport seriýasy baradaky güwänamasy') },
|
key: "snt_zagran_passport",
|
||||||
]
|
label: t("sberPayments.documents.sentZagranPassport", "Ugradyjynyň daşary ýurt pasportynyň asyl görnüşi we göçürmesi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "snt_entry_stamp",
|
||||||
|
label: t("sberPayments.documents.sentEntryStamp", "Ugradyjynyň daşary döwletine girenliği ştamply sahypasynyň göçürmesi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "snt_relation_doc",
|
||||||
|
label: t("sberPayments.documents.sentRelationDoc", "Ugradyjy we kabul edijiniň garyndaşlyk tassyklaýjy resminamasynyn göçürmesi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "snt_new_passport_series",
|
||||||
|
label: t("sberPayments.documents.sentNewPassportSeries", "Ugradyjy/kabul ediji täze (2015+) pasport seriýasy maglumaty"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "snt_old_passport_series",
|
||||||
|
label: t("sberPayments.documents.sentOldPassportSeries", "Ugradyjy/kabul ediji köne pasport seriýasy baradaky güwänamasy"),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// ─── Step panels ──────────────────────────────────────────────────────────────
|
// ─── Step panels ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function StepGeneral({
|
function StepGeneral({
|
||||||
form, errors, set, t,
|
form,
|
||||||
|
errors,
|
||||||
|
set,
|
||||||
|
t,
|
||||||
}: {
|
}: {
|
||||||
form: SberPaymentFormData
|
form: SberPaymentFormData;
|
||||||
errors: FlatErrors
|
errors: FlatErrors;
|
||||||
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void
|
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void;
|
||||||
t: (key: string, fallback?: string) => string
|
t: (key: string, fallback?: string) => string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('sberPayments.cards.musteri', 'Müşderi')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t('sberPayments.fields.client_id', 'Ulanyjy')}
|
label={t("sberPayments.fields.client_id", "Ulanyjy")}
|
||||||
value={form.client_id}
|
value={form.client_id}
|
||||||
onChange={(v) => set('client_id', v)}
|
onChange={(v) => set("client_id", v)}
|
||||||
options={[]}
|
options={[]}
|
||||||
placeholder={t('sberPayments.placeholders.select', 'Saýlamak üçin basyň')}
|
placeholder={t("sberPayments.placeholders.select", "Saýlamak üçin basyň")}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.status', 'Status')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="select"
|
||||||
label={t('sberPayments.fields.status', 'Status')}
|
label={t("sberPayments.fields.status", "Status")}
|
||||||
value={form.status}
|
value={form.status}
|
||||||
onChange={(v) => set('status', v as PaymentStatus)}
|
onChange={(v) => set("status", v as PaymentStatus)}
|
||||||
options={STATUSES}
|
options={STATUSES}
|
||||||
error={errors.status}
|
error={errors.status}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.bellik', 'Bellik')} span="full">
|
<BentoCard span="full">
|
||||||
<FormInput
|
<FormInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label={t('sberPayments.fields.bellik', 'Bellik')}
|
label={t("sberPayments.fields.bellik", "Bellik")}
|
||||||
value={form.bellik}
|
value={form.bellik}
|
||||||
onChange={(v) => set('bellik', v)}
|
onChange={(v) => set("bellik", v)}
|
||||||
placeholder={t('sberPayments.placeholders.bellik', 'Bellik...')}
|
placeholder={t("sberPayments.placeholders.bellik", "Bellik...")}
|
||||||
rows={2}
|
rows={2}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepLocation({
|
function StepLocation({
|
||||||
form, errors, set, t,
|
form,
|
||||||
|
errors,
|
||||||
|
set,
|
||||||
|
t,
|
||||||
}: {
|
}: {
|
||||||
form: SberPaymentFormData
|
form: SberPaymentFormData;
|
||||||
errors: FlatErrors
|
errors: FlatErrors;
|
||||||
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void
|
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void;
|
||||||
t: (key: string, fallback?: string) => string
|
t: (key: string, fallback?: string) => string;
|
||||||
}) {
|
}) {
|
||||||
const branches = form.welayat ? (SAHAMCALAR[form.welayat] ?? []) : []
|
const branches = form.welayat ? (SAHAMCALAR[form.welayat] ?? []) : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('sberPayments.cards.welayat', 'Welaýat')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="select"
|
||||||
label={t('sberPayments.fields.welayat', 'Welaýat')}
|
label={t("sberPayments.fields.welayat", "Welaýat")}
|
||||||
value={form.welayat}
|
value={form.welayat}
|
||||||
onChange={(v) => { set('welayat', v); set('sahamca', '') }}
|
onChange={(v) => {
|
||||||
|
set("welayat", v);
|
||||||
|
set("sahamca", "");
|
||||||
|
}}
|
||||||
options={WELAYATLAR.map((w) => ({ value: w, label: w }))}
|
options={WELAYATLAR.map((w) => ({ value: w, label: w }))}
|
||||||
placeholder={t('sberPayments.placeholders.welayat', 'Aşgabat')}
|
placeholder={t("sberPayments.placeholders.welayat", "Aşgabat")}
|
||||||
error={errors.welayat}
|
error={errors.welayat}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{t('sberPayments.hints.selectRegion', 'Welaýaty saýlasaňyz şahamçalar güncellenar.')}
|
|
||||||
</p>
|
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.sahamca', 'Şahamça')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t('sberPayments.fields.sahamca', 'Şahamça')}
|
label={t("sberPayments.fields.sahamca", "Şahamça")}
|
||||||
value={form.sahamca}
|
value={form.sahamca}
|
||||||
onChange={(v) => set('sahamca', v)}
|
onChange={(v) => set("sahamca", v)}
|
||||||
options={branches.map((b) => ({ value: b, label: b }))}
|
options={branches.map((b) => ({ value: b, label: b }))}
|
||||||
placeholder={t('sberPayments.placeholders.select', 'Saýlamak üçin basyň')}
|
placeholder={t("sberPayments.placeholders.select", "Saýlamak üçin basyň")}
|
||||||
disabled={!form.welayat}
|
disabled={!form.welayat}
|
||||||
error={errors.sahamca}
|
error={errors.sahamca}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepPersonal({
|
function StepPersonal({
|
||||||
form, errors, set, t,
|
form,
|
||||||
|
errors,
|
||||||
|
set,
|
||||||
|
t,
|
||||||
}: {
|
}: {
|
||||||
form: SberPaymentFormData
|
form: SberPaymentFormData;
|
||||||
errors: FlatErrors
|
errors: FlatErrors;
|
||||||
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void
|
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void;
|
||||||
t: (key: string, fallback?: string) => string
|
t: (key: string, fallback?: string) => string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('sberPayments.cards.atFamilia', 'At-familýa')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('sberPayments.fields.lastName', 'Pasportdaky familiýa')}
|
label={t("sberPayments.fields.lastName", "Pasportdaky familiýa")}
|
||||||
value={form.lastName}
|
value={form.lastName}
|
||||||
onChange={(v) => set('lastName', v)}
|
onChange={(v) => set("lastName", v)}
|
||||||
placeholder={t('sberPayments.placeholders.lastName', 'NURYYEW')}
|
placeholder={t("sberPayments.placeholders.lastName", "NURYYEW")}
|
||||||
error={errors.lastName}
|
error={errors.lastName}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('sberPayments.fields.firstName', 'Pasportdaky ady')}
|
label={t("sberPayments.fields.firstName", "Pasportdaky ady")}
|
||||||
value={form.firstName}
|
value={form.firstName}
|
||||||
onChange={(v) => set('firstName', v)}
|
onChange={(v) => set("firstName", v)}
|
||||||
placeholder={t('sberPayments.placeholders.firstName', 'HAÝDAR')}
|
placeholder={t("sberPayments.placeholders.firstName", "HAÝDAR")}
|
||||||
error={errors.firstName}
|
error={errors.firstName}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.kontakt', 'Kontakt')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="phone"
|
type="phone"
|
||||||
label={t('sberPayments.fields.phone', 'Telefon')}
|
label={t("sberPayments.fields.phone", "Telefon")}
|
||||||
value={form.phone}
|
value={form.phone}
|
||||||
onChange={(v) => set('phone', v)}
|
onChange={(v) => set("phone", v)}
|
||||||
error={errors.phone}
|
error={errors.phone}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="email"
|
type="email"
|
||||||
label={t('sberPayments.fields.email', 'E-poçta')}
|
label={t("sberPayments.fields.email", "E-poçta")}
|
||||||
value={form.email}
|
value={form.email}
|
||||||
onChange={(v) => set('email', v)}
|
onChange={(v) => set("email", v)}
|
||||||
placeholder={t('sberPayments.placeholders.email', 'email@example.com')}
|
placeholder={t("sberPayments.placeholders.email", "email@example.com")}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.yasysYeri', 'Häzirki ýaşyş ýeri')} span="full">
|
<BentoCard span="full">
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('sberPayments.fields.address', 'Salgy')}
|
label={t("sberPayments.fields.address", "Salgy")}
|
||||||
value={form.address}
|
value={form.address}
|
||||||
onChange={(v) => set('address', v)}
|
onChange={(v) => set("address", v)}
|
||||||
placeholder={t('sberPayments.placeholders.address', 'Köçe, jaý belgisi...')}
|
placeholder={t("sberPayments.placeholders.address", "Köçe, jaý belgisi...")}
|
||||||
error={errors.address}
|
error={errors.address}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepPayment({
|
function StepPayment({
|
||||||
form, errors, set, t,
|
form,
|
||||||
|
errors,
|
||||||
|
set,
|
||||||
|
t,
|
||||||
}: {
|
}: {
|
||||||
form: SberPaymentFormData
|
form: SberPaymentFormData;
|
||||||
errors: FlatErrors
|
errors: FlatErrors;
|
||||||
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void
|
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void;
|
||||||
t: (key: string, fallback?: string) => string
|
t: (key: string, fallback?: string) => string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('sberPayments.cards.pasportMaglumatlary', 'Pasport maglumatlary')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t('sberPayments.fields.passportSeries', 'Pasport seriýasy')}
|
label={t("sberPayments.fields.passportSeries", "Pasport seriýasy")}
|
||||||
value={form.passportSeries}
|
value={form.passportSeries}
|
||||||
onChange={(v) => set('passportSeries', v)}
|
onChange={(v) => set("passportSeries", v)}
|
||||||
options={[
|
options={[
|
||||||
{ value: 'II-MA', label: 'II-MA' },
|
{ value: "II-MA", label: "II-MA" },
|
||||||
{ value: 'II-MB', label: 'II-MB' },
|
{ value: "II-MB", label: "II-MB" },
|
||||||
{ value: 'II-MC', label: 'II-MC' },
|
{ value: "II-MC", label: "II-MC" },
|
||||||
{ value: 'II-MD', label: 'II-MD' },
|
{ value: "II-MD", label: "II-MD" },
|
||||||
]}
|
]}
|
||||||
placeholder={t('sberPayments.placeholders.select', 'Saýlamak üçin basyň')}
|
placeholder={t("sberPayments.placeholders.select", "Saýlamak üçin basyň")}
|
||||||
error={errors.passportSeries}
|
error={errors.passportSeries}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('sberPayments.fields.passportNumber', 'Pasport nomeri')}
|
label={t("sberPayments.fields.passportNumber", "Pasport nomeri")}
|
||||||
value={form.passportNumber}
|
value={form.passportNumber}
|
||||||
onChange={(v) => set('passportNumber', v)}
|
onChange={(v) => set("passportNumber", v)}
|
||||||
placeholder={t('sberPayments.placeholders.passportNumber', 'A123456')}
|
placeholder={t("sberPayments.placeholders.passportNumber", "A123456")}
|
||||||
error={errors.passportNumber}
|
error={errors.passportNumber}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.ugradyjy', 'Ugradyjy')}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('sberPayments.fields.fullName', 'Ady Familiýasy Atasynyň ady')}
|
label={t("sberPayments.fields.fullName", "Ady Familiýasy Atasynyň ady")}
|
||||||
value={form.fullName}
|
value={form.fullName}
|
||||||
onChange={(v) => set('fullName', v)}
|
onChange={(v) => set("fullName", v)}
|
||||||
placeholder={t('sberPayments.placeholders.fullName', 'Doly ady...')}
|
placeholder={t("sberPayments.placeholders.fullName", "Doly ady...")}
|
||||||
error={errors.fullName}
|
error={errors.fullName}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('sberPayments.fields.accountNumber', 'Goýum hasaby')}
|
label={t("sberPayments.fields.accountNumber", "Goýum hasaby")}
|
||||||
value={form.accountNumber}
|
value={form.accountNumber}
|
||||||
onChange={(v) => set('accountNumber', v)}
|
onChange={(v) => set("accountNumber", v)}
|
||||||
placeholder={t('sberPayments.placeholders.accountNumber', '1234 5678 ...')}
|
placeholder={t("sberPayments.placeholders.accountNumber", "1234 5678 ...")}
|
||||||
error={errors.accountNumber}
|
error={errors.accountNumber}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepDocs({
|
function StepDocs({
|
||||||
form, set, t,
|
form,
|
||||||
|
set,
|
||||||
|
t,
|
||||||
}: {
|
}: {
|
||||||
form: SberPaymentFormData
|
form: SberPaymentFormData;
|
||||||
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void
|
set: <K extends keyof SberPaymentFormData>(k: K, v: SberPaymentFormData[K]) => void;
|
||||||
t: (key: string, fallback?: string) => string
|
t: (key: string, fallback?: string) => string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('sberPayments.cards.documentsAccepted', 'Kabul ediji talyp — 8 resminama')}>
|
<BentoCard>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{ACCEPTED_DOCS(t).map(({ key, label }) => (
|
{ACCEPTED_DOCS(t).map(({ key, label }) => (
|
||||||
<FormInput
|
<FormInput
|
||||||
@@ -323,7 +358,7 @@ function StepDocs({
|
|||||||
</div>
|
</div>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('sberPayments.cards.documentsSent', 'Ugradyjy — 6 resminama')}>
|
<BentoCard>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{SENT_DOCS(t).map(({ key, label }) => (
|
{SENT_DOCS(t).map(({ key, label }) => (
|
||||||
<FormInput
|
<FormInput
|
||||||
@@ -338,196 +373,236 @@ function StepDocs({
|
|||||||
</div>
|
</div>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Step definitions ─────────────────────────────────────────────────────────
|
// ─── Step definitions ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
interface StepDef {
|
interface StepDef {
|
||||||
id: string
|
id: string;
|
||||||
titleKey: string
|
titleKey: string;
|
||||||
titleFallback: string
|
titleFallback: string;
|
||||||
subtitleKey: string
|
subtitleKey: string;
|
||||||
subtitleFallback: string
|
subtitleFallback: string;
|
||||||
icon: LucideIcon
|
icon: LucideIcon;
|
||||||
validate: (form: SberPaymentFormData, mode: 'create' | 'edit', t: (key: string, fallback?: string) => string) => FlatErrors
|
validate: (form: SberPaymentFormData, mode: "create" | "edit", t: (key: string, fallback?: string) => string) => FlatErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STEPS: StepDef[] = [
|
const STEPS: StepDef[] = [
|
||||||
{ id: 'general', titleKey: 'sberPayments.steps.general.title', titleFallback: 'Esasy', subtitleKey: 'sberPayments.steps.general.subtitle', subtitleFallback: 'Status, müşderi', icon: User, validate: (f, m, t) => validateStep(0, f, m, t) },
|
{
|
||||||
{ id: 'location', titleKey: 'sberPayments.steps.location.title', titleFallback: 'Lokasiýa', subtitleKey: 'sberPayments.steps.location.subtitle', subtitleFallback: 'Welaýat, şahamça', icon: MapPin, validate: (f, m, t) => validateStep(1, f, m, t) },
|
id: "general",
|
||||||
{ id: 'personal', titleKey: 'sberPayments.steps.personal.title', titleFallback: 'Şahsy', subtitleKey: 'sberPayments.steps.personal.subtitle', subtitleFallback: 'Pasport, kontakt', icon: IdCard, validate: (f, m, t) => validateStep(2, f, m, t) },
|
titleKey: "sberPayments.steps.general.title",
|
||||||
{ id: 'payment', titleKey: 'sberPayments.steps.payment.title', titleFallback: 'Töleg', subtitleKey: 'sberPayments.steps.payment.subtitle', subtitleFallback: 'Hasap, ugradyjy', icon: CreditCard, validate: (f, m, t) => validateStep(3, f, m, t) },
|
titleFallback: "Esasy",
|
||||||
{ id: 'docs', titleKey: 'sberPayments.steps.docs.title', titleFallback: 'Resminamalar', subtitleKey: 'sberPayments.steps.docs.subtitle', subtitleFallback: '14 resminama', icon: Files, validate: () => ({}) },
|
subtitleKey: "sberPayments.steps.general.subtitle",
|
||||||
]
|
subtitleFallback: "Status, müşderi",
|
||||||
|
icon: User,
|
||||||
|
validate: (f, m, t) => validateStep(0, f, m, t),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "location",
|
||||||
|
titleKey: "sberPayments.steps.location.title",
|
||||||
|
titleFallback: "Lokasiýa",
|
||||||
|
subtitleKey: "sberPayments.steps.location.subtitle",
|
||||||
|
subtitleFallback: "Welaýat, şahamça",
|
||||||
|
icon: MapPin,
|
||||||
|
validate: (f, m, t) => validateStep(1, f, m, t),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "personal",
|
||||||
|
titleKey: "sberPayments.steps.personal.title",
|
||||||
|
titleFallback: "Şahsy",
|
||||||
|
subtitleKey: "sberPayments.steps.personal.subtitle",
|
||||||
|
subtitleFallback: "Pasport, kontakt",
|
||||||
|
icon: IdCard,
|
||||||
|
validate: (f, m, t) => validateStep(2, f, m, t),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "payment",
|
||||||
|
titleKey: "sberPayments.steps.payment.title",
|
||||||
|
titleFallback: "Töleg",
|
||||||
|
subtitleKey: "sberPayments.steps.payment.subtitle",
|
||||||
|
subtitleFallback: "Hasap, ugradyjy",
|
||||||
|
icon: CreditCard,
|
||||||
|
validate: (f, m, t) => validateStep(3, f, m, t),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "docs",
|
||||||
|
titleKey: "sberPayments.steps.docs.title",
|
||||||
|
titleFallback: "Resminamalar",
|
||||||
|
subtitleKey: "sberPayments.steps.docs.subtitle",
|
||||||
|
subtitleFallback: "14 resminama",
|
||||||
|
icon: Files,
|
||||||
|
validate: () => ({}),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// ─── Initial data mapper ──────────────────────────────────────────────────────
|
// ─── Initial data mapper ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
function mapInitialData(data: SberPaymentOrder): Partial<SberPaymentFormData> {
|
function mapInitialData(data: SberPaymentOrder): Partial<SberPaymentFormData> {
|
||||||
return {
|
return {
|
||||||
welayat: data.welayat,
|
welayat: data.welayat,
|
||||||
sahamca: data.sahamca,
|
sahamca: data.sahamca,
|
||||||
firstName: data.firstName,
|
firstName: data.firstName,
|
||||||
lastName: data.lastName,
|
lastName: data.lastName,
|
||||||
phone: data.phone,
|
phone: data.phone,
|
||||||
email: data.email,
|
email: data.email,
|
||||||
address: data.address,
|
address: data.address,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
bellik: data.bellik,
|
bellik: data.bellik,
|
||||||
accountNumber: data.accountNumber,
|
accountNumber: data.accountNumber,
|
||||||
passportSeries: data.passportSeries,
|
passportSeries: data.passportSeries,
|
||||||
passportNumber: data.passportNumber,
|
passportNumber: data.passportNumber,
|
||||||
fullName: data.fullName,
|
fullName: data.fullName,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Main component ───────────────────────────────────────────────────────────
|
// ─── Main component ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export function SberPaymentForm({ mode, initialData }: SberPaymentFormProps) {
|
export function SberPaymentForm({ mode, initialData }: SberPaymentFormProps) {
|
||||||
const { t: _t, i18n } = useTranslation()
|
const { t: _t, i18n } = useTranslation();
|
||||||
const t: (key: string, fallback?: string) => string = useCallback(
|
const t: (key: string, fallback?: string) => string = useCallback((key, fallback) => _t(key, fallback ?? key) as string, [_t]);
|
||||||
(key, fallback) => _t(key, fallback ?? key) as string,
|
const navigate = useNavigate();
|
||||||
[_t],
|
const createMutation = useCreateSberPayment();
|
||||||
)
|
const updateMutation = useUpdateSberPayment();
|
||||||
const navigate = useNavigate()
|
const isPending = createMutation.isPending || updateMutation.isPending;
|
||||||
const createMutation = useCreateSberPayment()
|
|
||||||
const updateMutation = useUpdateSberPayment()
|
|
||||||
const isPending = createMutation.isPending || updateMutation.isPending
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
watch, setValue, getValues, formState: { errors: rhfErrors }, clearErrors, setError,
|
watch,
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
formState: { errors: rhfErrors },
|
||||||
|
clearErrors,
|
||||||
|
setError,
|
||||||
} = useForm<SberPaymentFormData>({
|
} = useForm<SberPaymentFormData>({
|
||||||
defaultValues: mode === 'edit' && initialData
|
defaultValues: mode === "edit" && initialData ? { ...DEFAULT_FORM_VALUES, ...mapInitialData(initialData) } : DEFAULT_FORM_VALUES,
|
||||||
? { ...DEFAULT_FORM_VALUES, ...mapInitialData(initialData) }
|
});
|
||||||
: DEFAULT_FORM_VALUES,
|
|
||||||
})
|
|
||||||
|
|
||||||
const form = watch()
|
const form = watch();
|
||||||
const [currentStep, setCurrentStep] = useState(0)
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
const [visited, setVisited] = useState<Set<number>>(
|
const [visited, setVisited] = useState<Set<number>>(() => (mode === "edit" ? new Set(STEPS.map((_, i) => i)) : new Set<number>()));
|
||||||
() => mode === 'edit' ? new Set(STEPS.map((_, i) => i)) : new Set<number>(),
|
const [submittedSteps, setSubmittedSteps] = useState<Set<number>>(new Set());
|
||||||
)
|
|
||||||
const [submittedSteps, setSubmittedSteps] = useState<Set<number>>(new Set())
|
|
||||||
|
|
||||||
const stepsWithErrors = useMemo(() => {
|
const stepsWithErrors = useMemo(() => {
|
||||||
const out = new Set<number>()
|
const out = new Set<number>();
|
||||||
visited.forEach((i) => {
|
visited.forEach((i) => {
|
||||||
if (Object.keys(STEPS[i].validate(form, mode, t)).length > 0) out.add(i)
|
if (Object.keys(STEPS[i].validate(form, mode, t)).length > 0) out.add(i);
|
||||||
})
|
});
|
||||||
return out
|
return out;
|
||||||
}, [form, mode, visited, i18n.language, t])
|
}, [form, mode, visited, i18n.language, t]);
|
||||||
|
|
||||||
const set = useCallback(<K extends keyof SberPaymentFormData>(key: K, value: SberPaymentFormData[K]) => {
|
const set = useCallback(
|
||||||
(setValue as (name: K, val: SberPaymentFormData[K]) => void)(key, value)
|
<K extends keyof SberPaymentFormData>(key: K, value: SberPaymentFormData[K]) => {
|
||||||
clearErrors(key)
|
(setValue as (name: K, val: SberPaymentFormData[K]) => void)(key, value);
|
||||||
}, [setValue, clearErrors])
|
clearErrors(key);
|
||||||
|
},
|
||||||
|
[setValue, clearErrors],
|
||||||
|
);
|
||||||
|
|
||||||
const allSubmittedErrors = useMemo(() => {
|
const allSubmittedErrors = useMemo(() => {
|
||||||
const result: FlatErrors = {}
|
const result: FlatErrors = {};
|
||||||
for (const stepIdx of submittedSteps) {
|
for (const stepIdx of submittedSteps) {
|
||||||
Object.assign(result, STEPS[stepIdx].validate(form, mode, t))
|
Object.assign(result, STEPS[stepIdx].validate(form, mode, t));
|
||||||
}
|
}
|
||||||
return result
|
return result;
|
||||||
}, [form, mode, submittedSteps, i18n.language, t])
|
}, [form, mode, submittedSteps, i18n.language, t]);
|
||||||
|
|
||||||
const errors = useMemo(() => {
|
const errors = useMemo(() => {
|
||||||
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>)
|
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>);
|
||||||
return { ...fromRHF, ...allSubmittedErrors }
|
return { ...fromRHF, ...allSubmittedErrors };
|
||||||
}, [rhfErrors, allSubmittedErrors])
|
}, [rhfErrors, allSubmittedErrors]);
|
||||||
|
|
||||||
// ── Navigation ──────────────────────────────────────────────────────────────
|
// ── Navigation ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const markVisited = (i: number) =>
|
const markVisited = (i: number) => setVisited((prev) => new Set([...prev, i]));
|
||||||
setVisited((prev) => new Set([...prev, i]))
|
|
||||||
|
|
||||||
const markSubmitted = (i: number) =>
|
const markSubmitted = (i: number) => setSubmittedSteps((prev) => new Set([...prev, i]));
|
||||||
setSubmittedSteps((prev) => new Set([...prev, i]))
|
|
||||||
|
|
||||||
const handleNext = () => {
|
const handleNext = () => {
|
||||||
markVisited(currentStep)
|
markVisited(currentStep);
|
||||||
markSubmitted(currentStep)
|
markSubmitted(currentStep);
|
||||||
const errs = STEPS[currentStep].validate(form, mode, t)
|
const errs = STEPS[currentStep].validate(form, mode, t);
|
||||||
if (Object.keys(errs).length > 0) {
|
if (Object.keys(errs).length > 0) {
|
||||||
Object.entries(errs).forEach(([key, msg]) => {
|
Object.entries(errs).forEach(([key, msg]) => {
|
||||||
setError(key as keyof SberPaymentFormData, { type: 'manual', message: msg })
|
setError(key as keyof SberPaymentFormData, { type: "manual", message: msg });
|
||||||
})
|
});
|
||||||
toast.error(t('common.errors.fillRequiredCorrectly', 'Dogry maglumat girizmegiňizi haýyş edýäris.'))
|
toast.error(t("common.errors.fillRequiredCorrectly", "Dogry maglumat girizmegiňizi haýyş edýäris."));
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (currentStep < STEPS.length - 1) {
|
if (currentStep < STEPS.length - 1) {
|
||||||
setCurrentStep(currentStep + 1)
|
setCurrentStep(currentStep + 1);
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
if (currentStep > 0) {
|
if (currentStep > 0) {
|
||||||
markVisited(currentStep)
|
markVisited(currentStep);
|
||||||
setCurrentStep(currentStep - 1)
|
setCurrentStep(currentStep - 1);
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleGoTo = (i: number) => {
|
const handleGoTo = (i: number) => {
|
||||||
markVisited(currentStep)
|
markVisited(currentStep);
|
||||||
setCurrentStep(i)
|
setCurrentStep(i);
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}
|
};
|
||||||
|
|
||||||
// ── Submit ──────────────────────────────────────────────────────────────────
|
// ── Submit ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const doSubmit = () => {
|
const doSubmit = () => {
|
||||||
setVisited(new Set(STEPS.map((_, i) => i)))
|
setVisited(new Set(STEPS.map((_, i) => i)));
|
||||||
setSubmittedSteps(new Set(STEPS.map((_, i) => i)))
|
setSubmittedSteps(new Set(STEPS.map((_, i) => i)));
|
||||||
|
|
||||||
const allErrors: FlatErrors = {}
|
const allErrors: FlatErrors = {};
|
||||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode, t))
|
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode, t));
|
||||||
|
|
||||||
if (Object.keys(allErrors).length > 0) {
|
if (Object.keys(allErrors).length > 0) {
|
||||||
Object.entries(allErrors).forEach(([key, msg]) => {
|
Object.entries(allErrors).forEach(([key, msg]) => {
|
||||||
setError(key as keyof SberPaymentFormData, { type: 'manual', message: msg })
|
setError(key as keyof SberPaymentFormData, { type: "manual", message: msg });
|
||||||
})
|
});
|
||||||
toast.error(t('common.errors.requiredFieldsMissing', 'Käbir hökmany meýdanlar doldurylan däldir.'))
|
toast.error(t("common.errors.requiredFieldsMissing", "Käbir hökmany meýdanlar doldurylan däldir."));
|
||||||
for (let i = 0; i < STEPS.length; i++) {
|
for (let i = 0; i < STEPS.length; i++) {
|
||||||
if (Object.keys(STEPS[i].validate(form, mode, t)).length > 0) {
|
if (Object.keys(STEPS[i].validate(form, mode, t)).length > 0) {
|
||||||
setCurrentStep(i); break
|
setCurrentStep(i);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = buildPayload(getValues())
|
const payload = buildPayload(getValues());
|
||||||
|
|
||||||
if (mode === 'create') {
|
if (mode === "create") {
|
||||||
createMutation.mutate(payload, { onSuccess: () => navigate('/sber-payments') })
|
createMutation.mutate(payload, { onSuccess: () => navigate("/sber-payments") });
|
||||||
} else if (initialData) {
|
} else if (initialData) {
|
||||||
updateMutation.mutate({ ...payload, id: initialData.id }, { onSuccess: () => navigate('/sber-payments') })
|
updateMutation.mutate({ ...payload, id: initialData.id }, { onSuccess: () => navigate("/sber-payments") });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// ── StepBarCards data ──
|
// ── StepBarCards data ──
|
||||||
|
|
||||||
const stepBarItems: StepCardItem[] = STEPS.map((s, i) => {
|
const stepBarItems: StepCardItem[] = STEPS.map((s, i) => {
|
||||||
const isActive = i === currentStep
|
const isActive = i === currentStep;
|
||||||
const hasErrors = stepsWithErrors.has(i)
|
const hasErrors = stepsWithErrors.has(i);
|
||||||
const isDone = visited.has(i) && !hasErrors
|
const isDone = visited.has(i) && !hasErrors;
|
||||||
return {
|
return {
|
||||||
id: s.id,
|
id: s.id,
|
||||||
title: t(s.titleKey) || s.titleFallback,
|
title: t(s.titleKey) || s.titleFallback,
|
||||||
subtitle: t(s.subtitleKey) || s.subtitleFallback,
|
subtitle: t(s.subtitleKey) || s.subtitleFallback,
|
||||||
icon: s.icon,
|
icon: s.icon,
|
||||||
status: isActive ? 'active' : hasErrors ? 'error' : isDone ? 'done' : 'idle',
|
status: isActive ? "active" : hasErrors ? "error" : isDone ? "done" : "idle",
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
||||||
const isLastStep = currentStep === STEPS.length - 1
|
const isLastStep = currentStep === STEPS.length - 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto space-y-6 pb-8">
|
<div className="mx-auto space-y-6 pb-8">
|
||||||
<h1 className="text-2xl font-bold text-foreground">
|
<h1 className="text-2xl font-bold text-foreground">
|
||||||
{mode === 'create'
|
{mode === "create"
|
||||||
? t('sberPayments.formTitle.create', 'Sber töleg dörediň')
|
? t("sberPayments.formTitle.create", "Sber töleg dörediň")
|
||||||
: t('sberPayments.formTitle.edit', 'Sber töleg redaktirläň')}
|
: t("sberPayments.formTitle.edit", "Sber töleg redaktirläň")}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{/* Step bar */}
|
{/* Step bar */}
|
||||||
@@ -536,27 +611,27 @@ export function SberPaymentForm({ mode, initialData }: SberPaymentFormProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Step content */}
|
{/* Step content */}
|
||||||
{STEPS[currentStep].id === 'general' && <StepGeneral form={form} errors={errors} set={set} t={t} />}
|
{STEPS[currentStep].id === "general" && <StepGeneral form={form} errors={errors} set={set} t={t} />}
|
||||||
{STEPS[currentStep].id === 'location' && <StepLocation form={form} errors={errors} set={set} t={t} />}
|
{STEPS[currentStep].id === "location" && <StepLocation form={form} errors={errors} set={set} t={t} />}
|
||||||
{STEPS[currentStep].id === 'personal' && <StepPersonal form={form} errors={errors} set={set} t={t} />}
|
{STEPS[currentStep].id === "personal" && <StepPersonal form={form} errors={errors} set={set} t={t} />}
|
||||||
{STEPS[currentStep].id === 'payment' && <StepPayment form={form} errors={errors} set={set} t={t} />}
|
{STEPS[currentStep].id === "payment" && <StepPayment form={form} errors={errors} set={set} t={t} />}
|
||||||
{STEPS[currentStep].id === 'docs' && <StepDocs form={form} set={set} t={t} />}
|
{STEPS[currentStep].id === "docs" && <StepDocs form={form} set={set} t={t} />}
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Actions */}
|
||||||
<FormActions
|
<FormActions
|
||||||
isPending={isPending}
|
isPending={isPending}
|
||||||
onCancel={() => navigate('/sber-payments')}
|
onCancel={() => navigate("/sber-payments")}
|
||||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||||
onNext={!isLastStep ? handleNext : undefined}
|
onNext={!isLastStep ? handleNext : undefined}
|
||||||
showSubmit={isLastStep}
|
showSubmit={isLastStep}
|
||||||
onSubmit={isLastStep ? doSubmit : undefined}
|
onSubmit={isLastStep ? doSubmit : undefined}
|
||||||
submitLabel={
|
submitLabel={
|
||||||
mode === 'create'
|
mode === "create"
|
||||||
? t('sberPayments.buttons.create', 'Sber töleg (talyplar üçin) dörediň')
|
? t("sberPayments.buttons.create", "Sber töleg (talyplar üçin) dörediň")
|
||||||
: t('sberPayments.buttons.update', 'Ýatda sakla')
|
: t("sberPayments.buttons.update", "Ýatda sakla")
|
||||||
}
|
}
|
||||||
loadingLabel={t('sberPayments.buttons.loading', 'Ýüklenýär...')}
|
loadingLabel={t("sberPayments.buttons.loading", "Ýüklenýär...")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,331 +1,369 @@
|
|||||||
import { useState, useCallback, useMemo } from 'react'
|
import { useState, useCallback, useMemo } from "react";
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from "react-i18next";
|
||||||
import type { TFunction } from 'i18next'
|
import type { TFunction } from "i18next";
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from "react-hook-form";
|
||||||
import { toast } from 'sonner'
|
import { toast } from "sonner";
|
||||||
import {
|
import { User, MapPin, IdCard, CreditCard, Files } from "lucide-react";
|
||||||
User, MapPin, IdCard, CreditCard, Files,
|
import type { LucideIcon } from "lucide-react";
|
||||||
} from 'lucide-react'
|
import { FormInput } from "@/components/formInput";
|
||||||
import type { LucideIcon } from 'lucide-react'
|
import { FormActions } from "@/components/formActions";
|
||||||
import { FormInput } from '@/components/formInput'
|
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||||
import { FormActions } from '@/components/formActions'
|
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||||
import { StepBarCards, type StepCardItem } from '@/components/stepBarV2'
|
import type { IntlPaymentItem, IntlPaymentCreatePayload } from "../api/visaMasterPaymentsApi";
|
||||||
import { BentoGrid, BentoCard } from '@/components/bento'
|
import { useCreateIntlPayment, useUpdateIntlPayment } from "../hooks/useVisaMasterPayments";
|
||||||
import type { IntlPaymentItem, IntlPaymentCreatePayload } from '../api/visaMasterPaymentsApi'
|
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/visaMasterPayment.schema";
|
||||||
import { useCreateIntlPayment, useUpdateIntlPayment } from '../hooks/useVisaMasterPayments'
|
import type { IntlPaymentFormData } from "../schemas/visaMasterPayment.schema";
|
||||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from '../schemas/visaMasterPayment.schema'
|
|
||||||
import type { IntlPaymentFormData } from '../schemas/visaMasterPayment.schema'
|
|
||||||
|
|
||||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
interface IntlPaymentFormProps {
|
interface IntlPaymentFormProps {
|
||||||
mode: 'create' | 'edit'
|
mode: "create" | "edit";
|
||||||
initialData?: IntlPaymentItem
|
initialData?: IntlPaymentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlatErrors = Partial<Record<keyof IntlPaymentFormData, string>>
|
type FlatErrors = Partial<Record<keyof IntlPaymentFormData, string>>;
|
||||||
|
|
||||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const STATUS_OPTIONS = [
|
const STATUS_OPTIONS = [
|
||||||
{ value: 'pending', label: 'Garaşylýar' },
|
{ value: "pending", label: "Garaşylýar" },
|
||||||
{ value: 'approved', label: 'Tassyklandy' },
|
{ value: "approved", label: "Tassyklandy" },
|
||||||
{ value: 'rejected', label: 'Ret edildi' },
|
{ value: "rejected", label: "Ret edildi" },
|
||||||
]
|
];
|
||||||
|
|
||||||
const CURRENCY_OPTIONS = [
|
const CURRENCY_OPTIONS = [
|
||||||
{ value: 'visa', label: 'Visa' },
|
{ value: "visa", label: "Visa" },
|
||||||
{ value: 'mastercard', label: 'MasterCard' },
|
{ value: "mastercard", label: "MasterCard" },
|
||||||
]
|
];
|
||||||
|
|
||||||
const PASSPORT_SERIES_OPTIONS = [
|
const PASSPORT_SERIES_OPTIONS = [
|
||||||
{ value: 'I', label: 'I' },
|
{ value: "I", label: "I" },
|
||||||
{ value: 'II', label: 'II' },
|
{ value: "II", label: "II" },
|
||||||
{ value: 'I-MR', label: 'I-MR' },
|
{ value: "I-MR", label: "I-MR" },
|
||||||
{ value: 'II-MR', label: 'II-MR' },
|
{ value: "II-MR", label: "II-MR" },
|
||||||
]
|
];
|
||||||
|
|
||||||
const PROVINCE_OPTIONS = [
|
const PROVINCE_OPTIONS = [
|
||||||
{ value: 'ashgabat', label: 'Aşgabat' },
|
{ value: "ashgabat", label: "Aşgabat" },
|
||||||
{ value: 'ahal', label: 'Ahal' },
|
{ value: "ahal", label: "Ahal" },
|
||||||
{ value: 'mary', label: 'Mary' },
|
{ value: "mary", label: "Mary" },
|
||||||
{ value: 'dasoguz', label: 'Daşoguz' },
|
{ value: "dasoguz", label: "Daşoguz" },
|
||||||
{ value: 'lebap', label: 'Lebap' },
|
{ value: "lebap", label: "Lebap" },
|
||||||
{ value: 'balkan', label: 'Balkan' },
|
{ value: "balkan", label: "Balkan" },
|
||||||
]
|
];
|
||||||
|
|
||||||
const KABUL_DOCS: { key: keyof IntlPaymentFormData; label: string }[] = [
|
const KABUL_DOCS: { key: keyof IntlPaymentFormData; label: string }[] = [
|
||||||
{ key: 'doc_sberbank_account', label: 'Talypyň SBERBANK kartynyň rekwizitleri' },
|
{ key: "doc_sberbank_account", label: "Talypyň SBERBANK kartynyň rekwizitleri" },
|
||||||
{ key: 'doc_school_enrollment', label: 'Daşary ýurt ÝOM-da okaýandygy barada güwänamasy' },
|
{ key: "doc_school_enrollment", label: "Daşary ýurt ÝOM-da okaýandygy barada güwänamasy" },
|
||||||
{ key: 'doc_summons', label: 'Çagyrylma hatynyn göçürmesi' },
|
{ key: "doc_summons", label: "Çagyrylma hatynyn göçürmesi" },
|
||||||
{ key: 'doc_passport_tm', label: 'TM içki pasportynyň asyl görnüşi we göçürmesi' },
|
{ key: "doc_passport_tm", label: "TM içki pasportynyň asyl görnüşi we göçürmesi" },
|
||||||
{ key: 'doc_foreign_passport', label: 'Daşary ýurt pasportynyň göçürmesi' },
|
{ key: "doc_foreign_passport", label: "Daşary ýurt pasportynyň göçürmesi" },
|
||||||
{ key: 'doc_foreign_passport_copy', label: 'Bakýan döwlet sahypasynyň göçürmesi' },
|
{ key: "doc_foreign_passport_copy", label: "Bakýan döwlet sahypasynyň göçürmesi" },
|
||||||
{ key: 'doc_exit_permission', label: 'Çykyş-giriş rugsat bellikli sahypa göçürmesi' },
|
{ key: "doc_exit_permission", label: "Çykyş-giriş rugsat bellikli sahypa göçürmesi" },
|
||||||
{ key: 'doc_school_foreign_info', label: 'ÝOM-dan hat (okuw dilinde)' },
|
{ key: "doc_school_foreign_info", label: "ÝOM-dan hat (okuw dilinde)" },
|
||||||
{ key: 'doc_school_departure_info', label: 'ÝOM-dan hat (döwlet dilinde)' },
|
{ key: "doc_school_departure_info", label: "ÝOM-dan hat (döwlet dilinde)" },
|
||||||
]
|
];
|
||||||
|
|
||||||
const UPGRAD_DOCS: { key: keyof IntlPaymentFormData; label: string }[] = [
|
const UPGRAD_DOCS: { key: keyof IntlPaymentFormData; label: string }[] = [
|
||||||
{ key: 'upd_doc_passport_tm', label: 'TM içki pasportynyň asyl görnüşi (upd)' },
|
{ key: "upd_doc_passport_tm", label: "TM içki pasportynyň asyl görnüşi (upd)" },
|
||||||
{ key: 'upd_doc_foreign_passport', label: 'Daşary ýurt pasportynyň göçürmesi (upd)' },
|
{ key: "upd_doc_foreign_passport", label: "Daşary ýurt pasportynyň göçürmesi (upd)" },
|
||||||
{ key: 'upd_doc_visa', label: 'Wiza bellenen sahypasynyň göçürmesi' },
|
{ key: "upd_doc_visa", label: "Wiza bellenen sahypasynyň göçürmesi" },
|
||||||
{ key: 'upd_doc_acceptance_letter', label: 'Kabul haty we beýleki resminamalar' },
|
{ key: "upd_doc_acceptance_letter", label: "Kabul haty we beýleki resminamalar" },
|
||||||
{ key: 'upd_doc_passport_biometric', label: 'Täze (2015+) pasport seriýasy maglumatlary' },
|
{ key: "upd_doc_passport_biometric", label: "Täze (2015+) pasport seriýasy maglumatlary" },
|
||||||
{ key: 'upd_doc_passport_old', label: 'Könelräk pasport seriýasy maglumatlary' },
|
{ key: "upd_doc_passport_old", label: "Könelräk pasport seriýasy maglumatlary" },
|
||||||
]
|
];
|
||||||
|
|
||||||
// ─── Step definitions ─────────────────────────────────────────────────────────
|
// ─── Step definitions ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
type StepId = 'general' | 'location' | 'personal' | 'payment' | 'docs'
|
type StepId = "general" | "location" | "personal" | "payment" | "docs";
|
||||||
|
|
||||||
interface StepDef {
|
interface StepDef {
|
||||||
id: StepId
|
id: StepId;
|
||||||
titleKey: string
|
titleKey: string;
|
||||||
titleFallback: string
|
titleFallback: string;
|
||||||
subtitleKey: string
|
subtitleKey: string;
|
||||||
subtitleFallback: string
|
subtitleFallback: string;
|
||||||
icon: LucideIcon
|
icon: LucideIcon;
|
||||||
validate: (form: IntlPaymentFormData, mode: 'create' | 'edit') => FlatErrors
|
validate: (form: IntlPaymentFormData, mode: "create" | "edit") => FlatErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
const STEPS: StepDef[] = [
|
const STEPS: StepDef[] = [
|
||||||
{ id: 'general', titleKey: 'intlPaymentForm.steps.general.title', titleFallback: 'Esasy', subtitleKey: 'intlPaymentForm.steps.general.subtitle', subtitleFallback: 'Status, müşderi', icon: User, validate: (f, m) => validateStep(0, f, m) },
|
{
|
||||||
{ id: 'location', titleKey: 'intlPaymentForm.steps.location.title', titleFallback: 'Lokasiýa', subtitleKey: 'intlPaymentForm.steps.location.subtitle', subtitleFallback: 'Welaýat, şahamça', icon: MapPin, validate: (f, m) => validateStep(1, f, m) },
|
id: "general",
|
||||||
{ id: 'personal', titleKey: 'intlPaymentForm.steps.personal.title', titleFallback: 'Şahsy', subtitleKey: 'intlPaymentForm.steps.personal.subtitle', subtitleFallback: 'Pasport, kontakt', icon: IdCard, validate: (f, m) => validateStep(2, f, m) },
|
titleKey: "intlPaymentForm.steps.general.title",
|
||||||
{ id: 'payment', titleKey: 'intlPaymentForm.steps.payment.title', titleFallback: 'Töleg', subtitleKey: 'intlPaymentForm.steps.payment.subtitle', subtitleFallback: 'Töleýji, kabul ediji', icon: CreditCard, validate: (f, m) => validateStep(3, f, m) },
|
titleFallback: "Esasy",
|
||||||
{ id: 'docs', titleKey: 'intlPaymentForm.steps.docs.title', titleFallback: 'Resminamalar', subtitleKey: 'intlPaymentForm.steps.docs.subtitle', subtitleFallback: '15 resminama', icon: Files, validate: () => ({}) },
|
subtitleKey: "intlPaymentForm.steps.general.subtitle",
|
||||||
]
|
subtitleFallback: "Status, müşderi",
|
||||||
|
icon: User,
|
||||||
|
validate: (f, m) => validateStep(0, f, m),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "location",
|
||||||
|
titleKey: "intlPaymentForm.steps.location.title",
|
||||||
|
titleFallback: "Lokasiýa",
|
||||||
|
subtitleKey: "intlPaymentForm.steps.location.subtitle",
|
||||||
|
subtitleFallback: "Welaýat, şahamça",
|
||||||
|
icon: MapPin,
|
||||||
|
validate: (f, m) => validateStep(1, f, m),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "personal",
|
||||||
|
titleKey: "intlPaymentForm.steps.personal.title",
|
||||||
|
titleFallback: "Şahsy",
|
||||||
|
subtitleKey: "intlPaymentForm.steps.personal.subtitle",
|
||||||
|
subtitleFallback: "Pasport, kontakt",
|
||||||
|
icon: IdCard,
|
||||||
|
validate: (f, m) => validateStep(2, f, m),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "payment",
|
||||||
|
titleKey: "intlPaymentForm.steps.payment.title",
|
||||||
|
titleFallback: "Töleg",
|
||||||
|
subtitleKey: "intlPaymentForm.steps.payment.subtitle",
|
||||||
|
subtitleFallback: "Töleýji, kabul ediji",
|
||||||
|
icon: CreditCard,
|
||||||
|
validate: (f, m) => validateStep(3, f, m),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "docs",
|
||||||
|
titleKey: "intlPaymentForm.steps.docs.title",
|
||||||
|
titleFallback: "Resminamalar",
|
||||||
|
subtitleKey: "intlPaymentForm.steps.docs.subtitle",
|
||||||
|
subtitleFallback: "15 resminama",
|
||||||
|
icon: Files,
|
||||||
|
validate: () => ({}),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// ─── Form errors helper ──────────────────────────────────────────────────────
|
// ─── Form errors helper ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
function flattenErrors(errors: Record<string, { message?: string } | undefined>): FlatErrors {
|
function flattenErrors(errors: Record<string, { message?: string } | undefined>): FlatErrors {
|
||||||
const result: FlatErrors = {}
|
const result: FlatErrors = {};
|
||||||
for (const key of Object.keys(errors)) {
|
for (const key of Object.keys(errors)) {
|
||||||
const msg = errors[key]?.message
|
const msg = errors[key]?.message;
|
||||||
if (msg) result[key as keyof IntlPaymentFormData] = msg
|
if (msg) result[key as keyof IntlPaymentFormData] = msg;
|
||||||
}
|
}
|
||||||
return result
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Step content components ──────────────────────────────────────────────────
|
// ─── Step content components ──────────────────────────────────────────────────
|
||||||
|
|
||||||
interface StepContentProps {
|
interface StepContentProps {
|
||||||
form: IntlPaymentFormData
|
form: IntlPaymentFormData;
|
||||||
errors: FlatErrors
|
errors: FlatErrors;
|
||||||
set: <K extends keyof IntlPaymentFormData>(k: K, v: IntlPaymentFormData[K]) => void
|
set: <K extends keyof IntlPaymentFormData>(k: K, v: IntlPaymentFormData[K]) => void;
|
||||||
t: TFunction
|
t: TFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepGeneral({ form, errors, set, t }: StepContentProps) {
|
function StepGeneral({ form, errors, set, t }: StepContentProps) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('intlPaymentForm.titles.general.client') || 'Müşderi'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t('User') || 'Ulanyjy'}
|
label={t("User") || "Ulanyjy"}
|
||||||
value={form.client_id}
|
value={form.client_id}
|
||||||
onChange={(v) => set('client_id', v)}
|
onChange={(v) => set("client_id", v)}
|
||||||
options={[]}
|
options={[]}
|
||||||
placeholder={t('loanOrderForm.placeholders.searchableSelect') || 'Saýlamak üçin basyň'}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.client_id}
|
error={errors.client_id}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('loanOrderForm.labels.status') || 'Status'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="select"
|
||||||
label={t('loanOrderForm.labels.status') || 'Status'}
|
label={t("loanOrderForm.labels.status") || "Status"}
|
||||||
value={form.status}
|
value={form.status}
|
||||||
onChange={(v) => set('status', v)}
|
onChange={(v) => set("status", v)}
|
||||||
options={STATUS_OPTIONS}
|
options={STATUS_OPTIONS}
|
||||||
error={errors.status}
|
error={errors.status}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('Card type') || 'Kart görnüşi'} span="full">
|
<BentoCard span="full">
|
||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="select"
|
||||||
label={t('Application type') || 'Ýüztumanyň görnüşi'}
|
label={t("Application type") || "Ýüztumanyň görnüşi"}
|
||||||
value={form.currency_type}
|
value={form.currency_type}
|
||||||
onChange={(v) => set('currency_type', v)}
|
onChange={(v) => set("currency_type", v)}
|
||||||
options={CURRENCY_OPTIONS}
|
options={CURRENCY_OPTIONS}
|
||||||
error={errors.currency_type}
|
error={errors.currency_type}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('Note') || 'Bellik'} span="full">
|
<BentoCard span="full">
|
||||||
<FormInput
|
<FormInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label={t('Note') || 'Bellik'}
|
label={t("Note") || "Bellik"}
|
||||||
value={form.note}
|
value={form.note}
|
||||||
onChange={(v) => set('note', v)}
|
onChange={(v) => set("note", v)}
|
||||||
placeholder={t('loanOrderForm.placeholders.note') || 'Bellik...'}
|
placeholder={t("loanOrderForm.placeholders.note") || "Bellik..."}
|
||||||
rows={2}
|
rows={2}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepLocation({ form, errors, set, t }: StepContentProps) {
|
function StepLocation({ form, errors, set, t }: StepContentProps) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('Region') || 'Welaýat'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t('Region') || 'Welaýat'}
|
label={t("Region") || "Welaýat"}
|
||||||
value={form.province}
|
value={form.province}
|
||||||
onChange={(v) => { set('province', v); set('branch', '') }}
|
onChange={(v) => {
|
||||||
|
set("province", v);
|
||||||
|
set("branch", "");
|
||||||
|
}}
|
||||||
options={PROVINCE_OPTIONS}
|
options={PROVINCE_OPTIONS}
|
||||||
error={errors.province}
|
error={errors.province}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{t('intlPaymentForm.hints.selectRegion') || 'Welaýaty saýlasaňyz şahamçalar güncellenar.'}
|
|
||||||
</p>
|
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('Branch') || 'Şahamça'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="searchable-select"
|
type="searchable-select"
|
||||||
label={t('Branch') || 'Şahamça'}
|
label={t("Branch") || "Şahamça"}
|
||||||
value={form.branch}
|
value={form.branch}
|
||||||
onChange={(v) => set('branch', v)}
|
onChange={(v) => set("branch", v)}
|
||||||
options={[]}
|
options={[]}
|
||||||
placeholder={t('loanOrderForm.placeholders.searchableSelect') || 'Saýlamak üçin basyň'}
|
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||||
error={errors.branch}
|
error={errors.branch}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepPersonal({ form, errors, set, t }: StepContentProps) {
|
function StepPersonal({ form, errors, set, t }: StepContentProps) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('intlPaymentForm.titles.personal.name') || 'At-familýa'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('Passport surname') || 'Pasportdaky familiýa'}
|
label={t("Passport surname") || "Pasportdaky familiýa"}
|
||||||
value={form.passport_last_name}
|
value={form.passport_last_name}
|
||||||
onChange={(v) => set('passport_last_name', v)}
|
onChange={(v) => set("passport_last_name", v)}
|
||||||
placeholder="NURYYEW"
|
placeholder="NURYYEW"
|
||||||
error={errors.passport_last_name}
|
error={errors.passport_last_name}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('Passport name') || 'Pasportdaky ady'}
|
label={t("Passport name") || "Pasportdaky ady"}
|
||||||
value={form.passport_first_name}
|
value={form.passport_first_name}
|
||||||
onChange={(v) => set('passport_first_name', v)}
|
onChange={(v) => set("passport_first_name", v)}
|
||||||
placeholder="HAÝDAR"
|
placeholder="HAÝDAR"
|
||||||
error={errors.passport_first_name}
|
error={errors.passport_first_name}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('Contact data') || 'Kontakt'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="phone"
|
type="phone"
|
||||||
label={t('Phone') || 'Telefon'}
|
label={t("Phone") || "Telefon"}
|
||||||
value={form.phone}
|
value={form.phone}
|
||||||
onChange={(v) => set('phone', v)}
|
onChange={(v) => set("phone", v)}
|
||||||
error={errors.phone}
|
error={errors.phone}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="email"
|
type="email"
|
||||||
label={t('Email') || 'E-poçta'}
|
label={t("Email") || "E-poçta"}
|
||||||
value={form.email}
|
value={form.email}
|
||||||
onChange={(v) => set('email', v)}
|
onChange={(v) => set("email", v)}
|
||||||
placeholder="email@example.com"
|
placeholder="email@example.com"
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('Current Residence') || 'Häzirki ýaşaýyş ýeri'} span="full">
|
<BentoCard span="full">
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('Current Residence') || 'Häzirki ýaşaýyş ýeri'}
|
label={t("Current Residence") || "Häzirki ýaşaýyş ýeri"}
|
||||||
value={form.home_address}
|
value={form.home_address}
|
||||||
onChange={(v) => set('home_address', v)}
|
onChange={(v) => set("home_address", v)}
|
||||||
placeholder={t('intlPaymentForm.placeholders.address') || 'Köçe, jaý belgisi...'}
|
placeholder={t("intlPaymentForm.placeholders.address") || "Köçe, jaý belgisi..."}
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepPayment({ form, errors, set, t }: StepContentProps) {
|
function StepPayment({ form, errors, set, t }: StepContentProps) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('Passport') || 'Pasport maglumatlary'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="select"
|
type="select"
|
||||||
label={t('Passport serie') || 'Pasport seriýasy'}
|
label={t("Passport serie") || "Pasport seriýasy"}
|
||||||
value={form.passport_series}
|
value={form.passport_series}
|
||||||
onChange={(v) => set('passport_series', v)}
|
onChange={(v) => set("passport_series", v)}
|
||||||
options={PASSPORT_SERIES_OPTIONS}
|
options={PASSPORT_SERIES_OPTIONS}
|
||||||
error={errors.passport_series}
|
error={errors.passport_series}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('Passport id') || 'Pasport belgisi'}
|
label={t("Passport id") || "Pasport belgisi"}
|
||||||
value={form.passport_number}
|
value={form.passport_number}
|
||||||
onChange={(v) => set('passport_number', v)}
|
onChange={(v) => set("passport_number", v)}
|
||||||
placeholder="A123456"
|
placeholder="A123456"
|
||||||
error={errors.passport_number}
|
error={errors.passport_number}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('intlPaymentForm.titles.payment.payer') || 'Töleýji'}>
|
<BentoCard>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('intlPaymentForm.labels.payerFullName') || 'Ady Familiýasy Atasynyň ady'}
|
label={t("intlPaymentForm.labels.payerFullName") || "Ady Familiýasy Atasynyň ady"}
|
||||||
value={form.payer_full_name}
|
value={form.payer_full_name}
|
||||||
onChange={(v) => set('payer_full_name', v)}
|
onChange={(v) => set("payer_full_name", v)}
|
||||||
placeholder={t('intlPaymentForm.placeholders.payerFullName') || 'Doly ady...'}
|
placeholder={t("intlPaymentForm.placeholders.payerFullName") || "Doly ady..."}
|
||||||
error={errors.payer_full_name}
|
error={errors.payer_full_name}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<FormInput
|
<FormInput
|
||||||
type="text"
|
type="text"
|
||||||
label={t('intlPaymentForm.labels.payerAccount') || 'Goşun hasaby'}
|
label={t("intlPaymentForm.labels.payerAccount") || "Goşun hasaby"}
|
||||||
value={form.payer_account_number}
|
value={form.payer_account_number}
|
||||||
onChange={(v) => set('payer_account_number', v)}
|
onChange={(v) => set("payer_account_number", v)}
|
||||||
placeholder={t('intlPaymentForm.placeholders.payerAccount') || '1234 5678 ...'}
|
placeholder={t("intlPaymentForm.placeholders.payerAccount") || "1234 5678 ..."}
|
||||||
error={errors.payer_account_number}
|
error={errors.payer_account_number}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('Payee information') || 'Kabul edijiniň maglumatlary'} span="full">
|
<BentoCard span="full">
|
||||||
<FormInput
|
<FormInput
|
||||||
type="textarea"
|
type="textarea"
|
||||||
label={t('intlPaymentForm.labels.receiverInfo') || 'Töleg kabul edijiniň maglumatlary'}
|
label={t("intlPaymentForm.labels.receiverInfo") || "Töleg kabul edijiniň maglumatlary"}
|
||||||
value={form.receiver_info}
|
value={form.receiver_info}
|
||||||
onChange={(v) => set('receiver_info', v)}
|
onChange={(v) => set("receiver_info", v)}
|
||||||
placeholder={t('intlPaymentForm.placeholders.receiverInfo') || 'Kabul ediji bank, hasap, Swift...'}
|
placeholder={t("intlPaymentForm.placeholders.receiverInfo") || "Kabul ediji bank, hasap, Swift..."}
|
||||||
rows={3}
|
rows={3}
|
||||||
error={errors.receiver_info}
|
error={errors.receiver_info}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepDocs({ form, set, t }: StepContentProps) {
|
function StepDocs({ form, set }: StepContentProps) {
|
||||||
return (
|
return (
|
||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t('intlPaymentForm.titles.docs.kabul') || 'Kabul ediji talyp — 9 resminama'}>
|
<BentoCard>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{KABUL_DOCS.map(({ key, label }) => (
|
{KABUL_DOCS.map(({ key, label }) => (
|
||||||
<FormInput
|
<FormInput
|
||||||
@@ -340,7 +378,7 @@ function StepDocs({ form, set, t }: StepContentProps) {
|
|||||||
</div>
|
</div>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t('intlPaymentForm.titles.docs.upgrad') || 'Upgradyý — 6 resminama'}>
|
<BentoCard>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{UPGRAD_DOCS.map(({ key, label }) => (
|
{UPGRAD_DOCS.map(({ key, label }) => (
|
||||||
<FormInput
|
<FormInput
|
||||||
@@ -355,181 +393,186 @@ function StepDocs({ form, set, t }: StepContentProps) {
|
|||||||
</div>
|
</div>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Initial data mapper ──────────────────────────────────────────────────────
|
// ─── Initial data mapper ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
function mapInitial(data: IntlPaymentItem): Partial<IntlPaymentFormData> {
|
function mapInitial(data: IntlPaymentItem): Partial<IntlPaymentFormData> {
|
||||||
return {
|
return {
|
||||||
client_id: data.client_id,
|
client_id: data.client_id,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
note: data.note ?? '',
|
note: data.note ?? "",
|
||||||
currency_type: data.currency_type,
|
currency_type: data.currency_type,
|
||||||
province: data.province,
|
province: data.province,
|
||||||
branch: data.branch,
|
branch: data.branch,
|
||||||
passport_first_name: data.passport_first_name,
|
passport_first_name: data.passport_first_name,
|
||||||
passport_last_name: data.passport_last_name,
|
passport_last_name: data.passport_last_name,
|
||||||
phone: data.phone,
|
phone: data.phone,
|
||||||
email: data.email ?? '',
|
email: data.email ?? "",
|
||||||
home_address: data.home_address ?? '',
|
home_address: data.home_address ?? "",
|
||||||
passport_series: data.passport_series,
|
passport_series: data.passport_series,
|
||||||
passport_number: data.passport_number,
|
passport_number: data.passport_number,
|
||||||
payer_full_name: data.payer_full_name,
|
payer_full_name: data.payer_full_name,
|
||||||
payer_account_number: data.payer_account_number,
|
payer_account_number: data.payer_account_number,
|
||||||
receiver_info: data.receiver_info,
|
receiver_info: data.receiver_info,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Main Component ───────────────────────────────────────────────────────────
|
// ─── Main Component ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export function IntlPaymentForm({ mode, initialData }: IntlPaymentFormProps) {
|
export function IntlPaymentForm({ mode, initialData }: IntlPaymentFormProps) {
|
||||||
const { t, i18n } = useTranslation()
|
const { t, i18n } = useTranslation();
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate();
|
||||||
const createMutation = useCreateIntlPayment()
|
const createMutation = useCreateIntlPayment();
|
||||||
const updateMutation = useUpdateIntlPayment(initialData?.id ?? '')
|
const updateMutation = useUpdateIntlPayment(initialData?.id ?? "");
|
||||||
const isPending = createMutation.isPending || updateMutation.isPending
|
const isPending = createMutation.isPending || updateMutation.isPending;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
watch, setValue, getValues, formState: { errors: rhfErrors }, clearErrors, setError,
|
watch,
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
formState: { errors: rhfErrors },
|
||||||
|
clearErrors,
|
||||||
|
setError,
|
||||||
} = useForm<IntlPaymentFormData>({
|
} = useForm<IntlPaymentFormData>({
|
||||||
defaultValues: initialData ? { ...DEFAULT_FORM_VALUES, ...mapInitial(initialData) } : DEFAULT_FORM_VALUES,
|
defaultValues: initialData ? { ...DEFAULT_FORM_VALUES, ...mapInitial(initialData) } : DEFAULT_FORM_VALUES,
|
||||||
})
|
});
|
||||||
|
|
||||||
const form = watch()
|
const form = watch();
|
||||||
const [currentStep, setCurrentStep] = useState(0)
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
const [visited, setVisited] = useState<Set<number>>(
|
const [visited, setVisited] = useState<Set<number>>(() => (mode === "edit" ? new Set(STEPS.map((_, i) => i)) : new Set<number>()));
|
||||||
() => mode === 'edit' ? new Set(STEPS.map((_, i) => i)) : new Set<number>(),
|
const [submittedSteps, setSubmittedSteps] = useState<Set<number>>(new Set());
|
||||||
)
|
|
||||||
const [submittedSteps, setSubmittedSteps] = useState<Set<number>>(new Set())
|
|
||||||
|
|
||||||
const stepsWithErrors = useMemo(() => {
|
const stepsWithErrors = useMemo(() => {
|
||||||
const out = new Set<number>()
|
const out = new Set<number>();
|
||||||
visited.forEach((i) => {
|
visited.forEach((i) => {
|
||||||
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) out.add(i)
|
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) out.add(i);
|
||||||
})
|
});
|
||||||
return out
|
return out;
|
||||||
}, [form, mode, visited, i18n.language])
|
}, [form, mode, visited, i18n.language]);
|
||||||
|
|
||||||
const set = useCallback(<K extends keyof IntlPaymentFormData>(key: K, value: IntlPaymentFormData[K]) => {
|
const set = useCallback(
|
||||||
(setValue as (name: K, val: IntlPaymentFormData[K]) => void)(key, value)
|
<K extends keyof IntlPaymentFormData>(key: K, value: IntlPaymentFormData[K]) => {
|
||||||
clearErrors(key)
|
(setValue as (name: K, val: IntlPaymentFormData[K]) => void)(key, value);
|
||||||
}, [setValue, clearErrors])
|
clearErrors(key);
|
||||||
|
},
|
||||||
|
[setValue, clearErrors],
|
||||||
|
);
|
||||||
|
|
||||||
const allSubmittedErrors = useMemo(() => {
|
const allSubmittedErrors = useMemo(() => {
|
||||||
const result: FlatErrors = {}
|
const result: FlatErrors = {};
|
||||||
for (const stepIdx of submittedSteps) {
|
for (const stepIdx of submittedSteps) {
|
||||||
Object.assign(result, STEPS[stepIdx].validate(form, mode))
|
Object.assign(result, STEPS[stepIdx].validate(form, mode));
|
||||||
}
|
}
|
||||||
return result
|
return result;
|
||||||
}, [form, mode, submittedSteps, i18n.language])
|
}, [form, mode, submittedSteps, i18n.language]);
|
||||||
|
|
||||||
const errors = useMemo(() => {
|
const errors = useMemo(() => {
|
||||||
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>)
|
const fromRHF = flattenErrors(rhfErrors as Record<string, { message?: string } | undefined>);
|
||||||
return { ...fromRHF, ...allSubmittedErrors }
|
return { ...fromRHF, ...allSubmittedErrors };
|
||||||
}, [rhfErrors, allSubmittedErrors])
|
}, [rhfErrors, allSubmittedErrors]);
|
||||||
|
|
||||||
const stepProps = useMemo(() => ({ form, errors, set, t }), [form, errors, set, t])
|
const stepProps = useMemo(() => ({ form, errors, set, t }), [form, errors, set, t]);
|
||||||
|
|
||||||
// ── Navigation ──────────────────────────────────────────────────────────────
|
// ── Navigation ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const markVisited = (i: number) =>
|
const markVisited = (i: number) => setVisited((prev) => new Set([...prev, i]));
|
||||||
setVisited((prev) => new Set([...prev, i]))
|
|
||||||
|
|
||||||
const markSubmitted = (i: number) =>
|
const markSubmitted = (i: number) => setSubmittedSteps((prev) => new Set([...prev, i]));
|
||||||
setSubmittedSteps((prev) => new Set([...prev, i]))
|
|
||||||
|
|
||||||
const handleNext = () => {
|
const handleNext = () => {
|
||||||
markVisited(currentStep)
|
markVisited(currentStep);
|
||||||
markSubmitted(currentStep)
|
markSubmitted(currentStep);
|
||||||
const errs = STEPS[currentStep].validate(form, mode)
|
const errs = STEPS[currentStep].validate(form, mode);
|
||||||
if (Object.keys(errs).length > 0) {
|
if (Object.keys(errs).length > 0) {
|
||||||
Object.entries(errs).forEach(([key, msg]) => {
|
Object.entries(errs).forEach(([key, msg]) => {
|
||||||
setError(key as keyof IntlPaymentFormData, { type: 'manual', message: msg })
|
setError(key as keyof IntlPaymentFormData, { type: "manual", message: msg });
|
||||||
})
|
});
|
||||||
toast.error(t('common.errors.fillRequiredCorrectly', 'Dogry maglumat girizmegiňizi haýyş edýäris.'))
|
toast.error(t("common.errors.fillRequiredCorrectly", "Dogry maglumat girizmegiňizi haýyş edýäris."));
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (currentStep < STEPS.length - 1) {
|
if (currentStep < STEPS.length - 1) {
|
||||||
setCurrentStep(currentStep + 1)
|
setCurrentStep(currentStep + 1);
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
if (currentStep > 0) {
|
if (currentStep > 0) {
|
||||||
markVisited(currentStep)
|
markVisited(currentStep);
|
||||||
setCurrentStep(currentStep - 1)
|
setCurrentStep(currentStep - 1);
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleGoTo = (i: number) => {
|
const handleGoTo = (i: number) => {
|
||||||
markVisited(currentStep)
|
markVisited(currentStep);
|
||||||
setCurrentStep(i)
|
setCurrentStep(i);
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
}
|
};
|
||||||
|
|
||||||
// ── Submit ──────────────────────────────────────────────────────────────────
|
// ── Submit ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const doSubmit = () => {
|
const doSubmit = () => {
|
||||||
setVisited(new Set(STEPS.map((_, i) => i)))
|
setVisited(new Set(STEPS.map((_, i) => i)));
|
||||||
setSubmittedSteps(new Set(STEPS.map((_, i) => i)))
|
setSubmittedSteps(new Set(STEPS.map((_, i) => i)));
|
||||||
|
|
||||||
const allErrors: FlatErrors = {}
|
const allErrors: FlatErrors = {};
|
||||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode))
|
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode));
|
||||||
|
|
||||||
if (Object.keys(allErrors).length > 0) {
|
if (Object.keys(allErrors).length > 0) {
|
||||||
Object.entries(allErrors).forEach(([key, msg]) => {
|
Object.entries(allErrors).forEach(([key, msg]) => {
|
||||||
setError(key as keyof IntlPaymentFormData, { type: 'manual', message: msg })
|
setError(key as keyof IntlPaymentFormData, { type: "manual", message: msg });
|
||||||
})
|
});
|
||||||
toast.error(t('common.errors.requiredFieldsMissing', 'Käbir hökmany meýdanlar doldurylan däldir.'))
|
toast.error(t("common.errors.requiredFieldsMissing", "Käbir hökmany meýdanlar doldurylan däldir."));
|
||||||
for (let i = 0; i < STEPS.length; i++) {
|
for (let i = 0; i < STEPS.length; i++) {
|
||||||
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) {
|
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) {
|
||||||
setCurrentStep(i); break
|
setCurrentStep(i);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = buildPayload(getValues())
|
const payload = buildPayload(getValues());
|
||||||
|
|
||||||
if (mode === 'create') {
|
if (mode === "create") {
|
||||||
createMutation.mutate(payload as IntlPaymentCreatePayload, {
|
createMutation.mutate(payload as IntlPaymentCreatePayload, {
|
||||||
onSuccess: (data) => navigate(`/intl-payments/visa-master/${data.id}`),
|
onSuccess: (data) => navigate(`/intl-payments/visa-master/${data.id}`),
|
||||||
})
|
});
|
||||||
} else if (initialData) {
|
} else if (initialData) {
|
||||||
updateMutation.mutate(payload as IntlPaymentCreatePayload, {
|
updateMutation.mutate(payload as IntlPaymentCreatePayload, {
|
||||||
onSuccess: () => navigate(`/intl-payments/visa-master/${initialData.id}`),
|
onSuccess: () => navigate(`/intl-payments/visa-master/${initialData.id}`),
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// ── StepBar items ──────────────────────────────────────────────────────────
|
// ── StepBar items ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const stepBarItems: StepCardItem[] = STEPS.map((s, i) => {
|
const stepBarItems: StepCardItem[] = STEPS.map((s, i) => {
|
||||||
const isActive = i === currentStep
|
const isActive = i === currentStep;
|
||||||
const hasErrors = stepsWithErrors.has(i)
|
const hasErrors = stepsWithErrors.has(i);
|
||||||
const isDone = visited.has(i) && !hasErrors
|
const isDone = visited.has(i) && !hasErrors;
|
||||||
return {
|
return {
|
||||||
id: s.id,
|
id: s.id,
|
||||||
title: t(s.titleKey) || s.titleFallback,
|
title: t(s.titleKey) || s.titleFallback,
|
||||||
subtitle: t(s.subtitleKey) || s.subtitleFallback,
|
subtitle: t(s.subtitleKey) || s.subtitleFallback,
|
||||||
icon: s.icon,
|
icon: s.icon,
|
||||||
status: isActive ? 'active' : hasErrors ? 'error' : isDone ? 'done' : 'idle',
|
status: isActive ? "active" : hasErrors ? "error" : isDone ? "done" : "idle",
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
|
||||||
const isLastStep = currentStep === STEPS.length - 1
|
const isLastStep = currentStep === STEPS.length - 1;
|
||||||
|
|
||||||
// ── Render ──────────────────────────────────────────────────────────────────
|
// ── Render ──────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto space-y-6">
|
<div className="mx-auto space-y-6">
|
||||||
<h1 className="text-2xl font-bold text-foreground">
|
<h1 className="text-2xl font-bold text-foreground">
|
||||||
{mode === 'create'
|
{mode === "create"
|
||||||
? t('intlPayment.createTitle', 'Visa/Master tölegler (talyplar üçin) dörediň')
|
? t("intlPayment.createTitle", "Visa/Master tölegler (talyplar üçin) dörediň")
|
||||||
: t('intlPayment.editTitle', 'Visa/Master tölegler (talyplar üçin) redaktirläň')}
|
: t("intlPayment.editTitle", "Visa/Master tölegler (talyplar üçin) redaktirläň")}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{/* Step bar */}
|
{/* Step bar */}
|
||||||
@@ -538,26 +581,22 @@ export function IntlPaymentForm({ mode, initialData }: IntlPaymentFormProps) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Step content */}
|
{/* Step content */}
|
||||||
{STEPS[currentStep].id === 'general' && <StepGeneral {...stepProps} />}
|
{STEPS[currentStep].id === "general" && <StepGeneral {...stepProps} />}
|
||||||
{STEPS[currentStep].id === 'location' && <StepLocation {...stepProps} />}
|
{STEPS[currentStep].id === "location" && <StepLocation {...stepProps} />}
|
||||||
{STEPS[currentStep].id === 'personal' && <StepPersonal {...stepProps} />}
|
{STEPS[currentStep].id === "personal" && <StepPersonal {...stepProps} />}
|
||||||
{STEPS[currentStep].id === 'payment' && <StepPayment {...stepProps} />}
|
{STEPS[currentStep].id === "payment" && <StepPayment {...stepProps} />}
|
||||||
{STEPS[currentStep].id === 'docs' && <StepDocs {...stepProps} />}
|
{STEPS[currentStep].id === "docs" && <StepDocs {...stepProps} />}
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Actions */}
|
||||||
<FormActions
|
<FormActions
|
||||||
isPending={isPending}
|
isPending={isPending}
|
||||||
onCancel={() => navigate('/intl-payments/visa-master')}
|
onCancel={() => navigate("/intl-payments/visa-master")}
|
||||||
onPrev={currentStep > 0 ? handleBack : undefined}
|
onPrev={currentStep > 0 ? handleBack : undefined}
|
||||||
onNext={!isLastStep ? handleNext : undefined}
|
onNext={!isLastStep ? handleNext : undefined}
|
||||||
showSubmit={isLastStep}
|
showSubmit={isLastStep}
|
||||||
onSubmit={isLastStep ? doSubmit : undefined}
|
onSubmit={isLastStep ? doSubmit : undefined}
|
||||||
submitLabel={
|
submitLabel={mode === "create" ? t("intlPayment.createBtn", "Dörediň") : t("intlPayment.editBtn", "Redaktirläň")}
|
||||||
mode === 'create'
|
|
||||||
? t('intlPayment.createBtn', 'Dörediň')
|
|
||||||
: t('intlPayment.editBtn', 'Redaktirläň')
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -605,7 +605,6 @@
|
|||||||
"intlPaymentForm.placeholders.payerAccount": "1234 5678 ...",
|
"intlPaymentForm.placeholders.payerAccount": "1234 5678 ...",
|
||||||
"intlPaymentForm.placeholders.receiverInfo": "Kabul ediji bank, hasap, Swift...",
|
"intlPaymentForm.placeholders.receiverInfo": "Kabul ediji bank, hasap, Swift...",
|
||||||
"intlPaymentForm.placeholders.address": "Köçe, jaý belgisi...",
|
"intlPaymentForm.placeholders.address": "Köçe, jaý belgisi...",
|
||||||
"intlPaymentForm.hints.selectRegion": "Welaýaty saýlasaňyz şahamçalar güncellenar.",
|
|
||||||
"visaMasterSettings.title": "Visa/Master, Sber sazlamalar",
|
"visaMasterSettings.title": "Visa/Master, Sber sazlamalar",
|
||||||
"visaMasterSettings.fields.kod": "Kod",
|
"visaMasterSettings.fields.kod": "Kod",
|
||||||
"visaMasterSettings.fields.ady": "Ady",
|
"visaMasterSettings.fields.ady": "Ady",
|
||||||
@@ -677,7 +676,6 @@
|
|||||||
"sberPayments.placeholders.passportNumber": "A123456",
|
"sberPayments.placeholders.passportNumber": "A123456",
|
||||||
"sberPayments.placeholders.fullName": "Doly ady...",
|
"sberPayments.placeholders.fullName": "Doly ady...",
|
||||||
"sberPayments.placeholders.accountNumber": "1234 5678 ...",
|
"sberPayments.placeholders.accountNumber": "1234 5678 ...",
|
||||||
"sberPayments.hints.selectRegion": "Welaýaty saýlasaňyz şahamçalar güncellenar.",
|
|
||||||
"sberPayments.documents.sberbankCard": "Talýba degişli SBERBANK kartynyň rekwizitleri",
|
"sberPayments.documents.sberbankCard": "Talýba degişli SBERBANK kartynyň rekwizitleri",
|
||||||
"sberPayments.documents.enrollment": "Daşary ýurt ÝOM-da okaýandygy baradaky güwänamasy",
|
"sberPayments.documents.enrollment": "Daşary ýurt ÝOM-da okaýandygy baradaky güwänamasy",
|
||||||
"sberPayments.documents.summons": "Çagyrylma hatynyn göçürmesi",
|
"sberPayments.documents.summons": "Çagyrylma hatynyn göçürmesi",
|
||||||
|
|||||||
+14
-24
@@ -1,8 +1,8 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Trash2, Database, CheckCircle2, XCircle, Clock } from "lucide-react";
|
import { Download, Database, CheckCircle2, XCircle, Clock } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
@@ -79,27 +79,17 @@ export default function BackupsPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<TableActions
|
||||||
<Button
|
extraActions={[
|
||||||
variant="ghost"
|
{
|
||||||
size="icon"
|
icon: Download,
|
||||||
className="h-7 w-7"
|
title: t("common.download", "Ýükle"),
|
||||||
onClick={() => downloadBackup.mutate(row.original.id)}
|
onClick: () => downloadBackup.mutate(row.original.id),
|
||||||
disabled={row.original.status === "in_progress"}
|
disabled: row.original.status === "in_progress",
|
||||||
title={t("common.download", "Ýükle")}
|
},
|
||||||
>
|
]}
|
||||||
<Download size={14} />
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
</Button>
|
/>
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Poz")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -128,7 +118,7 @@ export default function BackupsPage() {
|
|||||||
{t("backups.title", "Bekaplar")}
|
{t("backups.title", "Bekaplar")}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Eye, Pencil, Trash2 } from "lucide-react";
|
import { Download } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { VisibilityState } from "@tanstack/react-table";
|
import type { VisibilityState } from "@tanstack/react-table";
|
||||||
import { useCardBalances, useDeleteCardBalance, useDownloadCardBalance } from "@/features/cardBalance/hooks/useCardBalance";
|
import { useCardBalances, useDeleteCardBalance, useDownloadCardBalance } from "@/features/cardBalance/hooks/useCardBalance";
|
||||||
import { type CardBalance } from "@/features/cardBalance/api/cardBalanceApi";
|
import { type CardBalance } from "@/features/cardBalance/api/cardBalanceApi";
|
||||||
@@ -77,44 +77,13 @@ export default function CardBalancesPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<TableActions
|
||||||
<Button
|
extraActions={[{ icon: Download, title: t("Download", "Ýükle"), onClick: () => downloadMutation.mutate(row.original.id) }]}
|
||||||
variant="ghost"
|
onView={() => navigate(`/card-balances/${row.original.id}`)}
|
||||||
size="icon"
|
onEdit={() => navigate(`/card-balances/${row.original.id}/edit`)}
|
||||||
className="h-7 w-7"
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
onClick={() => downloadMutation.mutate(row.original.id)}
|
isDeleting={deleteMutation.isPending}
|
||||||
title={t("Download", "Ýükle")}
|
/>
|
||||||
>
|
|
||||||
<Download size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
onClick={() => navigate(`/card-balances/${row.original.id}`)}
|
|
||||||
title={t("View", "Görmek")}
|
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
onClick={() => navigate(`/card-balances/${row.original.id}/edit`)}
|
|
||||||
title={t("Edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("Delete", "Öçürmek")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -140,7 +109,7 @@ export default function CardBalancesPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-xl font-semibold text-foreground">{t("Card balances", "Kart galyndylary")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("Card balances", "Kart galyndylary")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import { DataTable } from "@/components/dataTable";
|
|||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
import { useCardPins } from "@/features/cardPins/hooks/useCardPins";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
|
||||||
import type { CardPinItem, CardPinStatus } from "@/features/cardPins/api/cardPinApi";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
|
|
||||||
|
import { useCardPins, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||||
|
import { type CardPinStatus, type CardPinItem } from "@/features/cardPins/api/cardPinApi";
|
||||||
|
|
||||||
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
// ─── Status Badge ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -114,22 +114,12 @@ export default function CardPinsPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1">
|
<TableActions
|
||||||
<Button size="icon" variant="ghost" className="h-7 w-7" onClick={() => navigate(`/card-pins/${row.original.id}`)}>
|
onView={() => navigate(`/card-pins/${row.original.id}`)}
|
||||||
<Eye size={14} />
|
onEdit={() => navigate(`/card-pins/${row.original.id}/edit`)}
|
||||||
</Button>
|
onDelete={() => setDeleteTarget(row.original)}
|
||||||
<Button size="icon" variant="ghost" className="h-7 w-7" onClick={() => navigate(`/card-pins/${row.original.id}/edit`)}>
|
isDeleting={isDeleting}
|
||||||
<Pencil size={14} />
|
/>
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteTarget(row.original)}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -147,7 +137,7 @@ export default function CardPinsPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-xl font-semibold text-foreground">{t("Card pins", "Kart pin bukjalary")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("Card pins", "Kart pin bukjalary")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Eye, Pencil, Trash2 } from "lucide-react";
|
import { Download } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { VisibilityState } from "@tanstack/react-table";
|
import type { VisibilityState } from "@tanstack/react-table";
|
||||||
import { useCardRequisites, useDeleteCardRequisite, useDownloadCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
import { useCardRequisites, useDeleteCardRequisite, useDownloadCardRequisite } from "@/features/cardRequisites/hooks/useCardRequisites";
|
||||||
import type { CardRequisite, CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
import type { CardRequisite, CardRequisiteStatus } from "@/features/cardRequisites/api/cardRequisitesApi";
|
||||||
@@ -122,25 +122,13 @@ export default function CardRequisitesPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<TableActions
|
||||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => downloadMutation.mutate(row.original.id)}>
|
extraActions={[{ icon: Download, title: t("Download", "Ýükle"), onClick: () => downloadMutation.mutate(row.original.id) }]}
|
||||||
<Download size={14} />
|
onView={() => navigate(`/card-requisites/${row.original.id}`)}
|
||||||
</Button>
|
onEdit={() => navigate(`/card-requisites/${row.original.id}/edit`)}
|
||||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => navigate(`/card-requisites/${row.original.id}`)}>
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
<Eye size={14} />
|
isDeleting={deleteMutation.isPending}
|
||||||
</Button>
|
/>
|
||||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => navigate(`/card-requisites/${row.original.id}/edit`)}>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -171,7 +159,7 @@ export default function CardRequisitesPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-xl font-semibold text-foreground">{t("Card requisites", "Kart rekwizitler")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("Card requisites", "Kart rekwizitler")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Download, Eye, Pencil, Trash2 } from "lucide-react";
|
import { Download } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ColumnMeta } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { VisibilityState } from "@tanstack/react-table";
|
import type { VisibilityState } from "@tanstack/react-table";
|
||||||
import {
|
import {
|
||||||
useCardTransactions,
|
useCardTransactions,
|
||||||
@@ -86,44 +86,13 @@ export default function CardTransactionsPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<TableActions
|
||||||
<Button
|
extraActions={[{ icon: Download, title: t("Download", "Ýükle"), onClick: () => downloadMutation.mutate(row.original.id) }]}
|
||||||
variant="ghost"
|
onView={() => navigate(`/card-transactions/${row.original.id}`)}
|
||||||
size="icon"
|
onEdit={() => navigate(`/card-transactions/${row.original.id}/edit`)}
|
||||||
className="h-7 w-7"
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
onClick={() => downloadMutation.mutate(row.original.id)}
|
isDeleting={deleteMutation.isPending}
|
||||||
title={t("Download", "Ýükle")}
|
/>
|
||||||
>
|
|
||||||
<Download size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
onClick={() => navigate(`/card-transactions/${row.original.id}`)}
|
|
||||||
title={t("View", "Görmek")}
|
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7"
|
|
||||||
onClick={() => navigate(`/card-transactions/${row.original.id}/edit`)}
|
|
||||||
title={t("Edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("Delete", "Öçürmek")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -155,7 +124,7 @@ export default function CardTransactionsPage() {
|
|||||||
<h1 className="text-xl font-semibold text-foreground">{t("Card transactions", "Kart hereketleri")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("Card transactions", "Kart hereketleri")}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { useState, useMemo, useCallback } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { useNavigate, Link } from "react-router-dom";
|
import { useNavigate, Link } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle, AlertCircle } from "lucide-react";
|
import { CheckCircle2, XCircle, AlertCircle } from "lucide-react";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useCardOrders, useDeleteCardOrder, useProvinces, useBranches } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
import { useCardOrders, useDeleteCardOrder, useProvinces, useBranches } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||||
import type { CardOrderListItem, CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
import type { CardOrderListItem, CardOrderStatus } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||||
@@ -183,30 +184,12 @@ export default function CardOrdersPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1.5 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/order-new-card/${row.original.id}`)}
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onEdit={() => navigate(`/order-new-card/${row.original.id}/edit`)}
|
||||||
title={t("common.view", "Görkez")}
|
onDelete={() => handleDelete(row.original.id)}
|
||||||
onClick={() => navigate(`/order-new-card/${row.original.id}`)}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
/>
|
||||||
<Eye size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
title={t("common.edit", "Düzet")}
|
|
||||||
onClick={() => navigate(`/order-new-card/${row.original.id}/edit`)}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => handleDelete(row.original.id)}
|
|
||||||
disabled={deleteMutation.isPending}
|
|
||||||
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", "Poz")}
|
|
||||||
>
|
|
||||||
<Trash2 size={15} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
@@ -247,7 +230,7 @@ export default function CardOrdersPage() {
|
|||||||
<h1 className="text-xl font-semibold text-foreground tracking-tight">{t("cardOrder.title", "Kart sargytlary")}</h1>
|
<h1 className="text-xl font-semibold text-foreground tracking-tight">{t("cardOrder.title", "Kart sargytlary")}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -3,12 +3,11 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
import { Button } from "@/components/ui/button";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useGetCurrencyRates, useDeleteCurrencyRate } from "@/features/currencyRates/hooks/useCurrencyRates";
|
import { useGetCurrencyRates, useDeleteCurrencyRate } from "@/features/currencyRates/hooks/useCurrencyRates";
|
||||||
import type { CurrencyRate } from "@/features/currencyRates/api/currencyRatesApi";
|
import type { CurrencyRate } from "@/features/currencyRates/api/currencyRatesApi";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
@@ -87,35 +86,12 @@ export default function CurrencyRatesPage() {
|
|||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-end gap-1">
|
<TableActions
|
||||||
<Button
|
onView={() => navigate(`/currency-rates/${row.original.id}`)}
|
||||||
variant="ghost"
|
onEdit={() => navigate(`/currency-rates/${row.original.id}/edit`)}
|
||||||
size="icon"
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
isDeleting={deleteMutation.isPending}
|
||||||
onClick={() => navigate(`/currency-rates/${row.original.id}`)}
|
/>
|
||||||
title={t("common.view", "Görmek")}
|
|
||||||
>
|
|
||||||
<Eye size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={() => navigate(`/currency-rates/${row.original.id}/edit`)}
|
|
||||||
title={t("common.edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Pozmak")}
|
|
||||||
>
|
|
||||||
<Trash2 size={15} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 120,
|
size: 120,
|
||||||
},
|
},
|
||||||
@@ -133,7 +109,7 @@ export default function CurrencyRatesPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("currencyRates.title", "Walýuta kursy")}</h1>
|
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("currencyRates.title", "Walýuta kursy")}</h1>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("common.search", "Gözlemek")} />
|
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("common.search", "Gözlemek")} />
|
||||||
<CreateButton
|
<CreateButton
|
||||||
label={t("currencyRates.actions.create", "Walýuta kursy dörediň")}
|
label={t("currencyRates.actions.create", "Walýuta kursy dörediň")}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Pencil, Trash2 } from "lucide-react";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
@@ -75,26 +75,10 @@ export default function VisaMasterSettingsPage() {
|
|||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-end gap-1">
|
<TableActions
|
||||||
<Button
|
onEdit={() => navigate(`/visa-master-sber-settings/${row.original.id}/edit`)}
|
||||||
variant="ghost"
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
size="icon"
|
/>
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={() => navigate(`/visa-master-sber-settings/${row.original.id}/edit`)}
|
|
||||||
title={t("common.edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Pozmak")}
|
|
||||||
>
|
|
||||||
<Trash2 size={15} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
@@ -112,7 +96,7 @@ export default function VisaMasterSettingsPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("visaMasterSettings.title", "Visa/Master, Sber sazlamalar")}</h1>
|
<h1 className="text-2xl font-semibold text-foreground mb-5">{t("visaMasterSettings.title", "Visa/Master, Sber sazlamalar")}</h1>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("common.search", "Gözlemek")} />
|
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("common.search", "Gözlemek")} />
|
||||||
<CreateButton
|
<CreateButton
|
||||||
label={t("visaMasterSettings.actions.create", "Visa/Master, Sber sazlamalar dörediň")}
|
label={t("visaMasterSettings.actions.create", "Visa/Master, Sber sazlamalar dörediň")}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useMemo, useCallback } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { Eye, Edit, ArrowUpDown, Trash2 } from "lucide-react";
|
import { Edit, ArrowUpDown } from "lucide-react";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -8,6 +8,7 @@ import { DataTable } from "@/components/dataTable";
|
|||||||
import { DataTableToolbar, type ColumnMeta, type FilterField, type ActiveFilter } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ColumnMeta, type FilterField, type ActiveFilter } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { MonthSelect } from "@/components/monthSelect";
|
import { MonthSelect } from "@/components/monthSelect";
|
||||||
import { useSberPaymentOrders, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
import { useSberPaymentOrders, useDeleteSberPayment } from "@/features/sberPayments/hooks/useSberPayments";
|
||||||
import {
|
import {
|
||||||
@@ -213,29 +214,13 @@ export default function SberPaymentsListPage() {
|
|||||||
const order = row.original;
|
const order = row.original;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-1">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/sber-payments/${order.id}`)}
|
||||||
onClick={() => navigate(`/sber-payments/${order.id}`)}
|
onEdit={() => navigate(`/sber-payments/${order.id}/edit`)}
|
||||||
className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors"
|
onDelete={() => setDeleteTarget(order)}
|
||||||
title={t("common.view", "View")}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
editIcon={Edit}
|
||||||
<Eye size={16} />
|
/>
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => navigate(`/sber-payments/${order.id}/edit`)}
|
|
||||||
className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
title={t("common.edit", "Edit")}
|
|
||||||
>
|
|
||||||
<Edit size={16} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => setDeleteTarget(order)}
|
|
||||||
className="p-1.5 rounded hover:bg-accent text-destructive hover:bg-destructive/10 transition-colors"
|
|
||||||
title={t("common.delete", "Delete")}
|
|
||||||
>
|
|
||||||
<Trash2 size={16} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -292,7 +277,7 @@ export default function SberPaymentsListPage() {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{/* Page Title */}
|
{/* Page Title */}
|
||||||
<h1 className="text-xl font-semibold text-foreground">{t("sberPayments.list.title", "Sber tölegler (talyplar üçin)")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("sberPayments.list.title", "Sber tölegler (talyplar üçin)")}</h1>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ import { DataTable } from "@/components/dataTable";
|
|||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
import { useIntlPayments, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { IntlPaymentItem, IntlPaymentStatus } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { MonthSelect } from "@/components/monthSelect";
|
import { MonthSelect } from "@/components/monthSelect";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||||
|
import { useIntlPayments, useDeleteIntlPayment } from "@/features/visaMasterPayments/hooks/useVisaMasterPayments";
|
||||||
|
import type { IntlPaymentStatus, IntlPaymentItem } from "@/features/visaMasterPayments/api/visaMasterPaymentsApi";
|
||||||
// ─── Status badge (defined inside component for t() access) ───────────────────
|
// ─── Status badge (defined inside component for t() access) ───────────────────
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
@@ -94,22 +93,12 @@ export default function IntlPaymentsPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1">
|
<TableActions
|
||||||
<Button size="icon" variant="ghost" className="h-7 w-7" onClick={() => navigate(`/visa-master/${row.original.id}`)}>
|
onView={() => navigate(`/visa-master/${row.original.id}`)}
|
||||||
<Eye size={14} />
|
onEdit={() => navigate(`/visa-master/${row.original.id}/edit`)}
|
||||||
</Button>
|
onDelete={() => setDeleteTarget(row.original)}
|
||||||
<Button size="icon" variant="ghost" className="h-7 w-7" onClick={() => navigate(`/visa-master/${row.original.id}/edit`)}>
|
isDeleting={isDeleting}
|
||||||
<Pencil size={14} />
|
/>
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteTarget(row.original)}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -127,7 +116,7 @@ export default function IntlPaymentsPage() {
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-xl font-semibold text-foreground">{t("intlPayment.title", "Halkara tölegler (Visa/Mastercard)")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("intlPayment.title", "Halkara tölegler (Visa/Mastercard)")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useMemo, useCallback } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle, Loader2 } from "lucide-react";
|
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from "lucide-react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||||
@@ -8,6 +8,7 @@ import { DataTable } from "@/components/dataTable";
|
|||||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
@@ -166,30 +167,12 @@ export default function LoanOrderMobilesPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1.5 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/loan-order-mobiles/${row.original.id}`)}
|
||||||
onClick={() => navigate(`/loan-order-mobiles/${row.original.id}`)}
|
onEdit={() => navigate(`/loan-order-mobiles/${row.original.id}/edit`)}
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onDelete={() => handleDelete(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
/>
|
||||||
<Eye size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => navigate(`/loan-order-mobiles/${row.original.id}/edit`)}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => handleDelete(row.original.id)}
|
|
||||||
disabled={deleteMutation.isPending}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
@@ -237,7 +220,7 @@ export default function LoanOrderMobilesPage() {
|
|||||||
<h1 className="text-xl font-semibold text-foreground">{t("loanOrderMobiles.title", "Karz sargytlary")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("loanOrderMobiles.title", "Karz sargytlary")}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { useState, useMemo, useCallback } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2, AlertCircle, CheckCircle2, XCircle, Loader2 } from "lucide-react";
|
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from "lucide-react";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||||
import { useLoanOrders, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
import { useLoanOrders, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||||
import type { LoanOrder, LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
import type { LoanOrder, LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||||
@@ -175,30 +176,12 @@ export default function LoanOrdersPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1.5 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/loan-orders/${row.original.id}`)}
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onEdit={() => navigate(`/loan-orders/${row.original.id}/edit`)}
|
||||||
title={t("common.view", "View")}
|
onDelete={() => handleDelete(row.original.id)}
|
||||||
onClick={() => navigate(`/loan-orders/${row.original.id}`)}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
/>
|
||||||
<Eye size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
title={t("common.edit", "Edit")}
|
|
||||||
onClick={() => navigate(`/loan-orders/${row.original.id}/edit`)}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => handleDelete(row.original.id)}
|
|
||||||
disabled={deleteMutation.isPending}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
@@ -243,7 +226,7 @@ export default function LoanOrdersPage() {
|
|||||||
<h1 className="text-xl font-semibold text-foreground">{t("loanOrders.title", "Karz sargytlary")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("loanOrders.title", "Karz sargytlary")}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { useState, useMemo, useCallback } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2, TableProperties } from "lucide-react";
|
import { TableProperties } from "lucide-react";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useLoanPaidOffLetters, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
import { useLoanPaidOffLetters, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||||
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
@@ -130,30 +131,12 @@ export default function LoanPaidOffLettersPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1.5 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/loan-paid-off-letters/${row.original.id}`)}
|
||||||
onClick={() => navigate(`/loan-paid-off-letters/${row.original.id}`)}
|
onEdit={() => navigate(`/loan-paid-off-letters/${row.original.id}/edit`)}
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onDelete={() => handleDelete(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
/>
|
||||||
<Eye size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => navigate(`/loan-paid-off-letters/${row.original.id}/edit`)}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => handleDelete(row.original.id)}
|
|
||||||
disabled={deleteMutation.isPending}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
@@ -181,7 +164,7 @@ export default function LoanPaidOffLettersPage() {
|
|||||||
<h1 className="text-xl font-semibold text-foreground">{t("loanPaidOffLetters.title", "Karzyň ýapylandygy barada güwanamalar")} </h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("loanPaidOffLetters.title", "Karzyň ýapylandygy barada güwanamalar")} </h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import { useState, useMemo, useCallback } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useLoanRemaining, useDeleteLoanRemaining } from "@/features/loanRemaining/hooks/useLoanRemaining";
|
import { useLoanRemaining, useDeleteLoanRemaining } from "@/features/loanRemaining/hooks/useLoanRemaining";
|
||||||
import type { LoanRemaining } from "@/features/loanRemaining/api/loanRemainingApi";
|
import type { LoanRemaining } from "@/features/loanRemaining/api/loanRemainingApi";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
@@ -94,30 +95,12 @@ export default function LoanRemainingPage() {
|
|||||||
header: "",
|
header: "",
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1.5 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/loan-remaining/${row.original.id}`)}
|
||||||
onClick={() => navigate(`/loan-remaining/${row.original.id}`)}
|
onEdit={() => navigate(`/loan-remaining/${row.original.id}/edit`)}
|
||||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onDelete={() => handleDelete(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
/>
|
||||||
<Eye size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => navigate(`/loan-remaining/${row.original.id}/edit`)}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => handleDelete(row.original.id)}
|
|
||||||
disabled={deleteMutation.isPending}
|
|
||||||
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} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
@@ -138,7 +121,7 @@ export default function LoanRemainingPage() {
|
|||||||
<h1 className="text-xl font-semibold text-foreground">{t("loanRemaining.title", "Karzyň galyndysy")}</h1>
|
<h1 className="text-xl font-semibold text-foreground">{t("loanRemaining.title", "Karzyň galyndysy")}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { useState } from "react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
||||||
import { useCardTypes, useDeleteCardType } from "@/features/cardTypes/hooks/useCardTypes";
|
import { useCardTypes, useDeleteCardType } from "@/features/cardTypes/hooks/useCardTypes";
|
||||||
import type { CardType } from "@/features/cardTypes/api/cardTypesApi";
|
import type { CardType } from "@/features/cardTypes/api/cardTypesApi";
|
||||||
@@ -92,29 +93,11 @@ export function CardTypesListPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-2 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/settings/card/card-types/${row.original.id}`)}
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onEdit={() => navigate(`/settings/card/card-types/${row.original.id}/edit`)}
|
||||||
onClick={() => navigate(`/settings/card/card-types/${row.original.id}`)}
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
onClick={() => navigate(`/settings/card/card-types/${row.original.id}/edit`)}
|
|
||||||
title={t("common.edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Öçürmek")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@@ -139,7 +122,7 @@ export function CardTypesListPage() {
|
|||||||
<h1 className="text-2xl font-bold text-foreground">{t("cardTypes.title", "Kart görnüşleri")}</h1>
|
<h1 className="text-2xl font-bold text-foreground">{t("cardTypes.title", "Kart görnüşleri")}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { useState } from "react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
||||||
import { useCardReasons, useDeleteCardReason } from "@/features/cardReasons/hooks/useCardReasons";
|
import { useCardReasons, useDeleteCardReason } from "@/features/cardReasons/hooks/useCardReasons";
|
||||||
import type { CardReason } from "@/features/cardReasons/api/cardReasonsApi";
|
import type { CardReason } from "@/features/cardReasons/api/cardReasonsApi";
|
||||||
@@ -103,29 +104,11 @@ export function CardReasonsListPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-2 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/settings/card/card-reasons/${row.original.id}`)}
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onEdit={() => navigate(`/settings/card/card-reasons/${row.original.id}/edit`)}
|
||||||
onClick={() => navigate(`/settings/card/card-reasons/${row.original.id}`)}
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
onClick={() => navigate(`/settings/card/card-reasons/${row.original.id}/edit`)}
|
|
||||||
title={t("common.edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Öçürmek")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@@ -150,7 +133,7 @@ export function CardReasonsListPage() {
|
|||||||
<h1 className="text-2xl font-bold text-foreground">{t("cardReasons.title", "Kartyň çykarylmagynyň sebäpleri")}</h1>
|
<h1 className="text-2xl font-bold text-foreground">{t("cardReasons.title", "Kartyň çykarylmagynyň sebäpleri")}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useGetLoanTypes, useDeleteLoanType } from "@/features/loanTypes/hooks/useLoanTypes";
|
import { useGetLoanTypes, useDeleteLoanType } from "@/features/loanTypes/hooks/useLoanTypes";
|
||||||
import type { LoanType } from "@/features/loanTypes/api/loanTypesApi";
|
import type { LoanType } from "@/features/loanTypes/api/loanTypesApi";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
@@ -71,29 +72,11 @@ function useLoanTypeColumns(
|
|||||||
size: 120,
|
size: 120,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1">
|
<TableActions
|
||||||
<button
|
onView={() => onView(row.original.id)}
|
||||||
onClick={() => onView(row.original.id)}
|
onEdit={() => onEdit(row.original.id)}
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onDelete={() => onDelete(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => onEdit(row.original.id)}
|
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
title={t("common.edit", "Redaktirlemek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => onDelete(row.original.id)}
|
|
||||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
|
||||||
title={t("common.delete", "Pozmak")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -138,7 +121,7 @@ export default function LoanTypesListPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h1 className="text-xl font-semibold text-foreground mb-5">{t("loanTypes.title", "Karz görnüşleri")}</h1>
|
<h1 className="text-xl font-semibold text-foreground mb-5">{t("loanTypes.title", "Karz görnüşleri")}</h1>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useGetRequiredDocuments, useDeleteRequiredDocument } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
import { useGetRequiredDocuments, useDeleteRequiredDocument } from "@/features/requiredDocuments/hooks/useRequiredDocuments";
|
||||||
import type { LoanDocument } from "@/features/requiredDocuments/api/requiredDocumentsApi";
|
import type { LoanDocument } from "@/features/requiredDocuments/api/requiredDocumentsApi";
|
||||||
import type { VisibilityState } from "@tanstack/react-table";
|
import type { VisibilityState } from "@tanstack/react-table";
|
||||||
@@ -72,30 +72,12 @@ export default function RequiredDocumentsListPage() {
|
|||||||
size: 100,
|
size: 100,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-end gap-1">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/settings/loan/required-documents/${row.original.id}`)}
|
||||||
onClick={() => navigate(`/settings/loan/required-documents/${row.original.id}`)}
|
onEdit={() => navigate(`/settings/loan/required-documents/${row.original.id}/edit`)}
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onDelete={() => handleDelete(row.original.id)}
|
||||||
title={t("common.view", "Görüntüle")}
|
isDeleting={deleteMutation.isPending}
|
||||||
>
|
/>
|
||||||
<Eye size={15} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => navigate(`/settings/loan/required-documents/${row.original.id}/edit`)}
|
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
title={t("common.edit", "Düzet")}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</button>
|
|
||||||
<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"
|
|
||||||
title={t("common.delete", "Öçür")}
|
|
||||||
>
|
|
||||||
<Trash2 size={15} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -108,7 +90,7 @@ export default function RequiredDocumentsListPage() {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{/* Page heading */}
|
{/* Page heading */}
|
||||||
<h1 className="text-xl font-semibold text-foreground mb-4">{t("loanDocuments.title", "Karz gerekli resminamalary")}</h1>
|
<h1 className="text-xl font-semibold text-foreground mb-4">{t("loanDocuments.title", "Karz gerekli resminamalary")}</h1>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { useState } from "react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
||||||
import { useBranches, useDeleteBranch } from "@/features/branches/hooks/useBranches";
|
import { useBranches, useDeleteBranch } from "@/features/branches/hooks/useBranches";
|
||||||
import type { Branch } from "@/features/branches/api/branchesApi";
|
import type { Branch } from "@/features/branches/api/branchesApi";
|
||||||
@@ -118,29 +119,11 @@ export function BranchesListPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-2 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/settings/location/branches/${row.original.id}`)}
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onEdit={() => navigate(`/settings/location/branches/${row.original.id}/edit`)}
|
||||||
onClick={() => navigate(`/settings/location/branches/${row.original.id}`)}
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
onClick={() => navigate(`/settings/location/branches/${row.original.id}/edit`)}
|
|
||||||
title={t("common.edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Öçürmek")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@@ -164,7 +147,7 @@ export function BranchesListPage() {
|
|||||||
<h1 className="text-2xl font-bold text-foreground">{t("branches.title", "Şahamçalar")}</h1>
|
<h1 className="text-2xl font-bold text-foreground">{t("branches.title", "Şahamçalar")}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { useState } from "react";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
|
||||||
import { useDistricts, useDeleteDistrict } from "@/features/districts/hooks/useDistricts";
|
import { useDistricts, useDeleteDistrict } from "@/features/districts/hooks/useDistricts";
|
||||||
import type { District } from "@/features/districts/api/districtsApi";
|
import type { District } from "@/features/districts/api/districtsApi";
|
||||||
@@ -86,29 +87,11 @@ export function DistrictsListPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-2 justify-end">
|
<TableActions
|
||||||
<button
|
onView={() => navigate(`/settings/location/districts/${row.original.id}`)}
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
onEdit={() => navigate(`/settings/location/districts/${row.original.id}/edit`)}
|
||||||
onClick={() => navigate(`/settings/location/districts/${row.original.id}`)}
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
title={t("common.view", "Görmek")}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
|
||||||
onClick={() => navigate(`/settings/location/districts/${row.original.id}/edit`)}
|
|
||||||
title={t("common.edit", "Üýtgetmek")}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
title={t("common.delete", "Öçürmek")}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@@ -132,7 +115,7 @@ export function DistrictsListPage() {
|
|||||||
<h1 className="text-2xl font-bold text-foreground">{t("districts.title", "Etraplar")}</h1>
|
<h1 className="text-2xl font-bold text-foreground">{t("districts.title", "Etraplar")}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
import { Button } from "@/components/ui/button";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { usePermissions, useDeletePermission } from "@/features/permissions/hooks/usePermissions";
|
import { usePermissions, useDeletePermission } from "@/features/permissions/hooks/usePermissions";
|
||||||
import type { Permission } from "@/features/permissions/api/permissionsApi";
|
import type { Permission } from "@/features/permissions/api/permissionsApi";
|
||||||
@@ -68,32 +67,12 @@ export default function PermissionsPage() {
|
|||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-end gap-1">
|
<TableActions
|
||||||
<Button
|
onView={() => navigate(`/settings/users/permissions/${row.original.id}`)}
|
||||||
variant="ghost"
|
onEdit={() => navigate(`/settings/users/permissions/${row.original.id}/edit`)}
|
||||||
size="icon"
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-primary"
|
isDeleting={deletePermission.isPending}
|
||||||
onClick={() => navigate(`/settings/users/permissions/${row.original.id}`)}
|
/>
|
||||||
>
|
|
||||||
<Eye size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-blue-500"
|
|
||||||
onClick={() => navigate(`/settings/users/permissions/${row.original.id}/edit`)}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
>
|
|
||||||
<Trash2 size={15} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -114,7 +93,7 @@ export default function PermissionsPage() {
|
|||||||
<div className="flex items-center justify-between mb-6">
|
<div className="flex items-center justify-between mb-6">
|
||||||
<h1 className="text-2xl font-bold text-foreground">{t("permissions.title", "Rugsatlar")}</h1>
|
<h1 className="text-2xl font-bold text-foreground">{t("permissions.title", "Rugsatlar")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2 } from "lucide-react";
|
|
||||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
import { Button } from "@/components/ui/button";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { useRoles, useDeleteRole } from "@/features/roles/hooks/useRoles";
|
import { useRoles, useDeleteRole } from "@/features/roles/hooks/useRoles";
|
||||||
import type { Role } from "@/features/roles/api/rolesApi";
|
import type { Role } from "@/features/roles/api/rolesApi";
|
||||||
@@ -68,32 +67,12 @@ export default function RolesPage() {
|
|||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center justify-end gap-1">
|
<TableActions
|
||||||
<Button
|
onView={() => navigate(`/settings/users/roles/${row.original.id}`)}
|
||||||
variant="ghost"
|
onEdit={() => navigate(`/settings/users/roles/${row.original.id}/edit`)}
|
||||||
size="icon"
|
onDelete={() => setDeleteId(row.original.id)}
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-primary"
|
isDeleting={deleteRole.isPending}
|
||||||
onClick={() => navigate(`/settings/users/roles/${row.original.id}`)}
|
/>
|
||||||
>
|
|
||||||
<Eye size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-blue-500"
|
|
||||||
onClick={() => navigate(`/settings/users/roles/${row.original.id}/edit`)}
|
|
||||||
>
|
|
||||||
<Pencil size={15} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={() => setDeleteId(row.original.id)}
|
|
||||||
>
|
|
||||||
<Trash2 size={15} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -114,7 +93,7 @@ export default function RolesPage() {
|
|||||||
<div className="flex items-center justify-between mb-6">
|
<div className="flex items-center justify-between mb-6">
|
||||||
<h1 className="text-2xl font-bold text-foreground">{t("roles.title", "Rollar")}</h1>
|
<h1 className="text-2xl font-bold text-foreground">{t("roles.title", "Rollar")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
|
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar, type ActiveFilter } from "@/components/dataTableToolbar";
|
import { DataTableToolbar, type ActiveFilter } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
import { Button } from "@/components/ui/button";
|
import { TableActions } from "@/components/tableActions";
|
||||||
import type { VisibilityState } from "@tanstack/react-table";
|
import type { VisibilityState } from "@tanstack/react-table";
|
||||||
|
|
||||||
import { useUsers, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
import { useUsers, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers";
|
||||||
@@ -120,22 +120,12 @@ export default function UsersListPage() {
|
|||||||
size: 100,
|
size: 100,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1">
|
<TableActions
|
||||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => navigate(`/all-users/${row.original.id}`)}>
|
onView={() => navigate(`/all-users/${row.original.id}`)}
|
||||||
<Eye size={14} />
|
onEdit={() => navigate(`/all-users/${row.original.id}/edit`)}
|
||||||
</Button>
|
onDelete={() => setDeleteTarget(row.original)}
|
||||||
<Button variant="ghost" size="icon" className="h-7 w-7" onClick={() => navigate(`/all-users/${row.original.id}/edit`)}>
|
isDeleting={deleteUser.isPending}
|
||||||
<Pencil size={14} />
|
/>
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-7 w-7 text-destructive hover:text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => setDeleteTarget(row.original)}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -153,7 +143,7 @@ export default function UsersListPage() {
|
|||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h1 className="text-2xl font-semibold text-foreground">{t("users.title", "Ähli ulanyjylar")}</h1>
|
<h1 className="text-2xl font-semibold text-foreground">{t("users.title", "Ähli ulanyjylar")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("users.searchPlaceholder", "Gözlemek")} />
|
<TableSearchInput value={search} onChange={handleSearchChange} placeholder={t("users.searchPlaceholder", "Gözlemek")} />
|
||||||
<CreateButton label={t("users.actions.create", "Ulanyjy dörediň")} onClick={() => navigate("/all-users/create")} />
|
<CreateButton label={t("users.actions.create", "Ulanyjy dörediň")} onClick={() => navigate("/all-users/create")} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useClients, useDeleteClient } from "@/features/clients/hooks/useClients";
|
import { useClients, useDeleteClient } from "@/features/clients/hooks/useClients";
|
||||||
import type { Client } from "@/features/clients/api/clientsApi";
|
import type { Client } from "@/features/clients/api/clientsApi";
|
||||||
|
|
||||||
@@ -85,32 +85,12 @@ export default function ClientsPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<TableActions
|
||||||
<Button
|
onView={() => navigate(`/clients/${row.original.id}`)}
|
||||||
size="icon"
|
onEdit={() => navigate(`/clients/${row.original.id}/edit`)}
|
||||||
variant="ghost"
|
onDelete={() => setDeleteTarget(row.original)}
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
isDeleting={deleteMutation.isPending}
|
||||||
onClick={() => navigate(`/clients/${row.original.id}`)}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={() => navigate(`/clients/${row.original.id}/edit`)}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={() => setDeleteTarget(row.original)}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 120,
|
size: 120,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
@@ -129,7 +109,7 @@ export default function ClientsPage() {
|
|||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h1 className="text-2xl font-semibold text-foreground">{t("clients.title", "Müşderiler")}</h1>
|
<h1 className="text-2xl font-semibold text-foreground">{t("clients.title", "Müşderiler")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from "lucide-react";
|
import { CheckCircle2, XCircle } from "lucide-react";
|
||||||
import { DeleteDialog } from "@/components/deleteDialog";
|
import { DeleteDialog } from "@/components/deleteDialog";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import { TableSearchInput } from "@/components/tableSearch";
|
import { TableSearchInput } from "@/components/tableSearch";
|
||||||
import { CreateButton } from "@/components/createButton";
|
import { CreateButton } from "@/components/createButton";
|
||||||
|
import { TableActions } from "@/components/tableActions";
|
||||||
import { useOperators, useDeleteOperator } from "@/features/operators/hooks/useOperators";
|
import { useOperators, useDeleteOperator } from "@/features/operators/hooks/useOperators";
|
||||||
import type { Operator } from "@/features/operators/api/operatorsApi";
|
import type { Operator } from "@/features/operators/api/operatorsApi";
|
||||||
|
|
||||||
@@ -91,32 +91,12 @@ export default function OperatorsPage() {
|
|||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1 justify-end">
|
<TableActions
|
||||||
<Button
|
onView={() => navigate(`/operators/${row.original.id}`)}
|
||||||
size="icon"
|
onEdit={() => navigate(`/operators/${row.original.id}/edit`)}
|
||||||
variant="ghost"
|
onDelete={() => setDeleteTarget(row.original)}
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
isDeleting={deleteMutation.isPending}
|
||||||
onClick={() => navigate(`/operators/${row.original.id}`)}
|
/>
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={() => navigate(`/operators/${row.original.id}/edit`)}
|
|
||||||
>
|
|
||||||
<Pencil size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
|
||||||
onClick={() => setDeleteTarget(row.original)}
|
|
||||||
>
|
|
||||||
<Trash2 size={14} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
size: 120,
|
size: 120,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
@@ -137,7 +117,7 @@ export default function OperatorsPage() {
|
|||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h1 className="text-2xl font-semibold text-foreground">{t("operators.title", "Operatorlar")}</h1>
|
<h1 className="text-2xl font-semibold text-foreground">{t("operators.title", "Operatorlar")}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap items-center gap-3 justify-between">
|
<div className="flex items-center gap-3 justify-between">
|
||||||
<TableSearchInput
|
<TableSearchInput
|
||||||
value={search}
|
value={search}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|||||||
@@ -1,45 +1,21 @@
|
|||||||
import { useParams, useNavigate } from "react-router-dom";
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import { TableActions } from "@/components/tableActions";
|
||||||
Pencil,
|
import { Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
|
||||||
Trash2,
|
|
||||||
CheckCircle2,
|
|
||||||
XCircle,
|
|
||||||
Eye,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||||
import {
|
import { BentoGrid, BentoCard, InfoRow, AuditLog, CollapsibleSection, EmptyState } from "@/components/viewPageComponents";
|
||||||
BentoGrid,
|
|
||||||
BentoCard,
|
|
||||||
InfoRow,
|
|
||||||
AuditLog,
|
|
||||||
CollapsibleSection,
|
|
||||||
EmptyState,
|
|
||||||
} from "@/components/viewPageComponents";
|
|
||||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||||
import {
|
import { useOperator, useDeleteOperator } from "@/features/operators/hooks/useOperators";
|
||||||
useOperator,
|
import type { OperatorRole, OperatorBranch, OperatorAuditLog, OperatorPermission } from "@/features/operators/api/operatorsApi";
|
||||||
useDeleteOperator,
|
|
||||||
} from "@/features/operators/hooks/useOperators";
|
|
||||||
import type {
|
|
||||||
OperatorRole,
|
|
||||||
OperatorBranch,
|
|
||||||
OperatorAuditLog,
|
|
||||||
OperatorPermission,
|
|
||||||
} from "@/features/operators/api/operatorsApi";
|
|
||||||
|
|
||||||
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
// ─── ActiveIndicator ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function ActiveIndicator({ active }: { active: boolean }) {
|
function ActiveIndicator({ active }: { active: boolean }) {
|
||||||
return active ? (
|
return active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-destructive" />;
|
||||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
|
||||||
) : (
|
|
||||||
<XCircle size={18} className="text-destructive" />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Page ─────────────────────────────────────────────────────────────────────
|
// ─── Page ─────────────────────────────────────────────────────────────────────
|
||||||
@@ -64,11 +40,7 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "id",
|
accessorKey: "id",
|
||||||
header: t("common.id", "ID"),
|
header: t("common.id", "ID"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||||
<span className="text-primary font-semibold text-sm">
|
|
||||||
{row.original.id}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
size: 80,
|
size: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -84,40 +56,13 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "guardName",
|
accessorKey: "guardName",
|
||||||
header: t("roles.fields.guardName", "GUARD NAME"),
|
header: t("roles.fields.guardName", "GUARD NAME"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm">{row.original.guardName}</span>,
|
||||||
<span className="text-sm">{row.original.guardName}</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
header: "",
|
header: "",
|
||||||
size: 120,
|
size: 120,
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <TableActions onView={() => navigate(`/roles/${row.original.id}`)} />,
|
||||||
<div className="flex items-center gap-1 justify-end">
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
||||||
onClick={() => navigate(`/roles/${row.original.id}`)}
|
|
||||||
>
|
|
||||||
<Eye size={14} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
||||||
>
|
|
||||||
<Pencil size={13} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
|
||||||
>
|
|
||||||
<Trash2 size={13} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -127,11 +72,7 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "id",
|
accessorKey: "id",
|
||||||
header: t("common.id", "ID"),
|
header: t("common.id", "ID"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||||
<span className="text-primary font-semibold text-sm">
|
|
||||||
{row.original.id}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
size: 80,
|
size: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -142,9 +83,7 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "guardName",
|
accessorKey: "guardName",
|
||||||
header: t("permissions.fields.guardName", "GUARD NAME"),
|
header: t("permissions.fields.guardName", "GUARD NAME"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm">{row.original.guardName}</span>,
|
||||||
<span className="text-sm">{row.original.guardName}</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
@@ -152,11 +91,7 @@ export default function OperatorDetailPage() {
|
|||||||
size: 60,
|
size: 60,
|
||||||
cell: () => (
|
cell: () => (
|
||||||
<div className="flex items-center justify-end">
|
<div className="flex items-center justify-end">
|
||||||
<Button
|
<Button size="icon" variant="ghost" className="h-7 w-7 text-muted-foreground hover:text-destructive">
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
|
||||||
>
|
|
||||||
<Trash2 size={13} />
|
<Trash2 size={13} />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -170,11 +105,7 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "id",
|
accessorKey: "id",
|
||||||
header: t("common.id", "ID"),
|
header: t("common.id", "ID"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-primary font-semibold text-sm">{row.original.id}</span>,
|
||||||
<span className="text-primary font-semibold text-sm">
|
|
||||||
{row.original.id}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
size: 60,
|
size: 60,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -190,16 +121,12 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "district",
|
accessorKey: "district",
|
||||||
header: t("branches.fields.district", "ETRAP"),
|
header: t("branches.fields.district", "ETRAP"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm">{row.original.district}</span>,
|
||||||
<span className="text-sm">{row.original.district}</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "uniqueCode",
|
accessorKey: "uniqueCode",
|
||||||
header: t("branches.fields.uniqueCode", "UNIKAL BELGI"),
|
header: t("branches.fields.uniqueCode", "UNIKAL BELGI"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm">{row.original.uniqueCode}</span>,
|
||||||
<span className="text-sm">{row.original.uniqueCode}</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "isActive",
|
accessorKey: "isActive",
|
||||||
@@ -210,29 +137,17 @@ export default function OperatorDetailPage() {
|
|||||||
{
|
{
|
||||||
accessorKey: "billingUsernameIbr",
|
accessorKey: "billingUsernameIbr",
|
||||||
header: t("branches.fields.billingIbr", "BILLING ULANYJY ADY"),
|
header: t("branches.fields.billingIbr", "BILLING ULANYJY ADY"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm font-mono">{row.original.billingUsernameIbr}</span>,
|
||||||
<span className="text-sm font-mono">
|
|
||||||
{row.original.billingUsernameIbr}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "billingUsernameSber",
|
accessorKey: "billingUsernameSber",
|
||||||
header: t("branches.fields.billingSber", "BILLING USERNAME (SBER)"),
|
header: t("branches.fields.billingSber", "BILLING USERNAME (SBER)"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm font-mono ">{row.original.billingUsernameSber}</span>,
|
||||||
<span className="text-sm font-mono ">
|
|
||||||
{row.original.billingUsernameSber}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "billingUsernameVisa",
|
accessorKey: "billingUsernameVisa",
|
||||||
header: t("branches.fields.billingVisa", "BILLING USERNAME (VISA)"),
|
header: t("branches.fields.billingVisa", "BILLING USERNAME (VISA)"),
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => <span className="text-sm font-mono ">{row.original.billingUsernameVisa}</span>,
|
||||||
<span className="text-sm font-mono ">
|
|
||||||
{row.original.billingUsernameVisa}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
@@ -240,11 +155,7 @@ export default function OperatorDetailPage() {
|
|||||||
size: 60,
|
size: 60,
|
||||||
cell: () => (
|
cell: () => (
|
||||||
<div className="flex items-center justify-end">
|
<div className="flex items-center justify-end">
|
||||||
<Button
|
<Button size="icon" variant="ghost" className="h-7 w-7 text-muted-foreground hover:text-destructive">
|
||||||
size="icon"
|
|
||||||
variant="ghost"
|
|
||||||
className="h-7 w-7 text-muted-foreground hover:text-destructive"
|
|
||||||
>
|
|
||||||
<Trash2 size={13} />
|
<Trash2 size={13} />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -260,10 +171,7 @@ export default function OperatorDetailPage() {
|
|||||||
<Skeleton className="h-7 w-64" />
|
<Skeleton className="h-7 w-64" />
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
{Array.from({ length: 4 }).map((_, i) => (
|
{Array.from({ length: 4 }).map((_, i) => (
|
||||||
<div
|
<div key={i} className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||||
key={i}
|
|
||||||
className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3"
|
|
||||||
>
|
|
||||||
<Skeleton className="h-3 w-24 mb-1" />
|
<Skeleton className="h-3 w-24 mb-1" />
|
||||||
{Array.from({ length: 3 }).map((_, j) => (
|
{Array.from({ length: 3 }).map((_, j) => (
|
||||||
<Skeleton key={j} className="h-4 w-full" />
|
<Skeleton key={j} className="h-4 w-full" />
|
||||||
@@ -287,18 +195,12 @@ export default function OperatorDetailPage() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const filteredRoles = (operator.roles ?? []).filter(
|
const filteredRoles = (operator.roles ?? []).filter(
|
||||||
(r) =>
|
(r) => r.name.toLowerCase().includes(roleSearch.toLowerCase()) || r.code.toLowerCase().includes(roleSearch.toLowerCase()),
|
||||||
r.name.toLowerCase().includes(roleSearch.toLowerCase()) ||
|
|
||||||
r.code.toLowerCase().includes(roleSearch.toLowerCase()),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const filteredPermissions = (operator.permissions ?? []).filter((p) =>
|
const filteredPermissions = (operator.permissions ?? []).filter((p) => p.name.toLowerCase().includes(permSearch.toLowerCase()));
|
||||||
p.name.toLowerCase().includes(permSearch.toLowerCase()),
|
|
||||||
);
|
|
||||||
|
|
||||||
const filteredBranches = (operator.branches ?? []).filter((b) =>
|
const filteredBranches = (operator.branches ?? []).filter((b) => b.name.toLowerCase().includes(branchSearch.toLowerCase()));
|
||||||
b.name.toLowerCase().includes(branchSearch.toLowerCase()),
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
@@ -331,28 +233,16 @@ export default function OperatorDetailPage() {
|
|||||||
<BentoGrid cols={2}>
|
<BentoGrid cols={2}>
|
||||||
<BentoCard title={t("operators.sections.basic", "Esasy maglumatlar")}>
|
<BentoCard title={t("operators.sections.basic", "Esasy maglumatlar")}>
|
||||||
<InfoRow label={t("common.id", "ID")} value={operator.id} />
|
<InfoRow label={t("common.id", "ID")} value={operator.id} />
|
||||||
<InfoRow
|
<InfoRow label={t("operators.fields.username", "Ulanyjy ady")} value={operator.username} />
|
||||||
label={t("operators.fields.username", "Ulanyjy ady")}
|
<InfoRow label={t("operators.fields.name", "Ady")} value={operator.name} />
|
||||||
value={operator.username}
|
|
||||||
/>
|
|
||||||
<InfoRow
|
|
||||||
label={t("operators.fields.name", "Ady")}
|
|
||||||
value={operator.name}
|
|
||||||
/>
|
|
||||||
<InfoRow label={t("operators.fields.isActive", "Işjeň")}>
|
<InfoRow label={t("operators.fields.isActive", "Işjeň")}>
|
||||||
<ActiveIndicator active={operator.isActive} />
|
<ActiveIndicator active={operator.isActive} />
|
||||||
</InfoRow>
|
</InfoRow>
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
|
|
||||||
<BentoCard title={t("operators.sections.contact", "Kontakt")}>
|
<BentoCard title={t("operators.sections.contact", "Kontakt")}>
|
||||||
<InfoRow
|
<InfoRow label={t("operators.fields.phone", "Telefon")} value={operator.phone ?? "—"} />
|
||||||
label={t("operators.fields.phone", "Telefon")}
|
<InfoRow label={t("operators.fields.email", "E-poçta")} value={operator.email ?? "—"} />
|
||||||
value={operator.phone ?? "—"}
|
|
||||||
/>
|
|
||||||
<InfoRow
|
|
||||||
label={t("operators.fields.email", "E-poçta")}
|
|
||||||
value={operator.email ?? "—"}
|
|
||||||
/>
|
|
||||||
</BentoCard>
|
</BentoCard>
|
||||||
</BentoGrid>
|
</BentoGrid>
|
||||||
|
|
||||||
@@ -372,18 +262,11 @@ export default function OperatorDetailPage() {
|
|||||||
/* modal aç ya da navigate */
|
/* modal aç ya da navigate */
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<DataTable
|
<DataTable columns={roleColumns} data={filteredRoles} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||||
columns={roleColumns}
|
|
||||||
data={filteredRoles}
|
|
||||||
getRowId={(r) => String(r.id)}
|
|
||||||
enableRowSelection
|
|
||||||
/>
|
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
|
|
||||||
{/* ── Rugsatlar ────────────────────────────────────────────────────── */}
|
{/* ── Rugsatlar ────────────────────────────────────────────────────── */}
|
||||||
<CollapsibleSection
|
<CollapsibleSection title={t("operators.sections.permissions", "Rugsatlar")}>
|
||||||
title={t("operators.sections.permissions", "Rugsatlar")}
|
|
||||||
>
|
|
||||||
<DataTableToolbar
|
<DataTableToolbar
|
||||||
searchValue={permSearch}
|
searchValue={permSearch}
|
||||||
onSearchChange={setPermSearch}
|
onSearchChange={setPermSearch}
|
||||||
@@ -397,26 +280,14 @@ export default function OperatorDetailPage() {
|
|||||||
onAction={() => {}}
|
onAction={() => {}}
|
||||||
/>
|
/>
|
||||||
{filteredPermissions.length === 0 ? (
|
{filteredPermissions.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState label={t("operators.noPermissions", "Berlen kriterýalara Rugsat gabat gelmedi.")} />
|
||||||
label={t(
|
|
||||||
"operators.noPermissions",
|
|
||||||
"Berlen kriterýalara Rugsat gabat gelmedi.",
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<DataTable
|
<DataTable columns={permissionColumns} data={filteredPermissions} getRowId={(p) => String(p.id)} enableRowSelection />
|
||||||
columns={permissionColumns}
|
|
||||||
data={filteredPermissions}
|
|
||||||
getRowId={(p) => String(p.id)}
|
|
||||||
enableRowSelection
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
|
|
||||||
{/* ── Şahamçalar ───────────────────────────────────────────────────── */}
|
{/* ── Şahamçalar ───────────────────────────────────────────────────── */}
|
||||||
<CollapsibleSection
|
<CollapsibleSection title={t("operators.sections.branches", "Şahamçalar")}>
|
||||||
title={t("operators.sections.branches", "Şahamçalar")}
|
|
||||||
>
|
|
||||||
<DataTableToolbar
|
<DataTableToolbar
|
||||||
searchValue={branchSearch}
|
searchValue={branchSearch}
|
||||||
onSearchChange={setBranchSearch}
|
onSearchChange={setBranchSearch}
|
||||||
@@ -429,18 +300,11 @@ export default function OperatorDetailPage() {
|
|||||||
actionLabel={t("operators.addBranch", "Şahamça birikdiriň")}
|
actionLabel={t("operators.addBranch", "Şahamça birikdiriň")}
|
||||||
onAction={() => {}}
|
onAction={() => {}}
|
||||||
/>
|
/>
|
||||||
<DataTable
|
<DataTable columns={branchColumns} data={filteredBranches} getRowId={(r) => String(r.id)} enableRowSelection />
|
||||||
columns={branchColumns}
|
|
||||||
data={filteredBranches}
|
|
||||||
getRowId={(r) => String(r.id)}
|
|
||||||
enableRowSelection
|
|
||||||
/>
|
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
|
|
||||||
{/* ── Karz sargyt ──────────────────────────────────────────────────── */}
|
{/* ── Karz sargyt ──────────────────────────────────────────────────── */}
|
||||||
<CollapsibleSection
|
<CollapsibleSection title={t("operators.sections.loanLimits", "Karz sargyt")}>
|
||||||
title={t("operators.sections.loanLimits", "Karz sargyt")}
|
|
||||||
>
|
|
||||||
<DataTableToolbar
|
<DataTableToolbar
|
||||||
searchValue=""
|
searchValue=""
|
||||||
onSearchChange={() => {}}
|
onSearchChange={() => {}}
|
||||||
@@ -454,19 +318,12 @@ export default function OperatorDetailPage() {
|
|||||||
hideSearch
|
hideSearch
|
||||||
/>
|
/>
|
||||||
{(operator.loanLimits ?? []).length === 0 && (
|
{(operator.loanLimits ?? []).length === 0 && (
|
||||||
<EmptyState
|
<EmptyState label={t("operators.noLoanLimits", "Berlen kriterýalara Karz sargyt gabat gelmedi.")} />
|
||||||
label={t(
|
|
||||||
"operators.noLoanLimits",
|
|
||||||
"Berlen kriterýalara Karz sargyt gabat gelmedi.",
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
|
|
||||||
{/* ── Kart sargyt ──────────────────────────────────────────────────── */}
|
{/* ── Kart sargyt ──────────────────────────────────────────────────── */}
|
||||||
<CollapsibleSection
|
<CollapsibleSection title={t("operators.sections.cardLimits", "Kart sargyt")}>
|
||||||
title={t("operators.sections.cardLimits", "Kart sargyt")}
|
|
||||||
>
|
|
||||||
<DataTableToolbar
|
<DataTableToolbar
|
||||||
searchValue=""
|
searchValue=""
|
||||||
onSearchChange={() => {}}
|
onSearchChange={() => {}}
|
||||||
@@ -480,12 +337,7 @@ export default function OperatorDetailPage() {
|
|||||||
hideSearch
|
hideSearch
|
||||||
/>
|
/>
|
||||||
{(operator.cardLimits ?? []).length === 0 && (
|
{(operator.cardLimits ?? []).length === 0 && (
|
||||||
<EmptyState
|
<EmptyState label={t("operators.noCardLimits", "Berlen kriterýalara Kart sargyt gabat gelmedi.")} />
|
||||||
label={t(
|
|
||||||
"operators.noCardLimits",
|
|
||||||
"Berlen kriterýalara Kart sargyt gabat gelmedi.",
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</CollapsibleSection>
|
</CollapsibleSection>
|
||||||
|
|
||||||
@@ -496,11 +348,7 @@ export default function OperatorDetailPage() {
|
|||||||
open={deleteOpen}
|
open={deleteOpen}
|
||||||
onOpenChange={setDeleteOpen}
|
onOpenChange={setDeleteOpen}
|
||||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||||
description={t(
|
description={t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", { name: operator.name })}
|
||||||
"operators.deleteConfirm",
|
|
||||||
"{{name}} operatoryny pozmak isleýärsiňizmi?",
|
|
||||||
{ name: operator.name },
|
|
||||||
)}
|
|
||||||
confirmLabel={t("common.delete", "Poz")}
|
confirmLabel={t("common.delete", "Poz")}
|
||||||
onConfirm={() =>
|
onConfirm={() =>
|
||||||
deleteMutation.mutate(operatorId, {
|
deleteMutation.mutate(operatorId, {
|
||||||
|
|||||||
+2
-3
@@ -20,11 +20,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
animation: {
|
animation: {
|
||||||
"collapsible-down":
|
"collapsible-down": "collapsible-down 0.2s cubic-bezier(0.16, 1, 0.3, 1)",
|
||||||
"collapsible-down 0.2s cubic-bezier(0.16, 1, 0.3, 1)",
|
|
||||||
"collapsible-up": "collapsible-up 0.18s cubic-bezier(0.16, 1, 0.3, 1)",
|
"collapsible-up": "collapsible-up 0.18s cubic-bezier(0.16, 1, 0.3, 1)",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [require("@tailwindcss/typography")],
|
plugins: [require("@tailwindcss/typography"), require("@tailwindcss/container-queries")],
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user