added new pages

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

View File

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

View File

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

View File

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