feat: Telegram admin notification on order status change
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,31 @@ const OrderModal = ({ order, onClose, onSaved, mode = 'edit' }) => {
|
||||
: 'Данные заказа обновлены',
|
||||
});
|
||||
if (evtErr) console.error('Failed to log order event:', evtErr);
|
||||
|
||||
if (statusChanged) {
|
||||
const message =
|
||||
`📋 Статус заказа изменён\n\n` +
|
||||
`Клиент: ${form.name}\n` +
|
||||
`Телефон: ${form.phone}\n` +
|
||||
(form.telegram_username ? `Telegram: ${form.telegram_username}\n` : '') +
|
||||
(form.max_username ? `Max: ${form.max_username}\n` : '') +
|
||||
`Статус: ${order.status} → ${form.status}\n` +
|
||||
(form.address ? `Адрес: ${form.address}\n` : '') +
|
||||
(form.final_cost ? `Сумма: ${Number(form.final_cost).toLocaleString('ru-RU')} ₽\n` : '');
|
||||
|
||||
fetch(
|
||||
`https://api.telegram.org/bot${import.meta.env.VITE_TG_BOT_TOKEN}/sendMessage`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
chat_id: import.meta.env.VITE_TG_CHAT_ID,
|
||||
text: message,
|
||||
parse_mode: 'HTML',
|
||||
}),
|
||||
}
|
||||
).catch(() => {});
|
||||
}
|
||||
}
|
||||
setSaving(false);
|
||||
onSaved?.();
|
||||
|
||||
Reference in New Issue
Block a user