adserver-dashboard 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ci/staging.yml +191 -0
- package/.dockerignore +117 -0
- package/.env +40 -0
- package/.env.staging +38 -0
- package/.gitlab-ci.yml +16 -0
- package/DEMO_STATUS.md +579 -0
- package/Dockerfile +61 -0
- package/Influence-MW-AdServer-12-02-2026/client/index.html +17 -0
- package/Influence-MW-AdServer-12-02-2026/client/public/favicon.png +0 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/App.tsx +91 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/advanced-map-drawer.tsx +1131 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ai-recommendation-panel.tsx +379 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/app-sidebar.tsx +183 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/auto-optimize-button.tsx +184 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/availability-drawer.tsx +385 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/brand-insights-panel.tsx +87 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/create-agency-drawer.tsx +198 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/create-brand-drawer.tsx +275 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/creative-assignment.tsx +526 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/data-table-toolbar.tsx +148 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/data-table.tsx +158 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/filter-drawer.tsx +356 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/form-insights-panel.tsx +82 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/geography-selector.tsx +699 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/header-user-menu.tsx +178 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/history-drawer.tsx +313 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/inventory-availability-section.tsx +176 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/inventory-format-drawer.tsx +173 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/inventory-selector.tsx +401 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/manual-inventory-drawer.tsx +368 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/mapbox-map.tsx +368 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/market-insights-panel.tsx +202 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/media-owner-drawer.tsx +217 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/metric-card.tsx +58 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/page-header.tsx +27 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/player-status-indicator.tsx +137 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/poi-targeting-drawer.tsx +298 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/recommendation-score-badge.tsx +102 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/recommended-inventories-panel.tsx +248 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/searchable-combobox.tsx +134 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/signal-visualizations.tsx +407 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/status-badge.tsx +35 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/theme-provider.tsx +73 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/theme-toggle.tsx +37 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/traffic-slider.tsx +75 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/accordion.tsx +56 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/alert-dialog.tsx +139 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/alert.tsx +59 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/aspect-ratio.tsx +5 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/avatar.tsx +51 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/badge.tsx +38 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/breadcrumb.tsx +115 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/button.tsx +62 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/calendar.tsx +68 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/card.tsx +85 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/carousel.tsx +260 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/chart.tsx +365 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/checkbox.tsx +28 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/collapsible.tsx +11 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/command.tsx +151 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/context-menu.tsx +198 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/dialog.tsx +122 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/drawer.tsx +118 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/dropdown-menu.tsx +198 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/form.tsx +178 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/hover-card.tsx +29 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/input-otp.tsx +69 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/input.tsx +23 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/label.tsx +24 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/menubar.tsx +256 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/navigation-menu.tsx +128 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/pagination.tsx +117 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/popover.tsx +29 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/progress.tsx +28 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/radio-group.tsx +42 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/resizable.tsx +45 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/scroll-area.tsx +46 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/select.tsx +160 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/separator.tsx +29 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/sheet.tsx +140 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/sidebar.tsx +727 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/skeleton.tsx +15 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/slider.tsx +26 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/switch.tsx +27 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/table.tsx +117 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/tabs.tsx +53 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/textarea.tsx +22 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toast.tsx +127 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toaster.tsx +33 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toggle-group.tsx +61 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/toggle.tsx +43 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/ui/tooltip.tsx +30 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/vendor-stores-modal.tsx +336 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/venue-type-drawer.tsx +359 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/components/venue-type-selector.tsx +436 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/hooks/use-mobile.tsx +19 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/hooks/use-toast.ts +191 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/index.css +244 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/lib/queryClient.ts +57 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/lib/utils.ts +39 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/lib/venue-taxonomy.ts +532 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/main.tsx +5 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/assign-creative.tsx +781 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/content-hub.tsx +995 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/custom-pois.tsx +431 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/dashboard.tsx +620 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/deal-detail.tsx +1062 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/deal-form.tsx +1570 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/deals.tsx +716 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/edit-creative-assignment.tsx +1051 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/geotargeting.tsx +675 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/integrations.tsx +425 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/line-item-creatives.tsx +622 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/line-item-form.tsx +3132 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/line-items.tsx +530 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/not-found.tsx +21 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/proof-of-play-upload.tsx +479 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/proof-of-play.tsx +880 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/reports.tsx +235 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/settings.tsx +652 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/signal-form.tsx +1117 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/signals.tsx +366 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/tags.tsx +332 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/pages/venues.tsx +381 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/types/mapbox-gl-draw.d.ts +37 -0
- package/Influence-MW-AdServer-12-02-2026/client/src/types/react-simple-maps.d.ts +57 -0
- package/Influence-MW-AdServer-12-02-2026/components.json +20 -0
- package/Influence-MW-AdServer-12-02-2026/docs/PRD.md +3373 -0
- package/Influence-MW-AdServer-12-02-2026/docs/influence-feature-mapping.csv +498 -0
- package/Influence-MW-AdServer-12-02-2026/drizzle.config.ts +14 -0
- package/Influence-MW-AdServer-12-02-2026/package-lock.json +9672 -0
- package/Influence-MW-AdServer-12-02-2026/package.json +118 -0
- package/Influence-MW-AdServer-12-02-2026/postcss.config.js +6 -0
- package/Influence-MW-AdServer-12-02-2026/replit.md +91 -0
- package/Influence-MW-AdServer-12-02-2026/script/build.ts +67 -0
- package/Influence-MW-AdServer-12-02-2026/scripts/create-miro-diagrams.cjs +318 -0
- package/Influence-MW-AdServer-12-02-2026/scripts/create-remaining-diagrams.cjs +270 -0
- package/Influence-MW-AdServer-12-02-2026/server/index.ts +103 -0
- package/Influence-MW-AdServer-12-02-2026/server/recommendation-service.ts +319 -0
- package/Influence-MW-AdServer-12-02-2026/server/routes.ts +1890 -0
- package/Influence-MW-AdServer-12-02-2026/server/static.ts +19 -0
- package/Influence-MW-AdServer-12-02-2026/server/storage.ts +2058 -0
- package/Influence-MW-AdServer-12-02-2026/server/vite.ts +58 -0
- package/Influence-MW-AdServer-12-02-2026/shared/schema.ts +1595 -0
- package/Influence-MW-AdServer-12-02-2026/tailwind.config.ts +107 -0
- package/Influence-MW-AdServer-12-02-2026/tsconfig.json +23 -0
- package/Influence-MW-AdServer-12-02-2026/vite.config.ts +40 -0
- package/LINE_ITEM_BUDGET_FIELD_MAPPING.md +178 -0
- package/PCM/.env.example +92 -0
- package/PCM/README.md +558 -0
- package/PCM/docs/TEST_CASES.md +422 -0
- package/PCM/index.js +106 -0
- package/PCM/package-lock.json +3282 -0
- package/PCM/package.json +32 -0
- package/PCM/replit.md +64 -0
- package/PCM/schema.sql +495 -0
- package/PCM/scripts/export-schema.js +183 -0
- package/PCM/scripts/seed-comprehensive.js +631 -0
- package/PCM/scripts/seed-production.js +477 -0
- package/PCM/src/config/db.js +56 -0
- package/PCM/src/config/swagger.js +5975 -0
- package/PCM/src/dto/EmailRequestDTO.js +166 -0
- package/PCM/src/middleware/errorHandler.js +52 -0
- package/PCM/src/middleware/logger.js +26 -0
- package/PCM/src/migrations/001_add_campaign_mode_fields.sql +36 -0
- package/PCM/src/migrations/002_create_deal_id_counters.sql +22 -0
- package/PCM/src/migrations/003_update_publishers_column.sql +15 -0
- package/PCM/src/migrations/004_add_direct_dealtype_and_advertiser.sql +5 -0
- package/PCM/src/migrations/005_add_programmatic_fields_and_update_enums.sql +31 -0
- package/PCM/src/migrations/006_add_line_item_programmatic_fields.sql +12 -0
- package/PCM/src/migrations/007_add_line_item_direct_fields.sql +15 -0
- package/PCM/src/migrations/008_add_inventory_fields.sql +45 -0
- package/PCM/src/migrations/009_move_inventory_fields_to_metadata.sql +32 -0
- package/PCM/src/migrations/010_add_draft_status_and_line_items_count.sql +23 -0
- package/PCM/src/migrations/011_add_planning_field.sql +21 -0
- package/PCM/src/migrations/012_fix_inventory_composite_pk.sql +17 -0
- package/PCM/src/migrations/013_make_external_id_optional.sql +3 -0
- package/PCM/src/migrations/014_create_change_history.sql +38 -0
- package/PCM/src/migrations/016_create_publisher_insertion_orders.sql +33 -0
- package/PCM/src/migrations/017_fix_line_item_id_fk_reference.sql +86 -0
- package/PCM/src/migrations/018_create_approval_tables.sql +44 -0
- package/PCM/src/migrations/019_add_encrypted_token_column.sql +2 -0
- package/PCM/src/migrations/020_add_rejection_reason_to_deals.sql +10 -0
- package/PCM/src/migrations/021_add_publisher_external_id_to_inventories.sql +12 -0
- package/PCM/src/migrations/022_add_line_item_extended_fields.sql +24 -0
- package/PCM/src/migrations/023_add_base_price_fields.sql +8 -0
- package/PCM/src/migrations/run-migrations.js +46 -0
- package/PCM/src/models/ApprovalOTP.js +51 -0
- package/PCM/src/models/ApprovalToken.js +79 -0
- package/PCM/src/models/ChangeHistory.js +107 -0
- package/PCM/src/models/Deal.js +186 -0
- package/PCM/src/models/DealIdCounter.js +28 -0
- package/PCM/src/models/LineItem.js +227 -0
- package/PCM/src/models/LineItemCreative.js +89 -0
- package/PCM/src/models/LineItemInventory.js +115 -0
- package/PCM/src/models/PublisherInsertionOrder.js +93 -0
- package/PCM/src/models/TransactionHistory.js +34 -0
- package/PCM/src/models/associations.js +81 -0
- package/PCM/src/routes/approval.js +321 -0
- package/PCM/src/routes/creatives.js +437 -0
- package/PCM/src/routes/deals.js +1638 -0
- package/PCM/src/routes/digitalSignage.js +242 -0
- package/PCM/src/routes/insertionOrders.js +380 -0
- package/PCM/src/routes/lineItems.js +926 -0
- package/PCM/src/routes/system.js +384 -0
- package/PCM/src/services/ApprovalService.js +885 -0
- package/PCM/src/services/CampaignImportConverter.js +631 -0
- package/PCM/src/services/CampaignModeService.js +273 -0
- package/PCM/src/services/CampaignStatusService.js +395 -0
- package/PCM/src/services/ChangeHistoryService.js +316 -0
- package/PCM/src/services/DealIdService.js +94 -0
- package/PCM/src/services/DealResponseFormatter.js +90 -0
- package/PCM/src/services/EmailNotificationService.js +315 -0
- package/PCM/src/services/LineItemResponseFormatter.js +122 -0
- package/PCM/src/services/LineItemStatusService.js +380 -0
- package/PCM/src/tests/comprehensiveTestRunner.js +360 -0
- package/PCM/src/tests/comprehensiveTests.js +1277 -0
- package/PCM/src/tests/dealTypeUnitTests.js +1058 -0
- package/PCM/src/tests/testRunner.js +248 -0
- package/PCM/src/utils/caseConverter.js +92 -0
- package/PCM/src/utils/dealCalculations.js +206 -0
- package/PCM/src/utils/lineItemPayloadNormalizer.js +41 -0
- package/PCM/src/utils/payloadNormalizer.js +34 -0
- package/PCM/src/utils/sourceNormalizer.js +56 -0
- package/PCM/src/validators/creativeValidator.js +27 -0
- package/PCM/src/validators/dealValidator.js +203 -0
- package/PCM/src/validators/lineItemValidator.js +489 -0
- package/PCM/tests/approval-flows.test.js +238 -0
- package/PCM/tests/approval-workflow.test.js +291 -0
- package/PCM/tests/campaign-import-converter.test.js +543 -0
- package/PCM/tests/campaign-import-e2e.test.js +520 -0
- package/PCM/tests/campaign-status.test.js +539 -0
- package/PCM/tests/direct-publisher-split-reimport.test.js +460 -0
- package/PCM/tests/e2e/digital-signage.test.js +145 -0
- package/PCM/tests/e2e/search-filter-pagination.test.js +399 -0
- package/PCM/tests/e2e-comprehensive.test.js +3446 -0
- package/PCM/tests/edge-cases.test.js +340 -0
- package/PCM/tests/line-item-status.test.js +340 -0
- package/PCM/tests/seller-account-external-ids.test.js +877 -0
- package/PCM/tests/source-validation.test.js +324 -0
- package/PRD.md +3373 -0
- package/README.md +186 -0
- package/client/index.html +35 -0
- package/client/public/DEMO_STATUS.md +579 -0
- package/client/public/img/MW-logo-trans_1754045676555.png +0 -0
- package/client/public/locales/ar/approval.json +144 -0
- package/client/public/locales/ar/buyer.json +61 -0
- package/client/public/locales/ar/campaigns.json +1 -0
- package/client/public/locales/ar/common.json +218 -0
- package/client/public/locales/ar/contentHub.json +266 -0
- package/client/public/locales/ar/creatives.json +79 -0
- package/client/public/locales/ar/dashboard.json +57 -0
- package/client/public/locales/ar/deals.json +886 -0
- package/client/public/locales/ar/dsp.json +131 -0
- package/client/public/locales/ar/inventory.json +201 -0
- package/client/public/locales/ar/lineItems.json +553 -0
- package/client/public/locales/ar/navigation.json +48 -0
- package/client/public/locales/ar/wizard.json +1 -0
- package/client/public/locales/en/approval.json +144 -0
- package/client/public/locales/en/buyer.json +65 -0
- package/client/public/locales/en/campaigns.json +1 -0
- package/client/public/locales/en/common.json +218 -0
- package/client/public/locales/en/contentHub.json +266 -0
- package/client/public/locales/en/creatives.json +79 -0
- package/client/public/locales/en/dashboard.json +57 -0
- package/client/public/locales/en/deals.json +886 -0
- package/client/public/locales/en/dsp.json +131 -0
- package/client/public/locales/en/inventory.json +201 -0
- package/client/public/locales/en/lineItems.json +659 -0
- package/client/public/locales/en/navigation.json +48 -0
- package/client/public/locales/en/wizard.json +1 -0
- package/client/public/locales/ja/approval.json +144 -0
- package/client/public/locales/ja/buyer.json +61 -0
- package/client/public/locales/ja/campaigns.json +1 -0
- package/client/public/locales/ja/common.json +218 -0
- package/client/public/locales/ja/contentHub.json +266 -0
- package/client/public/locales/ja/creatives.json +79 -0
- package/client/public/locales/ja/dashboard.json +57 -0
- package/client/public/locales/ja/deals.json +886 -0
- package/client/public/locales/ja/dsp.json +131 -0
- package/client/public/locales/ja/inventory.json +201 -0
- package/client/public/locales/ja/lineItems.json +553 -0
- package/client/public/locales/ja/navigation.json +48 -0
- package/client/public/locales/ja/wizard.json +1 -0
- package/client/public/locales/zh/approval.json +144 -0
- package/client/public/locales/zh/buyer.json +61 -0
- package/client/public/locales/zh/campaigns.json +1 -0
- package/client/public/locales/zh/common.json +218 -0
- package/client/public/locales/zh/contentHub.json +266 -0
- package/client/public/locales/zh/creatives.json +79 -0
- package/client/public/locales/zh/dashboard.json +57 -0
- package/client/public/locales/zh/deals.json +886 -0
- package/client/public/locales/zh/dsp.json +131 -0
- package/client/public/locales/zh/inventory.json +201 -0
- package/client/public/locales/zh/lineItems.json +553 -0
- package/client/public/locales/zh/navigation.json +48 -0
- package/client/public/locales/zh/wizard.json +1 -0
- package/client/public/manifest.json +36 -0
- package/client/src/App.tsx +464 -0
- package/client/src/components/app-sidebar.tsx +312 -0
- package/client/src/components/approval/approval-decision-form.test.tsx +294 -0
- package/client/src/components/approval/approval-decision-form.tsx +326 -0
- package/client/src/components/approval/approval-sheet.tsx +631 -0
- package/client/src/components/approval/line-item-details-sheet.tsx +371 -0
- package/client/src/components/approval/otp-verification.test.tsx +337 -0
- package/client/src/components/approval/otp-verification.tsx +180 -0
- package/client/src/components/content-hub/bulk-transcode-dialog.tsx +379 -0
- package/client/src/components/content-hub/content-hub-manager-v2.tsx +574 -0
- package/client/src/components/content-hub/content-hub-manager.tsx +330 -0
- package/client/src/components/content-hub/creative-card.tsx +456 -0
- package/client/src/components/content-hub/creative-detail-sheet.tsx +685 -0
- package/client/src/components/content-hub/creative-filters.tsx +457 -0
- package/client/src/components/content-hub/creative-grid.tsx +329 -0
- package/client/src/components/content-hub/creative-selector.tsx +415 -0
- package/client/src/components/content-hub/creative-upload.tsx +547 -0
- package/client/src/components/content-hub/folder-dialogs.tsx +445 -0
- package/client/src/components/content-hub/folder-list.tsx +280 -0
- package/client/src/components/content-hub/review-dialogs.tsx +268 -0
- package/client/src/components/content-hub/transcode-dialog.tsx +226 -0
- package/client/src/components/creative-library/creative-details-view.tsx +446 -0
- package/client/src/components/creative-library/creative-filters-panel.tsx +203 -0
- package/client/src/components/creative-library/creative-list.tsx +360 -0
- package/client/src/components/creative-library/creative-status-badge.tsx +71 -0
- package/client/src/components/creative-library/folder-card.tsx +78 -0
- package/client/src/components/creative-library/index.ts +27 -0
- package/client/src/components/creative-library/new-creative-card.tsx +211 -0
- package/client/src/components/creative-library/upload-creative-dialog.tsx +261 -0
- package/client/src/components/dashboard-overview.tsx +109 -0
- package/client/src/components/deals/approval-history-panel.test.tsx +240 -0
- package/client/src/components/deals/approval-history-panel.tsx +156 -0
- package/client/src/components/deals/deal-status-badge.tsx +92 -0
- package/client/src/components/deals/import-from-planner-dialog.tsx +399 -0
- package/client/src/components/deals/market-insights-panel.tsx +237 -0
- package/client/src/components/deals/reopen-deal-sheet.tsx +191 -0
- package/client/src/components/deals/request-approval-sheet.test.tsx +323 -0
- package/client/src/components/deals/request-approval-sheet.tsx +136 -0
- package/client/src/components/deals/resend-approval-sheet.tsx +201 -0
- package/client/src/components/direct-campaigns/campaign-card.tsx +283 -0
- package/client/src/components/direct-campaigns/deal-filter-panel.tsx +325 -0
- package/client/src/components/inventory/advanced-filters-panel.tsx +273 -0
- package/client/src/components/inventory/csv-upload-modal.tsx +639 -0
- package/client/src/components/inventory/inventory-availability-view.tsx +486 -0
- package/client/src/components/inventory/inventory-details-sheet.tsx +376 -0
- package/client/src/components/inventory/inventory-map-view.tsx +596 -0
- package/client/src/components/inventory/inventory-settings-menu.tsx +52 -0
- package/client/src/components/language-switcher.tsx +53 -0
- package/client/src/components/line-items/campaign-forecast-panel.tsx +138 -0
- package/client/src/components/line-items/form-insights.tsx +89 -0
- package/client/src/components/line-items/geofencing/LocationCsvUploadDrawer.tsx +100 -0
- package/client/src/components/line-items/geofencing/POIDropdown.tsx +379 -0
- package/client/src/components/line-items/geofencing/SelectedLocationsSidebar.tsx +436 -0
- package/client/src/components/line-items/geofencing/ViewFileLocationDrawer.tsx +199 -0
- package/client/src/components/line-items/geofencing/components/ExistingFilesTab.tsx +268 -0
- package/client/src/components/line-items/geofencing/components/TemplateDownloadSection.tsx +59 -0
- package/client/src/components/line-items/geofencing/components/UploadTab.tsx +215 -0
- package/client/src/components/line-items/geofencing-map.tsx +1270 -0
- package/client/src/components/line-items/inventory-availability-section.tsx +178 -0
- package/client/src/components/line-items/line-item-schedule-manager.tsx +313 -0
- package/client/src/components/line-items/manual-inventory-drawer.tsx +346 -0
- package/client/src/components/line-items/planner-inventory-card.tsx +495 -0
- package/client/src/components/line-items/planner-schedule-grid.tsx +495 -0
- package/client/src/components/line-items/schedule-rule-editor.tsx +649 -0
- package/client/src/components/line-items/schedule-rule-types.ts +122 -0
- package/client/src/components/line-items/steps/creatives-step.tsx +681 -0
- package/client/src/components/line-items/steps/inventory-schedule-step.tsx +1596 -0
- package/client/src/components/line-items/steps/inventory-step.tsx +1533 -0
- package/client/src/components/line-items/steps/line-item-details-step.tsx +916 -0
- package/client/src/components/line-items/steps/schedule-step.tsx +273 -0
- package/client/src/components/line-items/steps/summary-step.tsx +680 -0
- package/client/src/components/line-items/steps/targeting-step.tsx +1708 -0
- package/client/src/components/product-switcher.tsx +105 -0
- package/client/src/components/protected-route.tsx +49 -0
- package/client/src/components/skip-link.tsx +22 -0
- package/client/src/components/stat-card.tsx +53 -0
- package/client/src/components/status-badge.tsx +96 -0
- package/client/src/components/ui/hierarchical-venue-selector.tsx +389 -0
- package/client/src/components/ui/toaster.tsx +111 -0
- package/client/src/contexts/auth-context.tsx +181 -0
- package/client/src/contexts/sidebar-state.tsx +50 -0
- package/client/src/contexts/theme-context.tsx +66 -0
- package/client/src/data/campaign-data.json +107 -0
- package/client/src/data/countries.json +22 -0
- package/client/src/hooks/use-approval.ts +366 -0
- package/client/src/hooks/use-keyboard-shortcuts.ts +74 -0
- package/client/src/hooks/use-media-query.ts +46 -0
- package/client/src/hooks/use-mobile.tsx +19 -0
- package/client/src/hooks/use-page-title.ts +21 -0
- package/client/src/hooks/use-toast.ts +195 -0
- package/client/src/index.css +694 -0
- package/client/src/lib/__tests__/accessibility.test.ts +104 -0
- package/client/src/lib/__tests__/date-utils.test.ts +199 -0
- package/client/src/lib/__tests__/dsp-buyer-api.test.ts +127 -0
- package/client/src/lib/__tests__/dsp-buyer-integration.test.ts +247 -0
- package/client/src/lib/__tests__/storage-utils.test.ts +167 -0
- package/client/src/lib/__tests__/utils.test.ts +57 -0
- package/client/src/lib/accessibility.ts +141 -0
- package/client/src/lib/api-config.ts +9 -0
- package/client/src/lib/auth-service.ts +209 -0
- package/client/src/lib/campaign-creative-api.ts +82 -0
- package/client/src/lib/company-api.ts +61 -0
- package/client/src/lib/content-hub-api.ts +407 -0
- package/client/src/lib/creative-mapper.ts +61 -0
- package/client/src/lib/date-utils.ts +119 -0
- package/client/src/lib/deal-helpers.ts +220 -0
- package/client/src/lib/dsp-buyer-api.ts +196 -0
- package/client/src/lib/geo-import-api.ts +151 -0
- package/client/src/lib/google-poi-api.ts +305 -0
- package/client/src/lib/i18n/__tests__/formatting.test.ts +202 -0
- package/client/src/lib/i18n/formatting.ts +130 -0
- package/client/src/lib/i18n/index.ts +8 -0
- package/client/src/lib/i18n-compat.ts +76 -0
- package/client/src/lib/influence-deals-api.ts +896 -0
- package/client/src/lib/inventory-api.ts +399 -0
- package/client/src/lib/oauth-service.ts +678 -0
- package/client/src/lib/poi-types.ts +75 -0
- package/client/src/lib/queryClient.ts +144 -0
- package/client/src/lib/recommendation-api.ts +380 -0
- package/client/src/lib/storage-utils.ts +104 -0
- package/client/src/lib/tolgee.ts +85 -0
- package/client/src/lib/utils.ts +0 -0
- package/client/src/main.tsx +67 -0
- package/client/src/mapbox-draw-modes.d.ts +32 -0
- package/client/src/pages/all-folders.tsx +203 -0
- package/client/src/pages/auth-callback.tsx +115 -0
- package/client/src/pages/buyer-form.tsx +339 -0
- package/client/src/pages/buyer-list.tsx +622 -0
- package/client/src/pages/content-hub.tsx +1358 -0
- package/client/src/pages/create-deal.tsx +2093 -0
- package/client/src/pages/creative-assignment-page.tsx +548 -0
- package/client/src/pages/creatives.tsx +5 -0
- package/client/src/pages/custom-pois.tsx +425 -0
- package/client/src/pages/dashboard.tsx +615 -0
- package/client/src/pages/deal-history.tsx +434 -0
- package/client/src/pages/deal-line-items.tsx +1703 -0
- package/client/src/pages/demo-status.tsx +113 -0
- package/client/src/pages/direct-campaign-details.tsx +361 -0
- package/client/src/pages/direct-campaigns-new.tsx +824 -0
- package/client/src/pages/dsp-form.tsx +803 -0
- package/client/src/pages/dsp-list.tsx +239 -0
- package/client/src/pages/folder-content.tsx +336 -0
- package/client/src/pages/integrations.tsx +429 -0
- package/client/src/pages/line-item-creatives.tsx +789 -0
- package/client/src/pages/line-item-detail-page.tsx +684 -0
- package/client/src/pages/line-item-form-page.tsx +3261 -0
- package/client/src/pages/line-item-wizard.tsx +1207 -0
- package/client/src/pages/login.tsx +154 -0
- package/client/src/pages/not-found.tsx +23 -0
- package/client/src/pages/proof-of-play.tsx +397 -0
- package/client/src/pages/public-approval.tsx +551 -0
- package/client/src/pages/reports.tsx +231 -0
- package/client/src/pages/settings.tsx +760 -0
- package/client/src/pages/signals.tsx +389 -0
- package/client/src/pages/tags.tsx +318 -0
- package/client/src/pages/test-results.tsx +328 -0
- package/client/src/store/hooks.ts +5 -0
- package/client/src/store/index.ts +15 -0
- package/client/src/store/mapMarkerLocationsSlice.ts +241 -0
- package/client/src/styles/design-tokens.css +324 -0
- package/client/src/test/setup.ts +261 -0
- package/client/src/test/test-utils.tsx +40 -0
- package/client/src/types/approval.ts +221 -0
- package/client/src/types/content-hub.ts +209 -0
- package/client/src/types/geofencing.ts +67 -0
- package/client/src/types/transcoding.ts +140 -0
- package/client/src/vite-env.d.ts +18 -0
- package/components.json +20 -0
- package/creative-api.json +1 -0
- package/docs/AI_REFERENCE.md +459 -0
- package/docs/MWDesign-Prompt.md +132 -0
- package/docs/MWDesign-System.md +344 -0
- package/docs/test-plan.md +277 -0
- package/e2e/AUTONOMOUS-TESTING.md +406 -0
- package/e2e/README.md +219 -0
- package/e2e/autonomous-flow.spec.ts +308 -0
- package/e2e/debug-sso.spec.ts +163 -0
- package/e2e/direct-campaigns.spec.ts +219 -0
- package/e2e/explore-sso.spec.ts +149 -0
- package/e2e/fixtures/auth.ts +26 -0
- package/e2e/fixtures/enhanced-test.ts +331 -0
- package/e2e/pagination.spec.ts +280 -0
- package/e2e/view-toggle.spec.ts +312 -0
- package/generated-icon.png +0 -0
- package/i18next-scanner.config.cjs +46 -0
- package/package.json +141 -0
- package/playwright.config.ts +93 -0
- package/postcss.config.js +6 -0
- package/replit.md +196 -0
- package/screenshot-after-login.png +0 -0
- package/screenshot-contenthub-grid.png +0 -0
- package/screenshot-contenthub-list-fixed.png +0 -0
- package/screenshot-contenthub-list.png +0 -0
- package/screenshot-create-deal.png +0 -0
- package/screenshot-dashboard.png +0 -0
- package/screenshot-deals.png +0 -0
- package/screenshot-login-filled.png +0 -0
- package/screenshot-login.png +0 -0
- package/screenshot.mjs +24 -0
- package/scripts/deploy-stg.sh +185 -0
- package/shared/direct-io-schema.ts +383 -0
- package/shared/schema.ts +439 -0
- package/shared/screen-types.ts +149 -0
- package/springdocDefault.json +1 -0
- package/swagger-ui-bundle.js +2 -0
- package/swagger-ui-init.js +10316 -0
- package/tailwind.config.ts +282 -0
- package/terraform/README.md +306 -0
- package/terraform/cloudfront.tf +289 -0
- package/terraform/ecs.tf +727 -0
- package/terraform/environments/dev.tfvars +59 -0
- package/terraform/environments/production.tfvars +60 -0
- package/terraform/main.tf +47 -0
- package/terraform/outputs.tf +145 -0
- package/terraform/s3.tf +192 -0
- package/terraform/variables.tf +226 -0
- package/terraform/waf.tf +165 -0
- package/terraform-frontend/.terraform.lock.hcl +25 -0
- package/terraform-frontend/README.md +85 -0
- package/terraform-frontend/cloudfront.tf +125 -0
- package/terraform-frontend/main.tf +31 -0
- package/terraform-frontend/outputs.tf +24 -0
- package/terraform-frontend/terraform.tfvars +12 -0
- package/terraform-frontend/variables.tf +53 -0
- package/tsconfig.json +23 -0
- package/vite.config.ts +226 -0
- package/vitest.config.ts +56 -0
|
@@ -0,0 +1,1708 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useTranslation } from "@/lib/i18n";
|
|
4
|
+
import { Button } from "@moving-walls/design-system";
|
|
5
|
+
import { Card } from "@moving-walls/design-system";
|
|
6
|
+
import { Input } from "@moving-walls/design-system";
|
|
7
|
+
import { Label } from "@moving-walls/design-system";
|
|
8
|
+
import { Badge } from "@moving-walls/design-system";
|
|
9
|
+
import { MultiSelect } from "@moving-walls/design-system";
|
|
10
|
+
import { Select } from "@moving-walls/design-system";
|
|
11
|
+
import { Checkbox } from "@moving-walls/design-system";
|
|
12
|
+
import {
|
|
13
|
+
Sheet,
|
|
14
|
+
SheetContent,
|
|
15
|
+
} from "@moving-walls/design-system";
|
|
16
|
+
import { ScrollArea } from "@moving-walls/design-system";
|
|
17
|
+
import {
|
|
18
|
+
Collapsible,
|
|
19
|
+
CollapsibleContent,
|
|
20
|
+
CollapsibleTrigger,
|
|
21
|
+
} from "@moving-walls/design-system";
|
|
22
|
+
import {
|
|
23
|
+
Users,
|
|
24
|
+
ChevronLeft,
|
|
25
|
+
ChevronRight,
|
|
26
|
+
Sparkles,
|
|
27
|
+
Search,
|
|
28
|
+
MapPin,
|
|
29
|
+
Plus,
|
|
30
|
+
Trash2,
|
|
31
|
+
Upload,
|
|
32
|
+
X,
|
|
33
|
+
ChevronDown,
|
|
34
|
+
ChevronUp,
|
|
35
|
+
Loader2,
|
|
36
|
+
Map,
|
|
37
|
+
Check,
|
|
38
|
+
Monitor,
|
|
39
|
+
} from "lucide-react";
|
|
40
|
+
import { FormInsights } from "../form-insights";
|
|
41
|
+
import { GeofencingMap } from "../geofencing-map";
|
|
42
|
+
import { HierarchicalVenueSelector } from "../../ui/hierarchical-venue-selector";
|
|
43
|
+
import { LocationCsvUploadDrawer } from "../geofencing/LocationCsvUploadDrawer";
|
|
44
|
+
import { getAccessToken } from "@/lib/oauth-service";
|
|
45
|
+
import { API_CONFIG } from "@/lib/api-config";
|
|
46
|
+
import { cn } from "@moving-walls/design-system";
|
|
47
|
+
import type { MapMarkerLocation } from "@/types/geofencing";
|
|
48
|
+
import {
|
|
49
|
+
submitRecommendation,
|
|
50
|
+
pollUntilCompleted,
|
|
51
|
+
type RecommendationRequest
|
|
52
|
+
} from "@/lib/recommendation-api";
|
|
53
|
+
import { useAuth } from "@/contexts/auth-context";
|
|
54
|
+
|
|
55
|
+
interface TargetingStepProps {
|
|
56
|
+
data?: any;
|
|
57
|
+
campaignData?: any;
|
|
58
|
+
lineItemId?: string;
|
|
59
|
+
lineItemData?: any;
|
|
60
|
+
onComplete: (data: any) => void;
|
|
61
|
+
onBack?: () => void;
|
|
62
|
+
isLoading?: boolean;
|
|
63
|
+
isPlannerRestricted?: boolean;
|
|
64
|
+
dealMode?: "DIRECT" | "PROGRAMMATIC";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface TargetingCriteria {
|
|
68
|
+
criteria_type: string;
|
|
69
|
+
criteria_config: any;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const AGE_GROUPS = [
|
|
73
|
+
{ value: "18-24", label: "18-24 years" },
|
|
74
|
+
{ value: "25-34", label: "25-34 years" },
|
|
75
|
+
{ value: "35-44", label: "35-44 years" },
|
|
76
|
+
{ value: "45-54", label: "45-54 years" },
|
|
77
|
+
{ value: "55-64", label: "55-64 years" },
|
|
78
|
+
{ value: "65+", label: "65+ years" },
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
const GENDERS = [
|
|
82
|
+
{ value: "male", label: "Male" },
|
|
83
|
+
{ value: "female", label: "Female" },
|
|
84
|
+
{ value: "other", label: "Other" },
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
const INCOME_BRACKETS = [
|
|
88
|
+
{ value: "low", label: "Low Income" },
|
|
89
|
+
{ value: "lower-middle", label: "Lower-Middle" },
|
|
90
|
+
{ value: "middle", label: "Middle" },
|
|
91
|
+
{ value: "upper-middle", label: "Upper-Middle" },
|
|
92
|
+
{ value: "high", label: "High Income" },
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const INTERESTS = [
|
|
96
|
+
{ value: "sports", label: "Sports & Fitness" },
|
|
97
|
+
{ value: "travel", label: "Travel" },
|
|
98
|
+
{ value: "technology", label: "Technology" },
|
|
99
|
+
{ value: "food", label: "Food & Dining" },
|
|
100
|
+
{ value: "entertainment", label: "Entertainment" },
|
|
101
|
+
{ value: "fashion", label: "Fashion" },
|
|
102
|
+
{ value: "automotive", label: "Automotive" },
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const AUDIENCE_BEHAVIORS = [
|
|
106
|
+
{ value: "daily_commuter", label: "Daily Commuter" },
|
|
107
|
+
{ value: "frequent_shopper", label: "Frequent Shopper" },
|
|
108
|
+
{ value: "weekend_shopper", label: "Weekend Shopper" },
|
|
109
|
+
{ value: "tourist", label: "Tourist" },
|
|
110
|
+
{ value: "student", label: "Student" },
|
|
111
|
+
{ value: "business_professional", label: "Business Professional" },
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
const SIGNAL_OPTIONS = [
|
|
115
|
+
{
|
|
116
|
+
id: "weather",
|
|
117
|
+
label: "Weather",
|
|
118
|
+
description: "Trigger ads based on weather conditions and temperature",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: "traffic",
|
|
122
|
+
label: "Traffic",
|
|
123
|
+
description: "Adjust delivery based on real-time traffic density",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "aqi",
|
|
127
|
+
label: "Air Quality Index",
|
|
128
|
+
description: "Target based on air quality levels",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "time_of_day",
|
|
132
|
+
label: "Time of Day",
|
|
133
|
+
description: "Daypart targeting (morning, afternoon, evening)",
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
const WEATHER_CONDITIONS = [
|
|
138
|
+
{ value: "sunny", label: "Sunny" },
|
|
139
|
+
{ value: "partly_cloudy", label: "Partly Cloudy" },
|
|
140
|
+
{ value: "cloudy", label: "Cloudy" },
|
|
141
|
+
{ value: "clear", label: "Clear" },
|
|
142
|
+
{ value: "rain", label: "Rain" },
|
|
143
|
+
{ value: "drizzle", label: "Drizzle" },
|
|
144
|
+
{ value: "thunderstorm", label: "Thunderstorm" },
|
|
145
|
+
{ value: "snow", label: "Snow" },
|
|
146
|
+
{ value: "fog", label: "Fog" },
|
|
147
|
+
{ value: "haze", label: "Haze" },
|
|
148
|
+
{ value: "windy", label: "Windy" },
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
const TEMPERATURE_UNITS = [
|
|
152
|
+
{ value: "celsius", label: "Celsius (°C)" },
|
|
153
|
+
{ value: "fahrenheit", label: "Fahrenheit (°F)" },
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
const TRAFFIC_DENSITY = [
|
|
157
|
+
{ value: "low", label: "Low" },
|
|
158
|
+
{ value: "moderate", label: "Moderate" },
|
|
159
|
+
{ value: "high", label: "High" },
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
const AQI_THRESHOLDS = [
|
|
163
|
+
{ value: "good", label: "Good" },
|
|
164
|
+
{ value: "moderate", label: "Moderate" },
|
|
165
|
+
{ value: "unhealthy_sensitive", label: "Unhealthy for Sensitive Groups" },
|
|
166
|
+
{ value: "unhealthy", label: "Unhealthy" },
|
|
167
|
+
{ value: "very_unhealthy", label: "Very Unhealthy" },
|
|
168
|
+
{ value: "hazardous", label: "Hazardous" },
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
const DAYPARTS = [
|
|
172
|
+
{ value: "morning", label: "Morning (6AM-12PM)" },
|
|
173
|
+
{ value: "afternoon", label: "Afternoon (12PM-6PM)" },
|
|
174
|
+
{ value: "evening", label: "Evening (6PM-10PM)" },
|
|
175
|
+
{ value: "night", label: "Night (10PM-6AM)" },
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
const getSmartSuggestions = (campaignData: any) => {
|
|
179
|
+
return [
|
|
180
|
+
{ id: "age_24_34", label: "24 - 34 Years", category: "age" },
|
|
181
|
+
{ id: "age_35_44", label: "35 - 44 Years", category: "age" },
|
|
182
|
+
{ id: "male", label: "Male", category: "gender" },
|
|
183
|
+
{ id: "high_income", label: "High Income", category: "income" },
|
|
184
|
+
{ id: "sports_fitness", label: "Sports & Fitness", category: "interest" },
|
|
185
|
+
{ id: "travel", label: "Travel", category: "interest" },
|
|
186
|
+
{ id: "transit", label: "Transit", category: "venue" },
|
|
187
|
+
{ id: "business", label: "Business", category: "venue" },
|
|
188
|
+
];
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const POI_OPTIONS = [
|
|
192
|
+
{ value: "accounting", label: "Accounting" },
|
|
193
|
+
{ value: "airport", label: "Airport" },
|
|
194
|
+
{ value: "amusement_park", label: "Amusement Park" },
|
|
195
|
+
{ value: "aquarium", label: "Aquarium" },
|
|
196
|
+
{ value: "atm", label: "ATM" },
|
|
197
|
+
{ value: "bank", label: "Bank" },
|
|
198
|
+
{ value: "bar", label: "Bar" },
|
|
199
|
+
{ value: "beauty_salon", label: "Beauty Salon" },
|
|
200
|
+
{ value: "cafe", label: "Cafe" },
|
|
201
|
+
{ value: "hospital", label: "Hospital" },
|
|
202
|
+
{ value: "mall", label: "Shopping Mall" },
|
|
203
|
+
{ value: "restaurant", label: "Restaurant" },
|
|
204
|
+
{ value: "school", label: "School" },
|
|
205
|
+
{ value: "university", label: "University" },
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
const MAX_POIS_PER_LOCATION = 5;
|
|
209
|
+
|
|
210
|
+
export function TargetingStep({
|
|
211
|
+
data,
|
|
212
|
+
campaignData,
|
|
213
|
+
lineItemId,
|
|
214
|
+
lineItemData,
|
|
215
|
+
onComplete,
|
|
216
|
+
onBack,
|
|
217
|
+
isLoading,
|
|
218
|
+
formId = "targeting-step-form",
|
|
219
|
+
isPlannerRestricted = false,
|
|
220
|
+
dealMode = "DIRECT",
|
|
221
|
+
}: TargetingStepProps & { formId?: string }) {
|
|
222
|
+
const { t } = useTranslation('lineItems');
|
|
223
|
+
const { user } = useAuth();
|
|
224
|
+
const [isGeoMapSheetOpen, setIsGeoMapSheetOpen] = useState(false);
|
|
225
|
+
const [geographyInput, setGeographyInput] = useState("");
|
|
226
|
+
|
|
227
|
+
// Recommendation submission state
|
|
228
|
+
const [isSubmittingRecommendation, setIsSubmittingRecommendation] = useState(false);
|
|
229
|
+
const [recommendationError, setRecommendationError] = useState<string | null>(null);
|
|
230
|
+
|
|
231
|
+
const [selectedAgeGroups, setSelectedAgeGroups] = useState<string[]>([]);
|
|
232
|
+
const [selectedGenders, setSelectedGenders] = useState<string[]>([]);
|
|
233
|
+
const [selectedIncomeBrackets, setSelectedIncomeBrackets] = useState<
|
|
234
|
+
string[]
|
|
235
|
+
>([]);
|
|
236
|
+
const [selectedInterests, setSelectedInterests] = useState<string[]>([]);
|
|
237
|
+
const [selectedVenueTypes, setSelectedVenueTypes] = useState<string[]>([]);
|
|
238
|
+
const [selectedBehaviors, setSelectedBehaviors] = useState<string[]>([]);
|
|
239
|
+
|
|
240
|
+
const [geoLocations, setGeoLocations] = useState<any[]>([]);
|
|
241
|
+
const [geoRadius, setGeoRadius] = useState("5");
|
|
242
|
+
const [locationSearch, setLocationSearch] = useState("");
|
|
243
|
+
const [includeAllLocations, setIncludeAllLocations] = useState(true);
|
|
244
|
+
const [selectedPOIs, setSelectedPOIs] = useState<string[]>([]);
|
|
245
|
+
const [showImportModal, setShowImportModal] = useState(false);
|
|
246
|
+
const [addPOIMode, setAddPOIMode] = useState(false);
|
|
247
|
+
const [selectedLocationIndex, setSelectedLocationIndex] = useState<
|
|
248
|
+
number | null
|
|
249
|
+
>(null);
|
|
250
|
+
const [shouldCenterOnLocation, setShouldCenterOnLocation] = useState(false);
|
|
251
|
+
|
|
252
|
+
const handleLocationsChange = (newLocations: any[]) => {
|
|
253
|
+
setGeoLocations((prev) => {
|
|
254
|
+
return newLocations.map((newLoc) => {
|
|
255
|
+
const existingLoc = prev.find((p) => p.id === newLoc.id);
|
|
256
|
+
if (existingLoc) {
|
|
257
|
+
return {
|
|
258
|
+
...newLoc,
|
|
259
|
+
properties: {
|
|
260
|
+
...newLoc.properties,
|
|
261
|
+
pois: existingLoc.properties?.pois || [],
|
|
262
|
+
included: existingLoc.properties?.included !== false,
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
...newLoc,
|
|
268
|
+
properties: {
|
|
269
|
+
...newLoc.properties,
|
|
270
|
+
pois: newLoc.properties?.pois || [],
|
|
271
|
+
included: newLoc.properties?.included !== false,
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const removeLocation = (locationIndex: number) => {
|
|
279
|
+
setGeoLocations((prev) => prev.filter((_, idx) => idx !== locationIndex));
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const toggleLocationIncluded = (locationIndex: number) => {
|
|
283
|
+
setGeoLocations((prev) =>
|
|
284
|
+
prev.map((loc, idx) => {
|
|
285
|
+
if (idx === locationIndex) {
|
|
286
|
+
const currentIncluded = loc.properties?.included !== false;
|
|
287
|
+
return {
|
|
288
|
+
...loc,
|
|
289
|
+
properties: {
|
|
290
|
+
...loc.properties,
|
|
291
|
+
included: !currentIncluded,
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
return loc;
|
|
296
|
+
}),
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const handleIncludeAllChange = () => {
|
|
301
|
+
const newValue = !includeAllLocations;
|
|
302
|
+
setIncludeAllLocations(newValue);
|
|
303
|
+
setGeoLocations((prev) =>
|
|
304
|
+
prev.map((loc) => ({
|
|
305
|
+
...loc,
|
|
306
|
+
properties: {
|
|
307
|
+
...loc.properties,
|
|
308
|
+
included: newValue,
|
|
309
|
+
},
|
|
310
|
+
})),
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const addPoiToLocation = (locationIndex: number, poiValue: string) => {
|
|
315
|
+
setGeoLocations((prev) =>
|
|
316
|
+
prev.map((loc, idx) => {
|
|
317
|
+
if (idx === locationIndex) {
|
|
318
|
+
const currentPois = loc.properties?.pois || [];
|
|
319
|
+
if (currentPois.length >= MAX_POIS_PER_LOCATION) {
|
|
320
|
+
return loc;
|
|
321
|
+
}
|
|
322
|
+
if (currentPois.some((p: any) => p.type === poiValue)) {
|
|
323
|
+
return loc;
|
|
324
|
+
}
|
|
325
|
+
const poiOption = POI_OPTIONS.find((p) => p.value === poiValue);
|
|
326
|
+
return {
|
|
327
|
+
...loc,
|
|
328
|
+
properties: {
|
|
329
|
+
...loc.properties,
|
|
330
|
+
pois: [
|
|
331
|
+
...currentPois,
|
|
332
|
+
{ type: poiValue, label: poiOption?.label || poiValue },
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
return loc;
|
|
338
|
+
}),
|
|
339
|
+
);
|
|
340
|
+
setAddPOIMode(false);
|
|
341
|
+
setSelectedLocationIndex(null);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const removePoiFromLocation = (locationIndex: number, poiType: string) => {
|
|
345
|
+
setGeoLocations((prev) =>
|
|
346
|
+
prev.map((loc, idx) => {
|
|
347
|
+
if (idx === locationIndex) {
|
|
348
|
+
const currentPois = loc.properties?.pois || [];
|
|
349
|
+
return {
|
|
350
|
+
...loc,
|
|
351
|
+
properties: {
|
|
352
|
+
...loc.properties,
|
|
353
|
+
pois: currentPois.filter((p: any) => p.type !== poiType),
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
return loc;
|
|
358
|
+
}),
|
|
359
|
+
);
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const handleCsvLocationsSelected = (locations: MapMarkerLocation[]) => {
|
|
363
|
+
const newGeoLocations = locations.map((loc, index) => ({
|
|
364
|
+
id: `csv-${Date.now()}-${index}`,
|
|
365
|
+
type: 'Feature' as const,
|
|
366
|
+
geometry: {
|
|
367
|
+
type: 'Point' as const,
|
|
368
|
+
coordinates: [loc.longitude, loc.latitude],
|
|
369
|
+
},
|
|
370
|
+
properties: {
|
|
371
|
+
name: loc.name,
|
|
372
|
+
address: loc.address || '',
|
|
373
|
+
included: true,
|
|
374
|
+
pois: [],
|
|
375
|
+
radius: loc.radius,
|
|
376
|
+
},
|
|
377
|
+
poi: [],
|
|
378
|
+
enabled: true,
|
|
379
|
+
}));
|
|
380
|
+
setGeoLocations([...geoLocations, ...newGeoLocations]);
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const [selectedSignals, setSelectedSignals] = useState<string[]>([]);
|
|
384
|
+
|
|
385
|
+
const [weatherConditions, setWeatherConditions] = useState<string[]>([]);
|
|
386
|
+
const [temperatureMin, setTemperatureMin] = useState<string>("");
|
|
387
|
+
const [temperatureMax, setTemperatureMax] = useState<string>("");
|
|
388
|
+
const [temperatureUnit, setTemperatureUnit] = useState<string>("celsius");
|
|
389
|
+
const [trafficDensity, setTrafficDensity] = useState<string[]>([]);
|
|
390
|
+
const [aqiThreshold, setAqiThreshold] = useState<string[]>([]);
|
|
391
|
+
const [dayparts, setDayparts] = useState<string[]>([]);
|
|
392
|
+
|
|
393
|
+
const [preservedCriteria, setPreservedCriteria] = useState<
|
|
394
|
+
TargetingCriteria[]
|
|
395
|
+
>([]);
|
|
396
|
+
|
|
397
|
+
const [selectedSuggestions, setSelectedSuggestions] = useState<string[]>([]);
|
|
398
|
+
|
|
399
|
+
interface VenueTaxonomy {
|
|
400
|
+
taxonomyId: string;
|
|
401
|
+
version: string;
|
|
402
|
+
name: string;
|
|
403
|
+
path: string;
|
|
404
|
+
parentId?: string;
|
|
405
|
+
parentName?: string;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const { data: venueTypes = [], isLoading: isLoadingVenues } = useQuery<
|
|
409
|
+
VenueTaxonomy[]
|
|
410
|
+
>({
|
|
411
|
+
queryKey: ["venue-taxonomies"],
|
|
412
|
+
queryFn: async () => {
|
|
413
|
+
const accessToken = getAccessToken();
|
|
414
|
+
const headers: Record<string, string> = {};
|
|
415
|
+
|
|
416
|
+
if (accessToken) {
|
|
417
|
+
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const response = await fetch(
|
|
421
|
+
`${API_CONFIG.inventory}/api/v1/venue-taxonomies`,
|
|
422
|
+
{ headers },
|
|
423
|
+
);
|
|
424
|
+
if (!response.ok) {
|
|
425
|
+
throw new Error("Failed to fetch venue taxonomies");
|
|
426
|
+
}
|
|
427
|
+
return response.json();
|
|
428
|
+
},
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
useEffect(() => {
|
|
432
|
+
if (!data) return;
|
|
433
|
+
|
|
434
|
+
if (data.targeting && typeof data.targeting === "object") {
|
|
435
|
+
const t = data.targeting;
|
|
436
|
+
if (t.demographics) {
|
|
437
|
+
if (t.demographics.ageGroups)
|
|
438
|
+
setSelectedAgeGroups(t.demographics.ageGroups);
|
|
439
|
+
if (t.demographics.genders) setSelectedGenders(t.demographics.genders);
|
|
440
|
+
if (t.demographics.incomeGroups)
|
|
441
|
+
setSelectedIncomeBrackets(t.demographics.incomeGroups);
|
|
442
|
+
if (t.demographics.interests)
|
|
443
|
+
setSelectedInterests(t.demographics.interests);
|
|
444
|
+
if (t.demographics.audienceBehaviour)
|
|
445
|
+
setSelectedBehaviors(t.demographics.audienceBehaviour);
|
|
446
|
+
}
|
|
447
|
+
if (t.venueTypes) setSelectedVenueTypes(t.venueTypes);
|
|
448
|
+
if (t.geofencing) {
|
|
449
|
+
const geoFeatures: any[] = [];
|
|
450
|
+
if (t.geofencing.geometrics) {
|
|
451
|
+
t.geofencing.geometrics.forEach((geom: any, idx: number) => {
|
|
452
|
+
geoFeatures.push({
|
|
453
|
+
id: `geometry-${idx}`,
|
|
454
|
+
type: "Feature",
|
|
455
|
+
properties: {
|
|
456
|
+
included: geom.included !== false,
|
|
457
|
+
pois: geom.pois || [],
|
|
458
|
+
},
|
|
459
|
+
geometry: {
|
|
460
|
+
type: geom.type,
|
|
461
|
+
coordinates: geom.coordinates,
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
if (t.geofencing.locations) {
|
|
467
|
+
t.geofencing.locations.forEach((loc: any, idx: number) => {
|
|
468
|
+
geoFeatures.push({
|
|
469
|
+
id: `location-${idx}`,
|
|
470
|
+
type: "Feature",
|
|
471
|
+
properties: {
|
|
472
|
+
included: loc.included !== false,
|
|
473
|
+
name: loc.name,
|
|
474
|
+
address: loc.address,
|
|
475
|
+
radius: loc.radius,
|
|
476
|
+
pois: loc.pois || [],
|
|
477
|
+
},
|
|
478
|
+
geometry: {
|
|
479
|
+
type: "Point",
|
|
480
|
+
coordinates: [loc.lng, loc.lat],
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
if (geoFeatures.length > 0) {
|
|
486
|
+
setGeoLocations(geoFeatures);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (data.deliveryTargeting?.signals) {
|
|
491
|
+
const signals = data.deliveryTargeting.signals;
|
|
492
|
+
const signalIds: string[] = [];
|
|
493
|
+
|
|
494
|
+
if (signals.weather) {
|
|
495
|
+
signalIds.push("weather");
|
|
496
|
+
if (signals.weather.conditions) {
|
|
497
|
+
setWeatherConditions(signals.weather.conditions);
|
|
498
|
+
}
|
|
499
|
+
if (signals.weather.temperature) {
|
|
500
|
+
if (signals.weather.temperature.min !== undefined) {
|
|
501
|
+
setTemperatureMin(signals.weather.temperature.min.toString());
|
|
502
|
+
}
|
|
503
|
+
if (signals.weather.temperature.max !== undefined) {
|
|
504
|
+
setTemperatureMax(signals.weather.temperature.max.toString());
|
|
505
|
+
}
|
|
506
|
+
if (signals.weather.temperature.unit) {
|
|
507
|
+
setTemperatureUnit(signals.weather.temperature.unit);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
if (signals.traffic) {
|
|
513
|
+
signalIds.push("traffic");
|
|
514
|
+
if (signals.traffic.density) {
|
|
515
|
+
const densities = Array.isArray(signals.traffic.density)
|
|
516
|
+
? signals.traffic.density
|
|
517
|
+
: [signals.traffic.density];
|
|
518
|
+
setTrafficDensity(densities);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (signals.aqi) {
|
|
523
|
+
signalIds.push("aqi");
|
|
524
|
+
if (signals.aqi.threshold) {
|
|
525
|
+
const thresholds = Array.isArray(signals.aqi.threshold)
|
|
526
|
+
? signals.aqi.threshold
|
|
527
|
+
: [signals.aqi.threshold];
|
|
528
|
+
setAqiThreshold(thresholds);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if (signals.timeOfDay) {
|
|
533
|
+
signalIds.push("time_of_day");
|
|
534
|
+
if (signals.timeOfDay.dayparts) {
|
|
535
|
+
setDayparts(signals.timeOfDay.dayparts);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Handle legacy standalone temperature signal (merge into weather)
|
|
540
|
+
if (signals.temperature && !signals.weather) {
|
|
541
|
+
if (!signalIds.includes("weather")) {
|
|
542
|
+
signalIds.push("weather");
|
|
543
|
+
}
|
|
544
|
+
if (signals.temperature.min !== undefined) {
|
|
545
|
+
setTemperatureMin(signals.temperature.min.toString());
|
|
546
|
+
}
|
|
547
|
+
if (signals.temperature.max !== undefined) {
|
|
548
|
+
setTemperatureMax(signals.temperature.max.toString());
|
|
549
|
+
}
|
|
550
|
+
if (signals.temperature.unit) {
|
|
551
|
+
setTemperatureUnit(signals.temperature.unit);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (signalIds.length > 0) {
|
|
556
|
+
setSelectedSignals(signalIds);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
564
|
+
const unhandledCriteria: TargetingCriteria[] = [];
|
|
565
|
+
|
|
566
|
+
data.forEach((item: any) => {
|
|
567
|
+
if (item.criteria_type === "demographics") {
|
|
568
|
+
const config = item.criteria_config;
|
|
569
|
+
if (config.age_groups) setSelectedAgeGroups(config.age_groups);
|
|
570
|
+
if (config.genders) setSelectedGenders(config.genders);
|
|
571
|
+
if (config.income_brackets)
|
|
572
|
+
setSelectedIncomeBrackets(config.income_brackets);
|
|
573
|
+
if (config.interests) setSelectedInterests(config.interests);
|
|
574
|
+
} else if (item.criteria_type === "venue") {
|
|
575
|
+
const config = item.criteria_config;
|
|
576
|
+
if (config.venue_types) setSelectedVenueTypes(config.venue_types);
|
|
577
|
+
} else if (item.criteria_type === "geofencing") {
|
|
578
|
+
const config = item.criteria_config;
|
|
579
|
+
if (config.locations) setGeoLocations(config.locations);
|
|
580
|
+
if (config.radius_km) setGeoRadius(config.radius_km.toString());
|
|
581
|
+
} else if (item.criteria_type === "search_behavior") {
|
|
582
|
+
const config = item.criteria_config;
|
|
583
|
+
if (config.behaviors) setSelectedBehaviors(config.behaviors);
|
|
584
|
+
} else if (item.criteria_type === "weather") {
|
|
585
|
+
unhandledCriteria.push(item);
|
|
586
|
+
setSelectedSignals((prev) =>
|
|
587
|
+
prev.includes("weather") ? prev : [...prev, "weather"],
|
|
588
|
+
);
|
|
589
|
+
} else if (item.criteria_type === "traffic") {
|
|
590
|
+
unhandledCriteria.push(item);
|
|
591
|
+
setSelectedSignals((prev) =>
|
|
592
|
+
prev.includes("traffic") ? prev : [...prev, "traffic"],
|
|
593
|
+
);
|
|
594
|
+
} else if (item.criteria_type === "aqi") {
|
|
595
|
+
unhandledCriteria.push(item);
|
|
596
|
+
setSelectedSignals((prev) =>
|
|
597
|
+
prev.includes("aqi") ? prev : [...prev, "aqi"],
|
|
598
|
+
);
|
|
599
|
+
} else {
|
|
600
|
+
unhandledCriteria.push(item);
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
setPreservedCriteria(unhandledCriteria);
|
|
605
|
+
}
|
|
606
|
+
}, [data]);
|
|
607
|
+
|
|
608
|
+
const addToList = (
|
|
609
|
+
value: string,
|
|
610
|
+
list: string[],
|
|
611
|
+
setter: (list: string[]) => void,
|
|
612
|
+
) => {
|
|
613
|
+
if (value && !list.includes(value)) {
|
|
614
|
+
setter([...list, value]);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
const removeFromList = (
|
|
619
|
+
value: string,
|
|
620
|
+
list: string[],
|
|
621
|
+
setter: (list: string[]) => void,
|
|
622
|
+
) => {
|
|
623
|
+
setter(list.filter((item) => item !== value));
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
const toggleSignal = (signalId: string) => {
|
|
627
|
+
if (selectedSignals.includes(signalId)) {
|
|
628
|
+
setSelectedSignals(selectedSignals.filter((s) => s !== signalId));
|
|
629
|
+
} else {
|
|
630
|
+
setSelectedSignals([...selectedSignals, signalId]);
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
const toggleSuggestion = (id: string) => {
|
|
635
|
+
if (selectedSuggestions.includes(id)) {
|
|
636
|
+
setSelectedSuggestions(selectedSuggestions.filter((s) => s !== id));
|
|
637
|
+
} else {
|
|
638
|
+
setSelectedSuggestions([...selectedSuggestions, id]);
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
const applySuggestions = () => {
|
|
643
|
+
const suggestions = getSmartSuggestions(campaignData);
|
|
644
|
+
selectedSuggestions.forEach((suggestionId) => {
|
|
645
|
+
const suggestion = suggestions.find((s) => s.id === suggestionId);
|
|
646
|
+
if (!suggestion) return;
|
|
647
|
+
|
|
648
|
+
if (suggestion.category === "age") {
|
|
649
|
+
const ageLabel = suggestion.label.replace(" Years", " years");
|
|
650
|
+
if (!selectedAgeGroups.includes(ageLabel)) {
|
|
651
|
+
setSelectedAgeGroups((prev) => [...prev, ageLabel]);
|
|
652
|
+
}
|
|
653
|
+
} else if (suggestion.category === "gender") {
|
|
654
|
+
if (!selectedGenders.includes(suggestion.label)) {
|
|
655
|
+
setSelectedGenders((prev) => [...prev, suggestion.label]);
|
|
656
|
+
}
|
|
657
|
+
} else if (suggestion.category === "income") {
|
|
658
|
+
if (!selectedIncomeBrackets.includes(suggestion.label)) {
|
|
659
|
+
setSelectedIncomeBrackets((prev) => [...prev, suggestion.label]);
|
|
660
|
+
}
|
|
661
|
+
} else if (suggestion.category === "interest") {
|
|
662
|
+
if (!selectedInterests.includes(suggestion.label)) {
|
|
663
|
+
setSelectedInterests((prev) => [...prev, suggestion.label]);
|
|
664
|
+
}
|
|
665
|
+
} else if (suggestion.category === "venue") {
|
|
666
|
+
const venueLower = suggestion.label.toLowerCase();
|
|
667
|
+
if (!selectedVenueTypes.includes(venueLower)) {
|
|
668
|
+
setSelectedVenueTypes((prev) => [...prev, venueLower]);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
setSelectedSuggestions([]);
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
const handleNext = () => {
|
|
676
|
+
const targeting: {
|
|
677
|
+
demographics?: {
|
|
678
|
+
ageGroups?: string[];
|
|
679
|
+
genders?: string[];
|
|
680
|
+
incomeGroups?: string[];
|
|
681
|
+
interests?: string[];
|
|
682
|
+
audienceBehaviour?: string[];
|
|
683
|
+
};
|
|
684
|
+
venueTypes?: string[];
|
|
685
|
+
geofencing?: {
|
|
686
|
+
geometrics?: any[];
|
|
687
|
+
locations?: any[];
|
|
688
|
+
};
|
|
689
|
+
} = {};
|
|
690
|
+
|
|
691
|
+
if (
|
|
692
|
+
selectedAgeGroups.length > 0 ||
|
|
693
|
+
selectedGenders.length > 0 ||
|
|
694
|
+
selectedIncomeBrackets.length > 0 ||
|
|
695
|
+
selectedInterests.length > 0 ||
|
|
696
|
+
selectedBehaviors.length > 0
|
|
697
|
+
) {
|
|
698
|
+
targeting.demographics = {};
|
|
699
|
+
if (selectedAgeGroups.length > 0) {
|
|
700
|
+
targeting.demographics.ageGroups = selectedAgeGroups;
|
|
701
|
+
}
|
|
702
|
+
if (selectedGenders.length > 0) {
|
|
703
|
+
targeting.demographics.genders = selectedGenders.map((g) =>
|
|
704
|
+
g.toLowerCase(),
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
if (selectedIncomeBrackets.length > 0) {
|
|
708
|
+
targeting.demographics.incomeGroups = selectedIncomeBrackets;
|
|
709
|
+
}
|
|
710
|
+
if (selectedInterests.length > 0) {
|
|
711
|
+
targeting.demographics.interests = selectedInterests;
|
|
712
|
+
}
|
|
713
|
+
if (selectedBehaviors.length > 0) {
|
|
714
|
+
targeting.demographics.audienceBehaviour = selectedBehaviors;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (selectedVenueTypes.length > 0) {
|
|
719
|
+
targeting.venueTypes = selectedVenueTypes;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (geoLocations.length > 0) {
|
|
723
|
+
const geometries: any[] = [];
|
|
724
|
+
const locations: any[] = [];
|
|
725
|
+
|
|
726
|
+
geoLocations.forEach((feature) => {
|
|
727
|
+
if (feature.type === "Feature" && feature.geometry) {
|
|
728
|
+
const geom = feature.geometry;
|
|
729
|
+
const props = feature.properties || {};
|
|
730
|
+
|
|
731
|
+
if (geom.type === "Point") {
|
|
732
|
+
const locationObj: any = {
|
|
733
|
+
name: props.name || "Location",
|
|
734
|
+
lat: geom.coordinates[1],
|
|
735
|
+
lng: geom.coordinates[0],
|
|
736
|
+
radius: props.radius || parseFloat(geoRadius) * 1000 || 5000,
|
|
737
|
+
metadata: props.metadata || {},
|
|
738
|
+
included: props.included !== false,
|
|
739
|
+
};
|
|
740
|
+
if (props.address && props.address.trim() !== "") {
|
|
741
|
+
locationObj.address = props.address;
|
|
742
|
+
}
|
|
743
|
+
if (props.pois && props.pois.length > 0) {
|
|
744
|
+
locationObj.pois = props.pois;
|
|
745
|
+
}
|
|
746
|
+
locations.push(locationObj);
|
|
747
|
+
} else {
|
|
748
|
+
const geomObj: any = {
|
|
749
|
+
type: geom.type,
|
|
750
|
+
coordinates: geom.coordinates,
|
|
751
|
+
included: props.included !== false,
|
|
752
|
+
};
|
|
753
|
+
if (props.pois && props.pois.length > 0) {
|
|
754
|
+
geomObj.pois = props.pois;
|
|
755
|
+
}
|
|
756
|
+
geometries.push(geomObj);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
if (geometries.length > 0 || locations.length > 0) {
|
|
762
|
+
targeting.geofencing = {};
|
|
763
|
+
if (geometries.length > 0) {
|
|
764
|
+
targeting.geofencing.geometrics = geometries;
|
|
765
|
+
}
|
|
766
|
+
if (locations.length > 0) {
|
|
767
|
+
targeting.geofencing.locations = locations;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
const deliveryTargeting: {
|
|
773
|
+
signals?: {
|
|
774
|
+
weather?: {
|
|
775
|
+
conditions?: string[];
|
|
776
|
+
temperature?: {
|
|
777
|
+
min?: number;
|
|
778
|
+
max?: number;
|
|
779
|
+
unit?: string;
|
|
780
|
+
};
|
|
781
|
+
};
|
|
782
|
+
traffic?: {
|
|
783
|
+
density?: string[];
|
|
784
|
+
};
|
|
785
|
+
aqi?: {
|
|
786
|
+
threshold?: string[];
|
|
787
|
+
};
|
|
788
|
+
timeOfDay?: {
|
|
789
|
+
dayparts?: string[];
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
} = {};
|
|
793
|
+
|
|
794
|
+
if (selectedSignals.length > 0) {
|
|
795
|
+
deliveryTargeting.signals = {};
|
|
796
|
+
|
|
797
|
+
selectedSignals.forEach((signal) => {
|
|
798
|
+
if (signal === "weather") {
|
|
799
|
+
const weatherSignal: {
|
|
800
|
+
conditions?: string[];
|
|
801
|
+
temperature?: { min?: number; max?: number; unit?: string };
|
|
802
|
+
} = {};
|
|
803
|
+
|
|
804
|
+
if (weatherConditions.length > 0) {
|
|
805
|
+
weatherSignal.conditions = weatherConditions;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
const hasTemperatureConfig =
|
|
809
|
+
temperatureMin !== "" || temperatureMax !== "";
|
|
810
|
+
if (hasTemperatureConfig) {
|
|
811
|
+
weatherSignal.temperature = {
|
|
812
|
+
unit: temperatureUnit,
|
|
813
|
+
};
|
|
814
|
+
if (temperatureMin !== "") {
|
|
815
|
+
weatherSignal.temperature.min = parseFloat(temperatureMin);
|
|
816
|
+
}
|
|
817
|
+
if (temperatureMax !== "") {
|
|
818
|
+
weatherSignal.temperature.max = parseFloat(temperatureMax);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// Always include weather signal when selected
|
|
823
|
+
deliveryTargeting.signals!.weather =
|
|
824
|
+
Object.keys(weatherSignal).length > 0 ? weatherSignal : {};
|
|
825
|
+
} else if (signal === "traffic") {
|
|
826
|
+
deliveryTargeting.signals!.traffic = {
|
|
827
|
+
density: trafficDensity.length > 0 ? trafficDensity : [],
|
|
828
|
+
};
|
|
829
|
+
} else if (signal === "aqi") {
|
|
830
|
+
deliveryTargeting.signals!.aqi = {
|
|
831
|
+
threshold: aqiThreshold.length > 0 ? aqiThreshold : [],
|
|
832
|
+
};
|
|
833
|
+
} else if (signal === "time_of_day") {
|
|
834
|
+
deliveryTargeting.signals!.timeOfDay = {
|
|
835
|
+
dayparts: dayparts.length > 0 ? dayparts : [],
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// Build targeting data for onComplete
|
|
842
|
+
const targetingData = {
|
|
843
|
+
targeting: Object.keys(targeting).length > 0 ? targeting : undefined,
|
|
844
|
+
deliveryTargeting:
|
|
845
|
+
Object.keys(deliveryTargeting).length > 0
|
|
846
|
+
? deliveryTargeting
|
|
847
|
+
: undefined,
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
// If we have a lineItemId, submit recommendation and poll until completed
|
|
851
|
+
if (lineItemId && lineItemData) {
|
|
852
|
+
setIsSubmittingRecommendation(true);
|
|
853
|
+
setRecommendationError(null);
|
|
854
|
+
|
|
855
|
+
const formatDateForAPI = (dateStr: string): string => {
|
|
856
|
+
try {
|
|
857
|
+
const date = new Date(dateStr);
|
|
858
|
+
if (isNaN(date.getTime())) {
|
|
859
|
+
return new Date().toISOString().split('T')[0];
|
|
860
|
+
}
|
|
861
|
+
return date.toISOString().split('T')[0];
|
|
862
|
+
} catch {
|
|
863
|
+
return new Date().toISOString().split('T')[0];
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
const country = campaignData?.direct?.marketSelection?.country || 'Japan';
|
|
868
|
+
const startDate = lineItemData?.startDate || lineItemData?.start_date;
|
|
869
|
+
const endDate = lineItemData?.endDate || lineItemData?.end_date;
|
|
870
|
+
|
|
871
|
+
const recommendationRequest: RecommendationRequest = {
|
|
872
|
+
country,
|
|
873
|
+
startDate: formatDateForAPI(startDate),
|
|
874
|
+
endDate: formatDateForAPI(endDate),
|
|
875
|
+
companyId: user?.company_id || campaignData?.companyId || campaignData?.company_id,
|
|
876
|
+
brandId: campaignData?.brandId || campaignData?.brand_id,
|
|
877
|
+
budget: lineItemData?.direct?.budgetSetup?.budgetAmount,
|
|
878
|
+
goal: lineItemData?.direct?.campaignGoal?.type as 'IMPRESSIONS' | 'REACH' | 'SOV' | undefined,
|
|
879
|
+
goalValue: lineItemData?.direct?.campaignGoal?.targetValue,
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
// Add audience targeting (demographics + audience segments)
|
|
883
|
+
const audienceTargeting: { demographics?: Record<string, string[]>; audienceSegments?: string[] } = {};
|
|
884
|
+
if (targeting.demographics && Object.keys(targeting.demographics).length > 0) {
|
|
885
|
+
audienceTargeting.demographics = targeting.demographics as Record<string, string[]>;
|
|
886
|
+
}
|
|
887
|
+
// Cast to any to check for audienceSegments which may be present in form data
|
|
888
|
+
const targetingAny = targeting as any;
|
|
889
|
+
if (targetingAny.audienceSegments && targetingAny.audienceSegments.length > 0) {
|
|
890
|
+
audienceTargeting.audienceSegments = targetingAny.audienceSegments;
|
|
891
|
+
}
|
|
892
|
+
if (Object.keys(audienceTargeting).length > 0) {
|
|
893
|
+
recommendationRequest.audienceTargeting = audienceTargeting;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// Add geography targeting (cities, states, geofences)
|
|
897
|
+
const geographyTargeting: { cities?: string[]; states?: string[]; geofences?: any[] } = {};
|
|
898
|
+
const geofencing = targeting.geofencing as any;
|
|
899
|
+
|
|
900
|
+
// Add cities from targeting
|
|
901
|
+
if (geofencing?.cities && geofencing.cities.length > 0) {
|
|
902
|
+
geographyTargeting.cities = geofencing.cities;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// Add states from targeting
|
|
906
|
+
if (geofencing?.states && geofencing.states.length > 0) {
|
|
907
|
+
geographyTargeting.states = geofencing.states;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// Add geofences from targeting locations
|
|
911
|
+
if (geofencing?.locations && geofencing.locations.length > 0) {
|
|
912
|
+
geographyTargeting.geofences = geofencing.locations.map((loc: any) => ({
|
|
913
|
+
type: loc.type || 'circle',
|
|
914
|
+
coordinates: loc.coordinates || [[loc.lng, loc.lat]],
|
|
915
|
+
centerLng: loc.lng,
|
|
916
|
+
centerLat: loc.lat,
|
|
917
|
+
}));
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Add geofences from geometrics (polygons, circles drawn on map)
|
|
921
|
+
if (geofencing?.geometrics && geofencing.geometrics.length > 0) {
|
|
922
|
+
const geometricGeofences = geofencing.geometrics.map((geom: any) => ({
|
|
923
|
+
type: geom.type || 'polygon',
|
|
924
|
+
coordinates: geom.coordinates || [],
|
|
925
|
+
centerLng: geom.center?.lng || geom.centerLng || 0,
|
|
926
|
+
centerLat: geom.center?.lat || geom.centerLat || 0,
|
|
927
|
+
}));
|
|
928
|
+
geographyTargeting.geofences = [
|
|
929
|
+
...(geographyTargeting.geofences || []),
|
|
930
|
+
...geometricGeofences,
|
|
931
|
+
];
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if (Object.keys(geographyTargeting).length > 0) {
|
|
935
|
+
recommendationRequest.geographyTargeting = geographyTargeting;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
const pollRecommendation = async () => {
|
|
939
|
+
try {
|
|
940
|
+
const response = await submitRecommendation(lineItemId, recommendationRequest);
|
|
941
|
+
|
|
942
|
+
let finalStatus = response;
|
|
943
|
+
if (response.status === 'IN_PROGRESS') {
|
|
944
|
+
finalStatus = await pollUntilCompleted(lineItemId, recommendationRequest);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
setIsSubmittingRecommendation(false);
|
|
948
|
+
|
|
949
|
+
console.log('[Targeting] Recommendation completed, runId:', finalStatus.runId, 'Full response:', finalStatus);
|
|
950
|
+
|
|
951
|
+
onComplete({
|
|
952
|
+
...targetingData,
|
|
953
|
+
recommendationRunId: finalStatus.runId,
|
|
954
|
+
});
|
|
955
|
+
} catch (error) {
|
|
956
|
+
console.error('Recommendation submission failed:', error);
|
|
957
|
+
setIsSubmittingRecommendation(false);
|
|
958
|
+
setRecommendationError(error instanceof Error ? error.message : 'Failed to get recommendations');
|
|
959
|
+
|
|
960
|
+
onComplete(targetingData);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
pollRecommendation();
|
|
965
|
+
} else {
|
|
966
|
+
// No lineItemId, proceed without recommendations
|
|
967
|
+
onComplete(targetingData);
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
const suggestions = getSmartSuggestions(campaignData);
|
|
972
|
+
|
|
973
|
+
const handleFormSubmit = (e: React.FormEvent) => {
|
|
974
|
+
e.preventDefault();
|
|
975
|
+
if (!isSubmittingRecommendation) {
|
|
976
|
+
handleNext();
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
const dealCountry = campaignData?.direct?.marketSelection?.country;
|
|
981
|
+
|
|
982
|
+
return (
|
|
983
|
+
<form
|
|
984
|
+
id={formId}
|
|
985
|
+
onSubmit={handleFormSubmit}
|
|
986
|
+
className="flex flex-col h-full relative"
|
|
987
|
+
>
|
|
988
|
+
{/* Loading overlay for recommendation submission */}
|
|
989
|
+
{isSubmittingRecommendation && (
|
|
990
|
+
<div className="absolute inset-0 bg-white/80 dark:bg-gray-900/80 z-50 flex flex-col items-center justify-center">
|
|
991
|
+
<Loader2 className="h-8 w-8 animate-spin text-primary mb-4" />
|
|
992
|
+
<p className="text-lg font-medium">{t('wizard.common.findingBestInventory')}</p>
|
|
993
|
+
<p className="text-sm text-muted-foreground mt-1">{t('wizard.common.mayTakeMoment')}</p>
|
|
994
|
+
</div>
|
|
995
|
+
)}
|
|
996
|
+
|
|
997
|
+
{recommendationError && (
|
|
998
|
+
<div className="mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg">
|
|
999
|
+
<p className="text-sm text-yellow-700">{t('wizard.common.note')} {recommendationError}</p>
|
|
1000
|
+
<p className="text-xs text-yellow-600">{t('wizard.common.proceedingWithStandardSearch')}</p>
|
|
1001
|
+
</div>
|
|
1002
|
+
)}
|
|
1003
|
+
|
|
1004
|
+
{isPlannerRestricted && (
|
|
1005
|
+
<div className="mb-4 p-3 bg-purple-50 border border-purple-200 rounded-lg">
|
|
1006
|
+
<p className="text-sm text-purple-700 font-medium">{t('wizard.common.readOnly')}</p>
|
|
1007
|
+
<p className="text-xs text-purple-600">{t('wizard.targeting.plannerRestrictedDesc')}</p>
|
|
1008
|
+
</div>
|
|
1009
|
+
)}
|
|
1010
|
+
<div className="flex-1 flex gap-6">
|
|
1011
|
+
<div className="min-w-0 space-y-6 flex-1">
|
|
1012
|
+
<div className="space-y-1">
|
|
1013
|
+
<div className="flex items-center justify-between p-3 bg-mw-neutral-50 dark:bg-mw-neutral-800 rounded-lg">
|
|
1014
|
+
<div className="flex items-center gap-2">
|
|
1015
|
+
<Monitor className="h-4 w-4 text-mw-neutral-500" />
|
|
1016
|
+
<span className="text-sm">Media Type</span>
|
|
1017
|
+
</div>
|
|
1018
|
+
<div className="flex items-center gap-2">
|
|
1019
|
+
<span className="text-sm text-mw-neutral-700 dark:text-mw-neutral-300">DOOH</span>
|
|
1020
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1021
|
+
</div>
|
|
1022
|
+
</div>
|
|
1023
|
+
|
|
1024
|
+
<Collapsible>
|
|
1025
|
+
<CollapsibleTrigger asChild>
|
|
1026
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1027
|
+
<div className="flex items-center gap-2">
|
|
1028
|
+
<MapPin className="h-4 w-4 text-mw-neutral-500" />
|
|
1029
|
+
<span className="text-sm">{t('wizard.targeting.geofencingTab')}</span>
|
|
1030
|
+
</div>
|
|
1031
|
+
<div className="flex items-center gap-2">
|
|
1032
|
+
<span className="text-sm text-mw-neutral-500">{geoLocations.length} locations selected</span>
|
|
1033
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1034
|
+
</div>
|
|
1035
|
+
</div>
|
|
1036
|
+
</CollapsibleTrigger>
|
|
1037
|
+
<CollapsibleContent>
|
|
1038
|
+
<div className="px-3 pb-3 space-y-2">
|
|
1039
|
+
<div className="flex items-center justify-between">
|
|
1040
|
+
<Label className="text-xs text-mw-neutral-500">Enter locations</Label>
|
|
1041
|
+
<Button
|
|
1042
|
+
type="button"
|
|
1043
|
+
variant="outline"
|
|
1044
|
+
size="sm"
|
|
1045
|
+
className="gap-1 h-7 text-xs"
|
|
1046
|
+
onClick={() => setIsGeoMapSheetOpen(true)}
|
|
1047
|
+
>
|
|
1048
|
+
<Map className="h-3 w-3" />
|
|
1049
|
+
Advanced Map
|
|
1050
|
+
</Button>
|
|
1051
|
+
</div>
|
|
1052
|
+
<Input
|
|
1053
|
+
placeholder="Enter locations (comma separated)"
|
|
1054
|
+
value={geographyInput || geoLocations.filter((loc: any) => loc.properties?.included !== false).map((loc: any) => loc.properties?.name || "Location").filter(Boolean).join(", ")}
|
|
1055
|
+
onChange={(e) => {
|
|
1056
|
+
setGeographyInput(e.target.value);
|
|
1057
|
+
}}
|
|
1058
|
+
data-testid="input-geography"
|
|
1059
|
+
/>
|
|
1060
|
+
</div>
|
|
1061
|
+
</CollapsibleContent>
|
|
1062
|
+
</Collapsible>
|
|
1063
|
+
|
|
1064
|
+
<Collapsible>
|
|
1065
|
+
<CollapsibleTrigger asChild>
|
|
1066
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1067
|
+
<div className="flex items-center gap-2">
|
|
1068
|
+
<Users className="h-4 w-4 text-mw-neutral-500" />
|
|
1069
|
+
<span className="text-sm">{t('wizard.targeting.ageGroup')}</span>
|
|
1070
|
+
</div>
|
|
1071
|
+
<div className="flex items-center gap-2">
|
|
1072
|
+
<span className="text-sm text-mw-neutral-500">{selectedAgeGroups.length} selected</span>
|
|
1073
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1074
|
+
</div>
|
|
1075
|
+
</div>
|
|
1076
|
+
</CollapsibleTrigger>
|
|
1077
|
+
<CollapsibleContent>
|
|
1078
|
+
<div className={cn("px-3 pb-3", isPlannerRestricted && "opacity-60 pointer-events-none")}>
|
|
1079
|
+
<div className="grid grid-cols-3 gap-x-6 gap-y-2">
|
|
1080
|
+
{AGE_GROUPS.map((age) => (
|
|
1081
|
+
<div key={age.value} className="flex items-center gap-2">
|
|
1082
|
+
<Checkbox
|
|
1083
|
+
id={`age-${age.value}`}
|
|
1084
|
+
checked={selectedAgeGroups.includes(age.value)}
|
|
1085
|
+
onChange={() => {
|
|
1086
|
+
if (selectedAgeGroups.includes(age.value)) {
|
|
1087
|
+
setSelectedAgeGroups(selectedAgeGroups.filter((a) => a !== age.value));
|
|
1088
|
+
} else {
|
|
1089
|
+
setSelectedAgeGroups([...selectedAgeGroups, age.value]);
|
|
1090
|
+
}
|
|
1091
|
+
}}
|
|
1092
|
+
disabled={isPlannerRestricted}
|
|
1093
|
+
/>
|
|
1094
|
+
<Label htmlFor={`age-${age.value}`} className="text-sm font-normal cursor-pointer">
|
|
1095
|
+
{age.label}
|
|
1096
|
+
</Label>
|
|
1097
|
+
</div>
|
|
1098
|
+
))}
|
|
1099
|
+
</div>
|
|
1100
|
+
</div>
|
|
1101
|
+
</CollapsibleContent>
|
|
1102
|
+
</Collapsible>
|
|
1103
|
+
|
|
1104
|
+
<Collapsible>
|
|
1105
|
+
<CollapsibleTrigger asChild>
|
|
1106
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1107
|
+
<div className="flex items-center gap-2">
|
|
1108
|
+
<Users className="h-4 w-4 text-mw-neutral-500" />
|
|
1109
|
+
<span className="text-sm">{t('wizard.targeting.gender')}</span>
|
|
1110
|
+
</div>
|
|
1111
|
+
<div className="flex items-center gap-2">
|
|
1112
|
+
<span className="text-sm text-mw-neutral-500">{selectedGenders.length} selected</span>
|
|
1113
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1114
|
+
</div>
|
|
1115
|
+
</div>
|
|
1116
|
+
</CollapsibleTrigger>
|
|
1117
|
+
<CollapsibleContent>
|
|
1118
|
+
<div className={cn("px-3 pb-3", isPlannerRestricted && "opacity-60 pointer-events-none")}>
|
|
1119
|
+
<div className="grid grid-cols-3 gap-x-6 gap-y-2">
|
|
1120
|
+
{GENDERS.map((gender) => (
|
|
1121
|
+
<div key={gender.value} className="flex items-center gap-2">
|
|
1122
|
+
<Checkbox
|
|
1123
|
+
id={`gender-${gender.value}`}
|
|
1124
|
+
checked={selectedGenders.includes(gender.value)}
|
|
1125
|
+
onChange={() => {
|
|
1126
|
+
if (selectedGenders.includes(gender.value)) {
|
|
1127
|
+
setSelectedGenders(selectedGenders.filter((g) => g !== gender.value));
|
|
1128
|
+
} else {
|
|
1129
|
+
setSelectedGenders([...selectedGenders, gender.value]);
|
|
1130
|
+
}
|
|
1131
|
+
}}
|
|
1132
|
+
disabled={isPlannerRestricted}
|
|
1133
|
+
/>
|
|
1134
|
+
<Label htmlFor={`gender-${gender.value}`} className="text-sm font-normal cursor-pointer">
|
|
1135
|
+
{gender.label}
|
|
1136
|
+
</Label>
|
|
1137
|
+
</div>
|
|
1138
|
+
))}
|
|
1139
|
+
</div>
|
|
1140
|
+
</div>
|
|
1141
|
+
</CollapsibleContent>
|
|
1142
|
+
</Collapsible>
|
|
1143
|
+
|
|
1144
|
+
<Collapsible>
|
|
1145
|
+
<CollapsibleTrigger asChild>
|
|
1146
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1147
|
+
<div className="flex items-center gap-2">
|
|
1148
|
+
<Users className="h-4 w-4 text-mw-neutral-500" />
|
|
1149
|
+
<span className="text-sm">{t('wizard.targeting.incomeGroup')}</span>
|
|
1150
|
+
</div>
|
|
1151
|
+
<div className="flex items-center gap-2">
|
|
1152
|
+
<span className="text-sm text-mw-neutral-500">{selectedIncomeBrackets.length} selected</span>
|
|
1153
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1154
|
+
</div>
|
|
1155
|
+
</div>
|
|
1156
|
+
</CollapsibleTrigger>
|
|
1157
|
+
<CollapsibleContent>
|
|
1158
|
+
<div className={cn("px-3 pb-3", isPlannerRestricted && "opacity-60 pointer-events-none")}>
|
|
1159
|
+
<div className="grid grid-cols-3 gap-x-6 gap-y-2">
|
|
1160
|
+
{INCOME_BRACKETS.map((income) => (
|
|
1161
|
+
<div key={income.value} className="flex items-center gap-2">
|
|
1162
|
+
<Checkbox
|
|
1163
|
+
id={`income-${income.value}`}
|
|
1164
|
+
checked={selectedIncomeBrackets.includes(income.value)}
|
|
1165
|
+
onChange={() => {
|
|
1166
|
+
if (selectedIncomeBrackets.includes(income.value)) {
|
|
1167
|
+
setSelectedIncomeBrackets(selectedIncomeBrackets.filter((i) => i !== income.value));
|
|
1168
|
+
} else {
|
|
1169
|
+
setSelectedIncomeBrackets([...selectedIncomeBrackets, income.value]);
|
|
1170
|
+
}
|
|
1171
|
+
}}
|
|
1172
|
+
disabled={isPlannerRestricted}
|
|
1173
|
+
/>
|
|
1174
|
+
<Label htmlFor={`income-${income.value}`} className="text-sm font-normal cursor-pointer">
|
|
1175
|
+
{income.label}
|
|
1176
|
+
</Label>
|
|
1177
|
+
</div>
|
|
1178
|
+
))}
|
|
1179
|
+
</div>
|
|
1180
|
+
</div>
|
|
1181
|
+
</CollapsibleContent>
|
|
1182
|
+
</Collapsible>
|
|
1183
|
+
|
|
1184
|
+
<Collapsible>
|
|
1185
|
+
<CollapsibleTrigger asChild>
|
|
1186
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1187
|
+
<div className="flex items-center gap-2">
|
|
1188
|
+
<Users className="h-4 w-4 text-mw-neutral-500" />
|
|
1189
|
+
<span className="text-sm">{t('wizard.targeting.interestActivities')}</span>
|
|
1190
|
+
</div>
|
|
1191
|
+
<div className="flex items-center gap-2">
|
|
1192
|
+
<span className="text-sm text-mw-neutral-500">{selectedInterests.length} selected</span>
|
|
1193
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1194
|
+
</div>
|
|
1195
|
+
</div>
|
|
1196
|
+
</CollapsibleTrigger>
|
|
1197
|
+
<CollapsibleContent>
|
|
1198
|
+
<div className={cn("px-3 pb-3", isPlannerRestricted && "opacity-60 pointer-events-none")}>
|
|
1199
|
+
<div className="grid grid-cols-3 gap-x-6 gap-y-2">
|
|
1200
|
+
{INTERESTS.map((interest) => (
|
|
1201
|
+
<div key={interest.value} className="flex items-center gap-2">
|
|
1202
|
+
<Checkbox
|
|
1203
|
+
id={`interest-${interest.value}`}
|
|
1204
|
+
checked={selectedInterests.includes(interest.value)}
|
|
1205
|
+
onChange={() => {
|
|
1206
|
+
if (selectedInterests.includes(interest.value)) {
|
|
1207
|
+
setSelectedInterests(selectedInterests.filter((i) => i !== interest.value));
|
|
1208
|
+
} else {
|
|
1209
|
+
setSelectedInterests([...selectedInterests, interest.value]);
|
|
1210
|
+
}
|
|
1211
|
+
}}
|
|
1212
|
+
disabled={isPlannerRestricted}
|
|
1213
|
+
/>
|
|
1214
|
+
<Label htmlFor={`interest-${interest.value}`} className="text-sm font-normal cursor-pointer">
|
|
1215
|
+
{interest.label}
|
|
1216
|
+
</Label>
|
|
1217
|
+
</div>
|
|
1218
|
+
))}
|
|
1219
|
+
</div>
|
|
1220
|
+
</div>
|
|
1221
|
+
</CollapsibleContent>
|
|
1222
|
+
</Collapsible>
|
|
1223
|
+
|
|
1224
|
+
<Collapsible>
|
|
1225
|
+
<CollapsibleTrigger asChild>
|
|
1226
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1227
|
+
<div className="flex items-center gap-2">
|
|
1228
|
+
<Users className="h-4 w-4 text-mw-neutral-500" />
|
|
1229
|
+
<span className="text-sm">{t('wizard.targeting.venueType')}</span>
|
|
1230
|
+
</div>
|
|
1231
|
+
<div className="flex items-center gap-2">
|
|
1232
|
+
<span className="text-sm text-mw-neutral-500">{selectedVenueTypes.length} selected</span>
|
|
1233
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1234
|
+
</div>
|
|
1235
|
+
</div>
|
|
1236
|
+
</CollapsibleTrigger>
|
|
1237
|
+
<CollapsibleContent>
|
|
1238
|
+
<div className={cn("px-3 pb-3", isPlannerRestricted && "opacity-60 pointer-events-none")}>
|
|
1239
|
+
<HierarchicalVenueSelector
|
|
1240
|
+
label={t('wizard.targeting.venueType')}
|
|
1241
|
+
venues={venueTypes}
|
|
1242
|
+
selectedIds={selectedVenueTypes}
|
|
1243
|
+
onChange={setSelectedVenueTypes}
|
|
1244
|
+
placeholder={t('wizard.targeting.selectVenueType')}
|
|
1245
|
+
disabled={isLoadingVenues || isPlannerRestricted}
|
|
1246
|
+
/>
|
|
1247
|
+
</div>
|
|
1248
|
+
</CollapsibleContent>
|
|
1249
|
+
</Collapsible>
|
|
1250
|
+
|
|
1251
|
+
<Collapsible>
|
|
1252
|
+
<CollapsibleTrigger asChild>
|
|
1253
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1254
|
+
<div className="flex items-center gap-2">
|
|
1255
|
+
<Users className="h-4 w-4 text-mw-neutral-500" />
|
|
1256
|
+
<span className="text-sm">{t('wizard.targeting.audienceBehaviour')}</span>
|
|
1257
|
+
</div>
|
|
1258
|
+
<div className="flex items-center gap-2">
|
|
1259
|
+
<span className="text-sm text-mw-neutral-500">{selectedBehaviors.length} selected</span>
|
|
1260
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1261
|
+
</div>
|
|
1262
|
+
</div>
|
|
1263
|
+
</CollapsibleTrigger>
|
|
1264
|
+
<CollapsibleContent>
|
|
1265
|
+
<div className={cn("px-3 pb-3", isPlannerRestricted && "opacity-60 pointer-events-none")}>
|
|
1266
|
+
<div className="grid grid-cols-3 gap-x-6 gap-y-2">
|
|
1267
|
+
{AUDIENCE_BEHAVIORS.map((behavior) => (
|
|
1268
|
+
<div key={behavior.value} className="flex items-center gap-2">
|
|
1269
|
+
<Checkbox
|
|
1270
|
+
id={`behavior-${behavior.value}`}
|
|
1271
|
+
checked={selectedBehaviors.includes(behavior.value)}
|
|
1272
|
+
onChange={() => {
|
|
1273
|
+
if (selectedBehaviors.includes(behavior.value)) {
|
|
1274
|
+
setSelectedBehaviors(selectedBehaviors.filter((b) => b !== behavior.value));
|
|
1275
|
+
} else {
|
|
1276
|
+
setSelectedBehaviors([...selectedBehaviors, behavior.value]);
|
|
1277
|
+
}
|
|
1278
|
+
}}
|
|
1279
|
+
disabled={isPlannerRestricted}
|
|
1280
|
+
/>
|
|
1281
|
+
<Label htmlFor={`behavior-${behavior.value}`} className="text-sm font-normal cursor-pointer">
|
|
1282
|
+
{behavior.label}
|
|
1283
|
+
</Label>
|
|
1284
|
+
</div>
|
|
1285
|
+
))}
|
|
1286
|
+
</div>
|
|
1287
|
+
</div>
|
|
1288
|
+
</CollapsibleContent>
|
|
1289
|
+
</Collapsible>
|
|
1290
|
+
|
|
1291
|
+
{dealMode === "DIRECT" && (
|
|
1292
|
+
<Collapsible>
|
|
1293
|
+
<CollapsibleTrigger asChild>
|
|
1294
|
+
<div className="flex items-center justify-between p-3 cursor-pointer hover:bg-mw-neutral-50 dark:hover:bg-mw-neutral-800 rounded-lg transition-colors">
|
|
1295
|
+
<div className="flex items-center gap-2">
|
|
1296
|
+
<svg className="h-4 w-4 text-mw-neutral-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
1297
|
+
<path d="M12 2v4m0 12v4M4.93 4.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83" />
|
|
1298
|
+
</svg>
|
|
1299
|
+
<span className="text-sm">Signals & Triggers</span>
|
|
1300
|
+
</div>
|
|
1301
|
+
<div className="flex items-center gap-2">
|
|
1302
|
+
<span className="text-sm text-mw-neutral-500">{selectedSignals.length} selected</span>
|
|
1303
|
+
<Check className="h-4 w-4 text-mw-primary-500" />
|
|
1304
|
+
</div>
|
|
1305
|
+
</div>
|
|
1306
|
+
</CollapsibleTrigger>
|
|
1307
|
+
<CollapsibleContent>
|
|
1308
|
+
<div className="px-3 pb-3 space-y-4">
|
|
1309
|
+
<MultiSelect
|
|
1310
|
+
label="Select Signal Types"
|
|
1311
|
+
placeholder="Select signals & triggers..."
|
|
1312
|
+
options={SIGNAL_OPTIONS.map((s) => ({
|
|
1313
|
+
value: s.id,
|
|
1314
|
+
label: s.label,
|
|
1315
|
+
}))}
|
|
1316
|
+
value={selectedSignals}
|
|
1317
|
+
onChange={(values) => setSelectedSignals(values)}
|
|
1318
|
+
searchable={true}
|
|
1319
|
+
showSelectAll={true}
|
|
1320
|
+
/>
|
|
1321
|
+
|
|
1322
|
+
{selectedSignals.includes("weather") && (
|
|
1323
|
+
<Card className="p-4 bg-mw-neutral-50 dark:bg-mw-neutral-800/50 border-mw-primary-200">
|
|
1324
|
+
<h4 className="font-medium text-sm text-mw-neutral-900 dark:text-white mb-4 flex items-center gap-2">
|
|
1325
|
+
<svg className="h-4 w-4 text-yellow-500" viewBox="0 0 24 24" fill="currentColor">
|
|
1326
|
+
<path d="M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-2.25A.75.75 0 0112 18zM7.758 17.303a.75.75 0 00-1.061-1.06l-1.591 1.59a.75.75 0 001.06 1.061l1.591-1.59zM6 12a.75.75 0 01-.75.75H3a.75.75 0 010-1.5h2.25A.75.75 0 016 12zM6.697 7.757a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 00-1.061 1.06l1.59 1.591z"/>
|
|
1327
|
+
</svg>
|
|
1328
|
+
Weather Configuration
|
|
1329
|
+
</h4>
|
|
1330
|
+
<div className="space-y-4">
|
|
1331
|
+
<MultiSelect
|
|
1332
|
+
label="Weather Conditions"
|
|
1333
|
+
placeholder="Select weather conditions..."
|
|
1334
|
+
options={WEATHER_CONDITIONS}
|
|
1335
|
+
value={weatherConditions}
|
|
1336
|
+
onChange={setWeatherConditions}
|
|
1337
|
+
searchable={true}
|
|
1338
|
+
showSelectAll={true}
|
|
1339
|
+
/>
|
|
1340
|
+
<div className="border-t border-mw-neutral-200 dark:border-mw-neutral-700 pt-4">
|
|
1341
|
+
<Label className="text-sm font-medium text-mw-neutral-700 dark:text-mw-neutral-300 mb-3 block">
|
|
1342
|
+
Temperature Range (Optional)
|
|
1343
|
+
</Label>
|
|
1344
|
+
<div className="grid grid-cols-3 gap-3">
|
|
1345
|
+
<div>
|
|
1346
|
+
<Label className="text-xs text-mw-neutral-500 mb-1 block">Min</Label>
|
|
1347
|
+
<Input
|
|
1348
|
+
type="number"
|
|
1349
|
+
placeholder="Min"
|
|
1350
|
+
value={temperatureMin}
|
|
1351
|
+
onChange={(e) => setTemperatureMin(e.target.value)}
|
|
1352
|
+
className="h-9"
|
|
1353
|
+
/>
|
|
1354
|
+
</div>
|
|
1355
|
+
<div>
|
|
1356
|
+
<Label className="text-xs text-mw-neutral-500 mb-1 block">Max</Label>
|
|
1357
|
+
<Input
|
|
1358
|
+
type="number"
|
|
1359
|
+
placeholder="Max"
|
|
1360
|
+
value={temperatureMax}
|
|
1361
|
+
onChange={(e) => setTemperatureMax(e.target.value)}
|
|
1362
|
+
className="h-9"
|
|
1363
|
+
/>
|
|
1364
|
+
</div>
|
|
1365
|
+
<div>
|
|
1366
|
+
<Label className="text-xs text-mw-neutral-500 mb-1 block">Unit</Label>
|
|
1367
|
+
<Select
|
|
1368
|
+
value={temperatureUnit}
|
|
1369
|
+
onChange={(e) => setTemperatureUnit(e.target.value)}
|
|
1370
|
+
options={TEMPERATURE_UNITS}
|
|
1371
|
+
/>
|
|
1372
|
+
</div>
|
|
1373
|
+
</div>
|
|
1374
|
+
</div>
|
|
1375
|
+
</div>
|
|
1376
|
+
</Card>
|
|
1377
|
+
)}
|
|
1378
|
+
|
|
1379
|
+
{selectedSignals.includes("traffic") && (
|
|
1380
|
+
<Card className="p-4 bg-mw-neutral-50 dark:bg-mw-neutral-800/50 border-mw-primary-200">
|
|
1381
|
+
<h4 className="font-medium text-sm text-mw-neutral-900 dark:text-white mb-4 flex items-center gap-2">
|
|
1382
|
+
<svg className="h-4 w-4 text-blue-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
1383
|
+
<path d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
1384
|
+
</svg>
|
|
1385
|
+
Traffic Configuration
|
|
1386
|
+
</h4>
|
|
1387
|
+
<MultiSelect
|
|
1388
|
+
label="Traffic Density"
|
|
1389
|
+
placeholder="Select traffic density levels..."
|
|
1390
|
+
options={TRAFFIC_DENSITY}
|
|
1391
|
+
value={trafficDensity}
|
|
1392
|
+
onChange={setTrafficDensity}
|
|
1393
|
+
/>
|
|
1394
|
+
</Card>
|
|
1395
|
+
)}
|
|
1396
|
+
|
|
1397
|
+
{selectedSignals.includes("aqi") && (
|
|
1398
|
+
<Card className="p-4 bg-mw-neutral-50 dark:bg-mw-neutral-800/50 border-mw-primary-200">
|
|
1399
|
+
<h4 className="font-medium text-sm text-mw-neutral-900 dark:text-white mb-4 flex items-center gap-2">
|
|
1400
|
+
<svg className="h-4 w-4 text-green-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
1401
|
+
<path d="M4.26 10.147a60.436 60.436 0 00-.491 6.347A48.627 48.627 0 0112 20.904a48.627 48.627 0 018.232-4.41 60.46 60.46 0 00-.491-6.347m-15.482 0a50.57 50.57 0 00-2.658-.813A59.905 59.905 0 0112 3.493a59.902 59.902 0 0110.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.697 50.697 0 0112 13.489a50.702 50.702 0 017.74-3.342M6.75 15a.75.75 0 100-1.5.75.75 0 000 1.5zm0 0v-3.675A55.378 55.378 0 0112 8.443m-7.007 11.55A5.981 5.981 0 006.75 15.75v-1.5"/>
|
|
1402
|
+
</svg>
|
|
1403
|
+
Air Quality Index Configuration
|
|
1404
|
+
</h4>
|
|
1405
|
+
<MultiSelect
|
|
1406
|
+
label="AQI Threshold"
|
|
1407
|
+
placeholder="Select AQI thresholds..."
|
|
1408
|
+
options={AQI_THRESHOLDS}
|
|
1409
|
+
value={aqiThreshold}
|
|
1410
|
+
onChange={setAqiThreshold}
|
|
1411
|
+
/>
|
|
1412
|
+
</Card>
|
|
1413
|
+
)}
|
|
1414
|
+
|
|
1415
|
+
{selectedSignals.includes("time_of_day") && (
|
|
1416
|
+
<Card className="p-4 bg-mw-neutral-50 dark:bg-mw-neutral-800/50 border-mw-primary-200">
|
|
1417
|
+
<h4 className="font-medium text-sm text-mw-neutral-900 dark:text-white mb-4 flex items-center gap-2">
|
|
1418
|
+
<svg className="h-4 w-4 text-purple-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
1419
|
+
<path d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
1420
|
+
</svg>
|
|
1421
|
+
Time of Day Configuration
|
|
1422
|
+
</h4>
|
|
1423
|
+
<MultiSelect
|
|
1424
|
+
label="Dayparts"
|
|
1425
|
+
placeholder="Select dayparts..."
|
|
1426
|
+
options={DAYPARTS}
|
|
1427
|
+
value={dayparts}
|
|
1428
|
+
onChange={setDayparts}
|
|
1429
|
+
showSelectAll={true}
|
|
1430
|
+
/>
|
|
1431
|
+
</Card>
|
|
1432
|
+
)}
|
|
1433
|
+
|
|
1434
|
+
</div>
|
|
1435
|
+
</CollapsibleContent>
|
|
1436
|
+
</Collapsible>
|
|
1437
|
+
)}
|
|
1438
|
+
</div>
|
|
1439
|
+
</div>
|
|
1440
|
+
|
|
1441
|
+
<FormInsights
|
|
1442
|
+
insights={[
|
|
1443
|
+
{
|
|
1444
|
+
text: "Demographics help reach the right audience segments",
|
|
1445
|
+
color: "green",
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
text: "Geofencing allows precise location-based targeting",
|
|
1449
|
+
color: "blue",
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
text: "Signals enable dynamic triggering based on conditions",
|
|
1453
|
+
color: "green",
|
|
1454
|
+
},
|
|
1455
|
+
]}
|
|
1456
|
+
quickTips={[
|
|
1457
|
+
{
|
|
1458
|
+
text: "Use Smart Suggestions for AI-recommended targeting",
|
|
1459
|
+
color: "blue",
|
|
1460
|
+
},
|
|
1461
|
+
{
|
|
1462
|
+
text: "Combine multiple targeting criteria for precision",
|
|
1463
|
+
color: "green",
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
text: "Geofencing is UI-only (API support coming soon)",
|
|
1467
|
+
color: "orange",
|
|
1468
|
+
},
|
|
1469
|
+
]}
|
|
1470
|
+
/>
|
|
1471
|
+
</div>
|
|
1472
|
+
|
|
1473
|
+
<LocationCsvUploadDrawer
|
|
1474
|
+
open={showImportModal}
|
|
1475
|
+
onOpenChange={setShowImportModal}
|
|
1476
|
+
onLocationsSelected={handleCsvLocationsSelected}
|
|
1477
|
+
/>
|
|
1478
|
+
|
|
1479
|
+
<Sheet open={isGeoMapSheetOpen} onOpenChange={setIsGeoMapSheetOpen}>
|
|
1480
|
+
<SheetContent side="right" className="w-full sm:max-w-[90vw] lg:max-w-[80vw] overflow-hidden flex flex-col p-0">
|
|
1481
|
+
<div className="flex h-full">
|
|
1482
|
+
<div className="flex-1 relative">
|
|
1483
|
+
<GeofencingMap
|
|
1484
|
+
onLocationsChange={handleLocationsChange}
|
|
1485
|
+
initialLocations={geoLocations}
|
|
1486
|
+
radiusKm={parseFloat(geoRadius) || 5}
|
|
1487
|
+
country={dealCountry}
|
|
1488
|
+
addPOI={addPOIMode}
|
|
1489
|
+
selectedLocation={
|
|
1490
|
+
selectedLocationIndex !== null
|
|
1491
|
+
? geoLocations[selectedLocationIndex]
|
|
1492
|
+
: null
|
|
1493
|
+
}
|
|
1494
|
+
onCenterOnLocation={shouldCenterOnLocation}
|
|
1495
|
+
onAddPOIChange={(mode) => {
|
|
1496
|
+
setAddPOIMode(mode);
|
|
1497
|
+
if (!mode) setSelectedLocationIndex(null);
|
|
1498
|
+
}}
|
|
1499
|
+
onUpdateLocationPOIMetadata={(id, metadata, pois) => {
|
|
1500
|
+
setGeoLocations((prev) =>
|
|
1501
|
+
prev.map((loc) => {
|
|
1502
|
+
if (loc.id === id) {
|
|
1503
|
+
return {
|
|
1504
|
+
...loc,
|
|
1505
|
+
poi: pois,
|
|
1506
|
+
metadata: { ...loc.metadata, ...metadata },
|
|
1507
|
+
properties: {
|
|
1508
|
+
...loc.properties,
|
|
1509
|
+
pois: pois.map((p) => ({
|
|
1510
|
+
type: p,
|
|
1511
|
+
label: p,
|
|
1512
|
+
})),
|
|
1513
|
+
},
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
return loc;
|
|
1517
|
+
}),
|
|
1518
|
+
);
|
|
1519
|
+
setAddPOIMode(false);
|
|
1520
|
+
setSelectedLocationIndex(null);
|
|
1521
|
+
}}
|
|
1522
|
+
/>
|
|
1523
|
+
</div>
|
|
1524
|
+
|
|
1525
|
+
<div className="w-80 border-l border-mw-neutral-200 dark:border-mw-neutral-700 bg-white dark:bg-mw-neutral-900 flex flex-col">
|
|
1526
|
+
<div className="p-4 border-b border-mw-neutral-200 dark:border-mw-neutral-700">
|
|
1527
|
+
<h3 className="font-semibold text-lg text-mw-neutral-900 dark:text-white">
|
|
1528
|
+
{t('wizard.targeting.selectedLocations')}
|
|
1529
|
+
</h3>
|
|
1530
|
+
<p className="text-sm text-mw-neutral-500 mt-1">
|
|
1531
|
+
{t('wizard.targeting.clickMapToAddLocations')}
|
|
1532
|
+
</p>
|
|
1533
|
+
</div>
|
|
1534
|
+
|
|
1535
|
+
<div className="p-4 border-b border-mw-neutral-200 dark:border-mw-neutral-700">
|
|
1536
|
+
<div className="relative">
|
|
1537
|
+
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-mw-neutral-400" />
|
|
1538
|
+
<Input
|
|
1539
|
+
placeholder={t('wizard.targeting.searchAddedLocations')}
|
|
1540
|
+
value={locationSearch}
|
|
1541
|
+
onChange={(e) => setLocationSearch(e.target.value)}
|
|
1542
|
+
className="pl-9"
|
|
1543
|
+
/>
|
|
1544
|
+
</div>
|
|
1545
|
+
<div className="flex items-center gap-2 mt-3">
|
|
1546
|
+
<Checkbox
|
|
1547
|
+
checked={includeAllLocations}
|
|
1548
|
+
onChange={handleIncludeAllChange}
|
|
1549
|
+
/>
|
|
1550
|
+
<Label className="text-sm cursor-pointer">{t('wizard.targeting.includeAll')}</Label>
|
|
1551
|
+
</div>
|
|
1552
|
+
</div>
|
|
1553
|
+
|
|
1554
|
+
<ScrollArea className="flex-1">
|
|
1555
|
+
<div className="p-4 space-y-2">
|
|
1556
|
+
{geoLocations.length === 0 ? (
|
|
1557
|
+
<div className="text-center py-8 text-mw-neutral-500">
|
|
1558
|
+
<MapPin className="h-12 w-12 mx-auto mb-3 opacity-50" />
|
|
1559
|
+
<p>No locations added yet</p>
|
|
1560
|
+
</div>
|
|
1561
|
+
) : (
|
|
1562
|
+
geoLocations
|
|
1563
|
+
.filter((loc: any) => {
|
|
1564
|
+
if (!locationSearch) return true;
|
|
1565
|
+
const name = loc.properties?.name || "";
|
|
1566
|
+
return name.toLowerCase().includes(locationSearch.toLowerCase());
|
|
1567
|
+
})
|
|
1568
|
+
.map((location: any, index: number) => {
|
|
1569
|
+
const locationPois = location.properties?.pois || [];
|
|
1570
|
+
const canAddMorePois = locationPois.length < MAX_POIS_PER_LOCATION;
|
|
1571
|
+
const isSelected = selectedLocationIndex === index;
|
|
1572
|
+
|
|
1573
|
+
const handleLocationCardClick = () => {
|
|
1574
|
+
setSelectedLocationIndex(index);
|
|
1575
|
+
setShouldCenterOnLocation(true);
|
|
1576
|
+
setTimeout(() => setShouldCenterOnLocation(false), 100);
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
return (
|
|
1580
|
+
<div
|
|
1581
|
+
key={location.id || `loc-${index}`}
|
|
1582
|
+
className={`border rounded-lg p-3 cursor-pointer transition-colors ${
|
|
1583
|
+
isSelected
|
|
1584
|
+
? "border-mw-primary-500 bg-mw-primary-50 dark:bg-mw-primary-900/20"
|
|
1585
|
+
: "border-mw-neutral-200 dark:border-mw-neutral-700 hover:border-mw-primary-300"
|
|
1586
|
+
}`}
|
|
1587
|
+
onClick={handleLocationCardClick}
|
|
1588
|
+
>
|
|
1589
|
+
<div className="flex items-start justify-between mb-2">
|
|
1590
|
+
<div className="flex items-start gap-2">
|
|
1591
|
+
<Checkbox
|
|
1592
|
+
checked={location.properties?.included !== false}
|
|
1593
|
+
onChange={(e) => {
|
|
1594
|
+
e.stopPropagation();
|
|
1595
|
+
toggleLocationIncluded(index);
|
|
1596
|
+
}}
|
|
1597
|
+
onClick={(e) => e.stopPropagation()}
|
|
1598
|
+
className="mt-0.5"
|
|
1599
|
+
/>
|
|
1600
|
+
<div>
|
|
1601
|
+
<span className="text-sm font-medium block text-mw-neutral-900 dark:text-white">
|
|
1602
|
+
{location.properties?.name ||
|
|
1603
|
+
t('wizard.targeting.locationNumber', { number: index + 1 })}
|
|
1604
|
+
</span>
|
|
1605
|
+
<span className="text-xs text-mw-neutral-500">
|
|
1606
|
+
{t('wizard.targeting.drawnOnMap', { type: location.geometry?.type || "Point" })}
|
|
1607
|
+
</span>
|
|
1608
|
+
</div>
|
|
1609
|
+
</div>
|
|
1610
|
+
<Button
|
|
1611
|
+
variant="ghost"
|
|
1612
|
+
size="sm"
|
|
1613
|
+
className="h-8 w-8 p-0"
|
|
1614
|
+
onClick={(e) => {
|
|
1615
|
+
e.stopPropagation();
|
|
1616
|
+
removeLocation(index);
|
|
1617
|
+
}}
|
|
1618
|
+
>
|
|
1619
|
+
<Trash2 className="h-4 w-4 text-mw-neutral-400 hover:text-red-500" />
|
|
1620
|
+
</Button>
|
|
1621
|
+
</div>
|
|
1622
|
+
|
|
1623
|
+
{locationPois.length > 0 && (
|
|
1624
|
+
<div
|
|
1625
|
+
className="flex flex-wrap gap-1 mt-2 mb-2"
|
|
1626
|
+
onClick={(e) => e.stopPropagation()}
|
|
1627
|
+
>
|
|
1628
|
+
{locationPois.map(
|
|
1629
|
+
(poi: { type: string; label: string }) => (
|
|
1630
|
+
<Badge
|
|
1631
|
+
key={poi.type}
|
|
1632
|
+
variant="secondary"
|
|
1633
|
+
className="text-xs h-5 px-2 pr-1 flex items-center gap-1"
|
|
1634
|
+
>
|
|
1635
|
+
{poi.label}
|
|
1636
|
+
<Button
|
|
1637
|
+
type="button"
|
|
1638
|
+
variant="ghost"
|
|
1639
|
+
size="sm"
|
|
1640
|
+
isIconOnly
|
|
1641
|
+
onClick={(e) => {
|
|
1642
|
+
e.stopPropagation();
|
|
1643
|
+
removePoiFromLocation(index, poi.type);
|
|
1644
|
+
}}
|
|
1645
|
+
className="h-auto w-auto p-0.5"
|
|
1646
|
+
>
|
|
1647
|
+
<X className="h-3 w-3" />
|
|
1648
|
+
</Button>
|
|
1649
|
+
</Badge>
|
|
1650
|
+
),
|
|
1651
|
+
)}
|
|
1652
|
+
</div>
|
|
1653
|
+
)}
|
|
1654
|
+
|
|
1655
|
+
<div
|
|
1656
|
+
className="flex items-center justify-between border-t border-mw-neutral-100 dark:border-mw-neutral-700 pt-2 mt-2"
|
|
1657
|
+
onClick={(e) => e.stopPropagation()}
|
|
1658
|
+
>
|
|
1659
|
+
<span className="text-xs text-mw-neutral-500">
|
|
1660
|
+
{locationPois.length >= MAX_POIS_PER_LOCATION
|
|
1661
|
+
? t('wizard.targeting.limitReached')
|
|
1662
|
+
: t('wizard.targeting.canAddUpToPois', { max: MAX_POIS_PER_LOCATION })}
|
|
1663
|
+
</span>
|
|
1664
|
+
<Button
|
|
1665
|
+
type="button"
|
|
1666
|
+
variant="outline"
|
|
1667
|
+
size="sm"
|
|
1668
|
+
className="h-7 text-xs text-mw-primary-500 border-mw-primary-300"
|
|
1669
|
+
onClick={(e) => {
|
|
1670
|
+
e.stopPropagation();
|
|
1671
|
+
setSelectedLocationIndex(index);
|
|
1672
|
+
setAddPOIMode(true);
|
|
1673
|
+
}}
|
|
1674
|
+
disabled={!canAddMorePois}
|
|
1675
|
+
>
|
|
1676
|
+
<Plus className="h-3 w-3 mr-1" />
|
|
1677
|
+
Add POI
|
|
1678
|
+
</Button>
|
|
1679
|
+
</div>
|
|
1680
|
+
</div>
|
|
1681
|
+
);
|
|
1682
|
+
})
|
|
1683
|
+
)}
|
|
1684
|
+
</div>
|
|
1685
|
+
</ScrollArea>
|
|
1686
|
+
|
|
1687
|
+
<div className="p-3 border-t border-mw-neutral-200 dark:border-mw-neutral-700">
|
|
1688
|
+
<Button
|
|
1689
|
+
type="button"
|
|
1690
|
+
variant="outline"
|
|
1691
|
+
className="w-full text-mw-primary-600 border-mw-primary-300 hover:bg-mw-primary-50"
|
|
1692
|
+
onClick={(e) => {
|
|
1693
|
+
e.preventDefault();
|
|
1694
|
+
e.stopPropagation();
|
|
1695
|
+
setShowImportModal(true);
|
|
1696
|
+
}}
|
|
1697
|
+
>
|
|
1698
|
+
<Upload className="h-4 w-4 mr-2" />
|
|
1699
|
+
Import Locations
|
|
1700
|
+
</Button>
|
|
1701
|
+
</div>
|
|
1702
|
+
</div>
|
|
1703
|
+
</div>
|
|
1704
|
+
</SheetContent>
|
|
1705
|
+
</Sheet>
|
|
1706
|
+
</form>
|
|
1707
|
+
);
|
|
1708
|
+
}
|