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,699 @@
|
|
|
1
|
+
import { useState, useCallback, useRef, useEffect, useMemo } from "react";
|
|
2
|
+
import mapboxgl from "mapbox-gl";
|
|
3
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription } from "@/components/ui/sheet";
|
|
4
|
+
import { Button } from "@/components/ui/button";
|
|
5
|
+
import { Input } from "@/components/ui/input";
|
|
6
|
+
import { ScrollArea } from "@/components/ui/scroll-area";
|
|
7
|
+
import { Badge } from "@/components/ui/badge";
|
|
8
|
+
import { Checkbox } from "@/components/ui/checkbox";
|
|
9
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
10
|
+
import { Search, MapPin, X, Globe, Loader2, Store, ChevronDown, ChevronRight } from "lucide-react";
|
|
11
|
+
import { cn } from "@/lib/utils";
|
|
12
|
+
import { useQuery } from "@tanstack/react-query";
|
|
13
|
+
import type { POI } from "@shared/schema";
|
|
14
|
+
import "mapbox-gl/dist/mapbox-gl.css";
|
|
15
|
+
|
|
16
|
+
const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_PUBLIC_KEY || "";
|
|
17
|
+
|
|
18
|
+
interface SelectedLocation {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
fullName: string;
|
|
22
|
+
type: string;
|
|
23
|
+
coordinates: [number, number];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface GeographySelectorProps {
|
|
27
|
+
value: string[];
|
|
28
|
+
onChange: (value: string[]) => void;
|
|
29
|
+
allowedCountries?: string[];
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
showPOIs?: boolean;
|
|
32
|
+
selectedPOIs?: string[];
|
|
33
|
+
onPOIChange?: (pois: string[]) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface SearchResult {
|
|
37
|
+
id: string;
|
|
38
|
+
place_name: string;
|
|
39
|
+
text: string;
|
|
40
|
+
place_type: string[];
|
|
41
|
+
center: [number, number];
|
|
42
|
+
context?: Array<{ id: string; text: string; short_code?: string }>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const COUNTRY_CENTERS: Record<string, { lng: number; lat: number; zoom: number }> = {
|
|
46
|
+
Malaysia: { lng: 101.9758, lat: 4.2105, zoom: 5 },
|
|
47
|
+
Singapore: { lng: 103.8198, lat: 1.3521, zoom: 10 },
|
|
48
|
+
Thailand: { lng: 100.5018, lat: 13.7563, zoom: 5 },
|
|
49
|
+
Indonesia: { lng: 106.8456, lat: -6.2088, zoom: 4 },
|
|
50
|
+
Philippines: { lng: 121.774, lat: 12.8797, zoom: 5 },
|
|
51
|
+
"United States": { lng: -98.5795, lat: 39.8283, zoom: 3 },
|
|
52
|
+
"United Kingdom": { lng: -3.436, lat: 55.3781, zoom: 5 },
|
|
53
|
+
Australia: { lng: 133.7751, lat: -25.2744, zoom: 3 },
|
|
54
|
+
Japan: { lng: 138.2529, lat: 36.2048, zoom: 5 },
|
|
55
|
+
"South Korea": { lng: 127.7669, lat: 35.9078, zoom: 6 },
|
|
56
|
+
India: { lng: 78.9629, lat: 20.5937, zoom: 4 },
|
|
57
|
+
Germany: { lng: 10.4515, lat: 51.1657, zoom: 5 },
|
|
58
|
+
France: { lng: 2.2137, lat: 46.2276, zoom: 5 },
|
|
59
|
+
"United Arab Emirates": { lng: 53.9045, lat: 23.4241, zoom: 5 },
|
|
60
|
+
"Saudi Arabia": { lng: 45.0792, lat: 23.8859, zoom: 4 },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const COUNTRY_CODES: Record<string, string> = {
|
|
64
|
+
Malaysia: "my",
|
|
65
|
+
Singapore: "sg",
|
|
66
|
+
Thailand: "th",
|
|
67
|
+
Indonesia: "id",
|
|
68
|
+
Philippines: "ph",
|
|
69
|
+
"United States": "us",
|
|
70
|
+
"United Kingdom": "gb",
|
|
71
|
+
Australia: "au",
|
|
72
|
+
Japan: "jp",
|
|
73
|
+
"South Korea": "kr",
|
|
74
|
+
India: "in",
|
|
75
|
+
Germany: "de",
|
|
76
|
+
France: "fr",
|
|
77
|
+
"United Arab Emirates": "ae",
|
|
78
|
+
"Saudi Arabia": "sa",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function MapComponent({
|
|
82
|
+
center,
|
|
83
|
+
zoom,
|
|
84
|
+
selectedLocations,
|
|
85
|
+
pois,
|
|
86
|
+
selectedPOIs,
|
|
87
|
+
onPOIClick,
|
|
88
|
+
onMapReady,
|
|
89
|
+
}: {
|
|
90
|
+
center: { lng: number; lat: number };
|
|
91
|
+
zoom: number;
|
|
92
|
+
selectedLocations: SelectedLocation[];
|
|
93
|
+
pois: POI[];
|
|
94
|
+
selectedPOIs: string[];
|
|
95
|
+
onPOIClick?: (poiId: string) => void;
|
|
96
|
+
onMapReady?: (map: mapboxgl.Map) => void;
|
|
97
|
+
}) {
|
|
98
|
+
const mapContainer = useRef<HTMLDivElement>(null);
|
|
99
|
+
const map = useRef<mapboxgl.Map | null>(null);
|
|
100
|
+
const locationMarkersRef = useRef<mapboxgl.Marker[]>([]);
|
|
101
|
+
const poiMarkersRef = useRef<mapboxgl.Marker[]>([]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!mapContainer.current || !MAPBOX_TOKEN) return;
|
|
105
|
+
|
|
106
|
+
map.current = new mapboxgl.Map({
|
|
107
|
+
container: mapContainer.current,
|
|
108
|
+
style: "mapbox://styles/mapbox/streets-v12",
|
|
109
|
+
center: [center.lng, center.lat],
|
|
110
|
+
zoom: zoom,
|
|
111
|
+
accessToken: MAPBOX_TOKEN,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
map.current.addControl(new mapboxgl.NavigationControl(), "top-right");
|
|
115
|
+
|
|
116
|
+
if (onMapReady) {
|
|
117
|
+
onMapReady(map.current);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return () => {
|
|
121
|
+
map.current?.remove();
|
|
122
|
+
};
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!map.current) return;
|
|
127
|
+
|
|
128
|
+
map.current.flyTo({
|
|
129
|
+
center: [center.lng, center.lat],
|
|
130
|
+
zoom: zoom,
|
|
131
|
+
});
|
|
132
|
+
}, [center, zoom]);
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!map.current) return;
|
|
136
|
+
|
|
137
|
+
locationMarkersRef.current.forEach((marker) => marker.remove());
|
|
138
|
+
locationMarkersRef.current = [];
|
|
139
|
+
|
|
140
|
+
selectedLocations.forEach((location) => {
|
|
141
|
+
if (location.coordinates[0] !== 0 && location.coordinates[1] !== 0) {
|
|
142
|
+
const el = document.createElement("div");
|
|
143
|
+
el.className = "flex items-center justify-center w-8 h-8 bg-primary text-primary-foreground rounded-full shadow-lg";
|
|
144
|
+
el.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/><circle cx="12" cy="10" r="3"/></svg>';
|
|
145
|
+
|
|
146
|
+
const marker = new mapboxgl.Marker(el)
|
|
147
|
+
.setLngLat([location.coordinates[0], location.coordinates[1]])
|
|
148
|
+
.setPopup(new mapboxgl.Popup({ offset: 25 }).setHTML(`<strong>${location.name}</strong><p class="text-sm">${location.fullName}</p>`))
|
|
149
|
+
.addTo(map.current!);
|
|
150
|
+
|
|
151
|
+
locationMarkersRef.current.push(marker);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}, [selectedLocations]);
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (!map.current) return;
|
|
158
|
+
|
|
159
|
+
poiMarkersRef.current.forEach((marker) => marker.remove());
|
|
160
|
+
poiMarkersRef.current = [];
|
|
161
|
+
|
|
162
|
+
pois.forEach((poi) => {
|
|
163
|
+
const isSelected = selectedPOIs.includes(poi.id);
|
|
164
|
+
const el = document.createElement("div");
|
|
165
|
+
el.className = `flex items-center justify-center w-6 h-6 ${isSelected ? 'bg-amber-500' : 'bg-amber-400/70'} text-white rounded-full shadow-md cursor-pointer`;
|
|
166
|
+
el.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7"/><path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><path d="M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4"/><path d="M2 7h20"/><path d="M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7"/></svg>';
|
|
167
|
+
|
|
168
|
+
if (onPOIClick) {
|
|
169
|
+
el.addEventListener("click", (e) => {
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
onPOIClick(poi.id);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const popup = new mapboxgl.Popup({ offset: 20, closeButton: false })
|
|
176
|
+
.setHTML(`<div class="p-1"><strong class="text-sm">${poi.name}</strong><p class="text-xs text-muted-foreground">${poi.category}</p>${poi.address ? `<p class="text-xs">${poi.address}</p>` : ''}</div>`);
|
|
177
|
+
|
|
178
|
+
const marker = new mapboxgl.Marker(el)
|
|
179
|
+
.setLngLat([poi.longitude, poi.latitude])
|
|
180
|
+
.setPopup(popup)
|
|
181
|
+
.addTo(map.current!);
|
|
182
|
+
|
|
183
|
+
poiMarkersRef.current.push(marker);
|
|
184
|
+
});
|
|
185
|
+
}, [pois, selectedPOIs, onPOIClick]);
|
|
186
|
+
|
|
187
|
+
if (!MAPBOX_TOKEN) {
|
|
188
|
+
return (
|
|
189
|
+
<div className="h-full flex items-center justify-center bg-muted">
|
|
190
|
+
<div className="text-center text-muted-foreground">
|
|
191
|
+
<Globe className="h-12 w-12 mx-auto mb-2 opacity-50" />
|
|
192
|
+
<p>Map unavailable</p>
|
|
193
|
+
<p className="text-sm">Mapbox token not configured</p>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<div className="relative h-full w-full">
|
|
201
|
+
<div ref={mapContainer} className="h-full w-full" />
|
|
202
|
+
<div className="absolute bottom-4 left-4 bg-background/90 backdrop-blur-sm border rounded-lg p-2 text-xs shadow-md">
|
|
203
|
+
<div className="font-semibold mb-1">Legend</div>
|
|
204
|
+
<div className="flex items-center gap-2 mb-1">
|
|
205
|
+
<div className="w-4 h-4 bg-primary rounded-full flex items-center justify-center">
|
|
206
|
+
<MapPin className="h-2.5 w-2.5 text-primary-foreground" />
|
|
207
|
+
</div>
|
|
208
|
+
<span>Selected Locations</span>
|
|
209
|
+
</div>
|
|
210
|
+
<div className="flex items-center gap-2">
|
|
211
|
+
<div className="w-4 h-4 bg-amber-500 rounded-full flex items-center justify-center">
|
|
212
|
+
<Store className="h-2.5 w-2.5 text-white" />
|
|
213
|
+
</div>
|
|
214
|
+
<span>Points of Interest</span>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
interface GeographySelectorSheetProps extends GeographySelectorProps {
|
|
222
|
+
open: boolean;
|
|
223
|
+
onOpenChange: (open: boolean) => void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function GeographySelectorSheet({
|
|
227
|
+
value,
|
|
228
|
+
onChange,
|
|
229
|
+
allowedCountries = [],
|
|
230
|
+
open,
|
|
231
|
+
onOpenChange,
|
|
232
|
+
showPOIs = true,
|
|
233
|
+
selectedPOIs = [],
|
|
234
|
+
onPOIChange,
|
|
235
|
+
}: GeographySelectorSheetProps) {
|
|
236
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
237
|
+
const [poiSearchQuery, setPOISearchQuery] = useState("");
|
|
238
|
+
const [searchResults, setSearchResults] = useState<SearchResult[]>([]);
|
|
239
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
240
|
+
const [selectedLocations, setSelectedLocations] = useState<SelectedLocation[]>(() => {
|
|
241
|
+
return value.map((v, index) => {
|
|
242
|
+
try {
|
|
243
|
+
return JSON.parse(v);
|
|
244
|
+
} catch {
|
|
245
|
+
return {
|
|
246
|
+
id: `legacy-${index}`,
|
|
247
|
+
name: v,
|
|
248
|
+
fullName: v,
|
|
249
|
+
type: "place",
|
|
250
|
+
coordinates: [0, 0] as [number, number],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
const [expandedCategories, setExpandedCategories] = useState<string[]>([]);
|
|
256
|
+
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
257
|
+
const mapRef = useRef<mapboxgl.Map | null>(null);
|
|
258
|
+
|
|
259
|
+
const primaryCountry = allowedCountries[0] || "Malaysia";
|
|
260
|
+
const centerData = COUNTRY_CENTERS[primaryCountry] || COUNTRY_CENTERS.Malaysia;
|
|
261
|
+
|
|
262
|
+
const { data: pois = [], isLoading: isPOIsLoading } = useQuery<POI[]>({
|
|
263
|
+
queryKey: ["/api/pois", allowedCountries],
|
|
264
|
+
enabled: open && showPOIs && allowedCountries.length > 0,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const filteredPOIs = useMemo(() => {
|
|
268
|
+
if (!poiSearchQuery.trim()) return pois;
|
|
269
|
+
const query = poiSearchQuery.toLowerCase();
|
|
270
|
+
return pois.filter(poi =>
|
|
271
|
+
poi.name.toLowerCase().includes(query) ||
|
|
272
|
+
poi.category.toLowerCase().includes(query) ||
|
|
273
|
+
(poi.city && poi.city.toLowerCase().includes(query))
|
|
274
|
+
);
|
|
275
|
+
}, [pois, poiSearchQuery]);
|
|
276
|
+
|
|
277
|
+
const poisByCategory = useMemo(() => {
|
|
278
|
+
const grouped: Record<string, POI[]> = {};
|
|
279
|
+
filteredPOIs.forEach(poi => {
|
|
280
|
+
if (!grouped[poi.category]) {
|
|
281
|
+
grouped[poi.category] = [];
|
|
282
|
+
}
|
|
283
|
+
grouped[poi.category].push(poi);
|
|
284
|
+
});
|
|
285
|
+
return grouped;
|
|
286
|
+
}, [filteredPOIs]);
|
|
287
|
+
|
|
288
|
+
const relevantPOIs = useMemo(() => {
|
|
289
|
+
if (!allowedCountries.length) return filteredPOIs;
|
|
290
|
+
return filteredPOIs.filter(poi => allowedCountries.includes(poi.country));
|
|
291
|
+
}, [filteredPOIs, allowedCountries]);
|
|
292
|
+
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
const newLocations = value.map((v, index) => {
|
|
295
|
+
try {
|
|
296
|
+
return JSON.parse(v);
|
|
297
|
+
} catch {
|
|
298
|
+
return {
|
|
299
|
+
id: `legacy-${index}`,
|
|
300
|
+
name: v,
|
|
301
|
+
fullName: v,
|
|
302
|
+
type: "place",
|
|
303
|
+
coordinates: [0, 0] as [number, number],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
setSelectedLocations(newLocations);
|
|
308
|
+
}, [value]);
|
|
309
|
+
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
if (searchTimeoutRef.current) {
|
|
312
|
+
clearTimeout(searchTimeoutRef.current);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (!searchQuery.trim()) {
|
|
316
|
+
setSearchResults([]);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
setIsSearching(true);
|
|
321
|
+
searchTimeoutRef.current = setTimeout(async () => {
|
|
322
|
+
try {
|
|
323
|
+
let countryFilter = "";
|
|
324
|
+
if (allowedCountries.length > 0) {
|
|
325
|
+
const countryCodes = allowedCountries.map(c => {
|
|
326
|
+
const code = COUNTRY_CODES[c];
|
|
327
|
+
if (!code) {
|
|
328
|
+
console.warn(`Warning: Country "${c}" does not have a mapped ISO code.`);
|
|
329
|
+
}
|
|
330
|
+
return code || "";
|
|
331
|
+
}).filter(Boolean);
|
|
332
|
+
countryFilter = countryCodes.length > 0 ? `&country=${countryCodes.join(",")}` : "";
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const response = await fetch(
|
|
336
|
+
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(searchQuery)}.json?access_token=${MAPBOX_TOKEN}&types=place,locality,neighborhood,address,poi&limit=10${countryFilter}`
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
if (response.ok) {
|
|
340
|
+
const data = await response.json();
|
|
341
|
+
setSearchResults(data.features || []);
|
|
342
|
+
}
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error("Geocoding error:", error);
|
|
345
|
+
} finally {
|
|
346
|
+
setIsSearching(false);
|
|
347
|
+
}
|
|
348
|
+
}, 300);
|
|
349
|
+
|
|
350
|
+
return () => {
|
|
351
|
+
if (searchTimeoutRef.current) {
|
|
352
|
+
clearTimeout(searchTimeoutRef.current);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}, [searchQuery, allowedCountries]);
|
|
356
|
+
|
|
357
|
+
const handleSelectLocation = useCallback((result: SearchResult) => {
|
|
358
|
+
const existingIds = new Set(selectedLocations.map(l => l.id));
|
|
359
|
+
if (existingIds.has(result.id)) return;
|
|
360
|
+
|
|
361
|
+
const newLocation: SelectedLocation = {
|
|
362
|
+
id: result.id,
|
|
363
|
+
name: result.text,
|
|
364
|
+
fullName: result.place_name,
|
|
365
|
+
type: result.place_type[0] || "place",
|
|
366
|
+
coordinates: result.center,
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const updated = [...selectedLocations, newLocation];
|
|
370
|
+
setSelectedLocations(updated);
|
|
371
|
+
onChange(updated.map(l => JSON.stringify(l)));
|
|
372
|
+
setSearchQuery("");
|
|
373
|
+
setSearchResults([]);
|
|
374
|
+
|
|
375
|
+
if (mapRef.current) {
|
|
376
|
+
mapRef.current.flyTo({
|
|
377
|
+
center: result.center,
|
|
378
|
+
zoom: 12,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}, [selectedLocations, onChange]);
|
|
382
|
+
|
|
383
|
+
const handleRemoveLocation = useCallback((id: string) => {
|
|
384
|
+
const updated = selectedLocations.filter(l => l.id !== id);
|
|
385
|
+
setSelectedLocations(updated);
|
|
386
|
+
onChange(updated.map(l => JSON.stringify(l)));
|
|
387
|
+
}, [selectedLocations, onChange]);
|
|
388
|
+
|
|
389
|
+
const handleClearAll = useCallback(() => {
|
|
390
|
+
setSelectedLocations([]);
|
|
391
|
+
onChange([]);
|
|
392
|
+
}, [onChange]);
|
|
393
|
+
|
|
394
|
+
const handlePOIToggle = useCallback((poiId: string) => {
|
|
395
|
+
if (!onPOIChange) return;
|
|
396
|
+
const newSelected = selectedPOIs.includes(poiId)
|
|
397
|
+
? selectedPOIs.filter(id => id !== poiId)
|
|
398
|
+
: [...selectedPOIs, poiId];
|
|
399
|
+
onPOIChange(newSelected);
|
|
400
|
+
}, [selectedPOIs, onPOIChange]);
|
|
401
|
+
|
|
402
|
+
const toggleCategory = useCallback((category: string) => {
|
|
403
|
+
setExpandedCategories(prev =>
|
|
404
|
+
prev.includes(category)
|
|
405
|
+
? prev.filter(c => c !== category)
|
|
406
|
+
: [...prev, category]
|
|
407
|
+
);
|
|
408
|
+
}, []);
|
|
409
|
+
|
|
410
|
+
const getLocationIcon = (type: string) => {
|
|
411
|
+
switch (type) {
|
|
412
|
+
case "poi":
|
|
413
|
+
case "address":
|
|
414
|
+
return <MapPin className="h-4 w-4" />;
|
|
415
|
+
case "neighborhood":
|
|
416
|
+
return <div className="h-4 w-4 rounded-full border-2 border-current" />;
|
|
417
|
+
case "locality":
|
|
418
|
+
return <div className="h-4 w-4 rounded bg-current opacity-60" />;
|
|
419
|
+
case "place":
|
|
420
|
+
default:
|
|
421
|
+
return <Globe className="h-4 w-4" />;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
427
|
+
<SheetContent side="right" className="w-full sm:max-w-[900px] flex flex-col p-0">
|
|
428
|
+
<SheetHeader className="px-6 py-4 border-b">
|
|
429
|
+
<SheetTitle>Geography Targeting</SheetTitle>
|
|
430
|
+
<SheetDescription>
|
|
431
|
+
Search for and select geographic locations to target in your deal
|
|
432
|
+
</SheetDescription>
|
|
433
|
+
</SheetHeader>
|
|
434
|
+
|
|
435
|
+
<div className="flex flex-col flex-1 overflow-hidden">
|
|
436
|
+
<div className="p-4 border-b">
|
|
437
|
+
<div className="relative">
|
|
438
|
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
439
|
+
<Input
|
|
440
|
+
placeholder="Search for a location..."
|
|
441
|
+
value={searchQuery}
|
|
442
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
443
|
+
className="pl-9 pr-9"
|
|
444
|
+
data-testid="input-geography-search"
|
|
445
|
+
/>
|
|
446
|
+
{isSearching && (
|
|
447
|
+
<Loader2 className="absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 animate-spin text-muted-foreground" />
|
|
448
|
+
)}
|
|
449
|
+
</div>
|
|
450
|
+
|
|
451
|
+
{searchResults.length > 0 && (
|
|
452
|
+
<div className="absolute z-30 left-4 right-4 mt-1 bg-background border rounded-md shadow-lg max-h-[250px] overflow-y-auto">
|
|
453
|
+
{searchResults.map((result) => (
|
|
454
|
+
<button
|
|
455
|
+
key={result.id}
|
|
456
|
+
className="w-full px-4 py-3 text-left hover-elevate flex items-start gap-3 border-b last:border-b-0"
|
|
457
|
+
onClick={() => handleSelectLocation(result)}
|
|
458
|
+
data-testid={`button-location-${result.id}`}
|
|
459
|
+
>
|
|
460
|
+
<span className="mt-0.5 text-muted-foreground">
|
|
461
|
+
{getLocationIcon(result.place_type[0])}
|
|
462
|
+
</span>
|
|
463
|
+
<div className="flex-1 min-w-0">
|
|
464
|
+
<div className="font-medium truncate">{result.text}</div>
|
|
465
|
+
<div className="text-sm text-muted-foreground truncate">
|
|
466
|
+
{result.place_name.replace(`${result.text}, `, "")}
|
|
467
|
+
</div>
|
|
468
|
+
</div>
|
|
469
|
+
</button>
|
|
470
|
+
))}
|
|
471
|
+
</div>
|
|
472
|
+
)}
|
|
473
|
+
</div>
|
|
474
|
+
|
|
475
|
+
<div className="flex-1 flex min-h-0">
|
|
476
|
+
<div className="flex-1 p-4">
|
|
477
|
+
<div className="h-full rounded-lg overflow-hidden border">
|
|
478
|
+
<MapComponent
|
|
479
|
+
center={centerData}
|
|
480
|
+
zoom={centerData.zoom}
|
|
481
|
+
selectedLocations={selectedLocations}
|
|
482
|
+
pois={relevantPOIs}
|
|
483
|
+
selectedPOIs={selectedPOIs}
|
|
484
|
+
onPOIClick={onPOIChange ? handlePOIToggle : undefined}
|
|
485
|
+
onMapReady={(m) => { mapRef.current = m; }}
|
|
486
|
+
/>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
<div className="w-[300px] border-l flex flex-col">
|
|
491
|
+
<div className="p-3 border-b flex items-center justify-between">
|
|
492
|
+
<div>
|
|
493
|
+
<h3 className="font-semibold text-sm">Selected Locations</h3>
|
|
494
|
+
<p className="text-xs text-muted-foreground">{selectedLocations.length} selected</p>
|
|
495
|
+
</div>
|
|
496
|
+
{selectedLocations.length > 0 && (
|
|
497
|
+
<Button
|
|
498
|
+
variant="ghost"
|
|
499
|
+
size="sm"
|
|
500
|
+
className="text-destructive hover:text-destructive"
|
|
501
|
+
onClick={handleClearAll}
|
|
502
|
+
data-testid="button-clear-locations"
|
|
503
|
+
>
|
|
504
|
+
Clear All
|
|
505
|
+
</Button>
|
|
506
|
+
)}
|
|
507
|
+
</div>
|
|
508
|
+
|
|
509
|
+
<ScrollArea className="flex-1">
|
|
510
|
+
<div className="p-3">
|
|
511
|
+
{selectedLocations.length === 0 ? (
|
|
512
|
+
<div className="text-sm text-muted-foreground py-4 text-center">
|
|
513
|
+
No locations selected
|
|
514
|
+
</div>
|
|
515
|
+
) : (
|
|
516
|
+
<div className="space-y-2">
|
|
517
|
+
{selectedLocations.map((location) => (
|
|
518
|
+
<div
|
|
519
|
+
key={location.id}
|
|
520
|
+
className="flex items-start gap-2 p-2 rounded-md border"
|
|
521
|
+
>
|
|
522
|
+
<span className="mt-0.5 text-muted-foreground">
|
|
523
|
+
{getLocationIcon(location.type)}
|
|
524
|
+
</span>
|
|
525
|
+
<div className="flex-1 min-w-0">
|
|
526
|
+
<div className="font-medium text-sm truncate">{location.name}</div>
|
|
527
|
+
<div className="text-xs text-muted-foreground truncate">
|
|
528
|
+
{location.type}
|
|
529
|
+
</div>
|
|
530
|
+
</div>
|
|
531
|
+
<Button
|
|
532
|
+
variant="ghost"
|
|
533
|
+
size="icon"
|
|
534
|
+
className="h-6 w-6"
|
|
535
|
+
onClick={() => handleRemoveLocation(location.id)}
|
|
536
|
+
data-testid={`button-remove-location-${location.id}`}
|
|
537
|
+
>
|
|
538
|
+
<X className="h-3 w-3" />
|
|
539
|
+
</Button>
|
|
540
|
+
</div>
|
|
541
|
+
))}
|
|
542
|
+
</div>
|
|
543
|
+
)}
|
|
544
|
+
</div>
|
|
545
|
+
|
|
546
|
+
{showPOIs && (
|
|
547
|
+
<div className="border-t">
|
|
548
|
+
<div className="p-3">
|
|
549
|
+
<div className="flex items-center justify-between mb-2">
|
|
550
|
+
<h3 className="font-semibold text-sm flex items-center gap-1.5">
|
|
551
|
+
<Store className="h-4 w-4 text-amber-500" />
|
|
552
|
+
Points of Interest
|
|
553
|
+
</h3>
|
|
554
|
+
{selectedPOIs.length > 0 && (
|
|
555
|
+
<Badge variant="secondary" className="text-xs">
|
|
556
|
+
{selectedPOIs.length} selected
|
|
557
|
+
</Badge>
|
|
558
|
+
)}
|
|
559
|
+
</div>
|
|
560
|
+
|
|
561
|
+
<div className="relative mb-3">
|
|
562
|
+
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />
|
|
563
|
+
<Input
|
|
564
|
+
placeholder="Filter POIs..."
|
|
565
|
+
value={poiSearchQuery}
|
|
566
|
+
onChange={(e) => setPOISearchQuery(e.target.value)}
|
|
567
|
+
className="h-8 pl-8 text-sm"
|
|
568
|
+
data-testid="input-poi-search"
|
|
569
|
+
/>
|
|
570
|
+
</div>
|
|
571
|
+
|
|
572
|
+
{isPOIsLoading ? (
|
|
573
|
+
<div className="flex items-center justify-center py-4">
|
|
574
|
+
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
|
|
575
|
+
</div>
|
|
576
|
+
) : Object.keys(poisByCategory).length === 0 ? (
|
|
577
|
+
<div className="text-sm text-muted-foreground py-4 text-center">
|
|
578
|
+
No POIs available
|
|
579
|
+
</div>
|
|
580
|
+
) : (
|
|
581
|
+
<div className="space-y-1">
|
|
582
|
+
{Object.entries(poisByCategory).map(([category, categoryPOIs]) => {
|
|
583
|
+
const selectedInCategory = categoryPOIs.filter(p => selectedPOIs.includes(p.id)).length;
|
|
584
|
+
return (
|
|
585
|
+
<Collapsible
|
|
586
|
+
key={category}
|
|
587
|
+
open={expandedCategories.includes(category)}
|
|
588
|
+
onOpenChange={() => toggleCategory(category)}
|
|
589
|
+
>
|
|
590
|
+
<CollapsibleTrigger asChild>
|
|
591
|
+
<button
|
|
592
|
+
className="w-full flex items-center justify-between p-2 rounded-md hover-elevate text-sm"
|
|
593
|
+
data-testid={`button-category-${category}`}
|
|
594
|
+
>
|
|
595
|
+
<span className="flex items-center gap-2">
|
|
596
|
+
{expandedCategories.includes(category) ? (
|
|
597
|
+
<ChevronDown className="h-3.5 w-3.5" />
|
|
598
|
+
) : (
|
|
599
|
+
<ChevronRight className="h-3.5 w-3.5" />
|
|
600
|
+
)}
|
|
601
|
+
<span className="font-medium">{category}</span>
|
|
602
|
+
</span>
|
|
603
|
+
<span className="text-xs text-muted-foreground">
|
|
604
|
+
{selectedInCategory > 0 && (
|
|
605
|
+
<span className="text-amber-500 mr-1">{selectedInCategory}/</span>
|
|
606
|
+
)}
|
|
607
|
+
{categoryPOIs.length}
|
|
608
|
+
</span>
|
|
609
|
+
</button>
|
|
610
|
+
</CollapsibleTrigger>
|
|
611
|
+
<CollapsibleContent>
|
|
612
|
+
<div className="pl-4 space-y-0.5">
|
|
613
|
+
{categoryPOIs.map(poi => (
|
|
614
|
+
<label
|
|
615
|
+
key={poi.id}
|
|
616
|
+
className="flex items-start gap-2 p-2 rounded-md cursor-pointer hover-elevate"
|
|
617
|
+
data-testid={`label-poi-${poi.id}`}
|
|
618
|
+
>
|
|
619
|
+
<Checkbox
|
|
620
|
+
checked={selectedPOIs.includes(poi.id)}
|
|
621
|
+
onCheckedChange={() => handlePOIToggle(poi.id)}
|
|
622
|
+
className="mt-0.5"
|
|
623
|
+
data-testid={`checkbox-poi-${poi.id}`}
|
|
624
|
+
/>
|
|
625
|
+
<div className="flex-1 min-w-0">
|
|
626
|
+
<div className="text-sm truncate">{poi.name}</div>
|
|
627
|
+
<div className="text-xs text-muted-foreground truncate">
|
|
628
|
+
{poi.city}
|
|
629
|
+
</div>
|
|
630
|
+
</div>
|
|
631
|
+
</label>
|
|
632
|
+
))}
|
|
633
|
+
</div>
|
|
634
|
+
</CollapsibleContent>
|
|
635
|
+
</Collapsible>
|
|
636
|
+
);
|
|
637
|
+
})}
|
|
638
|
+
</div>
|
|
639
|
+
)}
|
|
640
|
+
</div>
|
|
641
|
+
</div>
|
|
642
|
+
)}
|
|
643
|
+
</ScrollArea>
|
|
644
|
+
</div>
|
|
645
|
+
</div>
|
|
646
|
+
</div>
|
|
647
|
+
|
|
648
|
+
<div className="px-6 py-4 border-t flex items-center justify-between">
|
|
649
|
+
<span className="text-sm text-muted-foreground">
|
|
650
|
+
{selectedLocations.length} location(s){selectedPOIs.length > 0 && `, ${selectedPOIs.length} POI(s)`} selected
|
|
651
|
+
</span>
|
|
652
|
+
<Button onClick={() => onOpenChange(false)} data-testid="button-geography-done">
|
|
653
|
+
Done
|
|
654
|
+
</Button>
|
|
655
|
+
</div>
|
|
656
|
+
</SheetContent>
|
|
657
|
+
</Sheet>
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export function GeographySelector(props: GeographySelectorProps) {
|
|
662
|
+
const [open, setOpen] = useState(false);
|
|
663
|
+
|
|
664
|
+
const selectedCount = props.value.length;
|
|
665
|
+
const poiCount = props.selectedPOIs?.length || 0;
|
|
666
|
+
|
|
667
|
+
return (
|
|
668
|
+
<>
|
|
669
|
+
<Button
|
|
670
|
+
type="button"
|
|
671
|
+
variant="outline"
|
|
672
|
+
className={cn(
|
|
673
|
+
"w-full justify-start text-left font-normal h-10",
|
|
674
|
+
!selectedCount && !poiCount && "text-muted-foreground"
|
|
675
|
+
)}
|
|
676
|
+
disabled={props.disabled}
|
|
677
|
+
onClick={() => setOpen(true)}
|
|
678
|
+
data-testid="button-geography-selector"
|
|
679
|
+
>
|
|
680
|
+
<MapPin className="h-4 w-4 mr-2" />
|
|
681
|
+
{selectedCount > 0 || poiCount > 0 ? (
|
|
682
|
+
<span>
|
|
683
|
+
{selectedCount > 0 && `${selectedCount} location${selectedCount !== 1 ? "s" : ""}`}
|
|
684
|
+
{selectedCount > 0 && poiCount > 0 && ", "}
|
|
685
|
+
{poiCount > 0 && `${poiCount} POI${poiCount !== 1 ? "s" : ""}`}
|
|
686
|
+
{" selected"}
|
|
687
|
+
</span>
|
|
688
|
+
) : (
|
|
689
|
+
<span>Select locations...</span>
|
|
690
|
+
)}
|
|
691
|
+
</Button>
|
|
692
|
+
<GeographySelectorSheet
|
|
693
|
+
{...props}
|
|
694
|
+
open={open}
|
|
695
|
+
onOpenChange={setOpen}
|
|
696
|
+
/>
|
|
697
|
+
</>
|
|
698
|
+
);
|
|
699
|
+
}
|