fixed some ux components, added constants
This commit is contained in:
@@ -56,6 +56,7 @@ src/
|
||||
├── app/ # Global provider'lar, store'lar ve router konfigürasyonları
|
||||
├── assets/ # Görseller, fontlar vb. statik dosyalar
|
||||
├── components/ # Global ve UI bileşenleri (shadcn vb. ortak bileşenler)
|
||||
├── constants/ # Paylaşılan sabitler ve lookup verileri (passportSeries, statusOptions vb.)
|
||||
├── features/ # Özellik bazlı modüller (auth, dashboard, users vb.)
|
||||
│ └── [feature]/
|
||||
│ ├── api/ # Feature'a özel axios istek fonksiyonları
|
||||
@@ -127,3 +128,7 @@ src/
|
||||
- Her shared endpoint fonksiyonu için `src/features/shared/hooks/useShared[Resource].ts` adında bir React Query hook'u oluşturulur.
|
||||
- Shared hook'larda `staleTime` mutlaka belirtilmelidir (dropdown/lookup verileri için minimum 5 dakika önerilir).
|
||||
- Aynı `queryKey` ile çağrılan hook TanStack Query tarafından otomatik olarak dedup edilir; aynı hook'u birden fazla component'te çağırmak ekstra network isteği oluşturmaz.
|
||||
13. **Paylaşımlı Sabitler ve Lookup Verileri (Shared Constants):**
|
||||
- Birden fazla feature veya sayfada kullanılan statik veriler (pasport seri numaraları, durum/status seçenekleri, sabit listeler vb.) `src/constants/` dizininde tanımlanmalıdır.
|
||||
- `src/constants/index.ts` üzerinden dışa aktarılarak `@/constants` yoluyla projenin her yerinde yeniden kullanılmalıdır.
|
||||
- Form select seçenekleri için `SelectOption[]` formatında sabitler (`PASSPORT_SERIES_OPTIONS`, `STATUS_OPTIONS`) veya i18n uyumlu yardımcı fonksiyonlar (`getStatusOptions` vb.) sunulmalıdır.
|
||||
|
||||
@@ -146,6 +146,11 @@ src/
|
||||
│ ├── tableButton.tsx # Small icon button used inside table rows
|
||||
│ └── tableSearch.tsx # Standalone search input for tables
|
||||
│
|
||||
├── constants/ # Global shared constants & options
|
||||
│ ├── index.ts # Main entry point for re-exporting constants
|
||||
│ ├── passportSeries.ts # Shared passport series options (I-AŞ, I-MR, etc.)
|
||||
│ └── statusOptions.ts # Shared status options & i18n helpers (pending, approved, etc.)
|
||||
│
|
||||
├── features/ # Feature-Sliced Design — one folder per domain
|
||||
│ ├── shared/ # APIs and hooks used by 2+ features
|
||||
│ │ ├── api/ # sharedApi.ts — shared endpoints + TypeScript types
|
||||
@@ -621,6 +626,7 @@ All authenticated routes are nested under `DashboardLayout`. The full list:
|
||||
| Disable buttons during mutation | `disabled={mutation.isPending}` on submit buttons. |
|
||||
| `PageErrorBoundary` on every route | Already set via `errorElement` in the router. |
|
||||
| No duplicate API calls | If an endpoint is used by 2+ features, it belongs in `src/features/shared/` — never copy-paste API functions across feature folders. |
|
||||
| Use shared constants | Common lookup options (passport series, status options) must be stored in `src/constants/` and exported via `@/constants`. |
|
||||
|
||||
---
|
||||
|
||||
|
||||
2
src/constants/index.ts
Normal file
2
src/constants/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./passportSeries";
|
||||
export * from "./statusOptions";
|
||||
10
src/constants/passportSeries.ts
Normal file
10
src/constants/passportSeries.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { SelectOption } from "@/components/formInput";
|
||||
|
||||
export const PASSPORT_SERIES = ["I-AŞ", "I-MR", "II-MR", "I-AH", "II-AH", "I-LB", "II-LB", "I-BN", "II-BN", "I-DZ", "II-DZ"] as const;
|
||||
|
||||
export type PassportSerie = (typeof PASSPORT_SERIES)[number];
|
||||
|
||||
export const PASSPORT_SERIES_OPTIONS: SelectOption[] = PASSPORT_SERIES.map((serie) => ({
|
||||
label: serie,
|
||||
value: serie,
|
||||
}));
|
||||
51
src/constants/statusOptions.ts
Normal file
51
src/constants/statusOptions.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import type { SelectOption } from "@/components/formInput";
|
||||
import type { StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
|
||||
export const STATUS_VALUES = ["pending", "approved", "rejected", "completed"] as const;
|
||||
|
||||
export type StatusValue = (typeof STATUS_VALUES)[number];
|
||||
|
||||
export const STATUS_OPTIONS: SelectOption[] = [
|
||||
{ value: "pending", label: "Pending" },
|
||||
{ value: "approved", label: "Approved" },
|
||||
{ value: "rejected", label: "Rejected" },
|
||||
{ value: "completed", label: "Completed" },
|
||||
];
|
||||
|
||||
type TranslateFn = TFunction | ((key: string, fallback?: string) => string);
|
||||
|
||||
export function getStatusOptions(t?: TranslateFn, prefix = "status"): SelectOption[] {
|
||||
if (!t) return STATUS_OPTIONS;
|
||||
|
||||
return [
|
||||
{ value: "pending", label: t(`${prefix}.pending`, "Pending") },
|
||||
{ value: "approved", label: t(`${prefix}.approved`, "Approved") },
|
||||
{ value: "rejected", label: t(`${prefix}.rejected`, "Rejected") },
|
||||
{ value: "completed", label: t(`${prefix}.completed`, "Completed") },
|
||||
];
|
||||
}
|
||||
|
||||
export const STATUS_BADGE_VARIANTS: Record<StatusValue, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
completed: "info",
|
||||
};
|
||||
|
||||
export const STATUS_LABEL_FALLBACKS: Record<StatusValue, string> = {
|
||||
pending: "Pending",
|
||||
approved: "Approved",
|
||||
rejected: "Rejected",
|
||||
completed: "Completed",
|
||||
};
|
||||
|
||||
export function isStatusValue(value: string): value is StatusValue {
|
||||
return STATUS_VALUES.includes(value as StatusValue);
|
||||
}
|
||||
|
||||
export function getStatusLabel(status: string, t?: TranslateFn, prefix = "status"): string {
|
||||
if (!isStatusValue(status)) return status;
|
||||
const fallback = STATUS_LABEL_FALLBACKS[status];
|
||||
return t ? t(`${prefix}.${status}`, fallback) : fallback;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { toast } from "sonner";
|
||||
import { CreditCard, User, FileText } from "lucide-react";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
import { FormInput } from "@/components/formInput";
|
||||
import { FormInput, type SelectOption } from "@/components/formInput";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
@@ -15,6 +15,10 @@ import type { CardPinOrder, CreateCardPinPayload } from "@/features/cardPins/api
|
||||
import { useCreateCardPin, useUpdateCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "@/features/cardPins/schemas/cardPin.schema";
|
||||
import type { CardPinFormData } from "@/features/cardPins/schemas/cardPin.schema";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { useBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -85,19 +89,15 @@ interface StepContentProps {
|
||||
errors: FlatErrors;
|
||||
set: <K extends keyof CardPinFormData>(k: K, v: CardPinFormData[K]) => void;
|
||||
t: TFunction;
|
||||
cardTypeOptions: SelectOption[];
|
||||
branchOptions: SelectOption[];
|
||||
districtOptions: SelectOption[];
|
||||
}
|
||||
|
||||
// ─── Step panels ──────────────────────────────────────────────────────────────
|
||||
|
||||
function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
const STATUS_OPTIONS = useMemo(
|
||||
() => [
|
||||
{ value: "pending", label: t("cardPin.status.pending", "Garaşylýar") },
|
||||
{ value: "approved", label: t("cardPin.status.approved", "Tassyklandy") },
|
||||
{ value: "rejected", label: t("cardPin.status.rejected", "Ýatyryldy") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
function StepCard({ form, errors, set, t, cardTypeOptions, branchOptions, districtOptions }: StepContentProps) {
|
||||
const statusOptions = useMemo(() => getStatusOptions(t, "cardPin.status"), [t]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -109,7 +109,7 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
required
|
||||
value={form.status}
|
||||
onChange={(v) => set("status", v)}
|
||||
options={STATUS_OPTIONS}
|
||||
options={statusOptions}
|
||||
error={errors.status}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
/>
|
||||
@@ -139,33 +139,36 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
error={errors.cardNumber}
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("cardPin.field.cardTypeId", "Kart görnüşi ID")}
|
||||
type="searchable-select"
|
||||
label={t("cardPin.field.cardTypeId", "Kart görnüşi")}
|
||||
required
|
||||
value={form.cardTypeId}
|
||||
onChange={(v) => set("cardTypeId", v)}
|
||||
placeholder={t("cardPin.field.cardTypeId", "Kart görnüşi ID")}
|
||||
options={cardTypeOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.cardTypeId}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPinForm.titles.location") || "Lokasiýa"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="searchable-select"
|
||||
label={t("cardPin.field.region", "Sebit")}
|
||||
required
|
||||
value={form.region}
|
||||
onChange={(v) => set("region", v)}
|
||||
placeholder={t("cardPin.field.region", "Sebit")}
|
||||
options={districtOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.region}
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("cardPin.field.branchId", "Şahamça ID")}
|
||||
type="searchable-select"
|
||||
label={t("cardPin.field.branchId", "Şahamça")}
|
||||
required
|
||||
value={form.branchId}
|
||||
onChange={(v) => set("branchId", v)}
|
||||
placeholder={t("cardPin.field.branchId", "Şahamça ID")}
|
||||
options={branchOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.branchId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -267,12 +270,13 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="select"
|
||||
label={t("cardPin.field.passportSerie", "Pasport seriýasy")}
|
||||
required
|
||||
value={form.passportSerie}
|
||||
onChange={(v) => set("passportSerie", v)}
|
||||
placeholder={t("cardPin.field.passportSerie", "Pasport seriýasy")}
|
||||
options={PASSPORT_SERIES_OPTIONS}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.passportSerie}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -336,10 +340,44 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
export function CardPinForm({ mode, initialData }: CardPinFormProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as "tm" | "ru" | "en";
|
||||
|
||||
const createMutation = useCreateCardPin();
|
||||
const updateMutation = useUpdateCardPin(initialData?.id ?? 0);
|
||||
const isPending = createMutation.isPending || updateMutation.isPending;
|
||||
|
||||
const { data: cardTypesData } = useCardTypes({ page: 1, limit: 100 });
|
||||
const { data: branchesData } = useBranches({ page: 1, limit: 100 });
|
||||
const { data: districtsData } = useDistricts({ page: 1, limit: 100 });
|
||||
|
||||
const cardTypeOptions = useMemo(
|
||||
() =>
|
||||
(cardTypesData?.paymentCards ?? []).map((ct) => ({
|
||||
value: String(ct.id),
|
||||
label: ct.title[lang] || ct.title.tm,
|
||||
})),
|
||||
[cardTypesData, lang],
|
||||
);
|
||||
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
(branchesData?.branches ?? []).map((b) => ({
|
||||
value: String(b.id),
|
||||
label: b.name[lang] || b.name.tm,
|
||||
})),
|
||||
[branchesData, lang],
|
||||
);
|
||||
|
||||
const districtOptions = useMemo(
|
||||
() =>
|
||||
(districtsData?.provinces ?? []).map((d) => ({
|
||||
value: d.region?.tm || d.name.tm,
|
||||
label: d.name[lang] || d.name.tm,
|
||||
})),
|
||||
[districtsData, lang],
|
||||
);
|
||||
|
||||
const {
|
||||
watch,
|
||||
setValue,
|
||||
@@ -388,7 +426,10 @@ export function CardPinForm({ mode, initialData }: CardPinFormProps) {
|
||||
return { ...fromRHF, ...allSubmittedErrors };
|
||||
}, [rhfErrors, allSubmittedErrors]);
|
||||
|
||||
const stepProps = useMemo(() => ({ form, errors, set, t }), [form, errors, set, t]);
|
||||
const stepProps = useMemo(
|
||||
() => ({ form, errors, set, t, cardTypeOptions, branchOptions, districtOptions }),
|
||||
[form, errors, set, t, cardTypeOptions, branchOptions, districtOptions],
|
||||
);
|
||||
|
||||
// ── Navigation ─────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import apiClient from "@/lib/api/client";
|
||||
import type { StatusValue } from "@/constants";
|
||||
|
||||
// ─── Types ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export type LoanOrderMobileStatus = "GARAŞYLÝAR" | "KANAGATLANDYRYLAN" | "RED_EDILDI" | "IŞLENÝÄR";
|
||||
export type LoanOrderMobileStatus = StatusValue;
|
||||
|
||||
export interface LoanOrderMobile {
|
||||
id: string;
|
||||
@@ -159,7 +160,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Oraz",
|
||||
lastName: "Annaýew",
|
||||
phone: "+99361123456",
|
||||
status: "GARAŞYLÝAR",
|
||||
status: "pending",
|
||||
note: "Müşderi dokumentleri tassyklamady",
|
||||
loanAmount: 15000,
|
||||
loanHistory: "positive",
|
||||
@@ -169,7 +170,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
dateOfBirth: "1992-04-18",
|
||||
residence: "Aşgabat, Bitarap Türkmenistan şaýoly, 15",
|
||||
currentResidence: "Aşgabat, Garaşsyzlyk köçesi, 5",
|
||||
passportSerie: "I",
|
||||
passportSerie: "I-AŞ",
|
||||
passportNumber: "123456",
|
||||
passportDateOfIssue: "2015-03-10",
|
||||
passportGivenBy: "Aşgabat şäheriniň Içeri işler müdirligi",
|
||||
@@ -190,7 +191,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
guarantor1Name: "Berdi",
|
||||
guarantor1Surname: "Berdiýew",
|
||||
guarantor1Patronic: "Annagulyýewiç",
|
||||
guarantor1PassportSerie: "II",
|
||||
guarantor1PassportSerie: "II-MR",
|
||||
guarantor1PassportNumber: "654321",
|
||||
guarantor1CardNumber: "4222222222222222",
|
||||
guarantor1CardName: "BERDI BERDIÝEW",
|
||||
@@ -211,7 +212,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Merjen",
|
||||
lastName: "Hudaýewa",
|
||||
phone: "+99362234567",
|
||||
status: "KANAGATLANDYRYLAN",
|
||||
status: "approved",
|
||||
loanAmount: 30000,
|
||||
loanHistory: "new",
|
||||
patronicName: "Myratowna",
|
||||
@@ -219,7 +220,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
marriageStatus: "SINGLE",
|
||||
dateOfBirth: "1995-11-20",
|
||||
residence: "Änew şäher, Garaşsyzlyk köçesi, 10",
|
||||
passportSerie: "I",
|
||||
passportSerie: "I-MR",
|
||||
passportNumber: "789012",
|
||||
passportDateOfIssue: "2018-07-22",
|
||||
passportGivenBy: "Ahal welaýatynyň Içeri işler müdirligi",
|
||||
@@ -235,7 +236,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
cardExpYear: "2028",
|
||||
guarantor1Name: "Merdan",
|
||||
guarantor1Surname: "Merdanow",
|
||||
guarantor1PassportSerie: "I",
|
||||
guarantor1PassportSerie: "I-AH",
|
||||
guarantor1PassportNumber: "345678",
|
||||
guarantor1CardNumber: "4444444444444444",
|
||||
guarantor1CardName: "MERDAN MERDANOW",
|
||||
@@ -256,7 +257,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Serdar",
|
||||
lastName: "Durdyýew",
|
||||
phone: "+99363345678",
|
||||
status: "IŞLENÝÄR",
|
||||
status: "pending",
|
||||
loanAmount: 50000,
|
||||
loanHistory: "positive",
|
||||
patronicName: "Annagylyjowiç",
|
||||
@@ -264,7 +265,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
marriageStatus: "MARRIED",
|
||||
dateOfBirth: "1988-07-12",
|
||||
residence: "Balkanabat, Magtymguly köçesi, 25",
|
||||
passportSerie: "II",
|
||||
passportSerie: "II-AH",
|
||||
passportNumber: "456123",
|
||||
passportDateOfIssue: "2016-05-18",
|
||||
passportGivenBy: "Balkan welaýatynyň Içeri işler müdirligi",
|
||||
@@ -279,7 +280,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
cardExpYear: "2029",
|
||||
guarantor1Name: "Döwran",
|
||||
guarantor1Surname: "Döwranow",
|
||||
guarantor1PassportSerie: "I",
|
||||
guarantor1PassportSerie: "I-LB",
|
||||
guarantor1PassportNumber: "789456",
|
||||
guarantor1CardNumber: "4666666666666666",
|
||||
guarantor1CardName: "DÖWRAN DÖWRANOW",
|
||||
@@ -296,14 +297,14 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Aýna",
|
||||
lastName: "Meredowa",
|
||||
phone: "+99365456789",
|
||||
status: "RED_EDILDI",
|
||||
status: "rejected",
|
||||
loanAmount: 25000,
|
||||
patronicName: "Begenjowna",
|
||||
education: "high",
|
||||
marriageStatus: "DIVORCED",
|
||||
dateOfBirth: "1991-02-28",
|
||||
residence: "Türkmenabat, Lebap köçesi, 8",
|
||||
passportSerie: "I",
|
||||
passportSerie: "II-LB",
|
||||
passportNumber: "321654",
|
||||
passportDateOfIssue: "2017-11-05",
|
||||
passportGivenBy: "Lebap welaýatynyň Içeri işler müdirligi",
|
||||
@@ -325,7 +326,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Begmyrat",
|
||||
lastName: "Oraz",
|
||||
phone: "+99366567890",
|
||||
status: "GARAŞYLÝAR",
|
||||
status: "pending",
|
||||
loanAmount: 8000,
|
||||
loanHistory: "new",
|
||||
patronicName: "Annageldiwiç",
|
||||
@@ -333,7 +334,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
marriageStatus: "SINGLE",
|
||||
dateOfBirth: "2000-08-15",
|
||||
residence: "Mary şäher, Saýat köçesi, 3",
|
||||
passportSerie: "I",
|
||||
passportSerie: "I-BN",
|
||||
passportNumber: "567890",
|
||||
passportDateOfIssue: "2020-01-20",
|
||||
passportGivenBy: "Mary welaýatynyň Içeri işler müdirligi",
|
||||
@@ -351,14 +352,14 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Gülälek",
|
||||
lastName: "Saparowa",
|
||||
phone: "+99361678901",
|
||||
status: "KANAGATLANDYRYLAN",
|
||||
status: "approved",
|
||||
loanAmount: 12000,
|
||||
patronicName: "Mämmedowna",
|
||||
education: "phd",
|
||||
marriageStatus: "MARRIED",
|
||||
dateOfBirth: "1985-12-03",
|
||||
residence: "Daşoguz, Gurbansoltan eje köçesi, 12",
|
||||
passportSerie: "II",
|
||||
passportSerie: "II-BN",
|
||||
passportNumber: "901234",
|
||||
passportDateOfIssue: "2014-08-30",
|
||||
passportGivenBy: "Daşoguz welaýatynyň Içeri işler müdirligi",
|
||||
@@ -373,7 +374,7 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
cardExpYear: "2028",
|
||||
guarantor1Name: "Maksat",
|
||||
guarantor1Surname: "Saparow",
|
||||
guarantor1PassportSerie: "I",
|
||||
guarantor1PassportSerie: "I-DZ",
|
||||
guarantor1PassportNumber: "112233",
|
||||
guarantor1CardNumber: "4999999999999999",
|
||||
guarantor1CardName: "MAKSAT SAPAROW",
|
||||
@@ -390,14 +391,14 @@ const MOCK_DATA: LoanOrderMobile[] = [
|
||||
firstName: "Myrat",
|
||||
lastName: "Ataýew",
|
||||
phone: "+99362789012",
|
||||
status: "IŞLENÝÄR",
|
||||
status: "pending",
|
||||
loanAmount: 35000,
|
||||
patronicName: "Batyrowiç",
|
||||
education: "high",
|
||||
marriageStatus: "MARRIED",
|
||||
dateOfBirth: "1989-09-22",
|
||||
residence: "Aşgabat, Çandybil köçesi, 45",
|
||||
passportSerie: "I",
|
||||
passportSerie: "II-DZ",
|
||||
passportNumber: "334455",
|
||||
passportDateOfIssue: "2015-12-12",
|
||||
passportGivenBy: "Aşgabat şäheriniň Içeri işler müdirligi",
|
||||
|
||||
@@ -15,6 +15,7 @@ import type { LoanOrderMobile } from "@/features/loanOrderMobiles/api/loanOrderM
|
||||
import { BRANCHES_BY_REGION_MOBILE } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "@/features/loanOrderMobiles/schemas/loanOrderMobile.schema";
|
||||
import type { LoanOrderMobileFormData } from "@/features/loanOrderMobiles/schemas/loanOrderMobile.schema";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
|
||||
// ─── Static options ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -46,13 +47,6 @@ const MARRIAGE_OPTIONS = [
|
||||
{ value: "LEGAL", label: "Raýat nika" },
|
||||
];
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: "GARAŞYLÝAR", label: "Garaşylýar" },
|
||||
{ value: "IŞLENÝÄR", label: "Işlenýär" },
|
||||
{ value: "KANAGATLANDYRYLAN", label: "Kanagatlandyrylan" },
|
||||
{ value: "RED_EDILDI", label: "Red edildi" },
|
||||
];
|
||||
|
||||
const LOAN_TYPE_OPTIONS = [
|
||||
{ value: "consumer", label: "Sarp ediş karzy" },
|
||||
{ value: "mortgage", label: "Ipoteka" },
|
||||
@@ -61,11 +55,6 @@ const LOAN_TYPE_OPTIONS = [
|
||||
{ value: "business", label: "Işewürlik karzy" },
|
||||
];
|
||||
|
||||
const PASSPORT_SERIES_OPTIONS = [
|
||||
{ value: "I", label: "I" },
|
||||
{ value: "II", label: "II" },
|
||||
];
|
||||
|
||||
const MONTH_OPTIONS = Array.from({ length: 12 }, (_, i) => ({
|
||||
value: String(i + 1).padStart(2, "0"),
|
||||
label: String(i + 1).padStart(2, "0"),
|
||||
@@ -687,6 +676,7 @@ function StepFiles({
|
||||
mode,
|
||||
initialData,
|
||||
}: StepContentProps & { mode: "create" | "edit"; initialData?: LoanOrderMobile }) {
|
||||
const statusOptions = useMemo(() => getStatusOptions(t, "loanOrderStatus"), [t]);
|
||||
const existingFiles =
|
||||
mode === "edit" && initialData
|
||||
? [
|
||||
@@ -707,7 +697,7 @@ function StepFiles({
|
||||
required
|
||||
value={form.status}
|
||||
onChange={(v) => set("status", v)}
|
||||
options={STATUS_OPTIONS}
|
||||
options={statusOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.status}
|
||||
/>
|
||||
@@ -993,7 +983,7 @@ export function LoanOrderMobileForm({ mode, initialData }: LoanOrderMobileFormPr
|
||||
|
||||
function mapInitial(order: LoanOrderMobile): Partial<LoanOrderMobileFormData> {
|
||||
return {
|
||||
status: order.status ?? "GARAŞYLÝAR",
|
||||
status: order.status ?? "pending",
|
||||
loanType: order.loanType ?? "",
|
||||
region: order.region ?? "Aşgabat",
|
||||
branch: order.branch ?? "",
|
||||
|
||||
@@ -191,7 +191,7 @@ export function validateStep(
|
||||
}
|
||||
|
||||
export const DEFAULT_FORM_VALUES: LoanOrderMobileFormData = {
|
||||
status: "GARAŞYLÝAR",
|
||||
status: "pending",
|
||||
loanType: "",
|
||||
region: "Aşgabat",
|
||||
branch: "",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { StatusValue } from "@/constants";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export type LoanOrderStatus = "GARAŞYLÝAR" | "KANAGATLANDYRYLAN" | "RED_EDILDI" | "IŞLENÝÄR";
|
||||
export type LoanOrderStatus = StatusValue;
|
||||
|
||||
export interface LoanOrder {
|
||||
id: string;
|
||||
@@ -166,7 +168,7 @@ const MOCK_DATA: LoanOrder[] = [
|
||||
firstName: "Aman",
|
||||
lastName: "Amanow",
|
||||
phone: "+993 65 112233",
|
||||
status: "GARAŞYLÝAR",
|
||||
status: "pending",
|
||||
note: "Müşderi dokumentleri tassyklamady",
|
||||
loanAmount: 50000,
|
||||
loanHistory: "positive",
|
||||
@@ -176,7 +178,7 @@ const MOCK_DATA: LoanOrder[] = [
|
||||
dateOfBirth: "1990-05-15",
|
||||
residence: "Aşgabat, Bitarap Türkmenistan şaýoly, 15",
|
||||
currentResidence: "Aşgabat, Garaşsyzlyk köçesi, 5",
|
||||
passportSerie: "I",
|
||||
passportSerie: "I-AŞ",
|
||||
passportNumber: "123456",
|
||||
passportDateOfIssue: "2015-03-10",
|
||||
passportGivenBy: "Aşgabat şäheriniň Içeri işler müdirligi",
|
||||
@@ -198,7 +200,7 @@ const MOCK_DATA: LoanOrder[] = [
|
||||
guarantor1Name: "Berdi",
|
||||
guarantor1Surname: "Berdiýew",
|
||||
guarantor1Patronic: "Annagulyýewiç",
|
||||
guarantor1PassportSerie: "II",
|
||||
guarantor1PassportSerie: "II-MR",
|
||||
guarantor1PassportNumber: "654321",
|
||||
guarantor1CardNumber: "4222222222222222",
|
||||
guarantor1CardName: "BERDI BERDIÝEW",
|
||||
@@ -219,7 +221,7 @@ const MOCK_DATA: LoanOrder[] = [
|
||||
firstName: "Oguljan",
|
||||
lastName: "Berdiýewa",
|
||||
phone: "+993 61 445566",
|
||||
status: "IŞLENÝÄR",
|
||||
status: "pending",
|
||||
note: null,
|
||||
loanAmount: 10000,
|
||||
loanHistory: "new",
|
||||
@@ -229,7 +231,7 @@ const MOCK_DATA: LoanOrder[] = [
|
||||
dateOfBirth: "1995-11-20",
|
||||
residence: "Mary şäher, Gurbansoltan eje köçesi, 10",
|
||||
currentResidence: "Mary şäher, Gurbansoltan eje köçesi, 10",
|
||||
passportSerie: "I",
|
||||
passportSerie: "I-MR",
|
||||
passportNumber: "789012",
|
||||
passportDateOfIssue: "2018-07-22",
|
||||
passportGivenBy: "Mary şäheriniň Içeri işler müdirligi",
|
||||
@@ -251,7 +253,7 @@ const MOCK_DATA: LoanOrder[] = [
|
||||
guarantor1Name: "Merdan",
|
||||
guarantor1Surname: "Merdanow",
|
||||
guarantor1Patronic: "Amanowiç",
|
||||
guarantor1PassportSerie: "I",
|
||||
guarantor1PassportSerie: "I-AH",
|
||||
guarantor1PassportNumber: "345678",
|
||||
guarantor1CardNumber: "4444444444444444",
|
||||
guarantor1CardName: "MERDAN MERDANOW",
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { LoanOrder } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { BRANCHES_BY_REGION } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "@/features/loanOrders/schemas/loanOrder.schema";
|
||||
import type { LoanOrderFormData } from "@/features/loanOrders/schemas/loanOrder.schema";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
|
||||
// ─── Static options ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -47,13 +48,6 @@ const MARRIAGE_OPTIONS = [
|
||||
{ value: "LEGAL", label: "Raýat nika" },
|
||||
];
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: "GARAŞYLÝAR", label: "Garaşylýar" },
|
||||
{ value: "IŞLENÝÄR", label: "Işlenýär" },
|
||||
{ value: "KANAGATLANDYRYLAN", label: "Kanagatlandyrylan" },
|
||||
{ value: "RED_EDILDI", label: "Red edildi" },
|
||||
];
|
||||
|
||||
const LOAN_TYPE_OPTIONS = [
|
||||
{ value: "consumer", label: "Sarp ediş karzy" },
|
||||
{ value: "mortgage", label: "Ipoteka" },
|
||||
@@ -62,11 +56,6 @@ const LOAN_TYPE_OPTIONS = [
|
||||
{ value: "business", label: "Işewürlik karzy" },
|
||||
];
|
||||
|
||||
const PASSPORT_SERIES_OPTIONS = [
|
||||
{ value: "I", label: "I" },
|
||||
{ value: "II", label: "II" },
|
||||
];
|
||||
|
||||
const MONTH_OPTIONS = Array.from({ length: 12 }, (_, i) => ({
|
||||
value: String(i + 1).padStart(2, "0"),
|
||||
label: String(i + 1).padStart(2, "0"),
|
||||
@@ -207,6 +196,8 @@ interface StepContentProps {
|
||||
// ─── Step panels ──────────────────────────────────────────────────────────────
|
||||
|
||||
function StepStatus({ form, errors, set, t }: StepContentProps) {
|
||||
const statusOptions = useMemo(() => getStatusOptions(t, "loanOrderStatus"), [t]);
|
||||
|
||||
return (
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard>
|
||||
@@ -216,7 +207,7 @@ function StepStatus({ form, errors, set, t }: StepContentProps) {
|
||||
required
|
||||
value={form.status}
|
||||
onChange={(v) => set("status", v)}
|
||||
options={STATUS_OPTIONS}
|
||||
options={statusOptions}
|
||||
error={errors.status}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
/>
|
||||
@@ -1061,7 +1052,7 @@ export function LoanOrderForm({ mode, initialData }: LoanOrderFormProps) {
|
||||
|
||||
function mapInitial(order: LoanOrder): Partial<LoanOrderFormData> {
|
||||
return {
|
||||
status: order.status ?? "GARAŞYLÝAR",
|
||||
status: order.status ?? "pending",
|
||||
loanType: order.loanType ?? "",
|
||||
region: order.region ?? "Aşgabat",
|
||||
branch: order.branch ?? "",
|
||||
|
||||
@@ -195,7 +195,7 @@ export function validateStep(
|
||||
}
|
||||
|
||||
export const DEFAULT_FORM_VALUES: LoanOrderFormData = {
|
||||
status: "GARAŞYLÝAR",
|
||||
status: "pending",
|
||||
loanType: "",
|
||||
region: "Aşgabat",
|
||||
branch: "",
|
||||
|
||||
@@ -11,6 +11,7 @@ import { FormInput, type SelectOption } from "@/components/formInput";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
|
||||
import { useCreateLoanPaidOffLetter, useUpdateLoanPaidOffLetter } from "../hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "../api/loanPaidOffLettersApi";
|
||||
@@ -161,11 +162,12 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoCard span="full">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="text"
|
||||
type="select"
|
||||
label={t("loanPaidOffLetters.fields.passportSerie", "Pasport seriýasy")}
|
||||
value={form.passportSerie}
|
||||
onChange={set("passportSerie")}
|
||||
placeholder="I-AG"
|
||||
options={PASSPORT_SERIES_OPTIONS}
|
||||
placeholder="I-AŞ"
|
||||
error={errors.passportSerie}
|
||||
required
|
||||
/>
|
||||
@@ -338,14 +340,7 @@ export function LoanPaidOffLetterForm({ mode, initialData }: LoanPaidOffLetterFo
|
||||
[setValue, clearErrors],
|
||||
);
|
||||
|
||||
const statusOptions = useMemo<SelectOption[]>(
|
||||
() => [
|
||||
{ value: "pending", label: t("loanPaidOffLetters.status.pending", "Pending") },
|
||||
{ value: "approved", label: t("loanPaidOffLetters.status.approved", "Approved") },
|
||||
{ value: "rejected", label: t("loanPaidOffLetters.status.rejected", "Rejected") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
const statusOptions = useMemo<SelectOption[]>(() => getStatusOptions(t, "loanPaidOffLetters.status"), [t]);
|
||||
|
||||
const regionOptions = useMemo<SelectOption[]>(
|
||||
() =>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CreditCard, User, FileText, MapPin } from "lucide-react";
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { FormInput } from "@/components/formInput";
|
||||
import { FormInput, type SelectOption } from "@/components/formInput";
|
||||
import { FormActions } from "@/components/formActions";
|
||||
import { StepBarCards, type StepCardItem } from "@/components/stepBarV2";
|
||||
import { BentoGrid, BentoCard } from "@/components/bento";
|
||||
@@ -15,6 +15,11 @@ import type { CardOrder } from "../api/orderNewCardApi";
|
||||
import { useCreateCard, useUpdateCard } from "../hooks/useOrderNewCard";
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/orderNewCard.schema";
|
||||
import type { OrderNewCardFormData } from "../schemas/orderNewCard.schema";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { useCardReasons } from "@/features/cardReasons/hooks/useCardReasons";
|
||||
import { useBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -94,19 +99,16 @@ interface StepContentProps {
|
||||
errors: FlatErrors;
|
||||
set: <K extends keyof OrderNewCardFormData>(k: K, v: OrderNewCardFormData[K]) => void;
|
||||
t: TFunction;
|
||||
cardTypeOptions: SelectOption[];
|
||||
cardStateOptions: SelectOption[];
|
||||
branchOptions: SelectOption[];
|
||||
districtOptions: SelectOption[];
|
||||
}
|
||||
|
||||
// ─── Step panels ──────────────────────────────────────────────────────────────
|
||||
|
||||
function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
const STATUS_OPTIONS = useMemo(
|
||||
() => [
|
||||
{ value: "PENDING", label: t("cardOrder.status.pending", "Garaşylýar") },
|
||||
{ value: "APPROVED", label: t("cardOrder.status.approved", "Tassyklandy") },
|
||||
{ value: "REJECTED", label: t("cardOrder.status.rejected", "Ýatyryldy") },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
function StepCard({ form, errors, set, t, cardTypeOptions, cardStateOptions, branchOptions, districtOptions }: StepContentProps) {
|
||||
const statusOptions = useMemo(() => getStatusOptions(t, "cardOrder.status"), [t]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -118,7 +120,7 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
required
|
||||
value={form.status}
|
||||
onChange={(v) => set("status", v)}
|
||||
options={STATUS_OPTIONS}
|
||||
options={statusOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.status}
|
||||
/>
|
||||
@@ -169,42 +171,46 @@ function StepCard({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard title={t("loanOrderForm.titles.cardInfo") || "Kart maglumatlary"}>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("cardOrder.field.cardTypeId", "Kart görnüşi ID")}
|
||||
type="searchable-select"
|
||||
label={t("cardOrder.field.cardTypeId", "Kart görnüşi")}
|
||||
required
|
||||
value={form.cardTypeId}
|
||||
onChange={(v) => set("cardTypeId", v)}
|
||||
placeholder={t("cardOrder.field.cardTypeId", "Kart görnüşi ID")}
|
||||
options={cardTypeOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.cardTypeId}
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("cardOrder.field.cardStateId", "Kart ýagdaýy ID")}
|
||||
type="searchable-select"
|
||||
label={t("cardOrder.field.cardStateId", "Kart ýagdaýy")}
|
||||
required
|
||||
value={form.cardStateId}
|
||||
onChange={(v) => set("cardStateId", v)}
|
||||
placeholder={t("cardOrder.field.cardStateId", "Kart ýagdaýy ID")}
|
||||
options={cardStateOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.cardStateId}
|
||||
/>
|
||||
</BentoCard>
|
||||
|
||||
<BentoCard title={t("cardPinForm.titles.location") || "Lokasiýa"}>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="searchable-select"
|
||||
label={t("cardOrder.field.region", "Sebit")}
|
||||
required
|
||||
value={form.region}
|
||||
onChange={(v) => set("region", v)}
|
||||
placeholder={t("cardOrder.field.region", "Sebit")}
|
||||
options={districtOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.region}
|
||||
/>
|
||||
<FormInput
|
||||
type="number"
|
||||
label={t("cardOrder.field.branchId", "Şahamça ID")}
|
||||
type="searchable-select"
|
||||
label={t("cardOrder.field.branchId", "Şahamça")}
|
||||
required
|
||||
value={form.branchId}
|
||||
onChange={(v) => set("branchId", v)}
|
||||
placeholder={t("cardOrder.field.branchId", "Şahamça ID")}
|
||||
options={branchOptions}
|
||||
placeholder={t("loanOrderForm.placeholders.searchableSelect") || "Saýlamak üçin basyň"}
|
||||
error={errors.branchId}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -323,12 +329,13 @@ function StepPassport({ form, errors, set, t }: StepContentProps) {
|
||||
<BentoGrid cols={3}>
|
||||
<BentoCard>
|
||||
<FormInput
|
||||
type="text"
|
||||
type="select"
|
||||
label={t("cardOrder.field.passportSerie", "Pasport seriýasy")}
|
||||
required
|
||||
value={form.passportSerie}
|
||||
onChange={(v) => set("passportSerie", v)}
|
||||
placeholder={t("cardOrder.field.passportSerie", "Pasport seriýasy")}
|
||||
options={PASSPORT_SERIES_OPTIONS}
|
||||
placeholder={t("loanOrderForm.placeholders.select") || "Saýlaň"}
|
||||
error={errors.passportSerie}
|
||||
/>
|
||||
</BentoCard>
|
||||
@@ -464,10 +471,53 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const lang = (i18n.language === "ru" ? "ru" : i18n.language === "en" ? "en" : "tm") as "tm" | "ru" | "en";
|
||||
|
||||
const createMutation = useCreateCard();
|
||||
const updateMutation = useUpdateCard(initialData?.id ?? 0);
|
||||
const isPending = createMutation.isPending || updateMutation.isPending;
|
||||
|
||||
const { data: cardTypesData } = useCardTypes({ page: 1, limit: 100 });
|
||||
const { data: cardReasonsData } = useCardReasons({ page: 1, limit: 100 });
|
||||
const { data: branchesData } = useBranches({ page: 1, limit: 100 });
|
||||
const { data: districtsData } = useDistricts({ page: 1, limit: 100 });
|
||||
|
||||
const cardTypeOptions = useMemo(
|
||||
() =>
|
||||
(cardTypesData?.paymentCards ?? []).map((ct) => ({
|
||||
value: String(ct.id),
|
||||
label: ct.title[lang] || ct.title.tm,
|
||||
})),
|
||||
[cardTypesData, lang],
|
||||
);
|
||||
|
||||
const cardStateOptions = useMemo(
|
||||
() =>
|
||||
(cardReasonsData?.reasonCards ?? []).map((cr) => ({
|
||||
value: String(cr.id),
|
||||
label: cr.title[lang] || cr.title.tm,
|
||||
})),
|
||||
[cardReasonsData, lang],
|
||||
);
|
||||
|
||||
const branchOptions = useMemo(
|
||||
() =>
|
||||
(branchesData?.branches ?? []).map((b) => ({
|
||||
value: String(b.id),
|
||||
label: b.name[lang] || b.name.tm,
|
||||
})),
|
||||
[branchesData, lang],
|
||||
);
|
||||
|
||||
const districtOptions = useMemo(
|
||||
() =>
|
||||
(districtsData?.provinces ?? []).map((d) => ({
|
||||
value: d.region?.tm || d.name.tm,
|
||||
label: d.name[lang] || d.name.tm,
|
||||
})),
|
||||
[districtsData, lang],
|
||||
);
|
||||
|
||||
const {
|
||||
watch,
|
||||
setValue,
|
||||
@@ -519,7 +569,10 @@ export function CardOrderForm({ mode, initialData }: CardOrderFormProps) {
|
||||
return { ...fromRHF, ...allSubmittedErrors };
|
||||
}, [rhfErrors, allSubmittedErrors]);
|
||||
|
||||
const stepProps = useMemo(() => ({ form, errors, set, t }), [form, errors, set, t]);
|
||||
const stepProps = useMemo(
|
||||
() => ({ form, errors, set, t, cardTypeOptions, cardStateOptions, branchOptions, districtOptions }),
|
||||
[form, errors, set, t, cardTypeOptions, cardStateOptions, branchOptions, districtOptions],
|
||||
);
|
||||
|
||||
// ── Navigation ──────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { IntlPaymentItem, IntlPaymentCreatePayload } from "../api/visaMaste
|
||||
import { useCreateIntlPayment, useUpdateIntlPayment } from "../hooks/useVisaMasterPayments";
|
||||
import { validateStep, DEFAULT_FORM_VALUES, buildPayload } from "../schemas/visaMasterPayment.schema";
|
||||
import type { IntlPaymentFormData } from "../schemas/visaMasterPayment.schema";
|
||||
import { PASSPORT_SERIES_OPTIONS, getStatusOptions } from "@/constants";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -26,24 +27,11 @@ type FlatErrors = Partial<Record<keyof IntlPaymentFormData, string>>;
|
||||
|
||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: "pending", label: "Garaşylýar" },
|
||||
{ value: "approved", label: "Tassyklandy" },
|
||||
{ value: "rejected", label: "Ret edildi" },
|
||||
];
|
||||
|
||||
const CURRENCY_OPTIONS = [
|
||||
{ value: "visa", label: "Visa" },
|
||||
{ value: "mastercard", label: "MasterCard" },
|
||||
];
|
||||
|
||||
const PASSPORT_SERIES_OPTIONS = [
|
||||
{ value: "I", label: "I" },
|
||||
{ value: "II", label: "II" },
|
||||
{ value: "I-MR", label: "I-MR" },
|
||||
{ value: "II-MR", label: "II-MR" },
|
||||
];
|
||||
|
||||
const PROVINCE_OPTIONS = [
|
||||
{ value: "ashgabat", label: "Aşgabat" },
|
||||
{ value: "ahal", label: "Ahal" },
|
||||
@@ -157,6 +145,8 @@ interface StepContentProps {
|
||||
}
|
||||
|
||||
function StepGeneral({ form, errors, set, t }: StepContentProps) {
|
||||
const statusOptions = useMemo(() => getStatusOptions(t, "intlPayment.status"), [t]);
|
||||
|
||||
return (
|
||||
<BentoGrid cols={2}>
|
||||
<BentoCard>
|
||||
@@ -178,7 +168,7 @@ function StepGeneral({ form, errors, set, t }: StepContentProps) {
|
||||
label={t("loanOrderForm.labels.status") || "Status"}
|
||||
value={form.status}
|
||||
onChange={(v) => set("status", v)}
|
||||
options={STATUS_OPTIONS}
|
||||
options={statusOptions}
|
||||
error={errors.status}
|
||||
required
|
||||
/>
|
||||
|
||||
@@ -424,6 +424,7 @@
|
||||
"loanPaidOffLetters.status.pending": "Pending",
|
||||
"loanPaidOffLetters.status.approved": "Approved",
|
||||
"loanPaidOffLetters.status.rejected": "Rejected",
|
||||
"loanPaidOffLetters.status.completed": "Completed",
|
||||
"loanPaidOffLetters.regions.AG": "Ashgabat",
|
||||
"loanPaidOffLetters.regions.AH": "Ahal",
|
||||
"loanPaidOffLetters.regions.BA": "Balkan",
|
||||
@@ -468,6 +469,10 @@
|
||||
"loanOrderStatus.KANAGATLANDYRYLAN": "APPROVED",
|
||||
"loanOrderStatus.RED_EDILDI": "REJECTED",
|
||||
"loanOrderStatus.IŞLENÝÄR": "PROCESSING",
|
||||
"loanOrderStatus.pending": "Pending",
|
||||
"loanOrderStatus.approved": "Approved",
|
||||
"loanOrderStatus.rejected": "Rejected",
|
||||
"loanOrderStatus.completed": "Completed",
|
||||
"Dashboards": "Dashboard",
|
||||
"Card Issuance Reasons": "Card Issuance Reasons",
|
||||
"Locale Manager": "Locale Manager",
|
||||
@@ -591,6 +596,7 @@
|
||||
"cardOrder.status.pending": "Pending",
|
||||
"cardOrder.status.approved": "Approved",
|
||||
"cardOrder.status.rejected": "Rejected",
|
||||
"cardOrder.status.completed": "Completed",
|
||||
"cardOrder.col.id": "ID",
|
||||
"cardOrder.col.reason": "Reason",
|
||||
"cardOrder.col.createdAt": "Created at",
|
||||
@@ -1094,6 +1100,7 @@
|
||||
"cardPin.status.pending": "Pending",
|
||||
"cardPin.status.approved": "Approved",
|
||||
"cardPin.status.rejected": "Rejected",
|
||||
"cardPin.status.completed": "Completed",
|
||||
"cardOrder.detailTitle": "Card order detail",
|
||||
"cardOrder.section.meta": "Main info",
|
||||
"cardOrder.section.card": "Card",
|
||||
@@ -1157,6 +1164,7 @@
|
||||
"intlPayment.status.pending": "Pending",
|
||||
"intlPayment.status.approved": "Approved",
|
||||
"intlPayment.status.rejected": "Rejected",
|
||||
"intlPayment.status.completed": "Completed",
|
||||
"intlPayment.col.id": "ID",
|
||||
"intlPayment.createdAt": "Created at",
|
||||
"intlPayment.firstName": "First name",
|
||||
|
||||
@@ -424,6 +424,7 @@
|
||||
"loanPaidOffLetters.status.pending": "В ожидании",
|
||||
"loanPaidOffLetters.status.approved": "Одобрено",
|
||||
"loanPaidOffLetters.status.rejected": "Отклонено",
|
||||
"loanPaidOffLetters.status.completed": "Завершено",
|
||||
"loanPaidOffLetters.regions.AG": "Ашхабад",
|
||||
"loanPaidOffLetters.regions.AH": "Ахал",
|
||||
"loanPaidOffLetters.regions.BA": "Балкан",
|
||||
@@ -468,6 +469,10 @@
|
||||
"loanOrderStatus.KANAGATLANDYRYLAN": "ОДОБРЕНО",
|
||||
"loanOrderStatus.RED_EDILDI": "ОТКЛОНЕНО",
|
||||
"loanOrderStatus.IŞLENÝÄR": "В ПРОЦЕССЕ",
|
||||
"loanOrderStatus.pending": "В ожидании",
|
||||
"loanOrderStatus.approved": "Одобрено",
|
||||
"loanOrderStatus.rejected": "Отклонено",
|
||||
"loanOrderStatus.completed": "Завершено",
|
||||
"Dashboards": "Панели управления",
|
||||
"Card Issuance Reasons": "Причины выдачи карты",
|
||||
"Locale Manager": "Управление локалью",
|
||||
@@ -591,6 +596,7 @@
|
||||
"cardOrder.status.pending": "В ожидании",
|
||||
"cardOrder.status.approved": "Одобрено",
|
||||
"cardOrder.status.rejected": "Отклонено",
|
||||
"cardOrder.status.completed": "Завершено",
|
||||
"cardOrder.col.id": "ID",
|
||||
"cardOrder.col.reason": "Причина",
|
||||
"cardOrder.col.createdAt": "Дата создания",
|
||||
@@ -1095,6 +1101,7 @@
|
||||
"cardPin.status.pending": "В ожидании",
|
||||
"cardPin.status.approved": "Подтверждено",
|
||||
"cardPin.status.rejected": "Отклонено",
|
||||
"cardPin.status.completed": "Завершено",
|
||||
"cardOrder.detailTitle": "Детали заявки на карту",
|
||||
"cardOrder.section.meta": "Основная информация",
|
||||
"cardOrder.section.card": "Карта",
|
||||
@@ -1158,6 +1165,7 @@
|
||||
"intlPayment.status.pending": "В ожидании",
|
||||
"intlPayment.status.approved": "Подтверждено",
|
||||
"intlPayment.status.rejected": "Отклонено",
|
||||
"intlPayment.status.completed": "Завершено",
|
||||
"intlPayment.col.id": "ID",
|
||||
"intlPayment.createdAt": "Дата создания",
|
||||
"intlPayment.firstName": "Имя",
|
||||
|
||||
@@ -424,6 +424,7 @@
|
||||
"loanPaidOffLetters.status.pending": "Garaşylýar",
|
||||
"loanPaidOffLetters.status.approved": "Tassyklandy",
|
||||
"loanPaidOffLetters.status.rejected": "Red edildi",
|
||||
"loanPaidOffLetters.status.completed": "Tamamlandy",
|
||||
"loanPaidOffLetters.regions.AG": "Aşgabat",
|
||||
"loanPaidOffLetters.regions.AH": "Ahal",
|
||||
"loanPaidOffLetters.regions.BA": "Balkan",
|
||||
@@ -468,6 +469,10 @@
|
||||
"loanOrderStatus.KANAGATLANDYRYLAN": "Tassyklandy",
|
||||
"loanOrderStatus.RED_EDILDI": "Ýatyryldy",
|
||||
"loanOrderStatus.IŞLENÝÄR": "Işlenýär",
|
||||
"loanOrderStatus.pending": "Garaşylýar",
|
||||
"loanOrderStatus.approved": "Tassyklandy",
|
||||
"loanOrderStatus.rejected": "Ýatyryldy",
|
||||
"loanOrderStatus.completed": "Tamamlandy",
|
||||
"Dashboards": "Dolandyryş panelleri",
|
||||
"Card Issuance Reasons": "Kartyň çykarylmagynyň sebäpleri",
|
||||
"Locale Manager": "Locale dolandyryjy",
|
||||
@@ -591,6 +596,7 @@
|
||||
"cardOrder.status.pending": "Garaşylýar",
|
||||
"cardOrder.status.approved": "Tassyklandy",
|
||||
"cardOrder.status.rejected": "Ýatyryldy",
|
||||
"cardOrder.status.completed": "Tamamlandy",
|
||||
"cardOrder.col.id": "ID",
|
||||
"cardOrder.col.reason": "Sebäp",
|
||||
"cardOrder.col.createdAt": "Döredilen wagty",
|
||||
@@ -1093,6 +1099,7 @@
|
||||
"cardPin.status.pending": "Garaşylýar",
|
||||
"cardPin.status.approved": "Tassyklandy",
|
||||
"cardPin.status.rejected": "Ýatyryldy",
|
||||
"cardPin.status.completed": "Tamamlandy",
|
||||
"cardOrder.detailTitle": "Kart sargyt giriş üçin",
|
||||
"cardOrder.section.meta": "Esasy maglumatlar",
|
||||
"cardOrder.section.card": "Kart",
|
||||
@@ -1156,6 +1163,7 @@
|
||||
"intlPayment.status.pending": "Garaşylýar",
|
||||
"intlPayment.status.approved": "Tassyklandy",
|
||||
"intlPayment.status.rejected": "Ret edildi",
|
||||
"intlPayment.status.completed": "Tamamlandy",
|
||||
"intlPayment.col.id": "ID",
|
||||
"intlPayment.createdAt": "Döredilen wagty",
|
||||
"intlPayment.firstName": "Ady",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
@@ -11,11 +12,12 @@ import { DeleteDialog } from "@/components/deleteDialog";
|
||||
|
||||
import { useCardPins, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { CardPinOrder } from "@/features/cardPins/api/cardPinApi";
|
||||
import { useBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Filter field IDs ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -26,56 +28,24 @@ const INITIAL_FILTERS: ActiveFilter[] = FILTER_IDS.map((fieldId) => ({ fieldId,
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const PENDING_STATUSES = [
|
||||
"pending",
|
||||
"garaşylýar",
|
||||
"garaşilyar",
|
||||
"garasylýar",
|
||||
"garasilyar",
|
||||
"garasylyar",
|
||||
"kutilyor",
|
||||
"kutiliyor",
|
||||
"waiting",
|
||||
"beklemede",
|
||||
];
|
||||
const APPROVED_STATUSES = [
|
||||
"approved",
|
||||
"tassyklandy",
|
||||
"tassyklanan",
|
||||
"tassyklandy",
|
||||
"tassyklanyldy",
|
||||
"accepted",
|
||||
"confirmed",
|
||||
"success",
|
||||
"completed",
|
||||
"approve",
|
||||
];
|
||||
const REJECTED_STATUSES = [
|
||||
"rejected",
|
||||
"reject",
|
||||
"ret",
|
||||
"ýatyryldy",
|
||||
"yatyryldy",
|
||||
"canceled",
|
||||
"cancelled",
|
||||
"cancelled",
|
||||
"declined",
|
||||
"failed",
|
||||
"error",
|
||||
"reject",
|
||||
"red edildi",
|
||||
];
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function statusConfig(status: string): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
function statusConfig(status: string, t: TFunction): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
const key = status.trim().toLowerCase();
|
||||
if (PENDING_STATUSES.includes(key)) return { label: "Garaşylýar", variant: "warning", icon: AlertCircle };
|
||||
if (APPROVED_STATUSES.includes(key)) return { label: "Tassyklandy", variant: "success", icon: CheckCircle2 };
|
||||
if (REJECTED_STATUSES.includes(key)) return { label: "Ýatyryldy", variant: "error", icon: XCircle };
|
||||
if (isStatusValue(key)) {
|
||||
return { label: getStatusLabel(key, t, "cardPin.status"), variant: STATUS_BADGE_VARIANTS[key], icon: STATUS_ICONS[key] };
|
||||
}
|
||||
return { label: status, variant: "default" };
|
||||
}
|
||||
|
||||
function StatusCell({ status }: { status: string }) {
|
||||
const cfg = statusConfig(status);
|
||||
const { t } = useTranslation();
|
||||
const cfg = statusConfig(status, t);
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
@@ -219,11 +189,7 @@ export default function CardPinsPage() {
|
||||
{
|
||||
id: "status",
|
||||
label: t("cardPin.filter.status", "Status"),
|
||||
options: [
|
||||
{ value: "pending", label: t("cardPin.status.pending", "Garaşylýar") },
|
||||
{ value: "approved", label: t("cardPin.status.approved", "Tassyklandy") },
|
||||
{ value: "rejected", label: t("cardPin.status.rejected", "Ýatyryldy") },
|
||||
],
|
||||
options: getStatusOptions(t, "cardPin.status"),
|
||||
},
|
||||
{
|
||||
id: "branch_id",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useParams, useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useCardPin, useDeleteCardPin } from "@/features/cardPins/hooks/useCardPins";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Pencil, Trash2 } from "lucide-react";
|
||||
@@ -19,59 +19,31 @@ import {
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const PENDING_STATUSES = [
|
||||
"pending",
|
||||
"garaşylýar",
|
||||
"garaşilyar",
|
||||
"garasylýar",
|
||||
"garasilyar",
|
||||
"garasylyar",
|
||||
"kutilyor",
|
||||
"kutiliyor",
|
||||
"waiting",
|
||||
"beklemede",
|
||||
];
|
||||
const APPROVED_STATUSES = [
|
||||
"approved",
|
||||
"tassyklandy",
|
||||
"tassyklanan",
|
||||
"tassyklandy",
|
||||
"tassyklanyldy",
|
||||
"accepted",
|
||||
"confirmed",
|
||||
"success",
|
||||
"completed",
|
||||
"approve",
|
||||
];
|
||||
const REJECTED_STATUSES = [
|
||||
"rejected",
|
||||
"reject",
|
||||
"ret",
|
||||
"ýatyryldy",
|
||||
"yatyryldy",
|
||||
"canceled",
|
||||
"cancelled",
|
||||
"cancelled",
|
||||
"declined",
|
||||
"failed",
|
||||
"error",
|
||||
"reject",
|
||||
"red edildi",
|
||||
];
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function statusConfig(status: string): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
function statusConfig(
|
||||
status: string,
|
||||
t: (key: string, fallback?: string) => string,
|
||||
): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
const key = status.trim().toLowerCase();
|
||||
if (PENDING_STATUSES.includes(key)) return { label: "Garaşylýar", variant: "warning", icon: AlertCircle };
|
||||
if (APPROVED_STATUSES.includes(key)) return { label: "Tassyklandy", variant: "success", icon: CheckCircle2 };
|
||||
if (REJECTED_STATUSES.includes(key)) return { label: "Ýatyryldy", variant: "error", icon: XCircle };
|
||||
if (isStatusValue(key)) {
|
||||
return { label: getStatusLabel(key, t, "cardPin.status"), variant: STATUS_BADGE_VARIANTS[key], icon: STATUS_ICONS[key] };
|
||||
}
|
||||
return { label: status, variant: "default" };
|
||||
}
|
||||
|
||||
function CardPinStatusBadge({ status }: { status: string }) {
|
||||
const cfg = statusConfig(status);
|
||||
const { t } = useTranslation();
|
||||
const cfg = statusConfig(status, (key, fallback) => t(key, fallback ?? key));
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useNavigate, Link } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ColumnMeta, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
@@ -17,74 +17,26 @@ import type { CardOrder } from "@/features/orderNewCard/api/orderNewCardApi";
|
||||
import { useBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { useCardTypes } from "@/features/cardTypes/hooks/useCardTypes";
|
||||
import { getStatusLabel, getStatusOptions, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
const PER_PAGE = 25;
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const PENDING_STATUSES = [
|
||||
"pending",
|
||||
"garaşylýar",
|
||||
"garaşilyar",
|
||||
"garasylýar",
|
||||
"garasilyar",
|
||||
"garasylyar",
|
||||
"kutilyor",
|
||||
"kutiliyor",
|
||||
"waiting",
|
||||
"beklemede",
|
||||
];
|
||||
const APPROVED_STATUSES = [
|
||||
"approved",
|
||||
"tassyklandy",
|
||||
"tassyklanan",
|
||||
"tassyklandy",
|
||||
"tassyklanyldy",
|
||||
"accepted",
|
||||
"confirmed",
|
||||
"success",
|
||||
"completed",
|
||||
"approve",
|
||||
];
|
||||
const REJECTED_STATUSES = [
|
||||
"rejected",
|
||||
"reject",
|
||||
"ret",
|
||||
"ýatyryldy",
|
||||
"yatyryldy",
|
||||
"canceled",
|
||||
"cancelled",
|
||||
"cancelled",
|
||||
"declined",
|
||||
"failed",
|
||||
"error",
|
||||
"reject",
|
||||
"red edildi",
|
||||
];
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function CardOrderStatusBadge({ status }: { status: string }) {
|
||||
const { t } = useTranslation();
|
||||
const key = (status || "").trim().toLowerCase();
|
||||
|
||||
let variant: StatusBadgeVariant = "default";
|
||||
let icon: React.ElementType | undefined;
|
||||
let label = status;
|
||||
|
||||
if (PENDING_STATUSES.includes(key)) {
|
||||
variant = "warning";
|
||||
icon = AlertCircle;
|
||||
label = t("cardOrder.status.pending", "Garaşylýar");
|
||||
} else if (APPROVED_STATUSES.includes(key)) {
|
||||
variant = "success";
|
||||
icon = CheckCircle2;
|
||||
label = t("cardOrder.status.approved", "Tassyklandy");
|
||||
} else if (REJECTED_STATUSES.includes(key)) {
|
||||
variant = "error";
|
||||
icon = XCircle;
|
||||
label = t("cardOrder.status.rejected", "Ýatyryldy");
|
||||
} else {
|
||||
label = t(`cardOrder.status.${status}`, status);
|
||||
}
|
||||
const isKnown = isStatusValue(key);
|
||||
const variant: StatusBadgeVariant = isKnown ? STATUS_BADGE_VARIANTS[key] : "default";
|
||||
const icon = isKnown ? STATUS_ICONS[key] : undefined;
|
||||
const label = isKnown ? getStatusLabel(key, t, "cardOrder.status") : status;
|
||||
|
||||
return <StatusBadge label={label} variant={variant} icon={icon} />;
|
||||
}
|
||||
@@ -237,11 +189,7 @@ export default function CardOrdersPage() {
|
||||
{
|
||||
id: "status",
|
||||
label: t("cardOrder.filter.status", "Status"),
|
||||
options: [
|
||||
{ value: "pending", label: t("cardOrder.status.pending", "Garaşylýar") },
|
||||
{ value: "approved", label: t("cardOrder.status.approved", "Tassyklandy") },
|
||||
{ value: "rejected", label: t("cardOrder.status.rejected", "Ýatyryldy") },
|
||||
],
|
||||
options: getStatusOptions(t, "cardOrder.status"),
|
||||
},
|
||||
{
|
||||
id: "branch_id",
|
||||
|
||||
@@ -17,60 +17,32 @@ import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useCardById, useDeleteCard } from "@/features/orderNewCard/hooks/useOrderNewCard";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { getStatusLabel, isStatusValue, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
|
||||
const PENDING_STATUSES = [
|
||||
"pending",
|
||||
"garaşylýar",
|
||||
"garaşilyar",
|
||||
"garasylýar",
|
||||
"garasilyar",
|
||||
"garasylyar",
|
||||
"kutilyor",
|
||||
"kutiliyor",
|
||||
"waiting",
|
||||
"beklemede",
|
||||
];
|
||||
const APPROVED_STATUSES = [
|
||||
"approved",
|
||||
"tassyklandy",
|
||||
"tassyklanan",
|
||||
"tassyklandy",
|
||||
"tassyklanyldy",
|
||||
"accepted",
|
||||
"confirmed",
|
||||
"success",
|
||||
"completed",
|
||||
"approve",
|
||||
];
|
||||
const REJECTED_STATUSES = [
|
||||
"rejected",
|
||||
"reject",
|
||||
"ret",
|
||||
"ýatyryldy",
|
||||
"yatyryldy",
|
||||
"canceled",
|
||||
"cancelled",
|
||||
"cancelled",
|
||||
"declined",
|
||||
"failed",
|
||||
"error",
|
||||
"reject",
|
||||
"red edildi",
|
||||
];
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function statusConfig(status: string): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
function statusConfig(
|
||||
status: string,
|
||||
t: (key: string, fallback?: string) => string,
|
||||
): { label: string; variant: StatusBadgeVariant; icon?: React.ElementType } {
|
||||
const key = status.trim().toLowerCase();
|
||||
if (PENDING_STATUSES.includes(key)) return { label: "Garaşylýar", variant: "warning", icon: AlertCircle };
|
||||
if (APPROVED_STATUSES.includes(key)) return { label: "Tassyklandy", variant: "success", icon: CheckCircle2 };
|
||||
if (REJECTED_STATUSES.includes(key)) return { label: "Ýatyryldy", variant: "error", icon: XCircle };
|
||||
if (isStatusValue(key)) {
|
||||
return { label: getStatusLabel(key, t, "cardOrder.status"), variant: STATUS_BADGE_VARIANTS[key], icon: STATUS_ICONS[key] };
|
||||
}
|
||||
return { label: status, variant: "default" };
|
||||
}
|
||||
|
||||
function CardOrderStatusBadge({ status }: { status: string }) {
|
||||
const cfg = statusConfig(status);
|
||||
const { t } = useTranslation();
|
||||
const cfg = statusConfig(status, (key, fallback) => t(key, fallback ?? key));
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from "lucide-react";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/components/dataTableToolbar";
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
@@ -12,20 +12,22 @@ import { TableActions } from "@/components/tableActions";
|
||||
import { useLoanOrderMobiles, useDeleteLoanOrderMobile } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { getStatusLabel, getStatusOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARAŞYLÝAR: { label: "Garaşylýar", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: "Kanagatlandyrylan", variant: "success" as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RED_EDILDI: { label: "Red edildi", variant: "error" as StatusBadgeVariant, icon: XCircle },
|
||||
IŞLENÝÄR: { label: "Işlenýär", variant: "info" as StatusBadgeVariant, icon: Loader2 },
|
||||
} satisfies Record<LoanOrderMobileStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>;
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={STATUS_BADGE_VARIANTS[status]} icon={STATUS_ICONS[status]} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
@@ -36,7 +38,6 @@ const COLUMN_IDS = ["id", "loanType", "createdAt", "region", "branch", "firstNam
|
||||
|
||||
// ─── Filter options (Internal keys/values) ───────────────────────────────────
|
||||
const REGION_OPTIONS = ["Balkan", "Ahal", "Daşoguz", "Lebap", "Mary", "Aşgabat"];
|
||||
const STATUS_OPTIONS: LoanOrderMobileStatus[] = ["GARAŞYLÝAR", "KANAGATLANDYRYLAN", "RED_EDILDI", "IŞLENÝÄR"];
|
||||
|
||||
// ─── Page Component ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -193,7 +194,7 @@ export default function LoanOrderMobilesPage() {
|
||||
{
|
||||
id: "status",
|
||||
label: t("loanOrderMobiles.filters.status", "STATUS"),
|
||||
options: STATUS_OPTIONS.map((v) => ({ value: v, label: t(`loanOrderStatus.${v}`) })),
|
||||
options: getStatusOptions(t, "loanOrderStatus"),
|
||||
},
|
||||
{
|
||||
id: "branch",
|
||||
|
||||
@@ -6,33 +6,26 @@ import { useLoanOrderMobileById, useDeleteLoanOrderMobile } from "@/features/loa
|
||||
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<LoanOrderMobileStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderMobileStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
const STATUS_ICON: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderMobileStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const variant = STATUS_BADGE_VARIANTS[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />;
|
||||
return <StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -4,34 +4,27 @@ import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { useLoanOrderById, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { BentoGrid, BentoCard, InfoRow, PassportImage, AuditLog, type AuditRowProps } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { getStatusLabel, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<LoanOrderStatus, StatusBadgeVariant> = {
|
||||
GARAŞYLÝAR: "warning",
|
||||
KANAGATLANDYRYLAN: "success",
|
||||
RED_EDILDI: "error",
|
||||
IŞLENÝÄR: "warning",
|
||||
};
|
||||
|
||||
const STATUS_ICON: Record<LoanOrderStatus, React.ElementType> = {
|
||||
GARAŞYLÝAR: AlertCircle,
|
||||
KANAGATLANDYRYLAN: CheckCircle2,
|
||||
RED_EDILDI: XCircle,
|
||||
IŞLENÝÄR: AlertCircle,
|
||||
const STATUS_ICON: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderMobileStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
const { t } = useTranslation();
|
||||
const variant = STATUS_VARIANT[status];
|
||||
const variant = STATUS_BADGE_VARIANTS[status];
|
||||
const Icon = STATUS_ICON[status];
|
||||
if (!variant) return <span className="text-xs text-muted-foreground">{status}</span>;
|
||||
return <StatusBadge label={t(`loanOrderStatus.${status}`)} variant={variant} icon={Icon} />;
|
||||
return <StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={variant} icon={Icon} />;
|
||||
}
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertCircle, CheckCircle2, XCircle, Loader2 } from "lucide-react";
|
||||
import { AlertCircle, CheckCircle2, XCircle, CheckCheck } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
|
||||
import { DataTable } from "@/components/dataTable";
|
||||
@@ -9,24 +9,26 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { useLoanOrders, useDeleteLoanOrder } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import type { LoanOrder, LoanOrderStatus } from "@/features/loanOrders/api/loanOrdersApi";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { getStatusLabel, getStatusOptions, STATUS_BADGE_VARIANTS, type StatusValue } from "@/constants";
|
||||
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_CONFIG = {
|
||||
GARAŞYLÝAR: { label: "Garaşylýar", variant: "warning" as StatusBadgeVariant, icon: AlertCircle },
|
||||
KANAGATLANDYRYLAN: { label: "Kanagatlandyrylan", variant: "success" as StatusBadgeVariant, icon: CheckCircle2 },
|
||||
RED_EDILDI: { label: "Red edildi", variant: "error" as StatusBadgeVariant, icon: XCircle },
|
||||
IŞLENÝÄR: { label: "Işlenýär", variant: "info" as StatusBadgeVariant, icon: Loader2 },
|
||||
} satisfies Record<LoanOrderStatus, { label: string; variant: StatusBadgeVariant; icon: React.ElementType }>;
|
||||
const STATUS_ICONS: Record<StatusValue, React.ElementType> = {
|
||||
pending: AlertCircle,
|
||||
approved: CheckCircle2,
|
||||
rejected: XCircle,
|
||||
completed: CheckCheck,
|
||||
};
|
||||
|
||||
function LoanOrderStatusBadge({ status }: { status: LoanOrderStatus }) {
|
||||
const cfg = STATUS_CONFIG[status];
|
||||
if (!cfg) return <span className="text-xs text-muted-foreground">{String(status)}</span>;
|
||||
return <StatusBadge label={cfg.label} variant={cfg.variant} icon={cfg.icon} />;
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StatusBadge label={getStatusLabel(status, t, "loanOrderStatus")} variant={STATUS_BADGE_VARIANTS[status]} icon={STATUS_ICONS[status]} />
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Column meta for toggle dropdown ─────────────────────────────────────────
|
||||
@@ -44,13 +46,6 @@ const REGION_OPTIONS = [
|
||||
{ value: "Aşgabat", label: "Aşgabat" },
|
||||
];
|
||||
|
||||
const STATUS_OPTIONS: { value: LoanOrderStatus; label: string }[] = [
|
||||
{ value: "GARAŞYLÝAR", label: "Garaşylýar" },
|
||||
{ value: "KANAGATLANDYRYLAN", label: "Kanagatlandyrylan" },
|
||||
{ value: "RED_EDILDI", label: "Red edildi" },
|
||||
{ value: "IŞLENÝÄR", label: "Işlenýär" },
|
||||
];
|
||||
|
||||
// ─── Page Component ───────────────────────────────────────────────────────────
|
||||
|
||||
export default function LoanOrdersPage() {
|
||||
@@ -201,7 +196,7 @@ export default function LoanOrdersPage() {
|
||||
{
|
||||
id: "status",
|
||||
label: t("Status", "STATUS"),
|
||||
options: STATUS_OPTIONS,
|
||||
options: getStatusOptions(t, "loanOrderStatus"),
|
||||
},
|
||||
{
|
||||
id: "branch",
|
||||
|
||||
@@ -9,12 +9,13 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from "@/compone
|
||||
import { TableSearchInput } from "@/components/tableSearch";
|
||||
import { CreateButton } from "@/components/createButton";
|
||||
import { TableActions } from "@/components/tableActions";
|
||||
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { useLoanPaidOffLetters, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
||||
import { DeleteDialog } from "@/components/deleteDialog";
|
||||
import { useBranches } from "@/features/branches/hooks/useBranches";
|
||||
import { useDistricts } from "@/features/districts/hooks/useDistricts";
|
||||
import { getStatusOptions, STATUS_BADGE_VARIANTS } from "@/constants";
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -29,12 +30,6 @@ const INITIAL_FILTERS: ActiveFilter[] = FILTER_IDS.map((fieldId) => ({ fieldId,
|
||||
|
||||
// ─── Status badge helpers ──────────────────────────────────────────────────────
|
||||
|
||||
const STATUS_VARIANT: Record<string, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
|
||||
// ─── Empty state component ─────────────────────────────────────────────────────
|
||||
|
||||
function EmptyState({ onCreate }: { onCreate: () => void }) {
|
||||
@@ -107,11 +102,7 @@ export default function LoanPaidOffLettersPage() {
|
||||
{
|
||||
id: "status",
|
||||
label: t("loanPaidOffLetters.filters.status", "Status"),
|
||||
options: [
|
||||
{ value: "pending", label: t("loanPaidOffLetters.status.pending", "Pending") },
|
||||
{ value: "approved", label: t("loanPaidOffLetters.status.approved", "Approved") },
|
||||
{ value: "rejected", label: t("loanPaidOffLetters.status.rejected", "Rejected") },
|
||||
],
|
||||
options: getStatusOptions(t, "loanPaidOffLetters.status"),
|
||||
},
|
||||
{
|
||||
id: "passport_id",
|
||||
@@ -202,7 +193,9 @@ export default function LoanPaidOffLettersPage() {
|
||||
header: t("loanPaidOffLetters.columns.status", "STATUS"),
|
||||
cell: ({ row }) => {
|
||||
const status = row.original.status;
|
||||
return <StatusBadge label={t(`loanPaidOffLetters.status.${status}`, status)} variant={STATUS_VARIANT[status] ?? "default"} />;
|
||||
return (
|
||||
<StatusBadge label={t(`loanPaidOffLetters.status.${status}`, status)} variant={STATUS_BADGE_VARIANTS[status] ?? "default"} />
|
||||
);
|
||||
},
|
||||
size: 120,
|
||||
},
|
||||
|
||||
@@ -3,17 +3,11 @@ import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import { useLoanPaidOffLetterById, useDeleteLoanPaidOffLetter } from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { StatusBadgeVariant } from "@/components/ui/statusBadge";
|
||||
import { StatusBadge } from "@/components/ui/statusBadge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { BentoGrid, BentoCard, InfoRow } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
const STATUS_VARIANT: Record<string, StatusBadgeVariant> = {
|
||||
pending: "warning",
|
||||
approved: "success",
|
||||
rejected: "error",
|
||||
};
|
||||
import { STATUS_BADGE_VARIANTS } from "@/constants";
|
||||
|
||||
function formatDate(value: string | null | undefined): string {
|
||||
if (!value) return "—";
|
||||
@@ -95,7 +89,7 @@ export default function LoanPaidOffLettersViewPage() {
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.status", "Status")}>
|
||||
<StatusBadge
|
||||
label={t(`loanPaidOffLetters.status.${record.status}`, record.status)}
|
||||
variant={STATUS_VARIANT[record.status] ?? "default"}
|
||||
variant={STATUS_BADGE_VARIANTS[record.status] ?? "default"}
|
||||
/>
|
||||
</InfoRow>
|
||||
<InfoRow label={t("loanPaidOffLetters.fields.createdAt", "Döredilen wagty")} value={formatDate(record.createdAt)} />
|
||||
|
||||
@@ -27,7 +27,7 @@ export function CardReasonsListPage() {
|
||||
const [search, setSearch] = useState("");
|
||||
const [activeFilters, setActiveFilters] = useState<ActiveFilter[]>([{ fieldId: "isActive", value: "" }]);
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>(["id", "name", "value", "description", "isActive", "actions"]);
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>(["id", "name", "price", "notes", "isActive", "actions"]);
|
||||
|
||||
// ── Delete dialog ────────────────────────────────────────────────────────────
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null);
|
||||
|
||||
@@ -60,11 +60,7 @@ function useLoanTypeColumns(
|
||||
header: t("loanTypes.columns.isActive", "IŞJEŇ"),
|
||||
size: 80,
|
||||
cell: ({ row }) =>
|
||||
row.original.active ? (
|
||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||
) : (
|
||||
<XCircle size={18} className="text-muted-foreground" />
|
||||
),
|
||||
row.original.active ? <CheckCircle2 size={18} className="text-emerald-500" /> : <XCircle size={18} className="text-red-500" />,
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
|
||||
Reference in New Issue
Block a user