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,1131 @@
|
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import { Search, Globe, X, Upload, Download, Check, Ban, Minus, Layers, Box, Circle, Pentagon, MapPin, Clock, ChevronDown } from "lucide-react";
|
|
3
|
+
import mapboxgl from "mapbox-gl";
|
|
4
|
+
import MapboxDraw from "@mapbox/mapbox-gl-draw";
|
|
5
|
+
import { Button } from "@/components/ui/button";
|
|
6
|
+
import { Input } from "@/components/ui/input";
|
|
7
|
+
import { Badge } from "@/components/ui/badge";
|
|
8
|
+
import { ScrollArea } from "@/components/ui/scroll-area";
|
|
9
|
+
import {
|
|
10
|
+
Sheet,
|
|
11
|
+
SheetContent,
|
|
12
|
+
SheetHeader,
|
|
13
|
+
SheetTitle,
|
|
14
|
+
SheetDescription,
|
|
15
|
+
} from "@/components/ui/sheet";
|
|
16
|
+
import {
|
|
17
|
+
Tooltip,
|
|
18
|
+
TooltipContent,
|
|
19
|
+
TooltipTrigger,
|
|
20
|
+
} from "@/components/ui/tooltip";
|
|
21
|
+
import {
|
|
22
|
+
DropdownMenu,
|
|
23
|
+
DropdownMenuContent,
|
|
24
|
+
DropdownMenuItem,
|
|
25
|
+
DropdownMenuTrigger,
|
|
26
|
+
} from "@/components/ui/dropdown-menu";
|
|
27
|
+
import {
|
|
28
|
+
Popover,
|
|
29
|
+
PopoverContent,
|
|
30
|
+
PopoverTrigger,
|
|
31
|
+
} from "@/components/ui/popover";
|
|
32
|
+
import { Slider } from "@/components/ui/slider";
|
|
33
|
+
import "mapbox-gl/dist/mapbox-gl.css";
|
|
34
|
+
import "@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css";
|
|
35
|
+
|
|
36
|
+
const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_TOKEN || "";
|
|
37
|
+
|
|
38
|
+
type GeoType = "country" | "region" | "city" | "town" | "poi" | "circle" | "polygon" | "line";
|
|
39
|
+
|
|
40
|
+
interface GeoSelection {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
type: GeoType;
|
|
44
|
+
coordinates?: [number, number];
|
|
45
|
+
geometry?: GeoJSON.Geometry;
|
|
46
|
+
radius?: number;
|
|
47
|
+
included: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface POI {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
category: string;
|
|
54
|
+
latitude: number;
|
|
55
|
+
longitude: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const MOCK_POIS: POI[] = [
|
|
59
|
+
{ id: "poi-1", name: "KLCC Mall", category: "Shopping", latitude: 3.1588, longitude: 101.7118 },
|
|
60
|
+
{ id: "poi-2", name: "Pavilion KL", category: "Shopping", latitude: 3.1488, longitude: 101.7131 },
|
|
61
|
+
{ id: "poi-3", name: "Changi Airport", category: "Transit", latitude: 1.3644, longitude: 103.9915 },
|
|
62
|
+
{ id: "poi-4", name: "Marina Bay Sands", category: "Entertainment", latitude: 1.2834, longitude: 103.8607 },
|
|
63
|
+
{ id: "poi-5", name: "Central World", category: "Shopping", latitude: 13.7466, longitude: 100.5392 },
|
|
64
|
+
{ id: "poi-6", name: "Suvarnabhumi Airport", category: "Transit", latitude: 13.6900, longitude: 100.7501 },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const MOCK_HEATMAP_DATA = [
|
|
68
|
+
{ lat: 3.139, lng: 101.6869, weight: 0.8 },
|
|
69
|
+
{ lat: 3.1588, lng: 101.7118, weight: 0.9 },
|
|
70
|
+
{ lat: 3.1488, lng: 101.7131, weight: 0.7 },
|
|
71
|
+
{ lat: 3.12, lng: 101.68, weight: 0.5 },
|
|
72
|
+
{ lat: 3.16, lng: 101.72, weight: 0.6 },
|
|
73
|
+
{ lat: 3.14, lng: 101.65, weight: 0.4 },
|
|
74
|
+
{ lat: 3.17, lng: 101.69, weight: 0.75 },
|
|
75
|
+
{ lat: 3.13, lng: 101.73, weight: 0.55 },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
interface AdvancedMapDrawerProps {
|
|
79
|
+
open: boolean;
|
|
80
|
+
onOpenChange: (open: boolean) => void;
|
|
81
|
+
selectedLocations: string[];
|
|
82
|
+
onSelectionChange: (locations: string[]) => void;
|
|
83
|
+
selectedCountry?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const TYPE_COLORS: Record<GeoType, string> = {
|
|
87
|
+
country: "bg-blue-500",
|
|
88
|
+
region: "bg-purple-500",
|
|
89
|
+
city: "bg-green-500",
|
|
90
|
+
town: "bg-teal-500",
|
|
91
|
+
poi: "bg-orange-500",
|
|
92
|
+
circle: "bg-pink-500",
|
|
93
|
+
polygon: "bg-indigo-500",
|
|
94
|
+
line: "bg-amber-500",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const TYPE_LABELS: Record<GeoType, string> = {
|
|
98
|
+
country: "Country",
|
|
99
|
+
region: "Region",
|
|
100
|
+
city: "City",
|
|
101
|
+
town: "Town",
|
|
102
|
+
poi: "POI",
|
|
103
|
+
circle: "Circle",
|
|
104
|
+
polygon: "Polygon",
|
|
105
|
+
line: "Line",
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export function AdvancedMapDrawer({
|
|
109
|
+
open,
|
|
110
|
+
onOpenChange,
|
|
111
|
+
selectedLocations,
|
|
112
|
+
onSelectionChange,
|
|
113
|
+
selectedCountry,
|
|
114
|
+
}: AdvancedMapDrawerProps) {
|
|
115
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
116
|
+
const [searchResults, setSearchResults] = useState<GeoSelection[]>([]);
|
|
117
|
+
const [selections, setSelections] = useState<GeoSelection[]>([]);
|
|
118
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
119
|
+
const [circleCount, setCircleCount] = useState(0);
|
|
120
|
+
const [polygonCount, setPolygonCount] = useState(0);
|
|
121
|
+
const [lineCount, setLineCount] = useState(0);
|
|
122
|
+
const [is3DMode, setIs3DMode] = useState(false);
|
|
123
|
+
const [showHeatmap, setShowHeatmap] = useState(false);
|
|
124
|
+
const [heatmapHour, setHeatmapHour] = useState(12);
|
|
125
|
+
const [activeTool, setActiveTool] = useState<"select" | "circle" | "polygon" | "line">("select");
|
|
126
|
+
const [drawingCircle, setDrawingCircle] = useState<{center: [number, number], radius: number} | null>(null);
|
|
127
|
+
|
|
128
|
+
const mapContainerRef = useRef<HTMLDivElement>(null);
|
|
129
|
+
const mapRef = useRef<mapboxgl.Map | null>(null);
|
|
130
|
+
const drawRef = useRef<MapboxDraw | null>(null);
|
|
131
|
+
const markersRef = useRef<mapboxgl.Marker[]>([]);
|
|
132
|
+
const circleLayersRef = useRef<string[]>([]);
|
|
133
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
134
|
+
const activeToolRef = useRef(activeTool);
|
|
135
|
+
const circleCountRef = useRef(circleCount);
|
|
136
|
+
const drawingCircleRef = useRef(drawingCircle);
|
|
137
|
+
|
|
138
|
+
useEffect(() => { activeToolRef.current = activeTool; }, [activeTool]);
|
|
139
|
+
useEffect(() => { circleCountRef.current = circleCount; }, [circleCount]);
|
|
140
|
+
useEffect(() => { drawingCircleRef.current = drawingCircle; }, [drawingCircle]);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (open) {
|
|
144
|
+
const initialSelections: GeoSelection[] = selectedLocations.map((loc, idx) => {
|
|
145
|
+
if (loc.startsWith("circle-")) {
|
|
146
|
+
return { id: loc, name: `Circle ${idx + 1}`, type: "circle" as GeoType, included: true };
|
|
147
|
+
} else if (loc.startsWith("polygon-")) {
|
|
148
|
+
return { id: loc, name: `Polygon ${idx + 1}`, type: "polygon" as GeoType, included: true };
|
|
149
|
+
} else if (loc.startsWith("line-")) {
|
|
150
|
+
return { id: loc, name: `Line ${idx + 1}`, type: "line" as GeoType, included: true };
|
|
151
|
+
} else if (loc.startsWith("poi-")) {
|
|
152
|
+
const poi = MOCK_POIS.find(p => p.id === loc);
|
|
153
|
+
return { id: loc, name: poi?.name || loc, type: "poi" as GeoType, included: true };
|
|
154
|
+
}
|
|
155
|
+
return { id: loc, name: loc, type: "city" as GeoType, included: true };
|
|
156
|
+
});
|
|
157
|
+
setSelections(initialSelections);
|
|
158
|
+
}
|
|
159
|
+
}, [open, selectedLocations]);
|
|
160
|
+
|
|
161
|
+
const addHeatmapLayer = useCallback((map: mapboxgl.Map) => {
|
|
162
|
+
if (map.getSource("heatmap-data")) return;
|
|
163
|
+
|
|
164
|
+
const hourMultiplier = Math.sin((heatmapHour / 24) * Math.PI) * 0.5 + 0.5;
|
|
165
|
+
|
|
166
|
+
map.addSource("heatmap-data", {
|
|
167
|
+
type: "geojson",
|
|
168
|
+
data: {
|
|
169
|
+
type: "FeatureCollection",
|
|
170
|
+
features: MOCK_HEATMAP_DATA.map(point => ({
|
|
171
|
+
type: "Feature" as const,
|
|
172
|
+
properties: { weight: point.weight * hourMultiplier },
|
|
173
|
+
geometry: {
|
|
174
|
+
type: "Point" as const,
|
|
175
|
+
coordinates: [point.lng, point.lat],
|
|
176
|
+
},
|
|
177
|
+
})),
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
map.addLayer({
|
|
182
|
+
id: "heatmap-layer",
|
|
183
|
+
type: "heatmap",
|
|
184
|
+
source: "heatmap-data",
|
|
185
|
+
paint: {
|
|
186
|
+
"heatmap-weight": ["get", "weight"],
|
|
187
|
+
"heatmap-intensity": 1,
|
|
188
|
+
"heatmap-color": [
|
|
189
|
+
"interpolate",
|
|
190
|
+
["linear"],
|
|
191
|
+
["heatmap-density"],
|
|
192
|
+
0, "rgba(0, 0, 255, 0)",
|
|
193
|
+
0.2, "rgb(0, 255, 255)",
|
|
194
|
+
0.4, "rgb(0, 255, 0)",
|
|
195
|
+
0.6, "rgb(255, 255, 0)",
|
|
196
|
+
0.8, "rgb(255, 128, 0)",
|
|
197
|
+
1, "rgb(255, 0, 0)",
|
|
198
|
+
],
|
|
199
|
+
"heatmap-radius": 50,
|
|
200
|
+
"heatmap-opacity": 0.7,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}, [heatmapHour]);
|
|
204
|
+
|
|
205
|
+
const removeHeatmapLayer = useCallback((map: mapboxgl.Map) => {
|
|
206
|
+
if (map.getLayer("heatmap-layer")) {
|
|
207
|
+
map.removeLayer("heatmap-layer");
|
|
208
|
+
}
|
|
209
|
+
if (map.getSource("heatmap-data")) {
|
|
210
|
+
map.removeSource("heatmap-data");
|
|
211
|
+
}
|
|
212
|
+
}, []);
|
|
213
|
+
|
|
214
|
+
const updateHeatmapHour = useCallback(() => {
|
|
215
|
+
if (!mapRef.current || !showHeatmap) return;
|
|
216
|
+
const map = mapRef.current;
|
|
217
|
+
removeHeatmapLayer(map);
|
|
218
|
+
addHeatmapLayer(map);
|
|
219
|
+
}, [showHeatmap, addHeatmapLayer, removeHeatmapLayer]);
|
|
220
|
+
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
updateHeatmapHour();
|
|
223
|
+
}, [heatmapHour, updateHeatmapHour]);
|
|
224
|
+
|
|
225
|
+
const toggle3DMode = useCallback(() => {
|
|
226
|
+
if (!mapRef.current) return;
|
|
227
|
+
const map = mapRef.current;
|
|
228
|
+
|
|
229
|
+
if (!is3DMode) {
|
|
230
|
+
map.easeTo({ pitch: 60, bearing: -20 });
|
|
231
|
+
if (!map.getLayer("3d-buildings")) {
|
|
232
|
+
map.addLayer({
|
|
233
|
+
id: "3d-buildings",
|
|
234
|
+
source: "composite",
|
|
235
|
+
"source-layer": "building",
|
|
236
|
+
filter: ["==", "extrude", "true"],
|
|
237
|
+
type: "fill-extrusion",
|
|
238
|
+
minzoom: 15,
|
|
239
|
+
paint: {
|
|
240
|
+
"fill-extrusion-color": "#aaa",
|
|
241
|
+
"fill-extrusion-height": ["get", "height"],
|
|
242
|
+
"fill-extrusion-base": ["get", "min_height"],
|
|
243
|
+
"fill-extrusion-opacity": 0.6,
|
|
244
|
+
},
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
map.easeTo({ pitch: 0, bearing: 0 });
|
|
249
|
+
if (map.getLayer("3d-buildings")) {
|
|
250
|
+
map.removeLayer("3d-buildings");
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
setIs3DMode(!is3DMode);
|
|
254
|
+
}, [is3DMode]);
|
|
255
|
+
|
|
256
|
+
const toggleHeatmap = useCallback(() => {
|
|
257
|
+
if (!mapRef.current) return;
|
|
258
|
+
const map = mapRef.current;
|
|
259
|
+
|
|
260
|
+
if (!showHeatmap) {
|
|
261
|
+
addHeatmapLayer(map);
|
|
262
|
+
} else {
|
|
263
|
+
removeHeatmapLayer(map);
|
|
264
|
+
}
|
|
265
|
+
setShowHeatmap(!showHeatmap);
|
|
266
|
+
}, [showHeatmap, addHeatmapLayer, removeHeatmapLayer]);
|
|
267
|
+
|
|
268
|
+
const addCircleToMap = useCallback((lng: number, lat: number, radiusMeters: number, id: string, name: string) => {
|
|
269
|
+
if (!mapRef.current) return;
|
|
270
|
+
const map = mapRef.current;
|
|
271
|
+
|
|
272
|
+
const sourceId = `circle-source-${id}`;
|
|
273
|
+
const layerId = `circle-layer-${id}`;
|
|
274
|
+
const outlineId = `circle-outline-${id}`;
|
|
275
|
+
const labelId = `circle-label-${id}`;
|
|
276
|
+
|
|
277
|
+
if (map.getSource(sourceId)) {
|
|
278
|
+
map.removeLayer(labelId);
|
|
279
|
+
map.removeLayer(outlineId);
|
|
280
|
+
map.removeLayer(layerId);
|
|
281
|
+
map.removeSource(sourceId);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const circleGeoJson = createCircleGeoJSON(lng, lat, radiusMeters / 1000);
|
|
285
|
+
|
|
286
|
+
map.addSource(sourceId, {
|
|
287
|
+
type: "geojson",
|
|
288
|
+
data: circleGeoJson,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
map.addLayer({
|
|
292
|
+
id: layerId,
|
|
293
|
+
type: "fill",
|
|
294
|
+
source: sourceId,
|
|
295
|
+
paint: {
|
|
296
|
+
"fill-color": "#ec4899",
|
|
297
|
+
"fill-opacity": 0.2,
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
map.addLayer({
|
|
302
|
+
id: outlineId,
|
|
303
|
+
type: "line",
|
|
304
|
+
source: sourceId,
|
|
305
|
+
paint: {
|
|
306
|
+
"line-color": "#ec4899",
|
|
307
|
+
"line-width": 2,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const center = circleGeoJson.geometry.coordinates[0][Math.floor(circleGeoJson.geometry.coordinates[0].length / 4)];
|
|
312
|
+
|
|
313
|
+
map.addSource(`${sourceId}-label`, {
|
|
314
|
+
type: "geojson",
|
|
315
|
+
data: {
|
|
316
|
+
type: "Feature",
|
|
317
|
+
properties: { label: `${name}\n${radiusMeters >= 1000 ? `${(radiusMeters/1000).toFixed(1)}km` : `${radiusMeters}m`}` },
|
|
318
|
+
geometry: { type: "Point", coordinates: [lng, lat] },
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
map.addLayer({
|
|
323
|
+
id: labelId,
|
|
324
|
+
type: "symbol",
|
|
325
|
+
source: `${sourceId}-label`,
|
|
326
|
+
layout: {
|
|
327
|
+
"text-field": ["get", "label"],
|
|
328
|
+
"text-size": 12,
|
|
329
|
+
"text-anchor": "center",
|
|
330
|
+
},
|
|
331
|
+
paint: {
|
|
332
|
+
"text-color": "#ec4899",
|
|
333
|
+
"text-halo-color": "#fff",
|
|
334
|
+
"text-halo-width": 1,
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
circleLayersRef.current.push(sourceId, layerId, outlineId, labelId, `${sourceId}-label`);
|
|
339
|
+
}, []);
|
|
340
|
+
|
|
341
|
+
useEffect(() => {
|
|
342
|
+
if (!open) {
|
|
343
|
+
if (mapRef.current) {
|
|
344
|
+
mapRef.current.remove();
|
|
345
|
+
mapRef.current = null;
|
|
346
|
+
drawRef.current = null;
|
|
347
|
+
}
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!mapContainerRef.current || !MAPBOX_TOKEN) return;
|
|
352
|
+
|
|
353
|
+
if (mapRef.current) {
|
|
354
|
+
setTimeout(() => mapRef.current?.resize(), 100);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const initMap = () => {
|
|
359
|
+
if (!mapContainerRef.current || mapRef.current) return;
|
|
360
|
+
|
|
361
|
+
mapboxgl.accessToken = MAPBOX_TOKEN;
|
|
362
|
+
const map = new mapboxgl.Map({
|
|
363
|
+
container: mapContainerRef.current,
|
|
364
|
+
style: "mapbox://styles/mapbox/light-v11",
|
|
365
|
+
center: [101.6869, 3.139],
|
|
366
|
+
zoom: 10,
|
|
367
|
+
});
|
|
368
|
+
mapRef.current = map;
|
|
369
|
+
|
|
370
|
+
map.on("load", () => {
|
|
371
|
+
map.resize();
|
|
372
|
+
|
|
373
|
+
const draw = new MapboxDraw({
|
|
374
|
+
displayControlsDefault: false,
|
|
375
|
+
controls: {},
|
|
376
|
+
defaultMode: "simple_select",
|
|
377
|
+
});
|
|
378
|
+
map.addControl(draw, "top-left");
|
|
379
|
+
drawRef.current = draw;
|
|
380
|
+
|
|
381
|
+
map.on("draw.create", (e: any) => {
|
|
382
|
+
const feature = e.features[0];
|
|
383
|
+
if (feature && feature.geometry.type === "Polygon") {
|
|
384
|
+
setPolygonCount(prev => {
|
|
385
|
+
const newCount = prev + 1;
|
|
386
|
+
const newSelection: GeoSelection = {
|
|
387
|
+
id: `polygon-${Date.now()}`,
|
|
388
|
+
name: `Polygon ${newCount}`,
|
|
389
|
+
type: "polygon",
|
|
390
|
+
geometry: feature.geometry,
|
|
391
|
+
included: true,
|
|
392
|
+
};
|
|
393
|
+
setSelections(prevSel => [...prevSel, newSelection]);
|
|
394
|
+
return newCount;
|
|
395
|
+
});
|
|
396
|
+
setActiveTool("select");
|
|
397
|
+
} else if (feature && feature.geometry.type === "LineString") {
|
|
398
|
+
setLineCount(prev => {
|
|
399
|
+
const newCount = prev + 1;
|
|
400
|
+
const newSelection: GeoSelection = {
|
|
401
|
+
id: `line-${Date.now()}`,
|
|
402
|
+
name: `Line ${newCount}`,
|
|
403
|
+
type: "line",
|
|
404
|
+
geometry: feature.geometry,
|
|
405
|
+
included: true,
|
|
406
|
+
};
|
|
407
|
+
setSelections(prevSel => [...prevSel, newSelection]);
|
|
408
|
+
return newCount;
|
|
409
|
+
});
|
|
410
|
+
setActiveTool("select");
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
map.on("draw.delete", (e: any) => {
|
|
415
|
+
const deletedIds = e.features.map((f: any) => f.id);
|
|
416
|
+
setSelections(prev => prev.filter(s => !deletedIds.includes(s.id)));
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
map.addControl(new mapboxgl.NavigationControl(), "top-right");
|
|
421
|
+
|
|
422
|
+
let circleStart: [number, number] | null = null;
|
|
423
|
+
|
|
424
|
+
map.on("mousedown", (e) => {
|
|
425
|
+
if (activeToolRef.current === "circle") {
|
|
426
|
+
circleStart = [e.lngLat.lng, e.lngLat.lat];
|
|
427
|
+
setDrawingCircle({ center: circleStart, radius: 0 });
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
map.on("mousemove", (e) => {
|
|
432
|
+
if (activeToolRef.current === "circle" && circleStart) {
|
|
433
|
+
const distance = getDistanceFromLatLonInM(
|
|
434
|
+
circleStart[1], circleStart[0],
|
|
435
|
+
e.lngLat.lat, e.lngLat.lng
|
|
436
|
+
);
|
|
437
|
+
setDrawingCircle({ center: circleStart, radius: distance });
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
map.on("mouseup", (e) => {
|
|
442
|
+
if (activeToolRef.current === "circle" && circleStart) {
|
|
443
|
+
const distance = getDistanceFromLatLonInM(
|
|
444
|
+
circleStart[1], circleStart[0],
|
|
445
|
+
e.lngLat.lat, e.lngLat.lng
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
if (distance > 10) {
|
|
449
|
+
const id = `circle-${Date.now()}`;
|
|
450
|
+
setCircleCount(prev => {
|
|
451
|
+
const newCount = prev + 1;
|
|
452
|
+
addCircleToMap(circleStart![0], circleStart![1], distance, id, `Circle ${newCount}`);
|
|
453
|
+
setSelections(prevSel => [...prevSel, {
|
|
454
|
+
id,
|
|
455
|
+
name: `Circle ${newCount}`,
|
|
456
|
+
type: "circle",
|
|
457
|
+
coordinates: circleStart!,
|
|
458
|
+
radius: distance,
|
|
459
|
+
included: true,
|
|
460
|
+
}]);
|
|
461
|
+
return newCount;
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
circleStart = null;
|
|
466
|
+
setDrawingCircle(null);
|
|
467
|
+
setActiveTool("select");
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
setTimeout(initMap, 100);
|
|
473
|
+
|
|
474
|
+
return () => {
|
|
475
|
+
markersRef.current.forEach((m) => m.remove());
|
|
476
|
+
markersRef.current = [];
|
|
477
|
+
};
|
|
478
|
+
}, [open, addCircleToMap]);
|
|
479
|
+
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
if (!mapRef.current || !open) return;
|
|
482
|
+
|
|
483
|
+
markersRef.current.forEach((m) => m.remove());
|
|
484
|
+
markersRef.current = [];
|
|
485
|
+
|
|
486
|
+
selections.forEach((sel) => {
|
|
487
|
+
if (sel.coordinates && sel.type !== "circle") {
|
|
488
|
+
const el = document.createElement("div");
|
|
489
|
+
el.className = `w-6 h-6 rounded-full flex items-center justify-center cursor-pointer ${TYPE_COLORS[sel.type]} text-white text-xs font-bold shadow-md`;
|
|
490
|
+
el.innerHTML = sel.type === "poi" ? "P" : sel.name.charAt(0).toUpperCase();
|
|
491
|
+
|
|
492
|
+
const marker = new mapboxgl.Marker({ element: el })
|
|
493
|
+
.setLngLat(sel.coordinates)
|
|
494
|
+
.setPopup(new mapboxgl.Popup().setHTML(`<strong>${sel.name}</strong><br/><span class="text-xs">${TYPE_LABELS[sel.type]}</span>`))
|
|
495
|
+
.addTo(mapRef.current!);
|
|
496
|
+
|
|
497
|
+
markersRef.current.push(marker);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}, [selections, open]);
|
|
501
|
+
|
|
502
|
+
const handleSearch = useCallback(async () => {
|
|
503
|
+
if (!searchQuery.trim()) {
|
|
504
|
+
setSearchResults([]);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
setIsSearching(true);
|
|
509
|
+
|
|
510
|
+
try {
|
|
511
|
+
const response = await fetch(
|
|
512
|
+
`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(searchQuery)}.json?access_token=${MAPBOX_TOKEN}&types=country,region,place,locality&limit=10`
|
|
513
|
+
);
|
|
514
|
+
const data = await response.json();
|
|
515
|
+
|
|
516
|
+
const results: GeoSelection[] = data.features?.map((feature: any) => {
|
|
517
|
+
let type: GeoType = "city";
|
|
518
|
+
if (feature.place_type?.includes("country")) type = "country";
|
|
519
|
+
else if (feature.place_type?.includes("region")) type = "region";
|
|
520
|
+
else if (feature.place_type?.includes("locality")) type = "town";
|
|
521
|
+
else if (feature.place_type?.includes("place")) type = "city";
|
|
522
|
+
|
|
523
|
+
return {
|
|
524
|
+
id: feature.id,
|
|
525
|
+
name: feature.place_name,
|
|
526
|
+
type,
|
|
527
|
+
coordinates: feature.center as [number, number],
|
|
528
|
+
included: true,
|
|
529
|
+
};
|
|
530
|
+
}) || [];
|
|
531
|
+
|
|
532
|
+
const matchingPOIs = MOCK_POIS.filter(poi =>
|
|
533
|
+
poi.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
|
534
|
+
poi.category.toLowerCase().includes(searchQuery.toLowerCase())
|
|
535
|
+
).map(poi => ({
|
|
536
|
+
id: poi.id,
|
|
537
|
+
name: `${poi.name} (${poi.category})`,
|
|
538
|
+
type: "poi" as GeoType,
|
|
539
|
+
coordinates: [poi.longitude, poi.latitude] as [number, number],
|
|
540
|
+
included: true,
|
|
541
|
+
}));
|
|
542
|
+
|
|
543
|
+
setSearchResults([...results, ...matchingPOIs]);
|
|
544
|
+
} catch (error) {
|
|
545
|
+
console.error("Search failed:", error);
|
|
546
|
+
setSearchResults([]);
|
|
547
|
+
} finally {
|
|
548
|
+
setIsSearching(false);
|
|
549
|
+
}
|
|
550
|
+
}, [searchQuery]);
|
|
551
|
+
|
|
552
|
+
useEffect(() => {
|
|
553
|
+
const timer = setTimeout(() => {
|
|
554
|
+
if (searchQuery.trim()) {
|
|
555
|
+
handleSearch();
|
|
556
|
+
} else {
|
|
557
|
+
setSearchResults([]);
|
|
558
|
+
}
|
|
559
|
+
}, 300);
|
|
560
|
+
return () => clearTimeout(timer);
|
|
561
|
+
}, [searchQuery, handleSearch]);
|
|
562
|
+
|
|
563
|
+
const handleAddSelection = (item: GeoSelection) => {
|
|
564
|
+
if (!selections.find(s => s.id === item.id)) {
|
|
565
|
+
setSelections(prev => [...prev, item]);
|
|
566
|
+
|
|
567
|
+
if (item.coordinates && mapRef.current) {
|
|
568
|
+
mapRef.current.flyTo({
|
|
569
|
+
center: item.coordinates,
|
|
570
|
+
zoom: item.type === "country" ? 5 : item.type === "region" ? 7 : 10,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
setSearchQuery("");
|
|
575
|
+
setSearchResults([]);
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
const handleRemoveSelection = (id: string) => {
|
|
579
|
+
setSelections(prev => prev.filter(s => s.id !== id));
|
|
580
|
+
|
|
581
|
+
if (mapRef.current) {
|
|
582
|
+
const map = mapRef.current;
|
|
583
|
+
const sourceId = `circle-source-${id}`;
|
|
584
|
+
if (map.getSource(sourceId)) {
|
|
585
|
+
[`circle-label-${id}`, `circle-outline-${id}`, `circle-layer-${id}`].forEach(layerId => {
|
|
586
|
+
if (map.getLayer(layerId)) map.removeLayer(layerId);
|
|
587
|
+
});
|
|
588
|
+
if (map.getSource(`${sourceId}-label`)) map.removeSource(`${sourceId}-label`);
|
|
589
|
+
map.removeSource(sourceId);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (drawRef.current) {
|
|
594
|
+
try {
|
|
595
|
+
drawRef.current.delete(id);
|
|
596
|
+
} catch (e) {}
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const toggleIncludeExclude = (id: string) => {
|
|
601
|
+
setSelections(prev => prev.map(s =>
|
|
602
|
+
s.id === id ? { ...s, included: !s.included } : s
|
|
603
|
+
));
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
const handleApply = () => {
|
|
607
|
+
onSelectionChange(selections.map(s => s.id));
|
|
608
|
+
onOpenChange(false);
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
const handleCancel = () => {
|
|
612
|
+
onOpenChange(false);
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
const handleClearAll = () => {
|
|
616
|
+
setSelections([]);
|
|
617
|
+
if (drawRef.current) {
|
|
618
|
+
drawRef.current.deleteAll();
|
|
619
|
+
}
|
|
620
|
+
if (mapRef.current) {
|
|
621
|
+
const map = mapRef.current;
|
|
622
|
+
circleLayersRef.current.forEach(id => {
|
|
623
|
+
if (map.getLayer(id)) map.removeLayer(id);
|
|
624
|
+
if (map.getSource(id)) map.removeSource(id);
|
|
625
|
+
});
|
|
626
|
+
circleLayersRef.current = [];
|
|
627
|
+
}
|
|
628
|
+
setCircleCount(0);
|
|
629
|
+
setPolygonCount(0);
|
|
630
|
+
setLineCount(0);
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
const handleStartCircle = () => {
|
|
634
|
+
setActiveTool("circle");
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
const handleStartPolygon = () => {
|
|
638
|
+
setActiveTool("polygon");
|
|
639
|
+
if (drawRef.current) {
|
|
640
|
+
drawRef.current.changeMode("draw_polygon");
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
const handleStartLine = () => {
|
|
645
|
+
setActiveTool("line");
|
|
646
|
+
if (drawRef.current) {
|
|
647
|
+
drawRef.current.changeMode("draw_line_string");
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
const handleDownloadTemplate = () => {
|
|
652
|
+
const template = "name,latitude,longitude,radius\nLocation 1,3.139,101.6869,500\nLocation 2,3.1588,101.7118,\n";
|
|
653
|
+
const blob = new Blob([template], { type: "text/csv" });
|
|
654
|
+
const url = URL.createObjectURL(blob);
|
|
655
|
+
const a = document.createElement("a");
|
|
656
|
+
a.href = url;
|
|
657
|
+
a.download = "coordinate-template.csv";
|
|
658
|
+
a.click();
|
|
659
|
+
URL.revokeObjectURL(url);
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
const handleFileUpload = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
663
|
+
const file = event.target.files?.[0];
|
|
664
|
+
if (!file) return;
|
|
665
|
+
|
|
666
|
+
const reader = new FileReader();
|
|
667
|
+
reader.onload = (e) => {
|
|
668
|
+
const text = e.target?.result as string;
|
|
669
|
+
const lines = text.split("\n").filter(line => line.trim());
|
|
670
|
+
|
|
671
|
+
if (lines.length < 2) return;
|
|
672
|
+
|
|
673
|
+
const newSelections: GeoSelection[] = [];
|
|
674
|
+
let count = circleCount;
|
|
675
|
+
|
|
676
|
+
for (let i = 1; i < lines.length; i++) {
|
|
677
|
+
const parts = lines[i].split(",").map(p => p.trim());
|
|
678
|
+
if (parts.length < 3) continue;
|
|
679
|
+
|
|
680
|
+
const name = parts[0] || `CSV Circle ${i}`;
|
|
681
|
+
const lat = parseFloat(parts[1]);
|
|
682
|
+
const lng = parseFloat(parts[2]);
|
|
683
|
+
const radius = parts[3] ? parseFloat(parts[3]) : 250;
|
|
684
|
+
|
|
685
|
+
if (isNaN(lat) || isNaN(lng)) continue;
|
|
686
|
+
|
|
687
|
+
count++;
|
|
688
|
+
const id = `circle-csv-${Date.now()}-${i}`;
|
|
689
|
+
|
|
690
|
+
addCircleToMap(lng, lat, radius, id, name);
|
|
691
|
+
|
|
692
|
+
newSelections.push({
|
|
693
|
+
id,
|
|
694
|
+
name,
|
|
695
|
+
type: "circle",
|
|
696
|
+
coordinates: [lng, lat],
|
|
697
|
+
radius,
|
|
698
|
+
included: true,
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
setCircleCount(count);
|
|
703
|
+
setSelections(prev => [...prev, ...newSelections]);
|
|
704
|
+
|
|
705
|
+
if (newSelections.length > 0 && mapRef.current) {
|
|
706
|
+
const firstCoord = newSelections[0].coordinates;
|
|
707
|
+
if (firstCoord) {
|
|
708
|
+
mapRef.current.flyTo({ center: firstCoord, zoom: 12 });
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
reader.readAsText(file);
|
|
713
|
+
|
|
714
|
+
if (fileInputRef.current) {
|
|
715
|
+
fileInputRef.current.value = "";
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
const includedCount = selections.filter(s => s.included).length;
|
|
720
|
+
const excludedCount = selections.filter(s => !s.included).length;
|
|
721
|
+
|
|
722
|
+
return (
|
|
723
|
+
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
724
|
+
<SheetContent
|
|
725
|
+
side="right"
|
|
726
|
+
className="w-full sm:max-w-[75vw] flex flex-col p-0"
|
|
727
|
+
data-testid="geography-drawer"
|
|
728
|
+
>
|
|
729
|
+
<div className="p-4 pb-3 border-b">
|
|
730
|
+
<SheetHeader>
|
|
731
|
+
<SheetTitle className="flex items-center gap-2">
|
|
732
|
+
<Globe className="h-5 w-5" />
|
|
733
|
+
Geography Selection
|
|
734
|
+
</SheetTitle>
|
|
735
|
+
<SheetDescription>
|
|
736
|
+
Search for locations, upload coordinates, or draw custom areas on the map
|
|
737
|
+
</SheetDescription>
|
|
738
|
+
</SheetHeader>
|
|
739
|
+
</div>
|
|
740
|
+
|
|
741
|
+
<div className="flex-1 flex overflow-hidden">
|
|
742
|
+
<div className="w-1/4 flex flex-col border-r bg-muted/20">
|
|
743
|
+
<div className="p-3 border-b space-y-2">
|
|
744
|
+
<div className="flex gap-2">
|
|
745
|
+
<div className="relative flex-1">
|
|
746
|
+
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
|
|
747
|
+
<Input
|
|
748
|
+
placeholder="Search locations, POIs..."
|
|
749
|
+
value={searchQuery}
|
|
750
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
751
|
+
className="pl-9"
|
|
752
|
+
data-testid="input-search-geography"
|
|
753
|
+
/>
|
|
754
|
+
</div>
|
|
755
|
+
<Tooltip>
|
|
756
|
+
<TooltipTrigger asChild>
|
|
757
|
+
<Button
|
|
758
|
+
type="button"
|
|
759
|
+
variant="outline"
|
|
760
|
+
size="icon"
|
|
761
|
+
onClick={handleDownloadTemplate}
|
|
762
|
+
data-testid="button-download-template"
|
|
763
|
+
>
|
|
764
|
+
<Download className="h-4 w-4" />
|
|
765
|
+
</Button>
|
|
766
|
+
</TooltipTrigger>
|
|
767
|
+
<TooltipContent>Download CSV Template</TooltipContent>
|
|
768
|
+
</Tooltip>
|
|
769
|
+
<Tooltip>
|
|
770
|
+
<TooltipTrigger asChild>
|
|
771
|
+
<Button
|
|
772
|
+
type="button"
|
|
773
|
+
variant="outline"
|
|
774
|
+
size="icon"
|
|
775
|
+
onClick={() => fileInputRef.current?.click()}
|
|
776
|
+
data-testid="button-upload-csv"
|
|
777
|
+
>
|
|
778
|
+
<Upload className="h-4 w-4" />
|
|
779
|
+
</Button>
|
|
780
|
+
</TooltipTrigger>
|
|
781
|
+
<TooltipContent>Upload CSV Coordinates</TooltipContent>
|
|
782
|
+
</Tooltip>
|
|
783
|
+
<input
|
|
784
|
+
ref={fileInputRef}
|
|
785
|
+
type="file"
|
|
786
|
+
accept=".csv"
|
|
787
|
+
onChange={handleFileUpload}
|
|
788
|
+
className="hidden"
|
|
789
|
+
/>
|
|
790
|
+
</div>
|
|
791
|
+
|
|
792
|
+
{searchResults.length > 0 && (
|
|
793
|
+
<div className="absolute z-50 mt-1 w-[calc(25%-3rem)] bg-background border rounded-md shadow-lg max-h-64 overflow-auto">
|
|
794
|
+
{searchResults.map((result) => (
|
|
795
|
+
<button
|
|
796
|
+
key={result.id}
|
|
797
|
+
type="button"
|
|
798
|
+
className="w-full text-left px-3 py-2 hover:bg-muted flex items-center gap-2"
|
|
799
|
+
onClick={() => handleAddSelection(result)}
|
|
800
|
+
data-testid={`search-result-${result.id}`}
|
|
801
|
+
>
|
|
802
|
+
<Badge variant="secondary" className={`text-xs text-white ${TYPE_COLORS[result.type]}`}>
|
|
803
|
+
{TYPE_LABELS[result.type]}
|
|
804
|
+
</Badge>
|
|
805
|
+
<span className="text-sm truncate flex-1">{result.name}</span>
|
|
806
|
+
</button>
|
|
807
|
+
))}
|
|
808
|
+
</div>
|
|
809
|
+
)}
|
|
810
|
+
</div>
|
|
811
|
+
|
|
812
|
+
<div className="p-3 border-b flex items-center justify-between">
|
|
813
|
+
<div className="flex items-center gap-2">
|
|
814
|
+
<span className="text-sm font-medium">Selected</span>
|
|
815
|
+
<Badge variant="secondary" className="text-xs">{selections.length}</Badge>
|
|
816
|
+
{includedCount > 0 && (
|
|
817
|
+
<Tooltip>
|
|
818
|
+
<TooltipTrigger>
|
|
819
|
+
<Badge variant="secondary" className="text-xs bg-green-100 text-green-700">
|
|
820
|
+
<Check className="h-3 w-3 mr-0.5" />{includedCount}
|
|
821
|
+
</Badge>
|
|
822
|
+
</TooltipTrigger>
|
|
823
|
+
<TooltipContent>Included</TooltipContent>
|
|
824
|
+
</Tooltip>
|
|
825
|
+
)}
|
|
826
|
+
{excludedCount > 0 && (
|
|
827
|
+
<Tooltip>
|
|
828
|
+
<TooltipTrigger>
|
|
829
|
+
<Badge variant="secondary" className="text-xs bg-red-100 text-red-700">
|
|
830
|
+
<Ban className="h-3 w-3 mr-0.5" />{excludedCount}
|
|
831
|
+
</Badge>
|
|
832
|
+
</TooltipTrigger>
|
|
833
|
+
<TooltipContent>Excluded</TooltipContent>
|
|
834
|
+
</Tooltip>
|
|
835
|
+
)}
|
|
836
|
+
</div>
|
|
837
|
+
{selections.length > 0 && (
|
|
838
|
+
<Button
|
|
839
|
+
type="button"
|
|
840
|
+
variant="ghost"
|
|
841
|
+
size="sm"
|
|
842
|
+
onClick={handleClearAll}
|
|
843
|
+
className="text-xs h-7"
|
|
844
|
+
data-testid="button-clear-all-geography"
|
|
845
|
+
>
|
|
846
|
+
Clear
|
|
847
|
+
</Button>
|
|
848
|
+
)}
|
|
849
|
+
</div>
|
|
850
|
+
|
|
851
|
+
<ScrollArea className="flex-1">
|
|
852
|
+
<div className="p-2 space-y-1">
|
|
853
|
+
{selections.length === 0 ? (
|
|
854
|
+
<p className="text-sm text-muted-foreground text-center py-4">
|
|
855
|
+
No locations selected. Search, upload CSV, or draw on the map.
|
|
856
|
+
</p>
|
|
857
|
+
) : (
|
|
858
|
+
selections.map((sel) => (
|
|
859
|
+
<div
|
|
860
|
+
key={sel.id}
|
|
861
|
+
className={`flex items-center gap-2 p-2 rounded-md border ${
|
|
862
|
+
sel.included ? "bg-background" : "bg-red-50 border-red-200"
|
|
863
|
+
}`}
|
|
864
|
+
data-testid={`selected-geography-${sel.id}`}
|
|
865
|
+
>
|
|
866
|
+
<Tooltip>
|
|
867
|
+
<TooltipTrigger asChild>
|
|
868
|
+
<button
|
|
869
|
+
type="button"
|
|
870
|
+
onClick={() => toggleIncludeExclude(sel.id)}
|
|
871
|
+
className={`shrink-0 p-1 rounded ${
|
|
872
|
+
sel.included
|
|
873
|
+
? "text-green-600 hover:bg-green-100"
|
|
874
|
+
: "text-red-600 hover:bg-red-100"
|
|
875
|
+
}`}
|
|
876
|
+
data-testid={`toggle-include-${sel.id}`}
|
|
877
|
+
>
|
|
878
|
+
{sel.included ? <Check className="h-4 w-4" /> : <Ban className="h-4 w-4" />}
|
|
879
|
+
</button>
|
|
880
|
+
</TooltipTrigger>
|
|
881
|
+
<TooltipContent>
|
|
882
|
+
{sel.included ? "Click to exclude" : "Click to include"}
|
|
883
|
+
</TooltipContent>
|
|
884
|
+
</Tooltip>
|
|
885
|
+
<Badge
|
|
886
|
+
variant="secondary"
|
|
887
|
+
className={`text-xs text-white shrink-0 ${TYPE_COLORS[sel.type]}`}
|
|
888
|
+
>
|
|
889
|
+
{TYPE_LABELS[sel.type]}
|
|
890
|
+
</Badge>
|
|
891
|
+
<div className="flex-1 min-w-0">
|
|
892
|
+
<span className="text-sm truncate block">{sel.name}</span>
|
|
893
|
+
{sel.radius && (
|
|
894
|
+
<span className="text-xs text-muted-foreground">
|
|
895
|
+
{sel.radius >= 1000 ? `${(sel.radius/1000).toFixed(1)}km` : `${Math.round(sel.radius)}m`}
|
|
896
|
+
</span>
|
|
897
|
+
)}
|
|
898
|
+
</div>
|
|
899
|
+
<button
|
|
900
|
+
type="button"
|
|
901
|
+
onClick={() => handleRemoveSelection(sel.id)}
|
|
902
|
+
className="text-muted-foreground hover:text-destructive shrink-0"
|
|
903
|
+
data-testid={`button-remove-${sel.id}`}
|
|
904
|
+
>
|
|
905
|
+
<X className="h-4 w-4" />
|
|
906
|
+
</button>
|
|
907
|
+
</div>
|
|
908
|
+
))
|
|
909
|
+
)}
|
|
910
|
+
</div>
|
|
911
|
+
</ScrollArea>
|
|
912
|
+
</div>
|
|
913
|
+
|
|
914
|
+
<div className="w-3/4 h-full relative">
|
|
915
|
+
<div
|
|
916
|
+
ref={mapContainerRef}
|
|
917
|
+
className="absolute inset-0 w-full h-full"
|
|
918
|
+
style={{ minHeight: "400px" }}
|
|
919
|
+
data-testid="geography-map"
|
|
920
|
+
/>
|
|
921
|
+
|
|
922
|
+
<div className="absolute top-3 left-3 z-10 flex flex-col gap-1 bg-white rounded-lg shadow-lg p-1">
|
|
923
|
+
<Tooltip>
|
|
924
|
+
<TooltipTrigger asChild>
|
|
925
|
+
<Button
|
|
926
|
+
type="button"
|
|
927
|
+
variant={activeTool === "circle" ? "default" : "ghost"}
|
|
928
|
+
size="icon"
|
|
929
|
+
onClick={handleStartCircle}
|
|
930
|
+
className="h-8 w-8"
|
|
931
|
+
data-testid="tool-circle"
|
|
932
|
+
>
|
|
933
|
+
<Circle className="h-4 w-4" />
|
|
934
|
+
</Button>
|
|
935
|
+
</TooltipTrigger>
|
|
936
|
+
<TooltipContent side="right">Draw Circle</TooltipContent>
|
|
937
|
+
</Tooltip>
|
|
938
|
+
|
|
939
|
+
<Tooltip>
|
|
940
|
+
<TooltipTrigger asChild>
|
|
941
|
+
<Button
|
|
942
|
+
type="button"
|
|
943
|
+
variant={activeTool === "polygon" ? "default" : "ghost"}
|
|
944
|
+
size="icon"
|
|
945
|
+
onClick={handleStartPolygon}
|
|
946
|
+
className="h-8 w-8"
|
|
947
|
+
data-testid="tool-polygon"
|
|
948
|
+
>
|
|
949
|
+
<Pentagon className="h-4 w-4" />
|
|
950
|
+
</Button>
|
|
951
|
+
</TooltipTrigger>
|
|
952
|
+
<TooltipContent side="right">Draw Polygon</TooltipContent>
|
|
953
|
+
</Tooltip>
|
|
954
|
+
|
|
955
|
+
<Tooltip>
|
|
956
|
+
<TooltipTrigger asChild>
|
|
957
|
+
<Button
|
|
958
|
+
type="button"
|
|
959
|
+
variant={activeTool === "line" ? "default" : "ghost"}
|
|
960
|
+
size="icon"
|
|
961
|
+
onClick={handleStartLine}
|
|
962
|
+
className="h-8 w-8"
|
|
963
|
+
data-testid="tool-line"
|
|
964
|
+
>
|
|
965
|
+
<Minus className="h-4 w-4" />
|
|
966
|
+
</Button>
|
|
967
|
+
</TooltipTrigger>
|
|
968
|
+
<TooltipContent side="right">Draw Line</TooltipContent>
|
|
969
|
+
</Tooltip>
|
|
970
|
+
|
|
971
|
+
<div className="w-full h-px bg-border my-1" />
|
|
972
|
+
|
|
973
|
+
<Tooltip>
|
|
974
|
+
<TooltipTrigger asChild>
|
|
975
|
+
<Button
|
|
976
|
+
type="button"
|
|
977
|
+
variant={is3DMode ? "default" : "ghost"}
|
|
978
|
+
size="icon"
|
|
979
|
+
onClick={toggle3DMode}
|
|
980
|
+
className="h-8 w-8"
|
|
981
|
+
data-testid="tool-3d"
|
|
982
|
+
>
|
|
983
|
+
<Box className="h-4 w-4" />
|
|
984
|
+
</Button>
|
|
985
|
+
</TooltipTrigger>
|
|
986
|
+
<TooltipContent side="right">3D View</TooltipContent>
|
|
987
|
+
</Tooltip>
|
|
988
|
+
|
|
989
|
+
<Popover>
|
|
990
|
+
<Tooltip>
|
|
991
|
+
<TooltipTrigger asChild>
|
|
992
|
+
<PopoverTrigger asChild>
|
|
993
|
+
<Button
|
|
994
|
+
type="button"
|
|
995
|
+
variant={showHeatmap ? "default" : "ghost"}
|
|
996
|
+
size="icon"
|
|
997
|
+
className="h-8 w-8"
|
|
998
|
+
data-testid="tool-heatmap"
|
|
999
|
+
>
|
|
1000
|
+
<Layers className="h-4 w-4" />
|
|
1001
|
+
</Button>
|
|
1002
|
+
</PopoverTrigger>
|
|
1003
|
+
</TooltipTrigger>
|
|
1004
|
+
<TooltipContent side="right">Audience Heatmap</TooltipContent>
|
|
1005
|
+
</Tooltip>
|
|
1006
|
+
<PopoverContent side="right" className="w-64">
|
|
1007
|
+
<div className="space-y-3">
|
|
1008
|
+
<div className="flex items-center justify-between">
|
|
1009
|
+
<span className="text-sm font-medium">Audience Density</span>
|
|
1010
|
+
<Button
|
|
1011
|
+
type="button"
|
|
1012
|
+
variant={showHeatmap ? "default" : "outline"}
|
|
1013
|
+
size="sm"
|
|
1014
|
+
onClick={toggleHeatmap}
|
|
1015
|
+
>
|
|
1016
|
+
{showHeatmap ? "Hide" : "Show"}
|
|
1017
|
+
</Button>
|
|
1018
|
+
</div>
|
|
1019
|
+
{showHeatmap && (
|
|
1020
|
+
<div className="space-y-2">
|
|
1021
|
+
<div className="flex items-center gap-2">
|
|
1022
|
+
<Clock className="h-4 w-4 text-muted-foreground" />
|
|
1023
|
+
<span className="text-sm">Hour: {heatmapHour}:00</span>
|
|
1024
|
+
</div>
|
|
1025
|
+
<Slider
|
|
1026
|
+
value={[heatmapHour]}
|
|
1027
|
+
onValueChange={([val]) => setHeatmapHour(val)}
|
|
1028
|
+
min={0}
|
|
1029
|
+
max={23}
|
|
1030
|
+
step={1}
|
|
1031
|
+
/>
|
|
1032
|
+
<div className="flex justify-between text-xs text-muted-foreground">
|
|
1033
|
+
<span>12 AM</span>
|
|
1034
|
+
<span>12 PM</span>
|
|
1035
|
+
<span>11 PM</span>
|
|
1036
|
+
</div>
|
|
1037
|
+
</div>
|
|
1038
|
+
)}
|
|
1039
|
+
</div>
|
|
1040
|
+
</PopoverContent>
|
|
1041
|
+
</Popover>
|
|
1042
|
+
</div>
|
|
1043
|
+
|
|
1044
|
+
{activeTool === "circle" && (
|
|
1045
|
+
<div className="absolute bottom-20 left-1/2 transform -translate-x-1/2 z-10 bg-white/90 backdrop-blur-sm px-4 py-2 rounded-lg shadow-lg">
|
|
1046
|
+
<p className="text-sm font-medium">Click and drag to draw a circle</p>
|
|
1047
|
+
{drawingCircle && drawingCircle.radius > 0 && (
|
|
1048
|
+
<p className="text-xs text-muted-foreground text-center mt-1">
|
|
1049
|
+
Radius: {drawingCircle.radius >= 1000 ? `${(drawingCircle.radius/1000).toFixed(2)}km` : `${Math.round(drawingCircle.radius)}m`}
|
|
1050
|
+
</p>
|
|
1051
|
+
)}
|
|
1052
|
+
</div>
|
|
1053
|
+
)}
|
|
1054
|
+
|
|
1055
|
+
{!MAPBOX_TOKEN && (
|
|
1056
|
+
<div className="absolute inset-0 flex items-center justify-center bg-muted/50">
|
|
1057
|
+
<p className="text-muted-foreground">Map token not configured</p>
|
|
1058
|
+
</div>
|
|
1059
|
+
)}
|
|
1060
|
+
</div>
|
|
1061
|
+
</div>
|
|
1062
|
+
|
|
1063
|
+
<div className="flex justify-between items-center p-4 border-t bg-background">
|
|
1064
|
+
<span className="text-sm text-muted-foreground">
|
|
1065
|
+
{selections.length} location{selections.length !== 1 ? "s" : ""} selected
|
|
1066
|
+
{excludedCount > 0 && ` (${excludedCount} excluded)`}
|
|
1067
|
+
</span>
|
|
1068
|
+
<div className="flex gap-2">
|
|
1069
|
+
<Button
|
|
1070
|
+
type="button"
|
|
1071
|
+
variant="outline"
|
|
1072
|
+
onClick={handleCancel}
|
|
1073
|
+
data-testid="button-cancel-geography"
|
|
1074
|
+
>
|
|
1075
|
+
Cancel
|
|
1076
|
+
</Button>
|
|
1077
|
+
<Button
|
|
1078
|
+
type="button"
|
|
1079
|
+
onClick={handleApply}
|
|
1080
|
+
data-testid="button-apply-geography"
|
|
1081
|
+
>
|
|
1082
|
+
Apply Selection
|
|
1083
|
+
</Button>
|
|
1084
|
+
</div>
|
|
1085
|
+
</div>
|
|
1086
|
+
</SheetContent>
|
|
1087
|
+
</Sheet>
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function createCircleGeoJSON(lng: number, lat: number, radiusKm: number): GeoJSON.Feature<GeoJSON.Polygon> {
|
|
1092
|
+
const points = 64;
|
|
1093
|
+
const coords: [number, number][] = [];
|
|
1094
|
+
|
|
1095
|
+
for (let i = 0; i < points; i++) {
|
|
1096
|
+
const angle = (i / points) * 2 * Math.PI;
|
|
1097
|
+
const dx = radiusKm * Math.cos(angle);
|
|
1098
|
+
const dy = radiusKm * Math.sin(angle);
|
|
1099
|
+
|
|
1100
|
+
const dlng = dx / (111.32 * Math.cos(lat * Math.PI / 180));
|
|
1101
|
+
const dlat = dy / 110.574;
|
|
1102
|
+
|
|
1103
|
+
coords.push([lng + dlng, lat + dlat]);
|
|
1104
|
+
}
|
|
1105
|
+
coords.push(coords[0]);
|
|
1106
|
+
|
|
1107
|
+
return {
|
|
1108
|
+
type: "Feature",
|
|
1109
|
+
properties: {},
|
|
1110
|
+
geometry: {
|
|
1111
|
+
type: "Polygon",
|
|
1112
|
+
coordinates: [coords],
|
|
1113
|
+
},
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function getDistanceFromLatLonInM(lat1: number, lon1: number, lat2: number, lon2: number): number {
|
|
1118
|
+
const R = 6371000;
|
|
1119
|
+
const dLat = deg2rad(lat2 - lat1);
|
|
1120
|
+
const dLon = deg2rad(lon2 - lon1);
|
|
1121
|
+
const a =
|
|
1122
|
+
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
1123
|
+
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
|
|
1124
|
+
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
1125
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
1126
|
+
return R * c;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
function deg2rad(deg: number): number {
|
|
1130
|
+
return deg * (Math.PI / 180);
|
|
1131
|
+
}
|