Commit Graph

197 Commits

Author SHA1 Message Date
root eabf30bceb fix: stop SMS UI for terminal delivery statuses (picked_up/delivered/cancelled)
- SmsStatusCard: show "SMS не отправляется" when delivery is terminal, hide countdown + restart buttons
- SmsCampaignPanel fmtAgreement: check terminal status FIRST → " Самовывоз завершён" instead of "Самовывоз (неполно)"
- update_delivery_status RPC: reset notification_status→completed on terminal transition
- Add completed to notification_status check constraint
- SW v60→v61
2026-07-04 11:27:03 +00:00
root 43d9116c51 fix: restore localStorage filter persistence in LogisticsReadinessBoard, SW v60 2026-07-03 15:04:05 +00:00
root 468c3c4097 fix: sessionStorage→localStorage for filter persistence, SW v59 2026-07-03 14:14:00 +00:00
root 1d288279c0 fix: extractCity word boundary + filter persistence in sessionStorage 2026-07-03 14:07:13 +00:00
root 8ade6a6ff3 fix: fallback fresh slots when all availableSlots passed + SW v57 2026-07-03 13:37:42 +00:00
root a74a5242b8 fix: use current date for slot availability + SW v56 2026-07-03 13:32:24 +00:00
root e93215f837 feat: SMS filter no_sms in queue + SW v55 2026-07-03 13:26:13 +00:00
root 6a34f36621 SW v54 — business schedule 2026-07-03 12:45:26 +00:00
root d397d0cb24 feat: configurable business schedule (delivery/pickup/SMS days)
- New table business_schedule_settings (delivery_days, pickup_days, sms_days)
- RPC get_business_schedule() (public) + update_business_schedule() (admin)
- Admin UI: BusinessSchedulePanel with day pills for each category
- ClientDeliveryPage: fetches schedule, replaces hardcoded Sunday/weekend checks
- PickupSlotsPicker: uses pickupDays prop instead of hardcoded isWeekend
- Edge function confirm-delivery-choice: reads delivery_days from DB
- delivery-invitations.ts: buildDefaultDatedAvailableSlots reads delivery_days
- RPC confirm_delivery_choice_by_token: checks delivery_days instead of extract(dow)=0
- SMS scripts: get_sms_days() reads sms_days from business_schedule_settings
  and overrides per-campaign work_days setting
- Nav item Расписание for mega_admin and admin roles
- Default: Mon-Fri (1,2,3,4,5) for all three categories
2026-07-03 12:45:02 +00:00
root d4d85bc767 fix: normalize_phone handles +7, 8, text, and multi-number fields
- Two numbers in one field (XXX / YYY) → take first 10 digits
- Text in field (Екатерина +7978...) → extract digits only
- 8 prefix → 7 (Russian landline style)
- 10 digits (no country code) → prepend 7
- All 4 SMS scripts patched (first, second, paid_storage)
2026-07-03 12:33:53 +00:00
root e55a4cafcc fix: manual_campaign EXISTS check — no manual_required without SMS sent
Scenario 3 (link_ready + next_check expired) now requires EXISTS
in sms_campaign_log. Prevents groups from being moved to
manual_required before first SMS is ever sent.
2026-07-03 12:18:28 +00:00
root db57624626 merge: resolve conflicts (our SmsCampaignPanel + SW v43) 2026-07-01 16:20:12 +00:00
root b78bdc48bb feat: drag-n-drop status sections + localStorage filters/collapsed + pickup date in logistics board
- Drag-n-drop reordering of status sections (desktop + touch)
- Section order saved in localStorage (logistics-section-order)
- Collapsed/expanded state saved in localStorage (logistics-collapsed)
- Filters (city, status, search) saved in localStorage (logistics-filters)
- Pickup date shown in delivery date column for self-pickup orders
- SMS campaign scripts (manual, second, paid_storage, timer manager)
- SmsCampaignStats + SmsStatusCard components
- DashboardPage: unified LogisticsReadinessBoard for all roles
- OrdersTable cleanup, StatusActionPanel updates
- SW v42
2026-07-01 16:16:22 +00:00
root 581239cc73 fix: unify table styles — no rounded rows, wider type col, horizontal scroll, pagination by filtered groups 2026-06-30 11:43:15 +00:00
root c0c549adca feat: show delivery type (pickup/delivery) in logistics board + driver planner 2026-06-30 09:04:27 +00:00
root 858d36e5b0 feat: manual SMS campaign shows groups in manual mode + pagination on all delivery pages 2026-06-30 07:30:12 +00:00
root 93d3ce4ca8 fix: manage-users — remove manual public.users insert, trigger handle_new_user does it via user_metadata 2026-06-30 07:04:24 +00:00
root cadcceef7e feat: manage-users edge function — admin user CRUD (create/delete) 2026-06-30 06:55:55 +00:00
root 4215001ab7 feat: test_mode toggle in admin + cache bump v10
- test_mode + test_phone columns in sms_campaign_settings (DB)
- Script reads test_mode from DB settings, not env vars
- Admin panel: toggle Test/Production mode with visual indicator
- test_mode=true (default): SMS only to test_phone
- test_mode=false: SMS to real customers
- Service worker cache v9 → v10 (fixes white screen)
2026-06-23 08:58:59 +00:00
root f264a53c0a feat: SmsCampaignPanel — SMS log + settings in mega_admin dashboard
- sms_campaign_log table: full audit trail (phone, sms_id, status, code, attempts)
- sms_campaign_settings: editable by megaadmin (wait times, max attempts, delays)
- New tab 'SMS-кампании' in mega_admin navigation
- State machine: no blocking sleeps, fast cron runs
- Protection: no duplicate SMS within 24h, code 231/132 = limit, not retry
2026-06-23 08:39:24 +00:00
root 174c74ec0b fix: DB host 10.0.4.5 (Docker internal IP) 2026-06-23 08:21:57 +00:00
root 05d4d86d37 feat: Python script replacing n8n first SMS campaign
- sms_first_campaign.py: full replacement for n8n workflow JnfZwOnpjEazseW5
- sms_campaign_log table: full audit trail in Supabase (visible in admin)
- sms_campaign_settings table: configurable by megaadmin (wait times, attempts, schedule)
- systemd service + timer (NOT activated, ready for deployment)
- Logic: send SMS → wait 25s → check status (102=in transit, 103=delivered)
  → retry check up to 90 min → retry SMS send up to 2 attempts → manual_required
- Telegram notifications after each send/delivery/failure
- Log file: /var/log/supersam-sms-first.log
2026-06-23 08:20:42 +00:00
root f792ea6fb9 fix: table fonts 12px (text-xs), compact padding py-1.5 2026-06-23 08:01:49 +00:00
root b0370ed03e fix: handle status=first_sms_sent when notification_status=link_ready
n8n workflow writes status='first_sms_sent' but leaves notification_status='link_ready'.
Added first_sms_sent/second_sms_sent to ORDER_GROUP_STATUS_LABELS and tone logic.
2026-06-23 07:53:01 +00:00
root a55e5857f8 fix: add SMS notification statuses to filter options, increase Badge font size
- Add first_sms_sent, second_sms_sent, send_failed, link_ready, ready_to_launch
  to ORDER_GROUP_DISPLAY_STATUS_OPTIONS (were missing from filter dropdown)
- Badge: text-xs (12px) → text-sm (14px), font-semibold → font-medium,
  px-3 py-1 → px-2.5 py-0.5 (matches table text size, less padding)
2026-06-23 07:38:54 +00:00
root bbe578eb3a fix: parseGroupDate now handles DD.MM.YYYY (4-digit year) format
customer_date in DB is stored as 23.06.2026 (DD.MM.YYYY) but parseGroupDate
only matched DD.MM.YY (2-digit year). This caused date filter to reject all
groups when filtering by date range, since parseGroupDate returned null
for 4-digit year dates.
2026-06-23 07:22:09 +00:00
root 45dbbd4cb3 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
2026-06-23 05:15:58 +00:00
root a879ad01c3 fix: get_delivery_invitation_by_token returns full order composition with items
RPC was returning only top-level invoice numbers (nom) without the nested
product items inside orderList[].items[]. Now returns {name, quantity, items}
structure matching flattenOrderProducts() expectations in OrderCompositionPanel.

Before: orderItems = [{name: 'ТП-008590', quantity: '1'}]
After:  orderItems = [{name: 'ТП-008590', items: [{name: 'СФ Т\ЕА-28944', items: [{product_name, product_quantity, product_ed}]}]}]

Also includes stop words, delivery type, pickup code, payed_ship fields.
2026-06-23 05:12:00 +00:00
root b74add32ef fix: skip Sunday in delivery date selection (client flow + backend validation)
- buildDefaultDatedAvailableSlots(): skip Sunday via getNextWorkday()
- ClientDeliveryPage.jsx: getAllowedDeliveryDateKeys() + fallback slots skip Sunday
- confirm-delivery-choice edge function: reject Sunday for delivery
- confirm_delivery_choice_by_token SQL RPC: extract(dow) = 0 → RAISE EXCEPTION
- Tests: Friday→Sat+Mon, Saturday→Mon+Tue (skip Sunday)
- Skill updated with pitfall
2026-06-23 04:56:49 +00:00
root d04901d296 security: fix 9 vulnerabilities + OrdersTable 14px font + colored status badges
Security fixes:
- Remove VITE_SUPABASE_SERVICE_ROLE_KEY from Docker build args
- Add missing security.ts functions (verifyInternalRequest, requireSameOrigin, etc)
- Store only OTP hash, remove plaintext otp_code
- Fix CORS origin check: startsWith → exact match
- Use atomic SQL check_rate_limit RPC instead of JS rate limiter
- Mask PII in get_delivery_invitation_by_token single-order path
- Add RequireAuth wrapper for protected routes
- Revoke anon execute on confirm_delivery_choice_by_token
- Add HSTS header to Caddyfile

UI:
- OrdersTable desktop: all cells text-sm (14px)
- Status column: use colored Badge with tone from getOrderGroupStatusTone
- Header row: text-sm (14px)
2026-06-19 12:14:19 +00:00
root cdb2ec7098 fix: Button→native button everywhere, table font 12px, dropdowns cleanup
- OrdersTable: font text-xs (12px), headers 11px, city column, horizontal scroll
- OrderFilters: dropdown items native button, no ovals, counter as plain text
- DriverAssignmentPanel: custom DriverDropdown in app style
- StopWordsPanel: all Button→button
- UserManagementPanel: all Button→button, RoleDropdown native
- SuggestionsPanel: all Button→button
- ActionLogPanel: Button→button
- ErrorLogPanel: all Button→button
- OrderDetailPanel: delivery tabs, problem reasons, expand toggle→button
- CalendarWidget: month nav arrows→button
- AppShell: nav buttons variant=ghost
- NotificationBell: buttons→native
- ClientDeliveryPage: hide delivery status badge, pickup code block
- PickupSlotsPicker: fix today morning slot logic
2026-06-19 11:36:45 +00:00
root 17fe2125a5 fix: replace Button with native button for mobile cards — proper left-align
Button component forces inline-flex items-center justify-center rounded-full
which was overriding all alignment. Switched to native <button> with
flex flex-col items-start justify-start. SW v8→v9.
2026-06-18 18:35:42 +00:00
root 28ccb655d3 fix: mobile card — no phone, show ordersTotal badge, cache-control headers
Mobile: removed phone + buildGroupSummary, kept name + type badge + status +
  order numbers + count badge (N сч.)
Caddyfile: Cache-Control immutable for assets, no-cache for HTML+SW
SW v7→v8
2026-06-18 17:56:37 +00:00
root 7b773dd4aa fix: mobile card left-align (!items-start !justify-start override Button center)
Button base has inline-flex items-center justify-center — overriding with
!important Tailwind utilities for mobile cards. SW cache v6→v7.
2026-06-18 17:48:19 +00:00
root 921b7dbf00 fix: bump SW cache v5→v6, force client cache bust 2026-06-18 17:33:14 +00:00
root 05b81cf128 fix: client name wraps to 2 lines in desktop table, prevents column stretch 2026-06-18 17:27:16 +00:00
root b721b26ce8 test: webhook autodeploy fix check 2026-06-18 17:22:07 +00:00
root 9fe8418d3e test: webhook autodeploy check 2026-06-18 17:17:19 +00:00
root 0b0626daa5 fix: restore mobile card (name+phone), remove updatedAt column, clean layout
Mobile: restored customer name + phone, buildGroupSummary, delivery type badge
Desktop: removed 'Обновлён' column (7→6 cols), grid updated
Server: added WatchdogSec=30 + Type=notify + sd_notify heartbeat to webhook-listener
2026-06-18 17:13:05 +00:00
root aefc588844 fix: clean up mobile card + desktop first column
Mobile card: removed phone, dates, updatedAt, buildGroupSummary — kept only
  name + delivery type badge + status badge + order numbers + problem alert
Desktop first column: removed duplicate name and groupKey (phone|date),
  kept only name + phone
2026-06-18 16:40:23 +00:00
root 693da3236e feat: payment + manager info in detail card, delivery type badge in mobile header
- orderGroupRepository: added manager_name, manager_email, manager_tel, payed_ship, is_payed_ship to SELECT
- OrderDetailPanel: manager name + tel, payment status with amount (✓ Оплачено + ₽), hidden for drivers
- OrdersTable mobile: delivery type badge moved to header row next to status badge
  - 🏪 Самовывоз (accent color) / 🚚 Доставка — immediately visible at top of card
2026-06-18 16:34:22 +00:00
root 7054390dcb feat: add delivery link panel in OrderDetail for non-driver roles
- Map delivery_link DB field to deliveryLink in order group object
- New panel in OrderDetailPanel: 'Ссылка на согласование'
- Two buttons: open approval page (link) + copy link to clipboard
- Visible for all roles except driver
- Shows when order.deliveryLink is present
2026-06-18 15:15:43 +00:00
root 54386e9710 feat: Тип column replaces Проблема, red highlight for problem rows, delivery type filter, clean status options
- OrdersTable: replaced 'Проблема' column with 'Тип' (Самовывоз/Доставка)
- Problem rows highlighted red (bg rgba danger 10%)
- Mobile cards also show Тип label
- OrderFilters: added deliveryType dropdown (Доставка/Самовывоз)
- filterOrderGroups: filter by deliveryType
- useOrderGroups: deliveryType in default filters state
- Cleaned ORDER_GROUP_DISPLAY_STATUS_OPTIONS: removed 'Повторное SMS' and 'SMS отправлены' (not used)
2026-06-18 15:00:58 +00:00
root 8d3d8dc0fe refactor: unify all buttons to <Button> component across app
- Replace 82 inline <button> elements with <Button variant/size> in 19 files
- UI primitives (SegmentedTabs, ThemeToggle, DatePicker) and ErrorBoundary kept as-is
- Consistent styling: primary (accent), secondary (outline), ghost (transparent)
2026-06-16 20:11:57 +00:00
root d28e00782b fix: never show raw English status keys to user — fall back to 'Неизвестно (key)' 2026-06-16 13:29:38 +00:00
root f1e2b47396 fix: refetch order groups on window focus and GroupDetailPage mount to prevent stale status 2026-06-16 13:25:41 +00:00
root 37ea7d3a19 fix: убрать генерацию pickup_code — приходит из 1С, показывать только при самовывозе 2026-06-16 07:36:47 +00:00
root 9408b98f06 fix: pickup_code — 6-значное число вместо букв 2026-06-16 06:57:57 +00:00
root 5867272873 feat: pickup_code для самовывоза + упрощение статуса отгрузки
- pickup_code: автогенерация 6-значного кода при выборе самовывоза
- Колонка pickup_code в order_groups + SELECT
- Отображение кода выдачи в карточках (логист, клиент)
- Упрощение: любая отгрузка → delivered (проблемы в has_delivery_problem)
- RPC: добавлены deliveryType, pickupCode, pickupDate, pickupTimeSlot
2026-06-16 06:53:12 +00:00
root 6184f5aeed fix: авто-статус delivered при полной отгрузке (включая с комментарием)
Раньше: все позиции отгружены → delivered, иначе → problem
Теперь: все отгружены ИЛИ все неотгруженные с комментарием → delivered
Только если есть неотгруженные без комментария → problem
2026-06-16 06:33:55 +00:00