Add znzt module
Deploy Manager App / deploy (push) Successful in 19s
Details
Deploy Manager App / deploy (push) Successful in 19s
Details
This commit is contained in:
parent
631b474367
commit
b5d38925e9
|
|
@ -156,26 +156,53 @@ export default function OrdersPage({ onError }: { onError: (msg: string) => void
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (isReadOnly) return;
|
if (isReadOnly) return;
|
||||||
|
|
||||||
for (const [clientName, order] of Object.entries(editableOrders)) {
|
for (const [clientName, order] of Object.entries(editableOrders)) {
|
||||||
|
// 1. Проверка комментария (уже была)
|
||||||
if (!order.manager_comment || order.manager_comment.trim() === '') {
|
if (!order.manager_comment || order.manager_comment.trim() === '') {
|
||||||
return notifications.show({ title: 'Внимание', message: `Комментарий обязателен для клиента "${clientName}"!`, color: 'yellow' })
|
return notifications.show({
|
||||||
|
title: 'Внимание',
|
||||||
|
message: `Комментарий обязателен для клиента "${clientName}"!`,
|
||||||
|
color: 'yellow'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasItems = order.items && order.items.some(i => i.quantity && i.quantity > 0);
|
||||||
|
|
||||||
|
if (hasItems) {
|
||||||
|
// Если заказ есть, проверяем обязательность метаданных: Декада, Доставка, Условия, Оплата
|
||||||
|
const missingMeta = [];
|
||||||
|
if (!order.decade) missingMeta.push('Декада');
|
||||||
|
if (!order.delivery) missingMeta.push('Доставка');
|
||||||
|
if (!order.conditions) missingMeta.push('Условия');
|
||||||
|
if (!order.payment_form) missingMeta.push('Оплата');
|
||||||
|
|
||||||
|
if (missingMeta.length > 0) {
|
||||||
|
return notifications.show({
|
||||||
|
title: 'Неполные данные заказа',
|
||||||
|
message: `Для клиента "${clientName}" указан заказ, но не заполнены поля: ${missingMeta.join(', ')}. Настройте их через иконку шестеренки в шапке таблицы.`,
|
||||||
|
color: 'red',
|
||||||
|
autoClose: 7000
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setSaving(true)
|
setSaving(true);
|
||||||
await monthlyOrdersApi.saveOrders(Object.values(editableOrders))
|
await monthlyOrdersApi.saveOrders(Object.values(editableOrders));
|
||||||
localStorage.removeItem(DRAFT_KEY);
|
localStorage.removeItem(DRAFT_KEY);
|
||||||
localStorage.removeItem(DRAFT_TIME_KEY);
|
localStorage.removeItem(DRAFT_TIME_KEY);
|
||||||
setDraftSavedAt(null);
|
setDraftSavedAt(null);
|
||||||
|
|
||||||
notifications.show({ title: 'Успешно', message: 'Заказы сохранены', color: 'green' })
|
notifications.show({ title: 'Успешно', message: 'Заказы сохранены', color: 'green' });
|
||||||
loadData(true)
|
loadData(true);
|
||||||
} catch {
|
} catch {
|
||||||
notifications.show({ title: 'Ошибка', message: 'Сбой при сохранении', color: 'red' })
|
notifications.show({ title: 'Ошибка', message: 'Сбой при сохранении', color: 'red' });
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false)
|
setSaving(false);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleResetDraft = () => {
|
const handleResetDraft = () => {
|
||||||
if (isReadOnly) return;
|
if (isReadOnly) return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue