feat: show client page open analytics in OrderDetailPanel
- Add delivery_invitation nested select (opened_at, access_count, last_accessed_at) - Map to invitationOpenedAt, invitationAccessCount, invitationLastAccessedAt - Show in 'Ссылка на согласование' panel: 'Клиент открывал страницу X раз, последний раз DD.MM' - Or 'Клиент ещё не открывал страницу согласования' - Data only updated by client-facing RPC, not by admin actions
This commit is contained in:
parent
a879ad01c3
commit
45dbbd4cb3
|
|
@ -1224,6 +1224,15 @@ export const OrderDetailPanel = ({
|
|||
</span>
|
||||
</Button>
|
||||
</div>
|
||||
{order.invitationAccessCount > 0 ? (
|
||||
<p className="text-sm text-[var(--color-text-muted)]">
|
||||
👁 Клиент открывал страницу {order.invitationAccessCount} раз{(order.invitationLastAccessedAt || order.invitationOpenedAt) ? `, последний раз ${new Date(order.invitationLastAccessedAt || order.invitationOpenedAt).toLocaleDateString("ru-RU", { day: "2-digit", month: "2-digit", year: "2-digit" })}` : ""}.
|
||||
</p>
|
||||
) : (
|
||||
<p className="text-sm text-[var(--color-text-muted)]">
|
||||
⏳ Клиент ещё не открывал страницу согласования.
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
) : null}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,6 +231,9 @@ export const mapOrderGroupRowToDeliveryGroup = (row) => {
|
|||
managerTel: normalizeText(row.manager_tel) || null,
|
||||
payedShip: row.payed_ship || null,
|
||||
isPayedShip: row.is_payed_ship || false,
|
||||
invitationOpenedAt: row.delivery_invitation?.opened_at || null,
|
||||
invitationAccessCount: row.delivery_invitation?.access_count || 0,
|
||||
invitationLastAccessedAt: row.delivery_invitation?.last_accessed_at || null,
|
||||
deliveryHalfDay: getOrderGroupDeliveryHalfDay({
|
||||
deliveryHalfDay: rawDeliveryHalfDay,
|
||||
deliveryTime: rawDeliveryTime,
|
||||
|
|
@ -271,7 +274,7 @@ export const mapOrderGroupRowToDeliveryGroup = (row) => {
|
|||
};
|
||||
};
|
||||
|
||||
const ORDER_GROUP_SELECT_FIELDS = `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, delivery_link_code, 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, customer_address, delivery_date_source, manual_confirmation_at, paid_storage_at, assigned_driver_id, assigned_driver:users!order_groups_assigned_driver_id_fkey(id, name), driver_shipment_data, delivery_type, pickup_date, pickup_time_slot, has_delivery_problem, delivery_problem_note, pickup_code, synced_to_1c_at, manager_name, manager_email, manager_tel, payed_ship, is_payed_ship`;
|
||||
const ORDER_GROUP_SELECT_FIELDS = `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, delivery_link_code, 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, customer_address, delivery_date_source, manual_confirmation_at, paid_storage_at, assigned_driver_id, assigned_driver:users!order_groups_assigned_driver_id_fkey(id, name), driver_shipment_data, delivery_type, pickup_date, pickup_time_slot, has_delivery_problem, delivery_problem_note, pickup_code, synced_to_1c_at, manager_name, manager_email, manager_tel, payed_ship, is_payed_ship, delivery_invitation:delivery_invitations!order_groups_delivery_invitation_id_fkey(opened_at, access_count, last_accessed_at)`;
|
||||
|
||||
export const updateOrderGroupDeliveryChoice = async ({
|
||||
orderGroupId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue