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