added confirm dialog, some translations
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user