added loan remaing pages

This commit is contained in:
@jcarymuhammedow committed 2026-05-05 19:07:59 +05:00
1 parent c612d5bae3
commit c2548280a2
24 files changed
+3182 -307

No files matched your search

@@ -18,6 +18,114 @@ export interface LoanOrderMobile {
lastName: string
phone: string
status: LoanOrderMobileStatus
createdBy?: string
// ── Detail fields ─────────────────────────────────────────────────────────
patronicName?: string | null
education?: string | null
marriageStatus?: string | null
dateOfBirth?: string | null
residence?: string | null
currentResidence?: string | null
// Passport
passportSerie?: string | null
passportNumber?: string | null
passportDateOfIssue?: string | null
passportGivenBy?: string | null
bornPlace?: string | null
passportPage1Url?: string | null
passportPage23Url?: string | null
passportPage89Url?: string | null
passportPage32Url?: string | null
// Contact
email?: string | null
phoneAdditional?: string | null
homePhone?: string | null
// Employment
workCompany?: string | null
workHrPhone?: string | null
workRegion?: string | null
workProvince?: string | null
position?: string | null
salary?: number | null
workStartedAt?: string | null
// New fields
note?: string | null
loanAmount?: number | null
loanHistory?: string | null
// Card (Zähmet haky)
cardNumber?: string | null
cardName?: string | null
cardExpMonth?: string | null
cardExpYear?: string | null
// Guarantor (Zamun)
guarantor1Name?: string | null
guarantor1Surname?: string | null
guarantor1Patronic?: string | null
guarantor1PassportSerie?: string | null
guarantor1PassportNumber?: string | null
guarantor1CardNumber?: string | null
guarantor1CardName?: string | null
guarantor1CardExpMonth?: string | null
guarantor1CardExpYear?: string | null
guarantor1Salary?: number | null
}
export interface LoanOrderMobilePayload {
status: string
loanType: string
region: string
branch: string
firstName: string
lastName: string
patronicName?: string
education: string
marriageStatus: string
dateOfBirth: string
residence: string
currentResidence?: string
passportSerie: string
passportNumber: string
passportDateOfIssue: string
passportGivenBy: string
bornPlace?: string
email?: string
phone: string
phoneAdditional?: string
homePhone?: string
workCompany: string
workHrPhone?: string
workRegion?: string
workProvince?: string
position: string
salary: number
workStartedAt: string
note?: string
loanAmount?: number
loanHistory?: string
cardNumber?: string
cardName?: string
cardExpMonth?: string
cardExpYear?: string
guarantor1Name?: string
guarantor1Surname?: string
guarantor1Patronic?: string
guarantor1PassportSerie?: string
guarantor1PassportNumber?: string
guarantor1CardNumber?: string
guarantor1CardName?: string
guarantor1CardExpMonth?: string
guarantor1CardExpYear?: string
guarantor1Salary?: number
}
export interface LoanOrderMobileListParams {
@@ -102,4 +210,45 @@ export async function deleteLoanOrderMobile(id: string): Promise<void> {
return
}
await apiClient.delete(`/loan-order-mobiles/${id}`)
}
export async function getLoanOrderMobileById(id: string): Promise<LoanOrderMobile> {
if (USE_MOCK) {
const order = MOCK_DATA.find((r) => r.id === id)
if (!order) throw new Error('Not found')
return order
}
const { data } = await apiClient.get<LoanOrderMobile>(`/loan-order-mobiles/${id}`)
return data
}
export async function createLoanOrderMobile(
payload: LoanOrderMobilePayload
): Promise<LoanOrderMobile> {
if (USE_MOCK) {
const newOrder: LoanOrderMobile = {
...payload,
id: `LOM-${String(MOCK_DATA.length + 1).padStart(4, '0')}`,
createdAt: new Date().toISOString().slice(0, 16).replace('T', ' '),
status: payload.status as LoanOrderMobileStatus,
}
MOCK_DATA.unshift(newOrder)
return newOrder
}
const { data } = await apiClient.post<LoanOrderMobile>('/loan-order-mobiles', payload)
return data
}
export async function updateLoanOrderMobile(
id: string,
payload: Partial<LoanOrderMobilePayload>
): Promise<LoanOrderMobile> {
if (USE_MOCK) {
const idx = MOCK_DATA.findIndex((r) => r.id === id)
if (idx === -1) throw new Error('Not found')
MOCK_DATA[idx] = { ...MOCK_DATA[idx], ...payload } as LoanOrderMobile
return MOCK_DATA[idx]
}
const { data } = await apiClient.put<LoanOrderMobile>(`/loan-order-mobiles/${id}`, payload)
return data
}
File diff suppressed because it is too large. Load diff
@@ -5,7 +5,11 @@ import { useTranslation } from 'react-i18next'
import {
fetchLoanOrderMobiles,
deleteLoanOrderMobile,
getLoanOrderMobileById,
createLoanOrderMobile,
updateLoanOrderMobile,
type LoanOrderMobileListParams,
type LoanOrderMobilePayload,
} from '../api/loanOrderMobilesApi'
// ─── Query keys ────────────────────────────────────────────────────────────────
@@ -14,6 +18,8 @@ export const loanOrderMobileKeys = {
all: ['loanOrderMobiles'] as const,
lists: () => [...loanOrderMobileKeys.all, 'list'] as const,
list: (params: LoanOrderMobileListParams) => [...loanOrderMobileKeys.lists(), params] as const,
details: () => [...loanOrderMobileKeys.all, 'detail'] as const,
detail: (id: string) => [...loanOrderMobileKeys.details(), id] as const,
}
// ─── Hooks ─────────────────────────────────────────────────────────────────────
@@ -39,4 +45,46 @@ export function useDeleteLoanOrderMobile() {
toast.error(t('loanOrderMobiles.deleteError', 'Pozmak başartmady, gaýtadan synanyşyň'))
},
})
}
export function useLoanOrderMobileById(id: string) {
return useQuery({
queryKey: loanOrderMobileKeys.detail(id),
queryFn: () => getLoanOrderMobileById(id),
enabled: !!id,
})
}
export function useCreateLoanOrderMobile() {
const queryClient = useQueryClient()
const { t } = useTranslation()
return useMutation({
mutationFn: (payload: LoanOrderMobilePayload) => createLoanOrderMobile(payload),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: loanOrderMobileKeys.lists() })
toast.success(t('loanOrderMobiles.createSuccess', 'Sargyt üstünlikli döredildi'))
},
onError: () => {
toast.error(t('loanOrderMobiles.createError', 'Sargyt döretmek başartmady'))
},
})
}
export function useUpdateLoanOrderMobile() {
const queryClient = useQueryClient()
const { t } = useTranslation()
return useMutation({
mutationFn: ({ id, payload }: { id: string; payload: Partial<LoanOrderMobilePayload> }) =>
updateLoanOrderMobile(id, payload),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({ queryKey: loanOrderMobileKeys.lists() })
queryClient.invalidateQueries({ queryKey: loanOrderMobileKeys.detail(variables.id) })
toast.success(t('loanOrderMobiles.updateSuccess', 'Sargyt üstünlikli üýtgedildi'))
},
onError: () => {
toast.error(t('loanOrderMobiles.updateError', 'Üýtgetmek başartmady'))
},
})
}