added some pages
This commit is contained in:
1 parent
c2548280a2
commit
c7797c3e31
61 files changed
+8309
-35
No files matched your search
@@ -0,0 +1,244 @@
|
||||
import { apiClient } from '@/lib/api/client'
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export type IntlPaymentStatus = 'pending' | 'approved' | 'rejected'
|
||||
export type CurrencyType = 'visa' | 'mastercard'
|
||||
|
||||
export interface IntlPaymentItem {
|
||||
id: string
|
||||
client_id: string
|
||||
client_label: string
|
||||
currency_type: CurrencyType
|
||||
currency_type_label: string
|
||||
created_at: string
|
||||
province: string
|
||||
province_label: string
|
||||
branch: string
|
||||
branch_label: string
|
||||
status: IntlPaymentStatus
|
||||
note: string | null
|
||||
|
||||
// Şahsy maglumatlar
|
||||
passport_first_name: string
|
||||
passport_last_name: string
|
||||
phone: string
|
||||
email: string | null
|
||||
home_address: string | null
|
||||
|
||||
// Töleg upgradyjynyň maglumatlary
|
||||
passport_series: string
|
||||
passport_number: string
|
||||
payer_full_name: string
|
||||
payer_account_number: string
|
||||
|
||||
// Töleg kabul edijiniň maglumatlary
|
||||
receiver_info: string
|
||||
|
||||
// Kabul ediji talyp boyunca resminamalar (9 sany)
|
||||
doc_sberbank_account: string | null // file url
|
||||
doc_school_enrollment: string | null
|
||||
doc_summons: string | null
|
||||
doc_passport_tm: string | null
|
||||
doc_foreign_passport: string | null
|
||||
doc_foreign_passport_copy: string | null
|
||||
doc_exit_permission: string | null
|
||||
doc_school_foreign_info: string | null
|
||||
doc_school_departure_info: string | null
|
||||
|
||||
// Upgradyý boyunca resminamalar (6 sany)
|
||||
upd_doc_passport_tm: string | null
|
||||
upd_doc_foreign_passport: string | null
|
||||
upd_doc_visa: string | null
|
||||
upd_doc_acceptance_letter: string | null
|
||||
upd_doc_passport_biometric: string | null
|
||||
upd_doc_passport_old: string | null
|
||||
|
||||
created_by: string
|
||||
created_by_label: string
|
||||
}
|
||||
|
||||
export interface IntlPaymentListParams {
|
||||
page?: number
|
||||
per_page?: number
|
||||
search?: string
|
||||
status?: IntlPaymentStatus | ''
|
||||
month?: string
|
||||
province?: string
|
||||
}
|
||||
|
||||
export interface IntlPaymentListResponse {
|
||||
data: IntlPaymentItem[]
|
||||
meta: {
|
||||
current_page: number
|
||||
last_page: number
|
||||
per_page: number
|
||||
total: number
|
||||
}
|
||||
}
|
||||
|
||||
export type IntlPaymentCreatePayload = {
|
||||
client_id: string
|
||||
status: IntlPaymentStatus
|
||||
note: string
|
||||
currency_type: CurrencyType
|
||||
province: string
|
||||
branch: string
|
||||
|
||||
passport_first_name: string
|
||||
passport_last_name: string
|
||||
phone: string
|
||||
email: string
|
||||
home_address: string
|
||||
|
||||
passport_series: string
|
||||
passport_number: string
|
||||
payer_full_name: string
|
||||
payer_account_number: string
|
||||
|
||||
receiver_info: string
|
||||
|
||||
// kabul ediji docs
|
||||
doc_sberbank_account: File | null
|
||||
doc_school_enrollment: File | null
|
||||
doc_summons: File | null
|
||||
doc_passport_tm: File | null
|
||||
doc_foreign_passport: File | null
|
||||
doc_foreign_passport_copy: File | null
|
||||
doc_exit_permission: File | null
|
||||
doc_school_foreign_info: File | null
|
||||
doc_school_departure_info: File | null
|
||||
|
||||
// upgradyý docs
|
||||
upd_doc_passport_tm: File | null
|
||||
upd_doc_foreign_passport: File | null
|
||||
upd_doc_visa: File | null
|
||||
upd_doc_acceptance_letter: File | null
|
||||
upd_doc_passport_biometric: File | null
|
||||
upd_doc_passport_old: File | null
|
||||
}
|
||||
|
||||
export type IntlPaymentUpdatePayload = IntlPaymentCreatePayload
|
||||
|
||||
// ─── API Functions ────────────────────────────────────────────────────────────
|
||||
|
||||
const MOCK_INTL_PAYMENTS: IntlPaymentItem[] = [
|
||||
{
|
||||
id: '1',
|
||||
client_id: '1',
|
||||
client_label: 'Jelaletdin',
|
||||
currency_type: 'visa',
|
||||
currency_type_label: 'Visa',
|
||||
created_at: '2024-05-07 12:00',
|
||||
province: 'ashgabat',
|
||||
province_label: 'Aşgabat',
|
||||
branch: '1',
|
||||
branch_label: 'Merkezi şahamça',
|
||||
status: 'pending',
|
||||
note: 'Test sargyt',
|
||||
passport_first_name: 'Aman',
|
||||
passport_last_name: 'Amanow',
|
||||
phone: '99365123456',
|
||||
email: 'aman@example.com',
|
||||
home_address: 'Aşgabat ş., Magtymguly şaýoly 1',
|
||||
passport_series: 'I-MR',
|
||||
passport_number: '123456',
|
||||
payer_full_name: 'Aman Amanow',
|
||||
payer_account_number: '1234567890123456',
|
||||
receiver_info: 'Test Receiver',
|
||||
doc_sberbank_account: null,
|
||||
doc_school_enrollment: null,
|
||||
doc_summons: null,
|
||||
doc_passport_tm: null,
|
||||
doc_foreign_passport: null,
|
||||
doc_foreign_passport_copy: null,
|
||||
doc_exit_permission: null,
|
||||
doc_school_foreign_info: null,
|
||||
doc_school_departure_info: null,
|
||||
upd_doc_passport_tm: null,
|
||||
upd_doc_foreign_passport: null,
|
||||
upd_doc_visa: null,
|
||||
upd_doc_acceptance_letter: null,
|
||||
upd_doc_passport_biometric: null,
|
||||
upd_doc_passport_old: null,
|
||||
created_by: '1',
|
||||
created_by_label: 'Admin',
|
||||
},
|
||||
]
|
||||
|
||||
export const intlPaymentApi = {
|
||||
list: async (params: IntlPaymentListParams): Promise<IntlPaymentListResponse> => {
|
||||
return {
|
||||
data: MOCK_INTL_PAYMENTS,
|
||||
meta: {
|
||||
current_page: params.page || 1,
|
||||
last_page: 1,
|
||||
per_page: params.per_page || 25,
|
||||
total: MOCK_INTL_PAYMENTS.length,
|
||||
}
|
||||
}
|
||||
|
||||
const { data } = await apiClient.get('/intl-payments/visa-master', { params })
|
||||
return data
|
||||
},
|
||||
|
||||
getById: async (id: string): Promise<IntlPaymentItem> => {
|
||||
const mock = MOCK_INTL_PAYMENTS.find(p => p.id === id)
|
||||
if (mock) return mock
|
||||
|
||||
const { data } = await apiClient.get(`/intl-payments/visa-master/${id}`)
|
||||
return data
|
||||
},
|
||||
|
||||
create: (payload: IntlPaymentCreatePayload): Promise<IntlPaymentItem> => {
|
||||
const form = buildFormData(payload)
|
||||
return apiClient
|
||||
.post('/intl-payments/visa-master', form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
.then((r) => r.data)
|
||||
},
|
||||
|
||||
update: (id: string, payload: IntlPaymentUpdatePayload): Promise<IntlPaymentItem> => {
|
||||
const form = buildFormData(payload)
|
||||
form.append('_method', 'PUT')
|
||||
return apiClient
|
||||
.post(`/intl-payments/visa-master/${id}`, form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
.then((r) => r.data)
|
||||
},
|
||||
|
||||
delete: (id: string): Promise<void> =>
|
||||
apiClient.delete(`/intl-payments/visa-master/${id}`).then((r) => r.data),
|
||||
}
|
||||
|
||||
// ─── Helper ───────────────────────────────────────────────────────────────────
|
||||
|
||||
const TEXT_FIELDS: (keyof IntlPaymentCreatePayload)[] = [
|
||||
'client_id', 'status', 'note', 'currency_type', 'province', 'branch',
|
||||
'passport_first_name', 'passport_last_name', 'phone', 'email', 'home_address',
|
||||
'passport_series', 'passport_number', 'payer_full_name', 'payer_account_number',
|
||||
'receiver_info',
|
||||
]
|
||||
|
||||
const FILE_FIELDS: (keyof IntlPaymentCreatePayload)[] = [
|
||||
'doc_sberbank_account', 'doc_school_enrollment', 'doc_summons',
|
||||
'doc_passport_tm', 'doc_foreign_passport', 'doc_foreign_passport_copy',
|
||||
'doc_exit_permission', 'doc_school_foreign_info', 'doc_school_departure_info',
|
||||
'upd_doc_passport_tm', 'upd_doc_foreign_passport', 'upd_doc_visa',
|
||||
'upd_doc_acceptance_letter', 'upd_doc_passport_biometric', 'upd_doc_passport_old',
|
||||
]
|
||||
|
||||
function buildFormData(payload: IntlPaymentCreatePayload): FormData {
|
||||
const form = new FormData()
|
||||
for (const key of TEXT_FIELDS) {
|
||||
const val = payload[key]
|
||||
if (val !== null && val !== undefined) form.append(key, String(val))
|
||||
}
|
||||
for (const key of FILE_FIELDS) {
|
||||
const file = payload[key]
|
||||
if (file instanceof File) form.append(key, file)
|
||||
}
|
||||
return form
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FormInput } from '@/components/formInput'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import type { IntlPaymentItem, IntlPaymentCreatePayload, IntlPaymentStatus, CurrencyType } from '../api/visaMasterPaymentsApi'
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
interface IntlPaymentFormProps {
|
||||
mode: 'create' | 'edit'
|
||||
initialData?: IntlPaymentItem
|
||||
onSubmit: (payload: IntlPaymentCreatePayload) => void
|
||||
isSubmitting: boolean
|
||||
}
|
||||
|
||||
type FileKey =
|
||||
| 'doc_sberbank_account' | 'doc_school_enrollment' | 'doc_summons'
|
||||
| 'doc_passport_tm' | 'doc_foreign_passport' | 'doc_foreign_passport_copy'
|
||||
| 'doc_exit_permission' | 'doc_school_foreign_info' | 'doc_school_departure_info'
|
||||
| 'upd_doc_passport_tm' | 'upd_doc_foreign_passport' | 'upd_doc_visa'
|
||||
| 'upd_doc_acceptance_letter' | 'upd_doc_passport_biometric' | 'upd_doc_passport_old'
|
||||
|
||||
interface FormState {
|
||||
client_id: string
|
||||
status: string
|
||||
note: string
|
||||
currency_type: string
|
||||
province: string
|
||||
branch: string
|
||||
passport_first_name: string
|
||||
passport_last_name: string
|
||||
phone: string
|
||||
email: string
|
||||
home_address: string
|
||||
passport_series: string
|
||||
passport_number: string
|
||||
payer_full_name: string
|
||||
payer_account_number: string
|
||||
receiver_info: string
|
||||
doc_sberbank_account: File | null
|
||||
doc_school_enrollment: File | null
|
||||
doc_summons: File | null
|
||||
doc_passport_tm: File | null
|
||||
doc_foreign_passport: File | null
|
||||
doc_foreign_passport_copy: File | null
|
||||
doc_exit_permission: File | null
|
||||
doc_school_foreign_info: File | null
|
||||
doc_school_departure_info: File | null
|
||||
upd_doc_passport_tm: File | null
|
||||
upd_doc_foreign_passport: File | null
|
||||
upd_doc_visa: File | null
|
||||
upd_doc_acceptance_letter: File | null
|
||||
upd_doc_passport_biometric: File | null
|
||||
upd_doc_passport_old: File | null
|
||||
}
|
||||
|
||||
type FormErrors = Partial<Record<keyof FormState, 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' },
|
||||
{ value: 'mary', label: 'Mary' },
|
||||
{ value: 'dasoguz', label: 'Daşoguz' },
|
||||
{ value: 'lebap', label: 'Lebap' },
|
||||
{ value: 'balkan', label: 'Balkan' },
|
||||
]
|
||||
|
||||
// Kabul ediji docs — 9 sany
|
||||
const KABUL_DOCS: { key: FileKey; label: string }[] = [
|
||||
{ key: 'doc_sberbank_account', label: 'Talypyň degişli welaýata "SBERBANK" kartyň rekwizitleri' },
|
||||
{ key: 'doc_school_enrollment', label: 'Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy' },
|
||||
{ key: 'doc_summons', label: 'Talypyň bilendiriň göçürmesi' },
|
||||
{ key: 'doc_passport_tm', label: 'Talypyň degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi' },
|
||||
{ key: 'doc_foreign_passport', label: 'Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi' },
|
||||
{ key: 'doc_foreign_passport_copy',label: 'Talypyň Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurtda galan döwründe bakýan döwleti baradaky bellenen sahypasynyň göçürmesi' },
|
||||
{ key: 'doc_exit_permission', label: 'Talypyň Türkmenistandan çykmak — we Türkmenistana girmek üçin pasportynyň dowletiniň girmesiz baradaky bellenen (goşmaç şaýmynyň) bellenen sahypasynyň göçürmesi' },
|
||||
{ key: 'doc_school_foreign_info', label: 'Talypyň daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy barada doly takyk dil ulgaýynda takyk dil maglumatly sebäpleri daşary ýurt döwletiniň ýokary okuw mekdebinden haty' },
|
||||
{ key: 'doc_school_departure_info',label: 'Talypyň daşary ýurt döwletinde döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamany döwlet dili maglumatlaryny talabap doly takyk dil ulgaýynda talaby daşary ýurt döwletiniň ýokary okuw mekdebinden haty' },
|
||||
]
|
||||
|
||||
// Upgradyý docs — 6 sany
|
||||
const UPGRAD_DOCS: { key: FileKey; label: string }[] = [
|
||||
{ key: 'upd_doc_passport_tm', label: 'Upgradyý degişli Türkmenistanyň raýatynyň içki milli pasportynyň asyl görnüşi we göçürmesi' },
|
||||
{ key: 'upd_doc_foreign_passport', label: 'Upgradyý degişli Türkmenistandan çykmak we Türkmenistana girmek üçin pasportynyň göçürmesi' },
|
||||
{ key: 'upd_doc_visa', label: 'Upgradyý Türkmenistandan — çykmak we Türkmenistana girmek üçin pasportynyň daşary ýurt döwletinde galýandygy we daşary ýurt döwleti baradaky şaýmynyň bellenen sahypasynyň göçürmesi' },
|
||||
{ key: 'upd_doc_acceptance_letter', label: 'Upgradyýyň we kabul edijiniň Batalyý töräre garyşdyryjy resminamalarynyň göçürmesi' },
|
||||
{ key: 'upd_doc_passport_biometric', label: 'Upgradyý we kabul ediji täze 2015-nji ýyldan soňra Türkmenistanyň raýatynyň pasportynyň tässy göreli alan bolsa, osta üstü görli 1 pasportynyň seriýasy baradaky maglumatlary' },
|
||||
{ key: 'upd_doc_passport_old', label: 'Upgradyý we kabul ediji täze 2015-nji ýyldan soňra Türkmenistanyň raýatynyň pasportynyň köp göreli alanlar soňra birleşi göreli alan bolsa, biri miwe möhüründen doglan doglan ata-enelerden biriniň alan pasportynyň seriýasy baradaky göwnamasy' },
|
||||
]
|
||||
|
||||
// ─── Default state ────────────────────────────────────────────────────────────
|
||||
|
||||
const defaultState: FormState = {
|
||||
client_id: '', status: 'pending', note: '',
|
||||
currency_type: '', province: '', branch: '',
|
||||
passport_first_name: '', passport_last_name: '',
|
||||
phone: '', email: '', home_address: '',
|
||||
passport_series: '', passport_number: '',
|
||||
payer_full_name: '', payer_account_number: '',
|
||||
receiver_info: '',
|
||||
doc_sberbank_account: null, doc_school_enrollment: null,
|
||||
doc_summons: null, doc_passport_tm: null,
|
||||
doc_foreign_passport: null, doc_foreign_passport_copy: null,
|
||||
doc_exit_permission: null, doc_school_foreign_info: null,
|
||||
doc_school_departure_info: null,
|
||||
upd_doc_passport_tm: null, upd_doc_foreign_passport: null,
|
||||
upd_doc_visa: null, upd_doc_acceptance_letter: null,
|
||||
upd_doc_passport_biometric: null, upd_doc_passport_old: null,
|
||||
}
|
||||
|
||||
// ─── Validation ───────────────────────────────────────────────────────────────
|
||||
|
||||
function validate(form: FormState): FormErrors {
|
||||
const errors: FormErrors = {}
|
||||
if (!form.client_id) errors.client_id = 'Ulanyjy hökmany'
|
||||
if (!form.status) errors.status = 'Status hökmany'
|
||||
if (!form.currency_type) errors.currency_type = 'Ýüztumanyň görnüşi hökmany'
|
||||
if (!form.province) errors.province = 'Welaýat hökmany'
|
||||
if (!form.branch) errors.branch = 'Şahamça hökmany'
|
||||
if (!form.passport_first_name) errors.passport_first_name = 'Ady hökmany'
|
||||
if (!form.passport_last_name) errors.passport_last_name = 'Familiýasy hökmany'
|
||||
if (!form.phone) errors.phone = 'Telefon hökmany'
|
||||
if (!form.passport_series) errors.passport_series = 'Pasport seriýasy hökmany'
|
||||
if (!form.passport_number) errors.passport_number = 'Pasport nomeri hökmany'
|
||||
if (!form.payer_full_name) errors.payer_full_name = 'Ady Familiýasy Atasnyň ady hökmany'
|
||||
if (!form.payer_account_number)errors.payer_account_number= 'Goşun hasaby hökmany'
|
||||
if (!form.receiver_info) errors.receiver_info = 'Töleg kabul edijiniň maglumatlary hökmany'
|
||||
return errors
|
||||
}
|
||||
|
||||
// ─── Section wrapper ──────────────────────────────────────────────────────────
|
||||
|
||||
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<section className="bg-card border border-border rounded-lg p-6 space-y-4">
|
||||
{title && (
|
||||
<h2 className="text-base font-semibold text-foreground">{title}</h2>
|
||||
)}
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Component ────────────────────────────────────────────────────────────────
|
||||
|
||||
export function IntlPaymentForm({ mode, initialData, onSubmit, isSubmitting }: IntlPaymentFormProps) {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [form, setForm] = useState<FormState>(defaultState)
|
||||
const [errors, setErrors] = useState<FormErrors>({})
|
||||
|
||||
useEffect(() => {
|
||||
if (mode === 'edit' && initialData) {
|
||||
setForm({
|
||||
client_id: initialData.client_id,
|
||||
status: initialData.status,
|
||||
note: initialData.note ?? '',
|
||||
currency_type: initialData.currency_type,
|
||||
province: initialData.province,
|
||||
branch: initialData.branch,
|
||||
passport_first_name: initialData.passport_first_name,
|
||||
passport_last_name: initialData.passport_last_name,
|
||||
phone: initialData.phone,
|
||||
email: initialData.email ?? '',
|
||||
home_address: initialData.home_address ?? '',
|
||||
passport_series: initialData.passport_series,
|
||||
passport_number: initialData.passport_number,
|
||||
payer_full_name: initialData.payer_full_name,
|
||||
payer_account_number: initialData.payer_account_number,
|
||||
receiver_info: initialData.receiver_info,
|
||||
doc_sberbank_account: null, doc_school_enrollment: null,
|
||||
doc_summons: null, doc_passport_tm: null,
|
||||
doc_foreign_passport: null, doc_foreign_passport_copy: null,
|
||||
doc_exit_permission: null, doc_school_foreign_info: null,
|
||||
doc_school_departure_info: null,
|
||||
upd_doc_passport_tm: null, upd_doc_foreign_passport: null,
|
||||
upd_doc_visa: null, upd_doc_acceptance_letter: null,
|
||||
upd_doc_passport_biometric: null, upd_doc_passport_old: null,
|
||||
})
|
||||
}
|
||||
}, [mode, initialData])
|
||||
|
||||
const set = <K extends keyof FormState>(key: K, value: FormState[K]) => {
|
||||
setForm((prev) => ({ ...prev, [key]: value }))
|
||||
if (errors[key]) setErrors((prev) => ({ ...prev, [key]: undefined }))
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
const errs = validate(form)
|
||||
if (Object.keys(errs).length > 0) {
|
||||
setErrors(errs)
|
||||
return
|
||||
}
|
||||
onSubmit({
|
||||
...form,
|
||||
status: form.status as IntlPaymentStatus,
|
||||
currency_type: form.currency_type as CurrencyType,
|
||||
})
|
||||
}
|
||||
|
||||
const title = mode === 'create'
|
||||
? t('intlPayment.createTitle', 'Visa/Master tölegler (talyplar üçin) dörediň')
|
||||
: t('intlPayment.editTitle', 'Visa/Master tölegler (talyplar üçin) redaktirläň')
|
||||
|
||||
const submitLabel = mode === 'create'
|
||||
? t('intlPayment.createBtn', 'Visa/Master tölegler (talyplar üçin) dörediň')
|
||||
: t('intlPayment.editBtn', 'Visa/Master tölegler (talyplar üçin) redaktirläň')
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto space-y-6">
|
||||
<h1 className="text-2xl font-bold text-foreground">{title}</h1>
|
||||
|
||||
{/* ── Status ────────────────────────────────────────────────────────── */}
|
||||
<Section title="">
|
||||
<FormInput
|
||||
type="searchable-select"
|
||||
label={t('intlPayment.client', 'Ulanyjy')}
|
||||
value={form.client_id}
|
||||
onChange={(v) => set('client_id', v)}
|
||||
options={[]} // Fetched from clients API
|
||||
placeholder="Saýlamak üçin basyň"
|
||||
error={errors.client_id}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="select"
|
||||
label={t('intlPayment.status', 'Status')}
|
||||
value={form.status}
|
||||
onChange={(v) => set('status', v)}
|
||||
options={STATUS_OPTIONS}
|
||||
error={errors.status}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="textarea"
|
||||
label={t('intlPayment.note', 'Bellik')}
|
||||
value={form.note}
|
||||
onChange={(v) => set('note', v)}
|
||||
placeholder="Bellik"
|
||||
rows={2}
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* ── Ýüztumanyň görnüşi ───────────────────────────────────────────── */}
|
||||
<Section title={t('intlPayment.currencySection', 'Ýüztumanyň görnüşi')}>
|
||||
<FormInput
|
||||
type="select"
|
||||
label={t('intlPayment.currencyType', 'Ýüztumanyň görnüşi')}
|
||||
value={form.currency_type}
|
||||
onChange={(v) => set('currency_type', v)}
|
||||
options={CURRENCY_OPTIONS}
|
||||
error={errors.currency_type}
|
||||
required
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* ── Lokasiýa ─────────────────────────────────────────────────────── */}
|
||||
<Section title={t('intlPayment.locationSection', 'Lokasiýa')}>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="searchable-select"
|
||||
label={t('intlPayment.province', 'Welaýat')}
|
||||
value={form.province}
|
||||
onChange={(v) => { set('province', v); set('branch', '') }}
|
||||
options={PROVINCE_OPTIONS}
|
||||
error={errors.province}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="searchable-select"
|
||||
label={t('intlPayment.branch', 'Şahamça')}
|
||||
value={form.branch}
|
||||
onChange={(v) => set('branch', v)}
|
||||
options={[]} // Fetched from branches API filtered by province
|
||||
placeholder="Saýlamak üçin basyň"
|
||||
error={errors.branch}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{/* ── Şahsy maglumatlar ─────────────────────────────────────────────── */}
|
||||
<Section title={t('intlPayment.personalSection', 'Şahsy maglumatlar')}>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="searchable-select"
|
||||
label={t('intlPayment.passportLastName', 'Pasportdaky familýa')}
|
||||
value={form.passport_last_name}
|
||||
onChange={(v) => set('passport_last_name', v)}
|
||||
options={[]}
|
||||
placeholder="Pasportdaky familýa"
|
||||
error={errors.passport_last_name}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t('intlPayment.passportFirstName', 'Pasportdaky ady')}
|
||||
value={form.passport_first_name}
|
||||
onChange={(v) => set('passport_first_name', v)}
|
||||
placeholder="Pasportdaky ady"
|
||||
error={errors.passport_first_name}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="phone"
|
||||
label={t('intlPayment.phone', 'Telefon')}
|
||||
value={form.phone}
|
||||
onChange={(v) => set('phone', v)}
|
||||
error={errors.phone}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="email"
|
||||
label={t('intlPayment.email', 'E-poçta')}
|
||||
value={form.email}
|
||||
onChange={(v) => set('email', v)}
|
||||
placeholder="E-poçta"
|
||||
/>
|
||||
</div>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t('intlPayment.homeAddress', 'Häzirki ýaşyş ýeri')}
|
||||
value={form.home_address}
|
||||
onChange={(v) => set('home_address', v)}
|
||||
placeholder="Häzirki ýaşyş ýeri"
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* ── Töleg upgradyjynyň maglumatlary ──────────────────────────────── */}
|
||||
<Section title={t('intlPayment.payerSection', 'Töleg upgradyjynyň maglumatlary')}>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<FormInput
|
||||
type="searchable-select"
|
||||
label={t('intlPayment.passportSeries', 'Pasport seriýasy')}
|
||||
value={form.passport_series}
|
||||
onChange={(v) => set('passport_series', v)}
|
||||
options={PASSPORT_SERIES_OPTIONS}
|
||||
error={errors.passport_series}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t('intlPayment.passportNumber', 'Pasport nomeri')}
|
||||
value={form.passport_number}
|
||||
onChange={(v) => set('passport_number', v)}
|
||||
placeholder="Pasport nomeri"
|
||||
error={errors.passport_number}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t('intlPayment.payerFullName', 'Ady Familiýasy Atasnyň ady')}
|
||||
value={form.payer_full_name}
|
||||
onChange={(v) => set('payer_full_name', v)}
|
||||
placeholder="Ady Familiýasy Atasnyň ady"
|
||||
error={errors.payer_full_name}
|
||||
required
|
||||
/>
|
||||
<FormInput
|
||||
type="text"
|
||||
label={t('intlPayment.payerAccount', 'Goşun hasaby')}
|
||||
value={form.payer_account_number}
|
||||
onChange={(v) => set('payer_account_number', v)}
|
||||
placeholder="Goşun hasaby"
|
||||
error={errors.payer_account_number}
|
||||
required
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* ── Töleg kabul edijiniň maglumatlary ────────────────────────────── */}
|
||||
<Section title={t('intlPayment.receiverSection', 'Töleg kabul edijiniň maglumatlary')}>
|
||||
<FormInput
|
||||
type="textarea"
|
||||
label={t('intlPayment.receiverInfo', 'Saňa ger')}
|
||||
value={form.receiver_info}
|
||||
onChange={(v) => set('receiver_info', v)}
|
||||
placeholder="Saňa ger"
|
||||
rows={3}
|
||||
error={errors.receiver_info}
|
||||
required
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* ── Kabul ediji talyp boyunca resminamalar ────────────────────────── */}
|
||||
<Section title={t('intlPayment.kabulDocsSection', 'Kabul ediji talyp boyunca resminamalar')}>
|
||||
<div className="space-y-4">
|
||||
{KABUL_DOCS.map(({ key, label }) => (
|
||||
<FormInput
|
||||
key={key}
|
||||
type="file"
|
||||
label={label}
|
||||
onFileChange={(f) => set(key, f)}
|
||||
fileValue={form[key] as File | null}
|
||||
accept="image/*,.pdf"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{/* ── Upgradyý boyunca resminamalar ─────────────────────────────────── */}
|
||||
<Section title={t('intlPayment.upgradDocsSection', 'Upgradyý boyunca resminamalar')}>
|
||||
<div className="space-y-4">
|
||||
{UPGRAD_DOCS.map(({ key, label }) => (
|
||||
<FormInput
|
||||
key={key}
|
||||
type="file"
|
||||
label={label}
|
||||
onFileChange={(f) => set(key, f)}
|
||||
fileValue={form[key] as File | null}
|
||||
accept="image/*,.pdf"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{/* ── Actions ───────────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-end gap-3 pb-6">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => navigate('/intl-payments/visa-master')}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting}
|
||||
className="min-w-[240px]"
|
||||
>
|
||||
{isSubmitting ? <Spinner className="size-4" /> : submitLabel}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import {
|
||||
intlPaymentApi,
|
||||
type IntlPaymentListParams,
|
||||
type IntlPaymentCreatePayload,
|
||||
type IntlPaymentUpdatePayload,
|
||||
} from '../api/visaMasterPaymentsApi'
|
||||
|
||||
export const INTL_PAYMENT_KEYS = {
|
||||
all: ['intl-payments-visa'] as const,
|
||||
lists: () => [...INTL_PAYMENT_KEYS.all, 'list'] as const,
|
||||
list: (p: IntlPaymentListParams) => [...INTL_PAYMENT_KEYS.lists(), p] as const,
|
||||
detail: (id: string) => [...INTL_PAYMENT_KEYS.all, 'detail', id] as const,
|
||||
}
|
||||
|
||||
export function useIntlPayments(params: IntlPaymentListParams) {
|
||||
return useQuery({
|
||||
queryKey: INTL_PAYMENT_KEYS.list(params),
|
||||
queryFn: () => intlPaymentApi.list(params),
|
||||
placeholderData: (prev) => prev,
|
||||
})
|
||||
}
|
||||
|
||||
export function useIntlPayment(id: string) {
|
||||
return useQuery({
|
||||
queryKey: INTL_PAYMENT_KEYS.detail(id),
|
||||
queryFn: () => intlPaymentApi.getById(id),
|
||||
enabled: !!id,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateIntlPayment() {
|
||||
const qc = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
return useMutation({
|
||||
mutationFn: (payload: IntlPaymentCreatePayload) => intlPaymentApi.create(payload),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
toast.success(t('intlPayment.createSuccess', 'Töleg döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('intlPayment.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateIntlPayment(id: string) {
|
||||
const qc = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
return useMutation({
|
||||
mutationFn: (payload: IntlPaymentUpdatePayload) => intlPaymentApi.update(id, payload),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.detail(id) })
|
||||
toast.success(t('intlPayment.updateSuccess', 'Töleg üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('intlPayment.updateError', 'Üýtgetmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteIntlPayment() {
|
||||
const qc = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => intlPaymentApi.delete(id),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
toast.success(t('intlPayment.deleteSuccess', 'Töleg pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('intlPayment.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user