fix: include order_list fields in queries and map to frontend object

This commit is contained in:
Codex 2026-05-19 10:37:40 +03:00
parent 0056e71b39
commit 3728ed0e95
2 changed files with 8 additions and 6 deletions

View File

@ -41,9 +41,9 @@ const renderValue = (value) => value || "Нет данных";
const parseOrderList = (order) => { const parseOrderList = (order) => {
if (!order) return []; if (!order) return [];
if (order.order_list_structured) { if (order.orderListStructured) {
try { try {
const parsed = JSON.parse(order.order_list_structured); const parsed = JSON.parse(order.orderListStructured);
if (parsed && Array.isArray(parsed.orders)) { if (parsed && Array.isArray(parsed.orders)) {
return parsed.orders; return parsed.orders;
} }
@ -52,9 +52,9 @@ const parseOrderList = (order) => {
} }
} }
if (order.order_list) { if (order.orderList) {
try { try {
const parsed = JSON.parse(order.order_list); const parsed = JSON.parse(order.orderList);
if (Array.isArray(parsed)) { if (Array.isArray(parsed)) {
return parsed; return parsed;
} }

View File

@ -128,6 +128,8 @@ export const mapOrderGroupRowToDeliveryGroup = (row) => {
legacyOrdersReady: row.legacy_orders_ready ?? null, legacyOrdersReady: row.legacy_orders_ready ?? null,
legacyOrdersNotReady: row.legacy_orders_not_ready ?? null, legacyOrdersNotReady: row.legacy_orders_not_ready ?? null,
sourceOrders: row.source_orders || null, sourceOrders: row.source_orders || null,
orderList: row.order_list || null,
orderListStructured: row.order_list_structured || null,
createdAt: row.created_at, createdAt: row.created_at,
updatedAt: row.updated_at, updatedAt: row.updated_at,
deliveryStatus, deliveryStatus,
@ -197,7 +199,7 @@ export const updateOrderGroupDeliveryChoice = async ({
const { data, error } = await client const { data, error } = await client
.from("order_groups") .from("order_groups")
.select("id, group_key, order_numbers, status, delivery_status, sms_sent_at, created_at, updated_at, created_from_exchange_at, source_key, customer_name, customer_phone, customer_phone_normalized, customer_date, orders_total, orders_ready, orders_not_ready, source_orders, delivery_invitation_id, delivery_link, notification_status, sms_attempts, first_sms_sent_at, second_sms_sent_at, last_sms_error, next_notification_check_at, delivery_date, delivery_time, delivery_address, manual_confirmation_at, assigned_driver_id, assigned_driver:users!order_groups_assigned_driver_id_fkey(id, name)") .select("id, group_key, order_numbers, status, delivery_status, sms_sent_at, created_at, updated_at, created_from_exchange_at, source_key, customer_name, customer_phone, customer_phone_normalized, customer_date, orders_total, orders_ready, orders_not_ready, source_orders, order_list, order_list_structured, delivery_invitation_id, delivery_link, notification_status, sms_attempts, first_sms_sent_at, second_sms_sent_at, last_sms_error, next_notification_check_at, delivery_date, delivery_time, delivery_address, manual_confirmation_at, assigned_driver_id, assigned_driver:users!order_groups_assigned_driver_id_fkey(id, name)")
.eq("id", orderGroupId) .eq("id", orderGroupId)
.single(); .single();
@ -280,7 +282,7 @@ export const fetchOrderGroups = async () => {
const client = requireSupabase(); const client = requireSupabase();
const { data, error } = await client const { data, error } = await client
.from("order_groups") .from("order_groups")
.select("id, group_key, order_numbers, status, delivery_status, sms_sent_at, created_at, updated_at, created_from_exchange_at, source_key, customer_name, customer_phone, customer_phone_normalized, customer_date, orders_total, orders_ready, orders_not_ready, source_orders, delivery_invitation_id, delivery_link, notification_status, sms_attempts, first_sms_sent_at, second_sms_sent_at, last_sms_error, next_notification_check_at, delivery_date, delivery_time, delivery_address, manual_confirmation_at, assigned_driver_id, assigned_driver:users!order_groups_assigned_driver_id_fkey(id, name)") .select("id, group_key, order_numbers, status, delivery_status, sms_sent_at, created_at, updated_at, created_from_exchange_at, source_key, customer_name, customer_phone, customer_phone_normalized, customer_date, orders_total, orders_ready, orders_not_ready, source_orders, order_list, order_list_structured, delivery_invitation_id, delivery_link, notification_status, sms_attempts, first_sms_sent_at, second_sms_sent_at, last_sms_error, next_notification_check_at, delivery_date, delivery_time, delivery_address, manual_confirmation_at, assigned_driver_id, assigned_driver:users!order_groups_assigned_driver_id_fkey(id, name)")
.order("updated_at", { ascending: false }); .order("updated_at", { ascending: false });
if (error) { if (error) {