chore(admin-ui): диагностическая инструментация сохранения записи [TEMP]
ВРЕМЕННО — для поиска причины «Save ничего не делает». Откатить после диагностики (все логи помечены [ordinis-diag]). SchemaDrivenForm: console.warn в submit() — событие формы, RHF onInvalid, результат AJV, ветки return, вызов onSubmit. dictionaries.$name: логи в route.handleSubmit + createMut/updateMut mutate + onSuccess/onError со статусом ответа. Также добавлен постоянный регресс-тест: повторный submit после исправления валидации вызывает onSubmit.
This commit is contained in:
@@ -578,6 +578,12 @@ function DictionaryDetail() {
|
||||
const rawRecordQuery = useRecordRaw(name, editingKey)
|
||||
|
||||
const handleSubmit = (req: CreateRecordRequest) => {
|
||||
// [ordinis-diag] DIAGNOSTIC BUILD — удалить после диагностики.
|
||||
console.warn('[ordinis-diag] route.handleSubmit(): получен req от формы', {
|
||||
editKind: edit.kind,
|
||||
approvalRequired,
|
||||
businessKey: req.businessKey,
|
||||
})
|
||||
// Fill validFrom at submit (review #5): defaultValues в RHF берётся
|
||||
// ТОЛЬКО при mount. Если user открыл modal в 12:00 и submit в 12:05 —
|
||||
// `validFrom` в req это значение из 12:00. Backend check `validFrom >
|
||||
@@ -631,14 +637,20 @@ function DictionaryDetail() {
|
||||
)
|
||||
return
|
||||
}
|
||||
console.warn('[ordinis-diag] route: вызываю createMut.mutate() — POST /records')
|
||||
createMut.mutate(
|
||||
{ payload: submitReq, idempotencyKey: recordIdempotencyKey },
|
||||
{
|
||||
onSuccess: () => {
|
||||
console.warn('[ordinis-diag] createMut onSuccess — запись создана')
|
||||
setEdit({ kind: 'closed' })
|
||||
resetRecordIdempotencyKey()
|
||||
},
|
||||
onError: (err) => {
|
||||
console.warn('[ordinis-diag] createMut onError', {
|
||||
status: (err as { response?: { status?: number } })?.response?.status,
|
||||
data: (err as { response?: { data?: unknown } })?.response?.data,
|
||||
})
|
||||
// Create rarely conflicts (no prior record to lock), но если backend
|
||||
// вернёт 409 по уникальному ключу — businessKey возьмём из payload.
|
||||
handleSaveError(err, submitReq.businessKey ?? '')
|
||||
@@ -669,6 +681,7 @@ function DictionaryDetail() {
|
||||
)
|
||||
return
|
||||
}
|
||||
console.warn('[ordinis-diag] route: вызываю updateMut.mutate() — PUT /records/' + edit.record.businessKey)
|
||||
updateMut.mutate(
|
||||
{
|
||||
businessKey: edit.record.businessKey,
|
||||
@@ -677,10 +690,17 @@ function DictionaryDetail() {
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
console.warn('[ordinis-diag] updateMut onSuccess — запись обновлена')
|
||||
setEdit({ kind: 'closed' })
|
||||
resetRecordIdempotencyKey()
|
||||
},
|
||||
onError: (err) => handleSaveError(err, edit.record.businessKey),
|
||||
onError: (err) => {
|
||||
console.warn('[ordinis-diag] updateMut onError', {
|
||||
status: (err as { response?: { status?: number } })?.response?.status,
|
||||
data: (err as { response?: { data?: unknown } })?.response?.data,
|
||||
})
|
||||
handleSaveError(err, edit.record.businessKey)
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user