added confirm dialog, some translations
This commit is contained in:
63
src/components/confirmDialog.tsx
Normal file
63
src/components/confirmDialog.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import type { ReactNode } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import * as VisuallyHidden from "@radix-ui/react-visually-hidden"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
|
||||
interface ConfirmDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
title: string
|
||||
description?: string
|
||||
confirmLabel?: string
|
||||
cancelLabel?: string
|
||||
onConfirm: () => void
|
||||
isLoading?: boolean
|
||||
children?: ReactNode
|
||||
}
|
||||
|
||||
export function ConfirmDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
description,
|
||||
confirmLabel,
|
||||
cancelLabel,
|
||||
onConfirm,
|
||||
isLoading,
|
||||
}: ConfirmDialogProps) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{title}</AlertDialogTitle>
|
||||
{description ? (
|
||||
<AlertDialogDescription>{description}</AlertDialogDescription>
|
||||
) : (
|
||||
<VisuallyHidden.Root>
|
||||
<AlertDialogDescription>{title}</AlertDialogDescription>
|
||||
</VisuallyHidden.Root>
|
||||
)}
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isLoading}>
|
||||
{cancelLabel ?? t("common.cancel", "Cancel")}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction variant="destructive" onClick={onConfirm} disabled={isLoading}>
|
||||
{confirmLabel ?? t("common.confirm", "Tassykla")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
)
|
||||
}
|
||||
@@ -8,8 +8,6 @@ import {
|
||||
type UsersListParams,
|
||||
} from '../api/allUsersApi'
|
||||
|
||||
// ─── Query Keys ───────────────────────────────────────────────────────────────
|
||||
|
||||
export const userKeys = {
|
||||
all: ['users'] as const,
|
||||
lists: () => [...userKeys.all, 'list'] as const,
|
||||
@@ -18,8 +16,6 @@ export const userKeys = {
|
||||
detail: (id: number) => [...userKeys.details(), id] as const,
|
||||
}
|
||||
|
||||
// ─── useUsers ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export function useUsers(params: UsersListParams = {}) {
|
||||
return useQuery({
|
||||
queryKey: userKeys.list(params),
|
||||
@@ -28,8 +24,6 @@ export function useUsers(params: UsersListParams = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useUser ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export function useUser(id: number) {
|
||||
return useQuery({
|
||||
queryKey: userKeys.detail(id),
|
||||
@@ -38,8 +32,6 @@ export function useUser(id: number) {
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useCreateUser ────────────────────────────────────────────────────────────
|
||||
|
||||
export function useCreateUser() {
|
||||
const { t } = useTranslation()
|
||||
const queryClient = useQueryClient()
|
||||
@@ -50,14 +42,9 @@ export function useCreateUser() {
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.lists() })
|
||||
toast.success(t('users.toast.createSuccess', 'Ulanyjy üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('users.toast.createError', 'Ulanyjy döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useUpdateUser ────────────────────────────────────────────────────────────
|
||||
|
||||
export function useUpdateUser(id: number) {
|
||||
const { t } = useTranslation()
|
||||
const queryClient = useQueryClient()
|
||||
@@ -69,14 +56,9 @@ export function useUpdateUser(id: number) {
|
||||
queryClient.setQueryData(userKeys.detail(id), updatedUser)
|
||||
toast.success(t('users.toast.updateSuccess', 'Ulanyjy üstünlikli täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('users.toast.updateError', 'Ulanyjy täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useDeleteUser ────────────────────────────────────────────────────────────
|
||||
|
||||
export function useDeleteUser() {
|
||||
const { t } = useTranslation()
|
||||
const queryClient = useQueryClient()
|
||||
@@ -87,8 +69,5 @@ export function useDeleteUser() {
|
||||
queryClient.invalidateQueries({ queryKey: userKeys.lists() })
|
||||
toast.success(t('users.toast.deleteSuccess', 'Ulanyjy üstünlikli öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('users.toast.deleteError', 'Ulanyjy öçürmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateUserPayload } from '../api/allUsersApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const baseSchema = z.object({
|
||||
username: z.string()
|
||||
.min(1, 'Ulanyjy ady hökmany')
|
||||
.min(3, 'Ulanyjy ady iň az 3 harp bolmaly'),
|
||||
name: z.string().min(1, 'Ady hökmany'),
|
||||
.min(1, t('validation.required', 'Ulanyjy ady hökmany'))
|
||||
.min(3, t('validation.minLength', 'Ulanyjy ady iň az 3 harp bolmaly')),
|
||||
name: z.string().min(1, t('validation.required', 'Ady hökmany')),
|
||||
phone: z.string()
|
||||
.min(1, 'Telefon hökmany')
|
||||
.regex(/^\d[\d\s-]{6,}$/, 'Nädogry telefon formaty'),
|
||||
.min(1, t('validation.required', 'Telefon hökmany'))
|
||||
.regex(/^\d[\d\s-]{6,}$/, t('validation.invalidPhone', 'Nädogry telefon formaty')),
|
||||
email: z.string()
|
||||
.refine(
|
||||
(v) => !v || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),
|
||||
'Nädogry e-poçta formaty',
|
||||
t('validation.invalidEmail', 'Nädogry e-poçta formaty'),
|
||||
)
|
||||
.default(''),
|
||||
password: z.string(),
|
||||
@@ -24,8 +27,8 @@ export function allUserFormSchema(mode: 'create' | 'edit') {
|
||||
return mode === 'create'
|
||||
? baseSchema.extend({
|
||||
password: z.string()
|
||||
.min(1, 'Açar sözi hökmany')
|
||||
.min(6, 'Açar sözi iň az 6 harp bolmaly'),
|
||||
.min(1, t('validation.required', 'Açar sözi hökmany'))
|
||||
.min(6, t('validation.minLength', 'Açar sözi iň az 6 harp bolmaly')),
|
||||
})
|
||||
: baseSchema
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { toast } from 'sonner'
|
||||
import i18next from 'i18next'
|
||||
import { useAuthStore } from '@/app/store/authStore'
|
||||
import { loginApi, type LoginRequest } from '../api/authApi'
|
||||
|
||||
@@ -11,6 +13,7 @@ export function useLogin() {
|
||||
mutationFn: (credentials: LoginRequest) => loginApi(credentials),
|
||||
onSuccess: ({ token, user }) => {
|
||||
setAuth(token, user)
|
||||
toast.success(i18next.t('Success login', 'Login successful'))
|
||||
navigate('/dashboard', { replace: true })
|
||||
},
|
||||
})
|
||||
|
||||
@@ -307,7 +307,7 @@ export function BranchForm({ mode, initialData, branchId }: BranchFormProps) {
|
||||
markVisited(currentStep)
|
||||
const errs = STEPS[currentStep].validate(form, mode)
|
||||
if (Object.keys(errs).length > 0) {
|
||||
toast.error('Dogry maglumat girizmegiňizi haýyş edýäris.')
|
||||
toast.error(t('common.errors.fillRequiredCorrectly', 'Dogry maglumat girizmegiňizi haýyş edýäris.'))
|
||||
return
|
||||
}
|
||||
if (currentStep < STEPS.length - 1) {
|
||||
@@ -337,7 +337,7 @@ export function BranchForm({ mode, initialData, branchId }: BranchFormProps) {
|
||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode))
|
||||
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
toast.error('Käbir hökmany meýdanlar doldurylan däldir.')
|
||||
toast.error(t('common.errors.requiredFieldsMissing', 'Käbir hökmany meýdanlar doldurylan däldir.'))
|
||||
for (let i = 0; i < STEPS.length; i++) {
|
||||
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) {
|
||||
setCurrentStep(i); break
|
||||
|
||||
@@ -50,9 +50,6 @@ export function useCreateBranch() {
|
||||
queryClient.invalidateQueries({ queryKey: branchKeys.lists() })
|
||||
toast.success(t('branches.toast.createSuccess', 'Şahamça döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('branches.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,9 +64,6 @@ export function useUpdateBranch() {
|
||||
queryClient.invalidateQueries({ queryKey: branchKeys.detail(data.id) })
|
||||
toast.success(t('branches.toast.updateSuccess', 'Şahamça täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('branches.toast.updateError', 'Täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -83,8 +77,5 @@ export function useDeleteBranch() {
|
||||
queryClient.invalidateQueries({ queryKey: branchKeys.lists() })
|
||||
toast.success(t('branches.toast.deleteSuccess', 'Şahamça öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('branches.toast.deleteError', 'Öçürmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateBranchPayload } from '@/features/branches/api/branchesApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const branchFormSchema = z.object({
|
||||
nameTk: z.string().min(1, 'Türkmen ady — hökmany'),
|
||||
nameRu: z.string().min(1, 'Rus ady — hökmany'),
|
||||
nameEn: z.string().min(1, 'Iňlis ady — hökmany'),
|
||||
code: z.string().min(1, 'Kod — hökmany'),
|
||||
districtId: z.string().min(1, 'Etrap — hökmany'),
|
||||
addressTk: z.string().min(1, 'Türkmen salgysy — hökmany'),
|
||||
addressRu: z.string().min(1, 'Rus salgysy — hökmany'),
|
||||
addressEn: z.string().min(1, 'Iňlis salgysy — hökmany'),
|
||||
phone: z.string().min(1, 'Telefon — hökmany'),
|
||||
email: z.string().min(1, 'E-poçta — hökmany'),
|
||||
workingHours: z.string().min(1, 'Iş wagty — hökmany'),
|
||||
nameTk: z.string().min(1, t('validation.required', '')),
|
||||
nameRu: z.string().min(1, t('validation.required', '')),
|
||||
nameEn: z.string().min(1, t('validation.required', '')),
|
||||
code: z.string().min(1, t('validation.required', '')),
|
||||
districtId: z.string().min(1, t('validation.required', '')),
|
||||
addressTk: z.string().min(1, t('validation.required', '')),
|
||||
addressRu: z.string().min(1, t('validation.required', '')),
|
||||
addressEn: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
email: z.string().min(1, t('validation.required', '')),
|
||||
workingHours: z.string().min(1, t('validation.required', '')),
|
||||
description: z.string().optional(),
|
||||
isActive: z.boolean(),
|
||||
})
|
||||
|
||||
@@ -35,9 +35,6 @@ export function useCreateCardBalance() {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card balance created successfully', 'Kart galyndysy üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to create card balance', 'Kart galyndysy döredilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -51,9 +48,6 @@ export function useUpdateCardBalance(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card balance updated successfully', 'Kart galyndysy üstünlikli üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to update card balance', 'Kart galyndysy üýtgedilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,9 +61,6 @@ export function useDeleteCardBalance() {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card balance deleted successfully', 'Kart galyndysy üstünlikli öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to delete card balance', 'Kart galyndysy öçürilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -89,8 +80,5 @@ export function useDownloadCardBalance() {
|
||||
onSuccess: () => {
|
||||
toast.success(t('Downloaded successfully', 'Üstünlikli ýüklenildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Download failed', 'Ýüklemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateCardBalancePayload } from '../api/cardBalanceApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const cardBalanceFormSchema = z.object({
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmanydyr'),
|
||||
passport_number: z.string().min(1, 'Pasport belgisi hökmanydyr'),
|
||||
card_number: z.string().min(1, 'Kart belgisi hökmanydyr'),
|
||||
card_expiry_month: z.string().min(1, 'Möhleti (aý) hökmanydyr'),
|
||||
card_expiry_year: z.string().min(1, 'Möhleti (ýyl) hökmanydyr'),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
card_number: z.string().min(1, t('validation.required', '')),
|
||||
card_expiry_month: z.string().min(1, t('validation.required', '')),
|
||||
card_expiry_year: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type CardBalanceFormData = z.infer<typeof cardBalanceFormSchema>
|
||||
|
||||
@@ -441,7 +441,7 @@ export function CardPinForm({ mode, initialData, onSubmit, isSubmitting }: CardP
|
||||
markVisited(currentStep)
|
||||
const errs = STEPS[currentStep].validate(form, mode)
|
||||
if (Object.keys(errs).length > 0) {
|
||||
toast.error('Dogry maglumat girizmegiňizi haýyş edýäris.')
|
||||
toast.error(t('common.errors.fillRequiredCorrectly', 'Dogry maglumat girizmegiňizi haýyş edýäris.'))
|
||||
return
|
||||
}
|
||||
setCurrentStep(currentStep + 1)
|
||||
@@ -470,7 +470,7 @@ export function CardPinForm({ mode, initialData, onSubmit, isSubmitting }: CardP
|
||||
for (const step of STEPS) Object.assign(allErrors, step.validate(values, mode))
|
||||
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
toast.error('Käbir hökmany meýdanlar doldurylan däldir.')
|
||||
toast.error(t('common.errors.requiredFieldsMissing', 'Käbir hökmany meýdanlar doldurylan däldir.'))
|
||||
for (let i = 0; i < STEPS.length; i++) {
|
||||
if (Object.keys(STEPS[i].validate(values, mode)).length > 0) {
|
||||
setCurrentStep(i)
|
||||
|
||||
@@ -42,9 +42,6 @@ export function useCreateCardPin() {
|
||||
qc.invalidateQueries({ queryKey: CARD_PIN_KEYS.lists() })
|
||||
toast.success(t('cardPin.createSuccess', 'Kart pin bukja döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cardPin.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,9 +58,6 @@ export function useUpdateCardPin(id: string) {
|
||||
qc.invalidateQueries({ queryKey: CARD_PIN_KEYS.detail(id) })
|
||||
toast.success(t('cardPin.updateSuccess', 'Kart pin bukja üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cardPin.updateError', 'Üýtgetmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,8 +73,5 @@ export function useDeleteCardPin() {
|
||||
qc.invalidateQueries({ queryKey: CARD_PIN_KEYS.lists() })
|
||||
toast.success(t('cardPin.deleteSuccess', 'Kart pin bukja pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cardPin.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,21 +1,24 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, 'Faýl hökmany')
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, t('validation.requiredFile', ''))
|
||||
|
||||
export const cardPinFormSchema = z.object({
|
||||
status: z.string().min(1, 'Status hökmany'),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
note: z.string().optional(),
|
||||
card_type: z.string().min(1, 'Kart görnüşi hökmany'),
|
||||
card_number: z.string().min(1, 'Kart belgisi hökmany'),
|
||||
province: z.string().min(1, 'Welaýat hökmany'),
|
||||
branch: z.string().min(1, 'Şahamça hökmany'),
|
||||
first_name: z.string().min(1, 'Ady hökmany'),
|
||||
last_name: z.string().min(1, 'Familiýasy hökmany'),
|
||||
card_type: z.string().min(1, t('validation.required', '')),
|
||||
card_number: z.string().min(1, t('validation.required', '')),
|
||||
province: z.string().min(1, t('validation.required', '')),
|
||||
branch: z.string().min(1, t('validation.required', '')),
|
||||
first_name: z.string().min(1, t('validation.required', '')),
|
||||
last_name: z.string().min(1, t('validation.required', '')),
|
||||
father_name: z.string().optional(),
|
||||
birth_date: z.string().min(1, 'Doglan güni hökmany'),
|
||||
phone: z.string().min(1, 'Telefon hökmany'),
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmany'),
|
||||
passport_number: z.string().min(1, 'Pasport belgisi hökmany'),
|
||||
birth_date: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
passport_file_1: z.custom<File | null>().nullable(),
|
||||
passport_file_2: z.custom<File | null>().nullable(),
|
||||
passport_file_3: z.custom<File | null>().nullable(),
|
||||
@@ -52,8 +55,8 @@ export const stepSchemas: Record<number, z.ZodType<Partial<CardPinFormData>>> =
|
||||
first_name: true, last_name: true, birth_date: true, phone: true,
|
||||
}),
|
||||
2: z.object({
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmany'),
|
||||
passport_number: z.string().min(1, 'Pasport belgisi hökmany'),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
passport_file_1: fileRequired,
|
||||
passport_file_2: fileRequired,
|
||||
passport_file_3: fileRequired,
|
||||
|
||||
@@ -57,9 +57,6 @@ export function useCreateCardReason() {
|
||||
queryClient.invalidateQueries({ queryKey: cardReasonKeys.lists() })
|
||||
toast.success(t('CardReasons.toast.createSuccess', 'Kart ýagdaýy döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('CardReasons.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,9 +73,6 @@ export function useUpdateCardReason() {
|
||||
queryClient.invalidateQueries({ queryKey: cardReasonKeys.detail(data.id) })
|
||||
toast.success(t('CardReasons.toast.updateSuccess', 'Kart ýagdaýy täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('CardReasons.toast.updateError', 'Täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -94,8 +88,5 @@ export function useDeleteCardReason() {
|
||||
queryClient.invalidateQueries({ queryKey: cardReasonKeys.lists() })
|
||||
toast.success(t('CardReasons.toast.deleteSuccess', 'Kart ýagdaýy öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('CardReasons.toast.deleteError', 'Öçürmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateCardReasonPayload } from '../api/cardReasonsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const cardReasonFormSchema = z.object({
|
||||
nameTk: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameRu: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameEn: z.string().min(1, 'Hökmany meýdan'),
|
||||
value: z.string().min(1, 'Dogry san giriziň').refine(
|
||||
nameTk: z.string().min(1, t('validation.required', '')),
|
||||
nameRu: z.string().min(1, t('validation.required', '')),
|
||||
nameEn: z.string().min(1, t('validation.required', '')),
|
||||
value: z.string().min(1, t('validation.invalidNumber', '')).refine(
|
||||
(v) => !isNaN(Number(v)) && Number(v) >= 0,
|
||||
{ message: 'Dogry san giriziň' },
|
||||
{ message: t('validation.invalidNumber', 'Dogry san giriziň') },
|
||||
),
|
||||
description: z.string().optional(),
|
||||
isActive: z.boolean(),
|
||||
|
||||
@@ -41,9 +41,6 @@ export function useCreateCardRequisite() {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card requisite created successfully', 'Kart rekwiziti üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to create card requisite', 'Kart rekwiziti döredilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -59,9 +56,6 @@ export function useUpdateCardRequisite(id: string) {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card requisite updated successfully', 'Kart rekwiziti üstünlikli üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to update card requisite', 'Kart rekwiziti üýtgedilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -77,9 +71,6 @@ export function useDeleteCardRequisite() {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card requisite deleted successfully', 'Kart rekwiziti üstünlikli öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to delete card requisite', 'Kart rekwiziti öçürilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -101,8 +92,5 @@ export function useDownloadCardRequisite() {
|
||||
onSuccess: () => {
|
||||
toast.success(t('Downloaded successfully', 'Üstünlikli ýüklenildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Download failed', 'Ýüklemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CardRequisiteStatus, CreateCardRequisitePayload } from '../api/cardRequisitesApi'
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, 'Faýl hökmany')
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, t('validation.requiredFile', ''))
|
||||
|
||||
export const cardRequisiteFormSchema = z.object({
|
||||
status: z.string().min(1, 'Status hökmanydyr'),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
note: z.string().optional(),
|
||||
card_type: z.string().min(1, 'Görnüşi hökmanydyr'),
|
||||
card_number: z.string().min(1, 'Kart belgisi hökmanydyr'),
|
||||
card_expiry_month: z.string().min(1, 'Möhleti (aý) hökmanydyr'),
|
||||
card_expiry_year: z.string().min(1, 'Möhleti (ýyl) hökmanydyr'),
|
||||
province_id: z.string().min(1, 'Welaýat hökmanydyr'),
|
||||
branch_id: z.string().min(1, 'Şahamça hökmanydyr'),
|
||||
first_name: z.string().min(1, 'Ady hökmanydyr'),
|
||||
last_name: z.string().min(1, 'Familiýasy hökmanydyr'),
|
||||
card_type: z.string().min(1, t('validation.required', '')),
|
||||
card_number: z.string().min(1, t('validation.required', '')),
|
||||
card_expiry_month: z.string().min(1, t('validation.required', '')),
|
||||
card_expiry_year: z.string().min(1, t('validation.required', '')),
|
||||
province_id: z.string().min(1, t('validation.required', '')),
|
||||
branch_id: z.string().min(1, t('validation.required', '')),
|
||||
first_name: z.string().min(1, t('validation.required', '')),
|
||||
last_name: z.string().min(1, t('validation.required', '')),
|
||||
middle_name: z.string().optional(),
|
||||
birth_date: z.string().min(1, 'Doglan güni hökmanydyr'),
|
||||
phone: z.string().min(1, 'Telefon hökmanydyr'),
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmanydyr'),
|
||||
passport_number: z.string().min(1, 'Pasport belgisi hökmanydyr'),
|
||||
birth_date: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
passport_page1: z.custom<File | null>().nullable(),
|
||||
passport_page2_3: z.custom<File | null>().nullable(),
|
||||
passport_page8_9: z.custom<File | null>().nullable(),
|
||||
@@ -37,8 +40,8 @@ export const stepSchemas: Record<number, z.ZodType<Partial<CardRequisiteFormData
|
||||
first_name: true, last_name: true, birth_date: true, phone: true,
|
||||
}),
|
||||
2: z.object({
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmanydyr'),
|
||||
passport_number: z.string().min(1, 'Pasport belgisi hökmanydyr'),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
passport_page1: fileRequired,
|
||||
passport_page2_3: fileRequired,
|
||||
passport_page8_9: fileRequired,
|
||||
@@ -53,8 +56,8 @@ export function validateStep(
|
||||
): Partial<Record<keyof CardRequisiteFormData, string>> {
|
||||
if (stepIndex === 2 && mode === 'edit') {
|
||||
const schema = z.object({
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmanydyr'),
|
||||
passport_number: z.string().min(1, 'Pasport belgisi hökmanydyr'),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
const result = schema.safeParse(form)
|
||||
if (result.success) return {}
|
||||
|
||||
@@ -42,9 +42,6 @@ export function useCreateCardTransaction() {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card transaction created successfully', 'Kart herekedi üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to create card transaction', 'Kart herekedi döredilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,9 +58,6 @@ export function useUpdateCardTransaction(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card transaction updated successfully', 'Kart herekedi üstünlikli üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to update card transaction', 'Kart herekedi üýtgedilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,9 +73,6 @@ export function useDeleteCardTransaction() {
|
||||
queryClient.invalidateQueries({ queryKey: [QUERY_KEY] })
|
||||
toast.success(t('Card transaction deleted successfully', 'Kart herekedi üstünlikli öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Failed to delete card transaction', 'Kart herekedi öçürilmedi'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -103,8 +94,5 @@ export function useDownloadCardTransaction() {
|
||||
onSuccess: () => {
|
||||
toast.success(t('Downloaded successfully', 'Üstünlikli ýüklenildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('Download failed', 'Ýüklemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateCardTransactionPayload } from '../api/cardTransactionsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const cardTransactionFormSchema = z.object({
|
||||
passport_series: z.string().min(1, 'Passport series is required'),
|
||||
passport_number: z.string().min(1, 'Passport number is required'),
|
||||
card_number: z.string().min(1, 'Card number is required'),
|
||||
card_expiry_month: z.string().min(1, 'Expiry month is required'),
|
||||
card_expiry_year: z.string().min(1, 'Expiry year is required'),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
card_number: z.string().min(1, t('validation.required', '')),
|
||||
card_expiry_month: z.string().min(1, t('validation.required', '')),
|
||||
card_expiry_year: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type CardTransactionFormData = z.infer<typeof cardTransactionFormSchema>
|
||||
|
||||
@@ -57,9 +57,6 @@ export function useCreateCardType() {
|
||||
queryClient.invalidateQueries({ queryKey: cardTypeKeys.lists() })
|
||||
toast.success(t('cardTypes.toast.createSuccess', 'Kart görnüşi döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cardTypes.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,9 +73,6 @@ export function useUpdateCardType() {
|
||||
queryClient.invalidateQueries({ queryKey: cardTypeKeys.detail(data.id) })
|
||||
toast.success(t('cardTypes.toast.updateSuccess', 'Kart görnüşi täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cardTypes.toast.updateError', 'Täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -94,8 +88,5 @@ export function useDeleteCardType() {
|
||||
queryClient.invalidateQueries({ queryKey: cardTypeKeys.lists() })
|
||||
toast.success(t('cardTypes.toast.deleteSuccess', 'Kart görnüşi öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cardTypes.toast.deleteError', 'Öçürmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateCardTypePayload } from '../api/cardTypesApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const cardTypeFormSchema = z.object({
|
||||
nameTk: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameRu: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameEn: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameTk: z.string().min(1, t('validation.required', '')),
|
||||
nameRu: z.string().min(1, t('validation.required', '')),
|
||||
nameEn: z.string().min(1, t('validation.required', 'Hökmany meýdan')),
|
||||
value: z.string().refine(
|
||||
(v) => v.trim() !== '' && !isNaN(Number(v)) && Number(v) >= 0,
|
||||
'Dogry san giriziň',
|
||||
t('validation.invalidNumber', 'Dogry san giriziň'),
|
||||
),
|
||||
description: z.string().optional(),
|
||||
isActive: z.boolean(),
|
||||
|
||||
@@ -50,9 +50,6 @@ export function useCreateClient() {
|
||||
queryClient.invalidateQueries({ queryKey: clientKeys.lists() })
|
||||
toast.success(t('clients.createSuccess', 'Müşderi üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('clients.createError', 'Müşderi döretmekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -69,14 +66,9 @@ export function useUpdateClient(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: clientKeys.detail(id) })
|
||||
toast.success(t('clients.updateSuccess', 'Müşderi üstünlikli täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('clients.updateError', 'Müşderi täzelemekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useDeleteClient ──────────────────────────────────────────────────────────
|
||||
|
||||
export function useDeleteClient() {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
@@ -87,9 +79,6 @@ export function useDeleteClient() {
|
||||
queryClient.invalidateQueries({ queryKey: clientKeys.lists() })
|
||||
toast.success(t('clients.deleteSuccess', 'Müşderi üstünlikli pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('clients.deleteError', 'Müşderi pozmakda ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -105,9 +94,6 @@ export function useAssignClientRole(clientId: number) {
|
||||
queryClient.invalidateQueries({ queryKey: clientKeys.detail(clientId) })
|
||||
toast.success(t('clients.roleAssigned', 'Rol birikdirildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('clients.roleAssignError', 'Rol birikdirmekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,9 +109,6 @@ export function useRemoveClientRole(clientId: number) {
|
||||
queryClient.invalidateQueries({ queryKey: clientKeys.detail(clientId) })
|
||||
toast.success(t('clients.roleRemoved', 'Rol aýryldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('clients.roleRemoveError', 'Rol aýyrmakda ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -141,8 +124,5 @@ export function useAssignClientBranch(clientId: number) {
|
||||
queryClient.invalidateQueries({ queryKey: clientKeys.detail(clientId) })
|
||||
toast.success(t('clients.branchAssigned', 'Şahamça birikdirildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('clients.branchAssignError', 'Şahamça birikdirmekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateClientPayload } from '../api/clientsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const baseSchema = z.object({
|
||||
username: z.string().min(1, 'Ulanyjy ady hökmany'),
|
||||
name: z.string().min(1, 'Ady hökmany'),
|
||||
phone: z.string().min(1, 'Telefon hökmany'),
|
||||
username: z.string().min(1, t('validation.required', '')),
|
||||
name: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
email: z.string().default(''),
|
||||
password: z.string(),
|
||||
isActive: z.boolean(),
|
||||
@@ -13,7 +16,7 @@ const baseSchema = z.object({
|
||||
export function clientFormSchema(mode: 'create' | 'edit') {
|
||||
return mode === 'create'
|
||||
? baseSchema.extend({
|
||||
password: z.string().min(1, 'Açar sözi hökmany'),
|
||||
password: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
: baseSchema
|
||||
}
|
||||
|
||||
@@ -56,9 +56,6 @@ export function useCreateCurrencyRate() {
|
||||
queryClient.invalidateQueries({ queryKey: currencyRateKeys.lists() })
|
||||
toast.success(t('currencyRates.toast.created', 'Walýuta kursy döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('currencyRates.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -75,9 +72,6 @@ export function useUpdateCurrencyRate(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: currencyRateKeys.detail(id) })
|
||||
toast.success(t('currencyRates.toast.updated', 'Walýuta kursy üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('currencyRates.toast.updateError', 'Üýtgetmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -93,8 +87,5 @@ export function useDeleteCurrencyRate() {
|
||||
queryClient.invalidateQueries({ queryKey: currencyRateKeys.lists() })
|
||||
toast.success(t('currencyRates.toast.deleted', 'Walýuta kursy pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('currencyRates.toast.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateCurrencyRatePayload, CurrencyCode } from '../api/currencyRatesApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const currencyRateFormSchema = z.object({
|
||||
currencyFrom: z.string().min(1, 'Hökmany meýdan'),
|
||||
currencyTo: z.string().min(1, 'Hökmany meýdan'),
|
||||
currencyFrom: z.string().min(1, t('validation.required', 'Hökmany meýdan')),
|
||||
currencyTo: z.string().min(1, t('validation.required', 'Hökmany meýdan')),
|
||||
value: z
|
||||
.string()
|
||||
.min(1, 'Hökmany meýdan')
|
||||
.refine((v) => !isNaN(Number(v)) && Number(v) > 0, 'Baha 0-dan uly bolmaly'),
|
||||
.min(1, t('validation.required', 'Hökmany meýdan'))
|
||||
.refine((v) => !isNaN(Number(v)) && Number(v) > 0, t('validation.valuePositive', 'Baha 0-dan uly bolmaly')),
|
||||
})
|
||||
|
||||
export type CurrencyRateFormData = z.infer<typeof currencyRateFormSchema>
|
||||
|
||||
@@ -49,9 +49,6 @@ export function useCreateDistrict() {
|
||||
queryClient.invalidateQueries({ queryKey: districtKeys.lists() })
|
||||
toast.success(t('districts.toast.createSuccess', 'Etrap döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('districts.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -66,9 +63,6 @@ export function useUpdateDistrict() {
|
||||
queryClient.invalidateQueries({ queryKey: districtKeys.detail(data.id) })
|
||||
toast.success(t('districts.toast.updateSuccess', 'Etrap täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('districts.toast.updateError', 'Täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,8 +76,5 @@ export function useDeleteDistrict() {
|
||||
queryClient.invalidateQueries({ queryKey: districtKeys.lists() })
|
||||
toast.success(t('districts.toast.deleteSuccess', 'Etrap öçürildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('districts.toast.deleteError', 'Öçürmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateDistrictPayload } from '../api/districtsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const districtFormSchema = z.object({
|
||||
nameTk: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameRu: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameEn: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameTk: z.string().min(1, t('validation.required', '')),
|
||||
nameRu: z.string().min(1, t('validation.required', '')),
|
||||
nameEn: z.string().min(1, t('validation.required', '')),
|
||||
description: z.string().optional(),
|
||||
isActive: z.boolean(),
|
||||
})
|
||||
|
||||
@@ -568,7 +568,7 @@ export function LoanOrderMobileForm({ mode, initialData, loanOrderId }: LoanOrde
|
||||
markVisited(currentStep);
|
||||
const errs = STEPS[currentStep].validate(form, mode);
|
||||
if (Object.keys(errs).length > 0) {
|
||||
toast.error("Dogry maglumat girizmegiňizi haýyş edýäris.");
|
||||
toast.error(t("common.errors.fillRequiredCorrectly", "Dogry maglumat girizmegiňizi haýyş edýäris."));
|
||||
return;
|
||||
}
|
||||
if (currentStep < STEPS.length - 1) {
|
||||
@@ -600,7 +600,7 @@ export function LoanOrderMobileForm({ mode, initialData, loanOrderId }: LoanOrde
|
||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode));
|
||||
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
toast.error("Käbir hökmany meýdanlar doldurylan däldir.");
|
||||
toast.error(t("common.errors.requiredFieldsMissing", "Käbir hökmany meýdanlar doldurylan däldir."));
|
||||
for (let i = 0; i < STEPS.length; i++) {
|
||||
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) {
|
||||
setCurrentStep(i);
|
||||
|
||||
@@ -41,9 +41,6 @@ export function useDeleteLoanOrderMobile() {
|
||||
queryClient.invalidateQueries({ queryKey: loanOrderMobileKeys.lists() })
|
||||
toast.success(t('loanOrderMobiles.deleteSuccess', 'Sargyt üstünlikli pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanOrderMobiles.deleteError', 'Pozmak başartmady, gaýtadan synanyşyň'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -65,9 +62,6 @@ export function useCreateLoanOrderMobile() {
|
||||
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'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -83,8 +77,5 @@ export function useUpdateLoanOrderMobile() {
|
||||
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'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,59 +1,62 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, 'Faýl hökmany')
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, t('validation.requiredFile', ''))
|
||||
|
||||
export const loanOrderMobileFormSchema = z.object({
|
||||
status: z.string().min(1, 'Status — hökmany'),
|
||||
loanType: z.string().min(1, 'Karz görnüşi — hökmany'),
|
||||
region: z.string().min(1, 'Welaýat — hökmany'),
|
||||
branch: z.string().min(1, 'Şahamça — hökmany'),
|
||||
firstName: z.string().min(1, 'Ady — hökmany'),
|
||||
lastName: z.string().min(1, 'Familiýasy — hökmany'),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
loanType: z.string().min(1, t('validation.required', '')),
|
||||
region: z.string().min(1, t('validation.required', '')),
|
||||
branch: z.string().min(1, t('validation.required', '')),
|
||||
firstName: z.string().min(1, t('validation.required', '')),
|
||||
lastName: z.string().min(1, t('validation.required', '')),
|
||||
patronicName: z.string().optional(),
|
||||
education: z.string().min(1, 'Bilimi — hökmany'),
|
||||
marriageStatus: z.string().min(1, 'Maşgala ýagdaýy — hökmany'),
|
||||
dateOfBirth: z.string().min(1, 'Doglan güni — hökmany'),
|
||||
residence: z.string().min(1, 'Ýazgy edilen salgy — hökmany'),
|
||||
education: z.string().min(1, t('validation.required', '')),
|
||||
marriageStatus: z.string().min(1, t('validation.required', '')),
|
||||
dateOfBirth: z.string().min(1, t('validation.required', '')),
|
||||
residence: z.string().min(1, t('validation.required', '')),
|
||||
currentResidence: z.string().optional(),
|
||||
passportSerie: z.string().min(1, 'Pasport seriýasy — hökmany'),
|
||||
passportNumber: z.string().min(1, 'Pasport belgisi — hökmany'),
|
||||
passportDateOfIssue: z.string().min(1, 'Pasport berlen senesi — hökmany'),
|
||||
passportGivenBy: z.string().min(1, 'Kim tarapyndan berildi — hökmany'),
|
||||
passportSerie: z.string().min(1, t('validation.required', '')),
|
||||
passportNumber: z.string().min(1, t('validation.required', '')),
|
||||
passportDateOfIssue: z.string().min(1, t('validation.required', '')),
|
||||
passportGivenBy: z.string().min(1, t('validation.required', '')),
|
||||
bornPlace: z.string().optional(),
|
||||
email: z.string().optional(),
|
||||
phone: z.string()
|
||||
.min(1, 'Telefon — hökmany')
|
||||
.refine((val) => val.replace(/\D/g, '').length >= 8, { message: 'Telefon belgisi nädogry' }),
|
||||
.min(1, t('validation.required', ''))
|
||||
.refine((val) => val.replace(/\D/g, '').length >= 8, { message: t('validation.invalidPhone', 'Telefon belgisi nädogry') }),
|
||||
phoneAdditional: z.string().optional(),
|
||||
homePhone: z.string().optional(),
|
||||
workCompany: z.string().min(1, 'Kärhananyň ady — hökmany'),
|
||||
workCompany: z.string().min(1, t('validation.required', '')),
|
||||
workHrPhone: z.string().optional(),
|
||||
workRegion: z.string().optional(),
|
||||
workProvince: z.string().optional(),
|
||||
position: z.string().min(1, 'Wezipe — hökmany'),
|
||||
salary: z.string().min(1, 'Zähmet haky — hökmany'),
|
||||
workStartedAt: z.string().min(1, 'Işe başlan wagty — hökmany'),
|
||||
position: z.string().min(1, t('validation.required', '')),
|
||||
salary: z.string().min(1, t('validation.required', '')),
|
||||
workStartedAt: z.string().min(1, t('validation.required', '')),
|
||||
passportPage1: z.custom<File | null>().nullable(),
|
||||
passportPage23: z.custom<File | null>().nullable(),
|
||||
passportPage89: z.custom<File | null>().nullable(),
|
||||
passportPage32: z.custom<File | null>().nullable(),
|
||||
note: z.string().optional(),
|
||||
loanAmount: z.string().min(1, 'Karz möçberi — hökmany'),
|
||||
loanAmount: z.string().min(1, t('validation.required', '')),
|
||||
loanHistory: z.string().optional(),
|
||||
cardNumber: z.string().min(1, 'Kart belgisi — hökmany'),
|
||||
cardName: z.string().min(1, 'Kartdaky ady — hökmany'),
|
||||
cardExpMonth: z.string().min(1, 'Kart möhleti (aý) — hökmany'),
|
||||
cardExpYear: z.string().min(1, 'Kart möhleti (ýyl) — hökmany'),
|
||||
guarantor1Name: z.string().min(1, 'Zamunyň ady — hökmany'),
|
||||
guarantor1Surname: z.string().min(1, 'Zamunyň familiýasy — hökmany'),
|
||||
cardNumber: z.string().min(1, t('validation.required', '')),
|
||||
cardName: z.string().min(1, t('validation.required', '')),
|
||||
cardExpMonth: z.string().min(1, t('validation.required', '')),
|
||||
cardExpYear: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Name: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Surname: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Patronic: z.string().optional(),
|
||||
guarantor1PassportSerie: z.string().min(1, 'Pasport seriýasy — hökmany'),
|
||||
guarantor1PassportNumber: z.string().min(1, 'Pasport belgisi — hökmany'),
|
||||
guarantor1CardNumber: z.string().min(1, 'Kart belgisi — hökmany'),
|
||||
guarantor1CardName: z.string().min(1, 'Kartdaky ady — hökmany'),
|
||||
guarantor1CardExpMonth: z.string().min(1, 'Möhleti (aý) — hökmany'),
|
||||
guarantor1CardExpYear: z.string().min(1, 'Möhleti (ýyl) — hökmany'),
|
||||
guarantor1Salary: z.string().min(1, 'Ortaca zähmet haky — hökmany'),
|
||||
guarantor1PassportSerie: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1PassportNumber: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardNumber: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardName: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardExpMonth: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardExpYear: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Salary: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type LoanOrderMobileFormData = z.infer<typeof loanOrderMobileFormSchema>
|
||||
|
||||
@@ -610,7 +610,7 @@ export function LoanOrderForm({ mode, initialData, loanOrderId }: LoanOrderFormP
|
||||
markVisited(currentStep)
|
||||
const errs = STEPS[currentStep].validate(form, mode)
|
||||
if (Object.keys(errs).length > 0) {
|
||||
toast.error('Dogry maglumat girizmegiňizi haýyş edýäris.')
|
||||
toast.error(t('common.errors.fillRequiredCorrectly', 'Dogry maglumat girizmegiňizi haýyş edýäris.'))
|
||||
return
|
||||
}
|
||||
if (currentStep < STEPS.length - 1) {
|
||||
@@ -642,7 +642,7 @@ export function LoanOrderForm({ mode, initialData, loanOrderId }: LoanOrderFormP
|
||||
for (const step of STEPS) Object.assign(allErrors, step.validate(form, mode))
|
||||
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
toast.error('Käbir hökmany meýdanlar doldurylan däldir.')
|
||||
toast.error(t('common.errors.requiredFieldsMissing', 'Käbir hökmany meýdanlar doldurylan däldir.'))
|
||||
for (let i = 0; i < STEPS.length; i++) {
|
||||
if (Object.keys(STEPS[i].validate(form, mode)).length > 0) {
|
||||
setCurrentStep(i); break
|
||||
|
||||
@@ -39,9 +39,6 @@ export function useCreateLoanOrder() {
|
||||
queryClient.invalidateQueries({ queryKey: [LOAN_ORDERS_KEY] })
|
||||
toast.success(t('loanOrders.createSuccess', 'Karz sargyt üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanOrders.createError', 'Karz sargyt döretmekde säwlik ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -56,9 +53,6 @@ export function useUpdateLoanOrder() {
|
||||
queryClient.invalidateQueries({ queryKey: [LOAN_ORDERS_KEY] })
|
||||
toast.success(t('loanOrders.updateSuccess', 'Karz sargyt üstünlikli üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanOrders.updateError', 'Karz sargyt üýtgetmekde säwlik ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -72,8 +66,5 @@ export function useDeleteLoanOrder() {
|
||||
queryClient.invalidateQueries({ queryKey: [LOAN_ORDERS_KEY] })
|
||||
toast.success(t('loanOrders.deleteSuccess', 'Karz sargyt üstünlikli pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanOrders.deleteError', 'Karz sargyt pozmakda säwlik ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,59 +1,62 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, 'Faýl hökmany')
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, t('validation.requiredFile', ''))
|
||||
|
||||
export const loanOrderFormSchema = z.object({
|
||||
status: z.string().min(1, 'Status — hökmany'),
|
||||
loanType: z.string().min(1, 'Karz görnüşi — hökmany'),
|
||||
region: z.string().min(1, 'Welaýat — hökmany'),
|
||||
branch: z.string().min(1, 'Şahamça — hökmany'),
|
||||
firstName: z.string().min(1, 'Ady — hökmany'),
|
||||
lastName: z.string().min(1, 'Familiýasy — hökmany'),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
loanType: z.string().min(1, t('validation.required', '')),
|
||||
region: z.string().min(1, t('validation.required', '')),
|
||||
branch: z.string().min(1, t('validation.required', '')),
|
||||
firstName: z.string().min(1, t('validation.required', '')),
|
||||
lastName: z.string().min(1, t('validation.required', '')),
|
||||
patronicName: z.string().optional(),
|
||||
education: z.string().min(1, 'Bilimi — hökmany'),
|
||||
marriageStatus: z.string().min(1, 'Maşgala ýagdaýy — hökmany'),
|
||||
dateOfBirth: z.string().min(1, 'Doglan güni — hökmany'),
|
||||
residence: z.string().min(1, 'Ýazgy edilen salgy — hökmany'),
|
||||
education: z.string().min(1, t('validation.required', '')),
|
||||
marriageStatus: z.string().min(1, t('validation.required', '')),
|
||||
dateOfBirth: z.string().min(1, t('validation.required', '')),
|
||||
residence: z.string().min(1, t('validation.required', '')),
|
||||
currentResidence: z.string().optional(),
|
||||
passportSerie: z.string().min(1, 'Pasport seriýasy — hökmany'),
|
||||
passportNumber: z.string().min(1, 'Pasport belgisi — hökmany'),
|
||||
passportDateOfIssue: z.string().min(1, 'Pasport berlen senesi — hökmany'),
|
||||
passportGivenBy: z.string().min(1, 'Kim tarapyndan berildi — hökmany'),
|
||||
passportSerie: z.string().min(1, t('validation.required', '')),
|
||||
passportNumber: z.string().min(1, t('validation.required', '')),
|
||||
passportDateOfIssue: z.string().min(1, t('validation.required', '')),
|
||||
passportGivenBy: z.string().min(1, t('validation.required', '')),
|
||||
bornPlace: z.string().optional(),
|
||||
email: z.string().optional(),
|
||||
phone: z.string()
|
||||
.min(1, 'Telefon — hökmany')
|
||||
.refine((val) => val.replace(/\D/g, '').length >= 8, { message: 'Telefon belgisi nädogry' }),
|
||||
.min(1, t('validation.required', ''))
|
||||
.refine((val) => val.replace(/\D/g, '').length >= 8, { message: t('validation.invalidPhone', 'Telefon belgisi nädogry') }),
|
||||
phoneAdditional: z.string().optional(),
|
||||
homePhone: z.string().optional(),
|
||||
workCompany: z.string().min(1, 'Kärhananyň ady — hökmany'),
|
||||
workCompany: z.string().min(1, t('validation.required', '')),
|
||||
workHrPhone: z.string().optional(),
|
||||
workRegion: z.string().optional(),
|
||||
workProvince: z.string().optional(),
|
||||
position: z.string().min(1, 'Wezipe — hökmany'),
|
||||
salary: z.string().min(1, 'Zähmet haky — hökmany'),
|
||||
workStartedAt: z.string().min(1, 'Işe başlan wagty — hökmany'),
|
||||
position: z.string().min(1, t('validation.required', '')),
|
||||
salary: z.string().min(1, t('validation.required', '')),
|
||||
workStartedAt: z.string().min(1, t('validation.required', '')),
|
||||
passportPage1: z.custom<File | null>().nullable(),
|
||||
passportPage23: z.custom<File | null>().nullable(),
|
||||
passportPage89: z.custom<File | null>().nullable(),
|
||||
passportPage32: z.custom<File | null>().nullable(),
|
||||
note: z.string().optional(),
|
||||
loanAmount: z.string().min(1, 'Karz möçberi — hökmany'),
|
||||
loanAmount: z.string().min(1, t('validation.required', '')),
|
||||
loanHistory: z.string().optional(),
|
||||
cardNumber: z.string().min(1, 'Kart belgisi — hökmany'),
|
||||
cardName: z.string().min(1, 'Kartdaky ady — hökmany'),
|
||||
cardExpMonth: z.string().min(1, 'Kart möhleti (aý) — hökmany'),
|
||||
cardExpYear: z.string().min(1, 'Kart möhleti (ýyl) — hökmany'),
|
||||
guarantor1Name: z.string().min(1, 'Zamunyň ady — hökmany'),
|
||||
guarantor1Surname: z.string().min(1, 'Zamunyň familiýasy — hökmany'),
|
||||
cardNumber: z.string().min(1, t('validation.required', '')),
|
||||
cardName: z.string().min(1, t('validation.required', '')),
|
||||
cardExpMonth: z.string().min(1, t('validation.required', '')),
|
||||
cardExpYear: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Name: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Surname: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Patronic: z.string().optional(),
|
||||
guarantor1PassportSerie: z.string().min(1, 'Pasport seriýasy — hökmany'),
|
||||
guarantor1PassportNumber: z.string().min(1, 'Pasport belgisi — hökmany'),
|
||||
guarantor1CardNumber: z.string().min(1, 'Kart belgisi — hökmany'),
|
||||
guarantor1CardName: z.string().min(1, 'Kartdaky ady — hökmany'),
|
||||
guarantor1CardExpMonth: z.string().min(1, 'Möhleti (aý) — hökmany'),
|
||||
guarantor1CardExpYear: z.string().min(1, 'Möhleti (ýyl) — hökmany'),
|
||||
guarantor1Salary: z.string().min(1, 'Ortaca zähmet haky — hökmany'),
|
||||
guarantor1PassportSerie: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1PassportNumber: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardNumber: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardName: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardExpMonth: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1CardExpYear: z.string().min(1, t('validation.required', '')),
|
||||
guarantor1Salary: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type LoanOrderFormData = z.infer<typeof loanOrderFormSchema>
|
||||
|
||||
@@ -36,8 +36,5 @@ export function useDeleteLoanPaidOffLetter() {
|
||||
queryClient.invalidateQueries({ queryKey: loanPaidOffLetterKeys.lists() })
|
||||
toast.success(t('loanPaidOffLetters.deleteSuccess', 'Güwanama üstünlikli pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanPaidOffLetters.deleteError', 'Pozmak başartmady, gaýtadan synanyşyň'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -70,9 +70,6 @@ export function LoanRemainingForm({
|
||||
toast.success(t('common.success.create', 'Üstünlikli döredildi'))
|
||||
navigate('/loan-remaining')
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('common.errors.somethingWentWrong', 'Näsazlyk ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
} else {
|
||||
updateMutation.mutate(payload, {
|
||||
@@ -80,9 +77,6 @@ export function LoanRemainingForm({
|
||||
toast.success(t('common.success.save', 'Üstünlikli ýatda saklandy'))
|
||||
navigate('/loan-remaining')
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('common.errors.somethingWentWrong', 'Näsazlyk ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,6 @@ export function useDeleteLoanRemaining() {
|
||||
queryClient.invalidateQueries({ queryKey: loanRemainingKeys.lists() })
|
||||
toast.success(t('loanRemaining.deleteSuccess', 'Ýazgy üstünlikli pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanRemaining.deleteError', 'Pozmak başartmady, gaýtadan synanyşyň'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -65,9 +62,6 @@ export function useCreateLoanRemaining() {
|
||||
queryClient.invalidateQueries({ queryKey: loanRemainingKeys.lists() })
|
||||
toast.success(t('loanRemaining.createSuccess', 'Üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanRemaining.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,8 +76,5 @@ export function useUpdateLoanRemaining(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: loanRemainingKeys.detail(id) })
|
||||
toast.success(t('loanRemaining.updateSuccess', 'Üstünlikli üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanRemaining.updateError', 'Üýtgetmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const loanRemainingFormSchema = z.object({
|
||||
passportSeries: z.string().min(1, 'Hökman doldurylmaly'),
|
||||
passportNumber: z.string().min(1, 'Hökman doldurylmaly'),
|
||||
loanAccount: z.string().min(1, 'Hökman doldurylmaly'),
|
||||
passportSeries: z.string().min(1, t('validation.required', '')),
|
||||
passportNumber: z.string().min(1, t('validation.required', '')),
|
||||
loanAccount: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type LoanRemainingFormData = z.infer<typeof loanRemainingFormSchema>
|
||||
|
||||
@@ -54,9 +54,6 @@ export function useCreateLoanType() {
|
||||
queryClient.invalidateQueries({ queryKey: loanTypeKeys.all() })
|
||||
toast.success(t('loanTypes.toast.created', 'Karz görnüşi üstünlikli döredildi'))
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t('loanTypes.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -72,9 +69,6 @@ export function useUpdateLoanType(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: loanTypeKeys.all() })
|
||||
toast.success(t('loanTypes.toast.updated', 'Karz görnüşi üstünlikli täzelendi'))
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t('loanTypes.toast.updateError', 'Täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -90,8 +84,5 @@ export function useDeleteLoanType() {
|
||||
queryClient.invalidateQueries({ queryKey: loanTypeKeys.all() })
|
||||
toast.success(t('loanTypes.toast.deleted', 'Karz görnüşi üstünlikli pozuldy'))
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t('loanTypes.toast.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,20 +1,23 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateLoanTypePayload } from '../api/loanTypesApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const loanTypeFormSchema = z.object({
|
||||
nameTk: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameRu: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameEn: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameTk: z.string().min(1, t('validation.required', '')),
|
||||
nameRu: z.string().min(1, t('validation.required', '')),
|
||||
nameEn: z.string().min(1, t('validation.required', '')),
|
||||
notesTk: z.string().optional(),
|
||||
notesRu: z.string().optional(),
|
||||
notesEn: z.string().optional(),
|
||||
tax: z.string().refine(
|
||||
(v) => v.trim() !== '' && !isNaN(Number(v)) && Number(v) > 0,
|
||||
'Oňyn san gerek',
|
||||
t('validation.positiveNumber', 'Oňyn san gerek'),
|
||||
),
|
||||
loanTerm: z.string().refine(
|
||||
(v) => v.trim() !== '' && !isNaN(Number(v)) && Number(v) > 0,
|
||||
'Oňyn san gerek',
|
||||
t('validation.positiveNumber', 'Oňyn san gerek'),
|
||||
),
|
||||
isActive: z.boolean(),
|
||||
})
|
||||
|
||||
@@ -53,8 +53,5 @@ export function useTriggerPaymentCallback() {
|
||||
queryClient.invalidateQueries({ queryKey: onlinePaymentKeys.lists() })
|
||||
toast.success(t('onlinePayments.toast.callbackTriggered', 'Callback ugradyldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('onlinePayments.toast.callbackError', 'Callback ugratmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -50,9 +50,6 @@ export function useCreateOperator() {
|
||||
queryClient.invalidateQueries({ queryKey: operatorKeys.lists() })
|
||||
toast.success(t('operators.createSuccess', 'Operator üstünlikli döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('operators.createError', 'Operator döretmekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -69,14 +66,9 @@ export function useUpdateOperator(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: operatorKeys.detail(id) })
|
||||
toast.success(t('operators.updateSuccess', 'Operator üstünlikli täzelendi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('operators.updateError', 'Operator täzelemekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useDeleteOperator ────────────────────────────────────────────────────────
|
||||
|
||||
export function useDeleteOperator() {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
@@ -87,9 +79,6 @@ export function useDeleteOperator() {
|
||||
queryClient.invalidateQueries({ queryKey: operatorKeys.lists() })
|
||||
toast.success(t('operators.deleteSuccess', 'Operator üstünlikli pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('operators.deleteError', 'Operator pozmakda ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -105,9 +94,6 @@ export function useAssignRole(operatorId: number) {
|
||||
queryClient.invalidateQueries({ queryKey: operatorKeys.detail(operatorId) })
|
||||
toast.success(t('operators.roleAssigned', 'Rol birikdirildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('operators.roleAssignError', 'Rol birikdirmekde ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -123,8 +109,5 @@ export function useRemoveRole(operatorId: number) {
|
||||
queryClient.invalidateQueries({ queryKey: operatorKeys.detail(operatorId) })
|
||||
toast.success(t('operators.roleRemoved', 'Rol aýryldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('operators.roleRemoveError', 'Rol aýyrmakda ýalňyşlyk'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateOperatorPayload } from '../api/operatorsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const baseSchema = z.object({
|
||||
username: z.string().min(1, 'Ulanyjy ady hökmany'),
|
||||
name: z.string().min(1, 'Ady hökmany'),
|
||||
username: z.string().min(1, t('validation.required', '')),
|
||||
name: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().default(''),
|
||||
email: z.string().default(''),
|
||||
password: z.string(),
|
||||
@@ -13,7 +16,7 @@ const baseSchema = z.object({
|
||||
export function operatorFormSchema(mode: 'create' | 'edit') {
|
||||
return mode === 'create'
|
||||
? baseSchema.extend({
|
||||
password: z.string().min(1, 'Açar sözi hökmany'),
|
||||
password: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
: baseSchema
|
||||
}
|
||||
|
||||
@@ -65,10 +65,6 @@ export function useCreateCardOrder() {
|
||||
qc.invalidateQueries({ queryKey: cardOrderKeys.lists() })
|
||||
toast.success(t('cardOrder.createSuccess', 'Kart sargyt üstünlikli döredildi'))
|
||||
},
|
||||
|
||||
onError: () => {
|
||||
toast.error(t('cardOrder.createError', 'Kart sargyt döredilende ýalňyşlyk ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,10 +82,6 @@ export function useUpdateCardOrder(id: string) {
|
||||
qc.setQueryData(cardOrderKeys.detail(id), updated)
|
||||
toast.success(t('cardOrder.updateSuccess', 'Kart sargyt üstünlikli täzelendi'))
|
||||
},
|
||||
|
||||
onError: () => {
|
||||
toast.error(t('cardOrder.updateError', 'Kart sargyt täzelende ýalňyşlyk ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -107,10 +99,6 @@ export function useDeleteCardOrder() {
|
||||
qc.removeQueries({ queryKey: cardOrderKeys.detail(id) })
|
||||
toast.success(t('cardOrder.deleteSuccess', 'Kart sargyt üstünlikli pozuldy'))
|
||||
},
|
||||
|
||||
onError: () => {
|
||||
toast.error(t('cardOrder.deleteError', 'Kart sargyt pozulanda ýalňyşlyk ýüze çykdy'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CardOrderStatus } from '../api/orderNewCardApi'
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, 'Faýl hökmany')
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileRequired = z.custom<File>((val) => val instanceof File, t('validation.requiredFile', ''))
|
||||
|
||||
export const orderNewCardFormSchema = z.object({
|
||||
isPaid: z.boolean(),
|
||||
status: z.string().min(1, 'Status — hökmany'),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
note: z.string().optional(),
|
||||
issuanceReasonId: z.string().min(1, 'Kartyň çykarylmagynyň sebäbi — hökmany'),
|
||||
cardTypeId: z.string().min(1, 'Kart görnüşi — hökmany'),
|
||||
provinceId: z.string().min(1, 'Welaýat — hökmany'),
|
||||
branchId: z.string().min(1, 'Şahamça — hökmany'),
|
||||
firstName: z.string().min(1, 'Ady — hökmany'),
|
||||
lastName: z.string().min(1, 'Familiýasy — hökmany'),
|
||||
issuanceReasonId: z.string().min(1, t('validation.required', '')),
|
||||
cardTypeId: z.string().min(1, t('validation.required', '')),
|
||||
provinceId: z.string().min(1, t('validation.required', '')),
|
||||
branchId: z.string().min(1, t('validation.required', '')),
|
||||
firstName: z.string().min(1, t('validation.required', '')),
|
||||
lastName: z.string().min(1, t('validation.required', '')),
|
||||
middleName: z.string().optional(),
|
||||
formerLastName: z.string().optional(),
|
||||
birthDate: z.string().min(1, 'Doglan güni — hökmany'),
|
||||
phone: z.string().min(1, 'Telefon — hökmany'),
|
||||
birthDate: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
phoneExtra: z.string().optional(),
|
||||
citizenship: z.string().min(1, 'Raýatlyk — hökmany'),
|
||||
registeredAddress: z.string().min(1, 'Ýazgy edilen salgy — hökmany'),
|
||||
currentAddress: z.string().min(1, 'Häzirki ýaşaýyş ýeri — hökmany'),
|
||||
workplace: z.string().min(1, 'Işleýän ýeri — hökmany'),
|
||||
passportSeriesId: z.string().min(1, 'Pasport seriýasy — hökmany'),
|
||||
passportNumber: z.string().min(1, 'Pasport belgisi — hökmany'),
|
||||
passportIssueDate: z.string().min(1, 'Pasport berlen senesi — hökmany'),
|
||||
passportIssuedBy: z.string().min(1, 'Kim tarapyndan berildi — hökmany'),
|
||||
passportBirthPlace: z.string().min(1, 'Doglan ýeri — hökmany'),
|
||||
citizenship: z.string().min(1, t('validation.required', '')),
|
||||
registeredAddress: z.string().min(1, t('validation.required', '')),
|
||||
currentAddress: z.string().min(1, t('validation.required', '')),
|
||||
workplace: z.string().min(1, t('validation.required', '')),
|
||||
passportSeriesId: z.string().min(1, t('validation.required', '')),
|
||||
passportNumber: z.string().min(1, t('validation.required', '')),
|
||||
passportIssueDate: z.string().min(1, t('validation.required', '')),
|
||||
passportIssuedBy: z.string().min(1, t('validation.required', '')),
|
||||
passportBirthPlace: z.string().min(1, t('validation.required', '')),
|
||||
passportPage1: z.custom<File | null>().nullable(),
|
||||
passportPage23: z.custom<File | null>().nullable(),
|
||||
passportPage89: z.custom<File | null>().nullable(),
|
||||
@@ -53,7 +56,7 @@ export const stepSchemas: Record<number, z.ZodType<Partial<OrderNewCardFormData>
|
||||
passportPage23: fileRequired,
|
||||
passportPage89: fileRequired,
|
||||
passportPage32: fileRequired,
|
||||
termsAccepted: z.literal(true, { message: 'Şertnama bilen razylaşmaly' }),
|
||||
termsAccepted: z.literal(true, { message: t('validation.requiredTerms', '') }),
|
||||
}),
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,6 @@ export function useCreatePermission() {
|
||||
queryClient.invalidateQueries({ queryKey: permissionKeys.all })
|
||||
toast.success(t('permissions.toast.created', 'Rugsat üstünlikli döredildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('permissions.toast.createError', 'Rugsat döretmekde ýalňyşlyk ýüze çykdy.'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -67,9 +64,6 @@ export function useUpdatePermission(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: permissionKeys.detail(id) })
|
||||
toast.success(t('permissions.toast.updated', 'Rugsat üstünlikli üýtgedildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('permissions.toast.updateError', 'Rugsat üýtgetmekde ýalňyşlyk ýüze çykdy.'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -85,8 +79,5 @@ export function useDeletePermission() {
|
||||
queryClient.invalidateQueries({ queryKey: permissionKeys.all })
|
||||
toast.success(t('permissions.toast.deleted', 'Rugsat üstünlikli pozuldy!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('permissions.toast.deleteError', 'Rugsat pozmakda ýalňyşlyk ýüze çykdy.'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -52,9 +52,6 @@ export function useCreateRequiredDocument() {
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.lists() })
|
||||
toast.success(t('loanDocuments.toast.created', 'Resminama üstünlikli döredildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanDocuments.toast.createError', 'Resminama döredilende ýalňyşlyk ýüze çykdy!'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,9 +68,6 @@ export function useUpdateRequiredDocument(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.detail(id) })
|
||||
toast.success(t('loanDocuments.toast.updated', 'Resminama üstünlikli täzelendi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanDocuments.toast.updateError', 'Resminama täzelenende ýalňyşlyk ýüze çykdy!'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -89,8 +83,5 @@ export function useDeleteRequiredDocument() {
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.lists() })
|
||||
toast.success(t('loanDocuments.toast.deleted', 'Resminama üstünlikli öçürildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanDocuments.toast.deleteError', 'Resminama öçürilende ýalňyşlyk ýüze çykdy!'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { LoanDocument, LoanDocumentPayload } from '../api/requiredDocumentsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const requiredDocumentFormSchema = z.object({
|
||||
nameTk: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameRu: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameEn: z.string().min(1, 'Hökmany meýdan'),
|
||||
descTk: z.string().min(1, 'Hökmany meýdan'),
|
||||
descRu: z.string().min(1, 'Hökmany meýdan'),
|
||||
descEn: z.string().min(1, 'Hökmany meýdan'),
|
||||
nameTk: z.string().min(1, t('validation.required', '')),
|
||||
nameRu: z.string().min(1, t('validation.required', '')),
|
||||
nameEn: z.string().min(1, t('validation.required', '')),
|
||||
descTk: z.string().min(1, t('validation.required', '')),
|
||||
descRu: z.string().min(1, t('validation.required', '')),
|
||||
descEn: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type RequiredDocumentFormData = z.infer<typeof requiredDocumentFormSchema>
|
||||
|
||||
@@ -42,9 +42,6 @@ export function useCreateRole() {
|
||||
queryClient.invalidateQueries({ queryKey: roleKeys.all })
|
||||
toast.success(t('roles.toast.created', 'Rol üstünlikli döredildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('roles.toast.createError', 'Rol döretmekde ýalňyşlyk ýüze çykdy.'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,9 +58,6 @@ export function useUpdateRole(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: roleKeys.detail(id) })
|
||||
toast.success(t('roles.toast.updated', 'Rol üstünlikli üýtgedildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('roles.toast.updateError', 'Roly üýtgetmekde ýalňyşlyk ýüze çykdy.'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -79,8 +73,5 @@ export function useDeleteRole() {
|
||||
queryClient.invalidateQueries({ queryKey: roleKeys.all })
|
||||
toast.success(t('roles.toast.deleted', 'Rol üstünlikli pozuldy!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('roles.toast.deleteError', 'Roly pozmakda ýalňyşlyk ýüze çykdy.'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useState, useMemo } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { toast } from 'sonner'
|
||||
import { User, MapPin, IdCard, CreditCard, Files } from 'lucide-react'
|
||||
@@ -406,6 +407,7 @@ function mapInitialData(data: SberPaymentOrder): Partial<SberPaymentFormData> {
|
||||
// ─── Main component ───────────────────────────────────────────────────────────
|
||||
|
||||
export function SberPaymentForm({ mode, initialData, orderId }: SberPaymentFormProps) {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const createMutation = useCreateSberPayment()
|
||||
const updateMutation = useUpdateSberPayment()
|
||||
@@ -481,22 +483,18 @@ export function SberPaymentForm({ mode, initialData, orderId }: SberPaymentFormP
|
||||
const handleSubmit = async () => {
|
||||
const allErrors = doValidateAll()
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
toast.error('Meýdanlary dolduryň')
|
||||
toast.error(t('common.errors.requiredFieldsMissing', 'Meýdanlary dolduryň'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
const payload = buildPayload(getValues())
|
||||
if (mode === 'create') {
|
||||
await createMutation.mutateAsync(payload)
|
||||
toast.success('Töleg üstünlikli döredildi')
|
||||
navigate('/sber-payments')
|
||||
} else if (orderId) {
|
||||
await updateMutation.mutateAsync({ ...payload, id: orderId })
|
||||
toast.success('Töleg üstünlikli täzelendi')
|
||||
navigate(`/sber-payments/${orderId}`)
|
||||
}
|
||||
} catch {
|
||||
toast.error('Ýalňyşlyk ýüze çykdy')
|
||||
const payload = buildPayload(getValues())
|
||||
if (mode === 'create') {
|
||||
await createMutation.mutateAsync(payload)
|
||||
toast.success(t('sberPayments.toast.created', 'Töleg üstünlikli döredildi'))
|
||||
navigate('/sber-payments')
|
||||
} else if (orderId) {
|
||||
await updateMutation.mutateAsync({ ...payload, id: orderId })
|
||||
toast.success(t('sberPayments.toast.updated', 'Töleg üstünlikli täzelendi'))
|
||||
navigate(`/sber-payments/${orderId}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { CreateSberPaymentPayload, PaymentStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||
|
||||
// ─── File helper ─────────────────────────────────────────────────────
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileField = z.custom<File | null>((val) => val === null || val instanceof File).nullable()
|
||||
|
||||
// ─── Full form schema ─────────────────────────────────────────────────
|
||||
|
||||
export const sberPaymentFormSchema = z.object({
|
||||
// From SberPaymentFormData
|
||||
welayat: z.string().min(1, 'Welaýat hökmany'),
|
||||
sahamca: z.string().min(1, 'Şahamça hökmany'),
|
||||
firstName: z.string().min(1, 'Ady hökmany'),
|
||||
lastName: z.string().min(1, 'Familiýasy hökmany'),
|
||||
phone: z.string().min(1, 'Telefon hökmany'),
|
||||
welayat: z.string().min(1, t('validation.required', '')),
|
||||
sahamca: z.string().min(1, t('validation.required', '')),
|
||||
firstName: z.string().min(1, t('validation.required', '')),
|
||||
lastName: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
email: z.string(),
|
||||
address: z.string().min(1, 'Salgy hökmany'),
|
||||
status: z.string().min(1, 'Status hökmany'),
|
||||
address: z.string().min(1, t('validation.required', '')),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
bellik: z.string(),
|
||||
accountNumber: z.string().min(1, 'Goýum hasaby hökmany'),
|
||||
passportSeries: z.string().min(1, 'Pasport seriýasy hökmany'),
|
||||
passportNumber: z.string().min(1, 'Pasport nomeri hökmany'),
|
||||
fullName: z.string().min(1, 'Doly ady hökmany'),
|
||||
// Client id
|
||||
accountNumber: z.string().min(1, t('validation.required', '')),
|
||||
passportSeries: z.string().min(1, t('validation.required', '')),
|
||||
passportNumber: z.string().min(1, t('validation.required', '')),
|
||||
fullName: z.string().min(1, t('validation.required', '')),
|
||||
client_id: z.string().optional(),
|
||||
// File fields
|
||||
acc_sberbank_card: fileField,
|
||||
acc_enrollment: fileField,
|
||||
acc_summons: fileField,
|
||||
@@ -43,8 +39,6 @@ export const sberPaymentFormSchema = z.object({
|
||||
|
||||
export type SberPaymentFormData = z.infer<typeof sberPaymentFormSchema>
|
||||
|
||||
// ─── Step schemas ─────────────────────────────────────────────────────
|
||||
|
||||
export const stepSchemas: Record<number, z.ZodType<Partial<SberPaymentFormData>>> = {
|
||||
0: sberPaymentFormSchema.pick({ status: true }),
|
||||
1: sberPaymentFormSchema.pick({ welayat: true, sahamca: true }),
|
||||
@@ -52,8 +46,6 @@ export const stepSchemas: Record<number, z.ZodType<Partial<SberPaymentFormData>>
|
||||
3: sberPaymentFormSchema.pick({ passportSeries: true, passportNumber: true, fullName: true, accountNumber: true }),
|
||||
}
|
||||
|
||||
// ─── validateStep ─────────────────────────────────────────────────────
|
||||
|
||||
export function validateStep(
|
||||
stepIndex: number,
|
||||
form: SberPaymentFormData,
|
||||
@@ -72,8 +64,6 @@ export function validateStep(
|
||||
return errors
|
||||
}
|
||||
|
||||
// ─── Default values ───────────────────────────────────────────────────
|
||||
|
||||
export const DEFAULT_FORM_VALUES: SberPaymentFormData = {
|
||||
client_id: '',
|
||||
welayat: '',
|
||||
@@ -105,8 +95,6 @@ export const DEFAULT_FORM_VALUES: SberPaymentFormData = {
|
||||
snt_old_passport_series: null,
|
||||
}
|
||||
|
||||
// ─── buildPayload ─────────────────────────────────────────────────────
|
||||
|
||||
export function buildPayload(data: SberPaymentFormData): CreateSberPaymentPayload {
|
||||
return {
|
||||
welayat: data.welayat,
|
||||
|
||||
@@ -40,9 +40,6 @@ export function useCreateIntlPayment() {
|
||||
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'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -56,9 +53,6 @@ export function useUpdateIntlPayment(id: string) {
|
||||
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'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,8 +65,5 @@ export function useDeleteIntlPayment() {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() })
|
||||
toast.success(t('intlPayment.deleteSuccess', 'Töleg pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('intlPayment.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { IntlPaymentCreatePayload, IntlPaymentStatus, CurrencyType } from '../api/visaMasterPaymentsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
const fileField = z.custom<File | null>().nullable()
|
||||
|
||||
export const visaMasterPaymentFormSchema = z.object({
|
||||
client_id: z.string().min(1, 'Ulanyjy hökmany'),
|
||||
status: z.string().min(1, 'Status hökmany'),
|
||||
client_id: z.string().min(1, t('validation.required', '')),
|
||||
status: z.string().min(1, t('validation.required', '')),
|
||||
note: z.string().optional().default(''),
|
||||
currency_type: z.string().min(1, 'Ýüztumanyň görnüşi hökmany'),
|
||||
province: z.string().min(1, 'Welaýat hökmany'),
|
||||
branch: z.string().min(1, 'Şahamça hökmany'),
|
||||
passport_first_name: z.string().min(1, 'Ady hökmany'),
|
||||
passport_last_name: z.string().min(1, 'Familiýasy hökmany'),
|
||||
phone: z.string().min(1, 'Telefon hökmany'),
|
||||
currency_type: z.string().min(1, t('validation.required', '')),
|
||||
province: z.string().min(1, t('validation.required', '')),
|
||||
branch: z.string().min(1, t('validation.required', '')),
|
||||
passport_first_name: z.string().min(1, t('validation.required', '')),
|
||||
passport_last_name: z.string().min(1, t('validation.required', '')),
|
||||
phone: z.string().min(1, t('validation.required', '')),
|
||||
email: z.string().optional().default(''),
|
||||
home_address: z.string().optional().default(''),
|
||||
passport_series: z.string().min(1, 'Pasport seriýasy hökmany'),
|
||||
passport_number: z.string().min(1, 'Pasport nomeri hökmany'),
|
||||
payer_full_name: z.string().min(1, 'Doly ady hökmany'),
|
||||
payer_account_number: z.string().min(1, 'Goşun hasaby hökmany'),
|
||||
receiver_info: z.string().min(1, 'Kabul edijiniň maglumatlary hökmany'),
|
||||
passport_series: z.string().min(1, t('validation.required', '')),
|
||||
passport_number: z.string().min(1, t('validation.required', '')),
|
||||
payer_full_name: z.string().min(1, t('validation.required', '')),
|
||||
payer_account_number: z.string().min(1, t('validation.required', '')),
|
||||
receiver_info: z.string().min(1, t('validation.required', '')),
|
||||
doc_sberbank_account: fileField,
|
||||
doc_school_enrollment: fileField,
|
||||
doc_summons: fileField,
|
||||
|
||||
@@ -55,9 +55,6 @@ export function useCreateVisaMasterSetting() {
|
||||
queryClient.invalidateQueries({ queryKey: visaMasterSettingKeys.lists() })
|
||||
toast.success(t('visaMasterSettings.toast.created', 'Sazlama döredildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('visaMasterSettings.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,9 +71,6 @@ export function useUpdateVisaMasterSetting(id: number) {
|
||||
queryClient.invalidateQueries({ queryKey: visaMasterSettingKeys.detail(id) })
|
||||
toast.success(t('visaMasterSettings.toast.updated', 'Sazlama üýtgedildi'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('visaMasterSettings.toast.updateError', 'Üýtgetmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -92,8 +86,5 @@ export function useDeleteVisaMasterSetting() {
|
||||
queryClient.invalidateQueries({ queryKey: visaMasterSettingKeys.lists() })
|
||||
toast.success(t('visaMasterSettings.toast.deleted', 'Sazlama pozuldy'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('visaMasterSettings.toast.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import i18next from 'i18next'
|
||||
import type { VisaMasterSettingPayload } from '../api/visaMasterSberSettingsApi'
|
||||
|
||||
const t = i18next.t.bind(i18next)
|
||||
|
||||
export const visaMasterSettingFormSchema = z.object({
|
||||
kod: z.string().min(1, 'Hökmany meýdan'),
|
||||
ady: z.string().min(1, 'Hökmany meýdan'),
|
||||
yazgy: z.string().min(1, 'Hökmany meýdan'),
|
||||
kod: z.string().min(1, t('validation.required', '')),
|
||||
ady: z.string().min(1, t('validation.required', '')),
|
||||
yazgy: z.string().min(1, t('validation.required', '')),
|
||||
})
|
||||
|
||||
export type VisaMasterSettingFormData = z.infer<typeof visaMasterSettingFormSchema>
|
||||
|
||||
@@ -293,7 +293,9 @@
|
||||
"Start date": "Start date",
|
||||
"Submit": "Submit",
|
||||
"Successfully created": "Successfully created",
|
||||
"Success login": "Login successful",
|
||||
"Successfully logged in": "Successfully logged in",
|
||||
"Privacy Policy": "Privacy Policy",
|
||||
"Successfully registered": "Successfully registered",
|
||||
"Successfully updated": "Successfully updated",
|
||||
"Surname": "Surname",
|
||||
@@ -362,6 +364,12 @@
|
||||
"common.view": "View",
|
||||
"common.edit": "Edit",
|
||||
"common.delete": "Delete",
|
||||
"common.goBack": "Go back",
|
||||
"common.backToHome": "Go to home",
|
||||
"errors.pageNotFoundTitle": "Page not found",
|
||||
"errors.pageNotFoundDescription": "The page you are looking for does not exist or has been moved.",
|
||||
"Phone or username": "Phone or username",
|
||||
"featureNotImplemented": "Not implemented",
|
||||
"common.search": "Search",
|
||||
"common.yes": "Yes",
|
||||
"common.no": "No",
|
||||
@@ -407,5 +415,18 @@
|
||||
"Locale Manager": "Locale Manager",
|
||||
"Resources": "Resources",
|
||||
"Currency rates": "Currency rates",
|
||||
"Loan balance": "Loan balance"
|
||||
"Loan balance": "Loan balance",
|
||||
"common.cancel": "Cancel",
|
||||
"common.confirm": "Confirm",
|
||||
"common.errors.fillRequiredCorrectly": "Please enter correct data.",
|
||||
"common.errors.requiredFieldsMissing": "Some required fields are missing.",
|
||||
"validation.required": "Required field",
|
||||
"validation.requiredFile": "File is required",
|
||||
"validation.invalidPhone": "Invalid phone number",
|
||||
"validation.positiveNumber": "Positive number required",
|
||||
"validation.invalidNumber": "Enter a valid number",
|
||||
"validation.requiredTerms": "You must agree to the terms",
|
||||
"validation.valuePositive": "Value must be greater than 0",
|
||||
"validation.minLength": "At least {length} characters",
|
||||
"validation.invalidEmail": "Invalid email format"
|
||||
}
|
||||
@@ -293,7 +293,9 @@
|
||||
"Start date": "Дата начала",
|
||||
"Submit": "Отправить",
|
||||
"Successfully created": "Успешно создано",
|
||||
"Success login": "Вход выполнен успешно",
|
||||
"Successfully logged in": "Успешно авторизован",
|
||||
"Privacy Policy": "Политика конфиденциальности",
|
||||
"Successfully registered": "Успешно зарегистрирован",
|
||||
"Successfully updated": "Успешно обновлено",
|
||||
"Surname": "Фамилия",
|
||||
@@ -362,6 +364,12 @@
|
||||
"common.view": "Просмотр",
|
||||
"common.edit": "Редактировать",
|
||||
"common.delete": "Удалить",
|
||||
"common.goBack": "Назад",
|
||||
"common.backToHome": "На главную",
|
||||
"errors.pageNotFoundTitle": "Страница не найдена",
|
||||
"errors.pageNotFoundDescription": "Страница, которую вы ищете, не существует или была перемещена.",
|
||||
"Phone or username": "Телефон или имя пользователя",
|
||||
"featureNotImplemented": "Эта функция еще не реализована",
|
||||
"common.search": "Поиск",
|
||||
"common.yes": "Да",
|
||||
"common.no": "Нет",
|
||||
@@ -407,5 +415,18 @@
|
||||
"Locale Manager": "Управление локалью",
|
||||
"Resources": "Ресурсы",
|
||||
"Currency rates": "Курсы валют",
|
||||
"Loan balance": "Остаток кредита"
|
||||
"Loan balance": "Остаток кредита",
|
||||
"common.cancel": "Отмена",
|
||||
"common.confirm": "Подтвердить",
|
||||
"common.errors.fillRequiredCorrectly": "Пожалуйста, введите корректные данные.",
|
||||
"common.errors.requiredFieldsMissing": "Некоторые обязательные поля не заполнены.",
|
||||
"validation.required": "Обязательное поле",
|
||||
"validation.requiredFile": "Файл обязателен",
|
||||
"validation.invalidPhone": "Неверный номер телефона",
|
||||
"validation.positiveNumber": "Введите положительное число",
|
||||
"validation.invalidNumber": "Введите корректное число",
|
||||
"validation.requiredTerms": "Необходимо согласиться с условиями",
|
||||
"validation.valuePositive": "Значение должно быть больше 0",
|
||||
"validation.minLength": "Минимум {length} символов",
|
||||
"validation.invalidEmail": "Неверный формат email"
|
||||
}
|
||||
@@ -293,7 +293,9 @@
|
||||
"Start date": "Başlangyç sene",
|
||||
"Submit": "Tassyklamak",
|
||||
"Successfully created": "Üstünlikli döredildi",
|
||||
"Success login": "Giriş üstünlikli",
|
||||
"Successfully logged in": "Üstünlik bilen girdiňiz",
|
||||
"Privacy Policy": "Gizlinlik syýasaty",
|
||||
"Successfully registered": "Üstünlikli hasaba alyndyňyz",
|
||||
"Successfully updated": "Üstünlikli üýtgedildi",
|
||||
"Surname": "Familiýasy",
|
||||
@@ -362,6 +364,12 @@
|
||||
"common.view": "Görmek",
|
||||
"common.edit": "Üýtgetmek",
|
||||
"common.delete": "Pozmak",
|
||||
"common.goBack": "Yza gaýt",
|
||||
"common.backToHome": "Baş sahypa",
|
||||
"errors.pageNotFoundTitle": "Sahypa tapylmady",
|
||||
"errors.pageNotFoundDescription": "Gözleýän sahypaňyz ýok ýa-da başga ýere geçirilen bolup biler.",
|
||||
"Phone or username": "Telefon ýada ulanyjy ady",
|
||||
"featureNotImplemented": "Bu funksiýa entek durmuşa geçirilmedi",
|
||||
"common.search": "Gözlemek",
|
||||
"common.yes": "Hawa",
|
||||
"common.no": "Ýok",
|
||||
@@ -423,5 +431,18 @@
|
||||
"loanDocuments.toast.updated": "Resminama üstünlikli täzelendi!",
|
||||
"loanDocuments.toast.updateError": "Resminama täzelenende ýalňyşlyk ýüze çykdy!",
|
||||
"loanDocuments.toast.deleted": "Resminama üstünlikli öçürildi!",
|
||||
"loanDocuments.toast.deleteError": "Resminama öçürilende ýalňyşlyk ýüze çykdy!"
|
||||
"loanDocuments.toast.deleteError": "Resminama öçürilende ýalňyşlyk ýüze çykdy!",
|
||||
"common.cancel": "Ýatyrmak",
|
||||
"common.confirm": "Tassykla",
|
||||
"common.errors.fillRequiredCorrectly": "Dogry maglumat girizmegiňizi haýyş edýäris.",
|
||||
"common.errors.requiredFieldsMissing": "Käbir hökmany meýdanlar doldurylan däldir.",
|
||||
"validation.required": "Hökmany meýdan",
|
||||
"validation.requiredFile": "Faýl hökmany",
|
||||
"validation.invalidPhone": "Telefon belgisi nädogry",
|
||||
"validation.positiveNumber": "Oňyn san gerek",
|
||||
"validation.invalidNumber": "Dogry san giriziň",
|
||||
"validation.requiredTerms": "Şertnama bilen razylaşmaly",
|
||||
"validation.valuePositive": "Baha 0-dan uly bolmaly",
|
||||
"validation.minLength": "Iň az {length} harp giriziň",
|
||||
"validation.invalidEmail": "Nädogry e-poçta formaty"
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
} from '@/features/orderNewCard/hooks/useOrderNewCard'
|
||||
import type { CardOrderListItem, CardOrderStatus } from '@/features/orderNewCard/api/orderNewCardApi'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
|
||||
// ─── Status badge ─────────────────────────────────────────────────────────────
|
||||
@@ -80,6 +81,7 @@ export default function CardOrdersPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteCardOrder()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
@@ -130,13 +132,15 @@ export default function CardOrdersPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: string) => {
|
||||
if (!window.confirm(t('cardOrder.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t]
|
||||
)
|
||||
const handleDelete = useCallback((id: string) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (!deleteId) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<CardOrderListItem>[]>(
|
||||
@@ -318,6 +322,15 @@ export default function CardOrdersPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('cardOrder.deleteConfirm', 'Bu sargyt pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,21 +7,12 @@ import { Eye, Pencil, Trash2 } from "lucide-react";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
useGetCurrencyRates,
|
||||
useDeleteCurrencyRate,
|
||||
} from "@/features/currencyRates/hooks/useCurrencyRates";
|
||||
import type { CurrencyRate } from "@/features/currencyRates/api/currencyRatesApi";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Column visibility defaults ───────────────────────────────────────────────
|
||||
|
||||
@@ -197,39 +188,15 @@ export default function CurrencyRatesPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete Confirmation Dialog */}
|
||||
<AlertDialog
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDeleteId(null);
|
||||
}}
|
||||
>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("currencyRates.deleteDialog.title", "Pozmak isleýärsiňizmi?")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
"currencyRates.deleteDialog.description",
|
||||
"Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.",
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending
|
||||
? t("common.deleting", "Pozulýar...")
|
||||
: t("common.delete", "Pozmak")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t("currencyRates.deleteDialog.title", "Pozmak isleýärsiňizmi?")}
|
||||
description={t("currencyRates.deleteDialog.description", "Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.")}
|
||||
confirmLabel={deleteMutation.isPending ? t("common.deleting", "Pozulýar...") : t("common.delete", "Pozmak")}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
// pages/CurrencyRateDetailPage.tsx
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2 } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetCurrencyRateById, useDeleteCurrencyRate } from '@/features/currencyRates/hooks/useCurrencyRates'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── CurrencyRateDetailPage ───────────────────────────────────────────────────
|
||||
|
||||
@@ -104,34 +95,15 @@ export default function CurrencyRateDetailPage() {
|
||||
/>
|
||||
</Section>
|
||||
|
||||
{/* Delete Dialog */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t('currencyRates.deleteDialog.title', 'Pozmak isleýärsiňizmi?')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'currencyRates.deleteDialog.description',
|
||||
'Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.'
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending
|
||||
? t('common.deleting', 'Pozulýar...')
|
||||
: t('common.delete', 'Pozmak')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t('currencyRates.deleteDialog.title', 'Pozmak isleýärsiňizmi?')}
|
||||
description={t('currencyRates.deleteDialog.description', 'Bu amal yzyna gaýtarylyp bilinmez. Walýuta kursy hemişelik pozular.')}
|
||||
confirmLabel={deleteMutation.isPending ? t('common.deleting', 'Pozulýar...') : t('common.delete', 'Pozmak')}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { InfoRow, AuditLog, type AuditRowProps } from '@/components/viewPageComp
|
||||
import { useSberPaymentOrder, useDeleteSberPayment } from '@/features/sberPayments/hooks/useSberPayments'
|
||||
import type { PaymentPaidStatus, PaymentStatus } from '@/features/sberPayments/api/sberPaymentsApi'
|
||||
import { useState } from 'react'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -137,12 +138,12 @@ export default function SberPaymentViewPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const [historySearch, setHistorySearch] = useState('')
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id!)
|
||||
const deleteMutation = useDeleteSberPayment()
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!window.confirm('Bu tolegi pozmak isleyanizmi?')) return
|
||||
await deleteMutation.mutateAsync(id!)
|
||||
navigate('/sber-payments')
|
||||
}
|
||||
@@ -179,7 +180,7 @@ export default function SberPaymentViewPage() {
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title="Poz"
|
||||
@@ -301,6 +302,14 @@ export default function SberPaymentViewPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title="Bu tölegi pozmak isleýärsiňizmi?"
|
||||
confirmLabel="Poz"
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -8,16 +8,7 @@ import { useIntlPayments, useDeleteIntlPayment } from '@/features/visaMasterPaym
|
||||
import type { IntlPaymentItem, IntlPaymentStatus } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Eye, Pencil, Trash2, ChevronDown } from 'lucide-react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
@@ -265,30 +256,19 @@ export default function IntlPaymentsPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialog open={!!deleteTarget} onOpenChange={(o) => !o && setDeleteTarget(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} {deleteTarget?.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() => {
|
||||
if (deleteTarget) {
|
||||
deletePayment(deleteTarget.id, { onSuccess: () => setDeleteTarget(null) })
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={deleteTarget !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}
|
||||
description={`${t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} ${deleteTarget?.id ?? ''}`}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deletePayment(deleteTarget.id, { onSuccess: () => setDeleteTarget(null) })
|
||||
}
|
||||
}}
|
||||
isLoading={isDeleting}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,17 +2,7 @@ import { useState } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, Download, Search, AlertCircle, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { InfoRow } from '@/components/viewPageComponents'
|
||||
@@ -138,10 +128,15 @@ export default function IntlPaymentViewPage() {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const [historySearch, setHistorySearch] = useState('')
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
const { data, isLoading, isError } = useIntlPayment(id!)
|
||||
const { mutate: deletePayment, isPending: isDeleting } = useDeleteIntlPayment()
|
||||
|
||||
const confirmDelete = () => {
|
||||
deletePayment(data!.id, { onSuccess: () => navigate('/intl-payments/visa-master') })
|
||||
}
|
||||
|
||||
if (isLoading) return <IntlPaymentViewSkeleton />
|
||||
|
||||
if (isError || !data) {
|
||||
@@ -182,34 +177,13 @@ export default function IntlPaymentViewPage() {
|
||||
{t('intlPayment.viewTitle', 'Halkara töleg')}: {data.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<button
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t('common.delete', 'Poz')}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} {data.id}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={isDeleting}>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
disabled={isDeleting}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
onClick={() => deletePayment(data.id, { onSuccess: () => navigate('/intl-payments/visa-master') })}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<button
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t('common.delete', 'Poz')}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => navigate(`/intl-payments/visa-master/${id}/edit`)}
|
||||
@@ -316,6 +290,15 @@ export default function IntlPaymentViewPage() {
|
||||
</BentoCard>
|
||||
</BentoGrid>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t('intlPayment.deleteTitle', 'Pozmak isleýärsiňizmi?')}
|
||||
description={`${t('intlPayment.deleteDesc', 'Bu amal yzyna dolanyp bolmaz.')} ${data?.id}`}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={isDeleting}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
useDeleteLoanOrderMobile,
|
||||
} from '@/features/loanOrderMobiles/hooks/useLoanOrderMobiles'
|
||||
import type { LoanOrderMobile, LoanOrderMobileStatus } from '@/features/loanOrderMobiles/api/loanOrderMobilesApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +56,7 @@ export default function LoanOrderMobilesPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanOrderMobile()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
@@ -97,13 +99,15 @@ export default function LoanOrderMobilesPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: string) => {
|
||||
if (!window.confirm(t('loanOrderMobiles.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t],
|
||||
)
|
||||
const handleDelete = useCallback((id: string) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (!deleteId) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<LoanOrderMobile>[]>(
|
||||
@@ -309,6 +313,15 @@ export default function LoanOrderMobilesPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanOrderMobiles.deleteConfirm', 'Bu sargyt pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
@@ -7,7 +8,6 @@ import {
|
||||
} from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
import { CreditCardVisual } from "@/components/creditCardVisual";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { toast } from "sonner";
|
||||
import type { LoanOrderMobileStatus } from "@/features/loanOrderMobiles/api/loanOrderMobilesApi";
|
||||
import {
|
||||
StatusBadge,
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -105,19 +106,17 @@ export default function LoanOrderMobilesViewPage() {
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const deleteMutation = useDeleteLoanOrderMobile()
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
|
||||
|
||||
const { data: order, isLoading } = useLoanOrderMobileById(id!)
|
||||
|
||||
const handleDelete = () => {
|
||||
if (!window.confirm(t("loanOrderMobiles.deleteConfirm", "Bu sargyt pozulsynmy?"))) return
|
||||
setShowDeleteDialog(true)
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("loanOrderMobiles.deleteSuccess", "Sargyt pozuldy"))
|
||||
navigate("/loan-order-mobiles")
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t("loanOrderMobiles.deleteError", "Pozma wagty ýalňyşlyk ýüze çykdy"))
|
||||
},
|
||||
onSuccess: () => navigate("/loan-order-mobiles"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -436,6 +435,14 @@ export default function LoanOrderMobilesViewPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanOrderMobiles.deleteConfirm", "Bu sargyt pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
@@ -6,7 +7,6 @@ import {
|
||||
useDeleteLoanOrder,
|
||||
} from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
StatusBadge,
|
||||
type StatusBadgeVariant,
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
AuditLog,
|
||||
type AuditRowProps,
|
||||
} from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Status config ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -102,19 +103,17 @@ export default function LoanOrderViewPage() {
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const deleteMutation = useDeleteLoanOrder()
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
|
||||
|
||||
const { data: order, isLoading } = useLoanOrderById(id!)
|
||||
|
||||
const handleDelete = () => {
|
||||
if (!window.confirm(t("loanOrders.deleteConfirm", "Bu sargyt pozulsynmy?"))) return
|
||||
setShowDeleteDialog(true)
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(id!, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("loanOrders.deleteSuccess", "Sargyt pozuldy"))
|
||||
navigate("/loan-orders")
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t("loanOrders.deleteError", "Pozma wagty ýalňyşlyk ýüze çykdy"))
|
||||
},
|
||||
onSuccess: () => navigate("/loan-orders"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -352,6 +351,14 @@ export default function LoanOrderViewPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanOrders.deleteConfirm", "Bu sargyt pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { DataTableToolbar, type ActiveFilter, type FilterField } from '@/compone
|
||||
import { StatusBadge, type StatusBadgeVariant } from '@/components/ui/statusBadge'
|
||||
import { useLoanOrders, useDeleteLoanOrder } from '@/features/loanOrders/hooks/useLoanOrders'
|
||||
import type { LoanOrder, LoanOrderStatus } from '@/features/loanOrders/api/loanOrdersApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Status Badge (inline) ────────────────────────────────────────────────────
|
||||
|
||||
@@ -56,6 +57,7 @@ export default function LoanOrdersPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanOrder()
|
||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||
|
||||
const [search, setSearch] = useState('')
|
||||
const [page, setPage] = useState(1)
|
||||
@@ -95,13 +97,15 @@ export default function LoanOrdersPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: string) => {
|
||||
if (!window.confirm(t('loanOrders.deleteConfirm', 'Bu sargyt pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t]
|
||||
)
|
||||
const handleDelete = useCallback((id: string) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (!deleteId) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
const columns = useMemo<ColumnDef<LoanOrder>[]>(
|
||||
() => [
|
||||
@@ -300,6 +304,15 @@ export default function LoanOrdersPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanOrders.deleteConfirm', 'Bu sargyt pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
useDeleteLoanPaidOffLetter,
|
||||
} from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import type { LoanPaidOffLetter } from "@/features/loanPaidOffLetters/api/loanPaidOffLettersApi";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -60,6 +61,7 @@ function EmptyState({ onCreate }: { onCreate: () => void }) {
|
||||
export default function LoanPaidOffLettersPage() {
|
||||
const { t } = useTranslation();
|
||||
const deleteMutation = useDeleteLoanPaidOffLetter();
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null);
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState("");
|
||||
@@ -92,18 +94,15 @@ export default function LoanPaidOffLettersPage() {
|
||||
setPage(1);
|
||||
}, []);
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: number) => {
|
||||
if (
|
||||
!window.confirm(
|
||||
t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?"),
|
||||
)
|
||||
)
|
||||
return;
|
||||
deleteMutation.mutate(id);
|
||||
},
|
||||
[deleteMutation, t],
|
||||
);
|
||||
const handleDelete = useCallback((id: number) => {
|
||||
setDeleteId(id);
|
||||
}, []);
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (deleteId === null) return;
|
||||
deleteMutation.mutate(deleteId);
|
||||
setDeleteId(null);
|
||||
}, [deleteId, deleteMutation]);
|
||||
|
||||
const handleCreate = useCallback(() => {
|
||||
// navigate to create page or open modal
|
||||
@@ -288,6 +287,15 @@ export default function LoanPaidOffLettersPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { DataTable } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ActiveFilter, type FilterField } from '@/components/dataTableToolbar'
|
||||
import { useLoanRemaining, useDeleteLoanRemaining } from '@/features/loanRemaining/hooks/useLoanRemaining'
|
||||
import type { LoanRemaining } from '@/features/loanRemaining/api/loanRemainingApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Column IDs ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -19,6 +20,7 @@ export default function LoanRemainingPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const deleteMutation = useDeleteLoanRemaining()
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null)
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
@@ -48,13 +50,15 @@ export default function LoanRemainingPage() {
|
||||
setPage(1)
|
||||
}, [])
|
||||
|
||||
const handleDelete = useCallback(
|
||||
(id: number) => {
|
||||
if (!window.confirm(t('loanRemaining.deleteConfirm', 'Bu ýazgy pozulsynmy?'))) return
|
||||
deleteMutation.mutate(id)
|
||||
},
|
||||
[deleteMutation, t],
|
||||
)
|
||||
const handleDelete = useCallback((id: number) => {
|
||||
setDeleteId(id)
|
||||
}, [])
|
||||
|
||||
const confirmDelete = useCallback(() => {
|
||||
if (deleteId === null) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}, [deleteId, deleteMutation])
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<LoanRemaining>[]>(
|
||||
@@ -188,6 +192,15 @@ export default function LoanRemainingPage() {
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanRemaining.deleteConfirm', 'Bu ýazgy pozulsynmy?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
@@ -6,8 +7,8 @@ import {
|
||||
useDeleteLoanRemaining,
|
||||
} from "@/features/loanRemaining/hooks/useLoanRemaining";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { toast } from "sonner";
|
||||
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
// ─── Skeleton ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -31,29 +32,17 @@ export default function LoanRemainingViewPage() {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanRemaining();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: record, isLoading } = useLoanRemainingById(id!);
|
||||
|
||||
const handleDelete = () => {
|
||||
if (
|
||||
!window.confirm(t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?"))
|
||||
)
|
||||
return;
|
||||
setShowDeleteDialog(true);
|
||||
};
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(Number(id!), {
|
||||
onSuccess: () => {
|
||||
toast.success(
|
||||
t("loanRemaining.deleteSuccess", "Ýazgy üstünlikli pozuldy"),
|
||||
);
|
||||
navigate("/loan-remaining");
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(
|
||||
t(
|
||||
"loanRemaining.deleteError",
|
||||
"Pozmak başartmady, gaýtadan synanyşyň",
|
||||
),
|
||||
);
|
||||
},
|
||||
onSuccess: () => navigate("/loan-remaining"),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -110,6 +99,15 @@ export default function LoanRemainingViewPage() {
|
||||
value={record.loanAccount}
|
||||
/>
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanRemaining.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,20 +105,12 @@ export default function AuthPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
loginMutation.mutate({ email: username, password }, {
|
||||
onSuccess: () => {
|
||||
toast.success(t("Success login", "Login successful"));
|
||||
},
|
||||
onError: (error: any) => {
|
||||
const message = error?.response?.data?.message || t("Server Error", "An error occurred during login");
|
||||
toast.error(message);
|
||||
}
|
||||
});
|
||||
loginMutation.mutate({ email: username, password });
|
||||
};
|
||||
|
||||
// Mock submit for other views
|
||||
const handleOtherSubmit = async () => {
|
||||
toast.info(t("Not Implemented", "This feature is not implemented yet"));
|
||||
toast.info(t("featureNotImplemented", "This feature is not implemented yet"));
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -170,7 +162,7 @@ export default function AuthPage() {
|
||||
|
||||
<div className="text-center mt-8">
|
||||
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
|
||||
Privacy Policy
|
||||
{t("Privacy Policy")}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
@@ -218,7 +210,7 @@ export default function AuthPage() {
|
||||
|
||||
<div className="text-center mt-8">
|
||||
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
|
||||
Privacy Policy
|
||||
{t("Privacy Policy")}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
@@ -248,7 +240,7 @@ export default function AuthPage() {
|
||||
|
||||
<div className="text-center mt-8">
|
||||
<span className="text-[13px] text-muted-foreground underline cursor-pointer hover:text-foreground transition-colors">
|
||||
Privacy Policy
|
||||
{t("Privacy Policy")}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -15,10 +15,10 @@ export default function NotFoundPage() {
|
||||
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-2xl font-bold tracking-tight sm:text-3xl">
|
||||
{t("errors.pageNotFoundTitle")}
|
||||
{t("errors.pageNotFoundTitle", "Sahypa tapylmady")}
|
||||
</h2>
|
||||
<p className="text-muted-foreground">
|
||||
{t("errors.pageNotFoundDescription")}
|
||||
{t("errors.pageNotFoundDescription", "Gözleýän sahypaňyz ýok ýa-da başga ýere geçirilen bolup biler.")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -27,13 +27,13 @@ export default function NotFoundPage() {
|
||||
variant="outline"
|
||||
onClick={() => navigate(-1)}
|
||||
>
|
||||
{t("common.goBack")}
|
||||
{t("common.goBack", "Yza gaýt")}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => navigate("/")}
|
||||
>
|
||||
{t("common.backToHome")}
|
||||
{t("common.backToHome", "Baş sahypa")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import { useGetRequiredDocuments, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import type { LoanDocument } from '@/features/requiredDocuments/api/requiredDocumentsApi'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Column visibility defaults ───────────────────────────────────────────────
|
||||
|
||||
@@ -27,11 +28,16 @@ export default function RequiredDocumentsListPage() {
|
||||
// ── Data ────────────────────────────────────────────────────────────────────
|
||||
const { data, isLoading } = useGetRequiredDocuments({ page, perPage, search })
|
||||
const deleteMutation = useDeleteRequiredDocument()
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null)
|
||||
|
||||
const handleDelete = (id: number) => {
|
||||
if (window.confirm(t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?'))) {
|
||||
deleteMutation.mutate(id)
|
||||
}
|
||||
setDeleteId(id)
|
||||
}
|
||||
|
||||
const confirmDelete = () => {
|
||||
if (deleteId === null) return
|
||||
deleteMutation.mutate(deleteId)
|
||||
setDeleteId(null)
|
||||
}
|
||||
|
||||
// ── Columns ─────────────────────────────────────────────────────────────────
|
||||
@@ -134,6 +140,15 @@ export default function RequiredDocumentsListPage() {
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteId !== null}
|
||||
onOpenChange={(o) => { if (!o) setDeleteId(null) }}
|
||||
title={t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetRequiredDocumentById, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
export default function RequiredDocumentsViewPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const [deleteOpen, setDeleteOpen] = useState(false)
|
||||
|
||||
const docId = Number(id)
|
||||
const { data, isLoading } = useGetRequiredDocumentById(docId)
|
||||
const deleteMutation = useDeleteRequiredDocument()
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (window.confirm(t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?'))) {
|
||||
await deleteMutation.mutateAsync(docId)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
}
|
||||
await deleteMutation.mutateAsync(docId)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
@@ -50,7 +51,7 @@ export default function RequiredDocumentsViewPage() {
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleDelete}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="text-muted-foreground hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
@@ -112,6 +113,15 @@ export default function RequiredDocumentsViewPage() {
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?')}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={handleDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -6,20 +6,11 @@ import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar, type ActiveFilter } from '@/components/dataTableToolbar'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
|
||||
import { useUsers, useDeleteUser } from '@/features/allUsers/hooks/useAllUsers'
|
||||
import type { UserListItem } from '@/features/allUsers/api/allUsersApi'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
|
||||
// ─── Constants ────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -245,31 +236,18 @@ export default function UsersListPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Delete confirm dialog */}
|
||||
<AlertDialog open={!!deleteTarget} onOpenChange={(o) => !o && setDeleteTarget(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'users.deleteDialog.description',
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace('{name}', deleteTarget?.username ?? '')}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýok')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteConfirm}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{t('common.delete', 'Öçür')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
|
||||
description={t(
|
||||
'users.deleteDialog.description',
|
||||
'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
|
||||
).replace('{name}', deleteTarget?.username ?? '')}
|
||||
confirmLabel={t('common.delete', 'Öçür')}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
isLoading={deleteUser.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -2,16 +2,7 @@ import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
@@ -189,33 +180,22 @@ export default function ClientsPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<AlertDialog open={!!deleteTarget} onOpenChange={(open) => !open && setDeleteTarget(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('clients.deleteTitle', 'Müşderini pozmak')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.', {
|
||||
name: deleteTarget?.name ?? '',
|
||||
})}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id, {
|
||||
onSuccess: () => setDeleteTarget(null),
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t('clients.deleteTitle', 'Müşderini pozmak')}
|
||||
description={t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.', {
|
||||
name: deleteTarget?.name ?? '',
|
||||
})}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id)
|
||||
setDeleteTarget(null)
|
||||
}
|
||||
}}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import { useState } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, ChevronDown } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { ConfirmDialog } from '@/components/confirmDialog'
|
||||
import { InfoRow, AuditLog } from '@/components/viewPageComponents'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
@@ -448,26 +439,15 @@ export default function ClientDetailPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
{/* ── Delete dialog ────────────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('clients.deleteTitle', 'Müşderini pozmak')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi?', { name: client.name })}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => deleteMutation.mutate(clientId, { onSuccess: () => navigate('/clients') })}
|
||||
>
|
||||
{t('common.delete', 'Poz')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t('clients.deleteTitle', 'Müşderini pozmak')}
|
||||
description={t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi?', { name: client.name })}
|
||||
confirmLabel={t('common.delete', 'Poz')}
|
||||
onConfirm={() => deleteMutation.mutate(clientId, { onSuccess: () => navigate('/clients') })}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,16 +2,7 @@ import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Eye, Pencil, CheckCircle2, XCircle } from "lucide-react";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -226,40 +217,20 @@ export default function OperatorsPage() {
|
||||
</div>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog
|
||||
<ConfirmDialog
|
||||
open={!!deleteTarget}
|
||||
onOpenChange={(open) => !open && setDeleteTarget(null)}
|
||||
>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t("operators.deleteTitle", "Operatory pozmak")}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
"operators.deleteConfirm",
|
||||
"{{name}} operatoryny pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.",
|
||||
{ name: deleteTarget?.name ?? "" },
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id, {
|
||||
onSuccess: () => setDeleteTarget(null),
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
onOpenChange={(o) => { if (!o) setDeleteTarget(null) }}
|
||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
description={t("operators.deleteDescription", 'Siz "{name}" operatoryny pozjakmy?').replace("{name}", deleteTarget?.name ?? "")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() => {
|
||||
if (deleteTarget) {
|
||||
deleteMutation.mutate(deleteTarget.id)
|
||||
setDeleteTarget(null)
|
||||
}
|
||||
}}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,16 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { Pencil, Trash2, ChevronDown } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
import { InfoRow, AuditLog } from "@/components/viewPageComponents";
|
||||
import { DataTable, type ColumnDef } from "@/components/dataTable";
|
||||
import { DataTableToolbar } from "@/components/dataTableToolbar";
|
||||
@@ -427,32 +418,15 @@ export default function OperatorDetailPage() {
|
||||
{/* ── Audit log ────────────────────────────────────────────────────── */}
|
||||
<AuditLog logs={auditLogs} />
|
||||
|
||||
{/* ── Delete dialog ────────────────────────────────────────────────── */}
|
||||
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t("operators.deleteTitle", "Operatory pozmak")}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", {
|
||||
name: operator.name,
|
||||
})}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t("common.cancel", "Ýatyr")}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
|
||||
onClick={() =>
|
||||
deleteMutation.mutate(operatorId, {
|
||||
onSuccess: () => navigate("/operators"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("common.delete", "Poz")}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
<ConfirmDialog
|
||||
open={deleteOpen}
|
||||
onOpenChange={setDeleteOpen}
|
||||
title={t("operators.deleteTitle", "Operatory pozmak")}
|
||||
description={t("operators.deleteConfirm", "{{name}} operatoryny pozmak isleýärsiňizmi?", { name: operator.name })}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={() => deleteMutation.mutate(operatorId, { onSuccess: () => navigate("/operators") })}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user