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,305 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
google: typeof google;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface PlaceResult {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
coordinates: [number, number];
|
|
11
|
+
address?: string;
|
|
12
|
+
types?: string[];
|
|
13
|
+
rating?: number;
|
|
14
|
+
userRatingsTotal?: number;
|
|
15
|
+
placeId?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FetchNearbyPlacesOptions {
|
|
19
|
+
location: { lat: number; lng: number };
|
|
20
|
+
searchType: string;
|
|
21
|
+
radius?: number;
|
|
22
|
+
maxResults?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const GOOGLE_PLACES_TYPE_MAP: Record<string, string> = {
|
|
26
|
+
rest_stop: 'rest_stop',
|
|
27
|
+
public_bath: 'spa',
|
|
28
|
+
rv_park: 'rv_park',
|
|
29
|
+
restaurant: 'restaurant',
|
|
30
|
+
cafe: 'cafe',
|
|
31
|
+
fast_food: 'meal_takeaway',
|
|
32
|
+
bar: 'bar',
|
|
33
|
+
hospital: 'hospital',
|
|
34
|
+
pharmacy: 'pharmacy',
|
|
35
|
+
doctor: 'doctor',
|
|
36
|
+
dentist: 'dentist',
|
|
37
|
+
school: 'school',
|
|
38
|
+
university: 'university',
|
|
39
|
+
library: 'library',
|
|
40
|
+
gas_station: 'gas_station',
|
|
41
|
+
car_wash: 'car_wash',
|
|
42
|
+
car_repair: 'car_repair',
|
|
43
|
+
parking: 'parking',
|
|
44
|
+
shopping_mall: 'shopping_mall',
|
|
45
|
+
supermarket: 'supermarket',
|
|
46
|
+
convenience_store: 'convenience_store',
|
|
47
|
+
clothing_store: 'clothing_store',
|
|
48
|
+
gym: 'gym',
|
|
49
|
+
spa: 'spa',
|
|
50
|
+
bank: 'bank',
|
|
51
|
+
atm: 'atm',
|
|
52
|
+
hotel: 'lodging',
|
|
53
|
+
motel: 'lodging',
|
|
54
|
+
campground: 'campground',
|
|
55
|
+
airport: 'airport',
|
|
56
|
+
train_station: 'train_station',
|
|
57
|
+
bus_station: 'bus_station',
|
|
58
|
+
transit_station: 'transit_station',
|
|
59
|
+
taxi_stand: 'taxi_stand',
|
|
60
|
+
park: 'park',
|
|
61
|
+
amusement_park: 'amusement_park',
|
|
62
|
+
zoo: 'zoo',
|
|
63
|
+
aquarium: 'aquarium',
|
|
64
|
+
museum: 'museum',
|
|
65
|
+
art_gallery: 'art_gallery',
|
|
66
|
+
movie_theater: 'movie_theater',
|
|
67
|
+
night_club: 'night_club',
|
|
68
|
+
bowling_alley: 'bowling_alley',
|
|
69
|
+
casino: 'casino',
|
|
70
|
+
stadium: 'stadium',
|
|
71
|
+
post_office: 'post_office',
|
|
72
|
+
laundry: 'laundry',
|
|
73
|
+
beauty_salon: 'beauty_salon',
|
|
74
|
+
hair_care: 'hair_care',
|
|
75
|
+
church: 'church',
|
|
76
|
+
mosque: 'mosque',
|
|
77
|
+
temple: 'hindu_temple',
|
|
78
|
+
synagogue: 'synagogue',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export function isGoogleMapsLoaded(): boolean {
|
|
82
|
+
return typeof window !== 'undefined' &&
|
|
83
|
+
typeof window.google !== 'undefined' &&
|
|
84
|
+
typeof window.google.maps !== 'undefined' &&
|
|
85
|
+
typeof window.google.maps.places !== 'undefined';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function loadGoogleMapsScript(apiKey: string): Promise<void> {
|
|
89
|
+
if (isGoogleMapsLoaded()) {
|
|
90
|
+
return Promise.resolve();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return new Promise((resolve, reject) => {
|
|
94
|
+
const existingScript = document.getElementById('google-maps-script');
|
|
95
|
+
if (existingScript) {
|
|
96
|
+
existingScript.addEventListener('load', () => resolve());
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const script = document.createElement('script');
|
|
101
|
+
script.id = 'google-maps-script';
|
|
102
|
+
script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`;
|
|
103
|
+
script.async = true;
|
|
104
|
+
script.defer = true;
|
|
105
|
+
script.onload = () => resolve();
|
|
106
|
+
script.onerror = () => reject(new Error('Failed to load Google Maps script'));
|
|
107
|
+
document.head.appendChild(script);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export async function fetchNearbyPlaces(
|
|
112
|
+
options: FetchNearbyPlacesOptions
|
|
113
|
+
): Promise<PlaceResult[]> {
|
|
114
|
+
const { location, searchType, radius = 5000, maxResults = 20 } = options;
|
|
115
|
+
|
|
116
|
+
if (!isGoogleMapsLoaded()) {
|
|
117
|
+
console.warn('Google Maps Places API not loaded. Returning mock data.');
|
|
118
|
+
return generateMockPlaces(location, searchType, maxResults);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return new Promise((resolve, reject) => {
|
|
122
|
+
try {
|
|
123
|
+
const mapDiv = document.createElement('div');
|
|
124
|
+
const map = new window.google.maps.Map(mapDiv, {
|
|
125
|
+
center: location,
|
|
126
|
+
zoom: 15,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const service = new window.google.maps.places.PlacesService(map);
|
|
130
|
+
const placeType = GOOGLE_PLACES_TYPE_MAP[searchType] || searchType;
|
|
131
|
+
|
|
132
|
+
const request: google.maps.places.PlaceSearchRequest = {
|
|
133
|
+
location: new window.google.maps.LatLng(location.lat, location.lng),
|
|
134
|
+
radius,
|
|
135
|
+
type: placeType,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
service.nearbySearch(request, (results, status) => {
|
|
139
|
+
if (status === window.google.maps.places.PlacesServiceStatus.OK && results) {
|
|
140
|
+
const places: PlaceResult[] = results.slice(0, maxResults).map((place, index) => ({
|
|
141
|
+
id: place.place_id || `place-${index}`,
|
|
142
|
+
name: place.name || 'Unknown Place',
|
|
143
|
+
coordinates: [
|
|
144
|
+
place.geometry?.location?.lng() || location.lng,
|
|
145
|
+
place.geometry?.location?.lat() || location.lat,
|
|
146
|
+
] as [number, number],
|
|
147
|
+
address: place.vicinity || '',
|
|
148
|
+
types: place.types || [],
|
|
149
|
+
rating: place.rating,
|
|
150
|
+
userRatingsTotal: place.user_ratings_total,
|
|
151
|
+
placeId: place.place_id,
|
|
152
|
+
}));
|
|
153
|
+
resolve(places);
|
|
154
|
+
} else if (status === window.google.maps.places.PlacesServiceStatus.ZERO_RESULTS) {
|
|
155
|
+
resolve([]);
|
|
156
|
+
} else {
|
|
157
|
+
console.warn('Google Places API error:', status);
|
|
158
|
+
resolve(generateMockPlaces(location, searchType, maxResults));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.error('Error fetching nearby places:', error);
|
|
163
|
+
resolve(generateMockPlaces(location, searchType, maxResults));
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function generateMockPlaces(
|
|
169
|
+
location: { lat: number; lng: number },
|
|
170
|
+
searchType: string,
|
|
171
|
+
count: number
|
|
172
|
+
): PlaceResult[] {
|
|
173
|
+
const places: PlaceResult[] = [];
|
|
174
|
+
const typeLabel = searchType.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
|
175
|
+
|
|
176
|
+
for (let i = 0; i < Math.min(count, 10); i++) {
|
|
177
|
+
const offsetLng = (Math.random() - 0.5) * 0.02;
|
|
178
|
+
const offsetLat = (Math.random() - 0.5) * 0.02;
|
|
179
|
+
|
|
180
|
+
places.push({
|
|
181
|
+
id: `mock-${searchType}-${i}`,
|
|
182
|
+
name: `${typeLabel} ${i + 1}`,
|
|
183
|
+
coordinates: [location.lng + offsetLng, location.lat + offsetLat],
|
|
184
|
+
address: `${Math.floor(Math.random() * 1000)} Example Street`,
|
|
185
|
+
types: [searchType],
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return places;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export async function fetchMultiplePOITypes(
|
|
193
|
+
location: { lat: number; lng: number },
|
|
194
|
+
poiTypes: string[],
|
|
195
|
+
radius?: number
|
|
196
|
+
): Promise<Map<string, PlaceResult[]>> {
|
|
197
|
+
const results = new Map<string, PlaceResult[]>();
|
|
198
|
+
|
|
199
|
+
const fetchPromises = poiTypes.map(async (type) => {
|
|
200
|
+
const places = await fetchNearbyPlaces({
|
|
201
|
+
location,
|
|
202
|
+
searchType: type,
|
|
203
|
+
radius,
|
|
204
|
+
maxResults: 10,
|
|
205
|
+
});
|
|
206
|
+
return { type, places };
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const allResults = await Promise.all(fetchPromises);
|
|
210
|
+
|
|
211
|
+
allResults.forEach(({ type, places }) => {
|
|
212
|
+
results.set(type, places);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
return results;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface POICategoryResult {
|
|
219
|
+
label: string;
|
|
220
|
+
value: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function fetchPOICategories(options: {
|
|
224
|
+
location: { lat: number; lng: number };
|
|
225
|
+
radius?: number;
|
|
226
|
+
}): Promise<POICategoryResult[]> {
|
|
227
|
+
const { location, radius = 5000 } = options;
|
|
228
|
+
|
|
229
|
+
if (!isGoogleMapsLoaded()) {
|
|
230
|
+
console.warn('Google Maps Places API not loaded. Returning default categories.');
|
|
231
|
+
return getDefaultPOICategories();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return new Promise((resolve) => {
|
|
235
|
+
try {
|
|
236
|
+
const mapDiv = document.createElement('div');
|
|
237
|
+
const map = new window.google.maps.Map(mapDiv, {
|
|
238
|
+
center: location,
|
|
239
|
+
zoom: 15,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const service = new window.google.maps.places.PlacesService(map);
|
|
243
|
+
|
|
244
|
+
const request: google.maps.places.PlaceSearchRequest = {
|
|
245
|
+
location: new window.google.maps.LatLng(location.lat, location.lng),
|
|
246
|
+
radius,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
service.nearbySearch(request, (results, status) => {
|
|
250
|
+
if (status === window.google.maps.places.PlacesServiceStatus.OK && results) {
|
|
251
|
+
const typeSet = new Set<string>();
|
|
252
|
+
|
|
253
|
+
results.forEach((place) => {
|
|
254
|
+
if (place.types) {
|
|
255
|
+
place.types.forEach((type) => {
|
|
256
|
+
if (!type.includes('establishment') && !type.includes('point_of_interest')) {
|
|
257
|
+
typeSet.add(type);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const categories: POICategoryResult[] = Array.from(typeSet).map((type) => ({
|
|
264
|
+
label: formatTypeLabel(type),
|
|
265
|
+
value: type,
|
|
266
|
+
}));
|
|
267
|
+
|
|
268
|
+
resolve(categories.length > 0 ? categories : getDefaultPOICategories());
|
|
269
|
+
} else {
|
|
270
|
+
resolve(getDefaultPOICategories());
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error('Error fetching POI categories:', error);
|
|
275
|
+
resolve(getDefaultPOICategories());
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function formatTypeLabel(type: string): string {
|
|
281
|
+
return type
|
|
282
|
+
.split('_')
|
|
283
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
284
|
+
.join(' ');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function getDefaultPOICategories(): POICategoryResult[] {
|
|
288
|
+
return [
|
|
289
|
+
{ label: 'Restaurant', value: 'restaurant' },
|
|
290
|
+
{ label: 'Cafe', value: 'cafe' },
|
|
291
|
+
{ label: 'Hospital', value: 'hospital' },
|
|
292
|
+
{ label: 'Shopping Mall', value: 'shopping_mall' },
|
|
293
|
+
{ label: 'School', value: 'school' },
|
|
294
|
+
{ label: 'University', value: 'university' },
|
|
295
|
+
{ label: 'Airport', value: 'airport' },
|
|
296
|
+
{ label: 'Train Station', value: 'train_station' },
|
|
297
|
+
{ label: 'Transit Station', value: 'transit_station' },
|
|
298
|
+
{ label: 'Hotel', value: 'lodging' },
|
|
299
|
+
{ label: 'Gas Station', value: 'gas_station' },
|
|
300
|
+
{ label: 'Gym', value: 'gym' },
|
|
301
|
+
{ label: 'Bank', value: 'bank' },
|
|
302
|
+
{ label: 'Supermarket', value: 'supermarket' },
|
|
303
|
+
{ label: 'Park', value: 'park' },
|
|
304
|
+
];
|
|
305
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
vi.mock('../index', () => ({
|
|
4
|
+
getCurrentLanguage: vi.fn(() => 'en-US'),
|
|
5
|
+
}));
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
formatDate,
|
|
9
|
+
formatDateTime,
|
|
10
|
+
formatNumber,
|
|
11
|
+
formatCurrency,
|
|
12
|
+
formatPercent,
|
|
13
|
+
formatRelativeTime,
|
|
14
|
+
formatCompactNumber,
|
|
15
|
+
formatList,
|
|
16
|
+
} from '../formatting';
|
|
17
|
+
|
|
18
|
+
describe('i18n formatting', () => {
|
|
19
|
+
describe('formatDate', () => {
|
|
20
|
+
it('should format a Date object', () => {
|
|
21
|
+
const date = new Date(2024, 0, 15);
|
|
22
|
+
const result = formatDate(date);
|
|
23
|
+
expect(result).toContain('2024');
|
|
24
|
+
expect(result).toContain('15');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should format a date string', () => {
|
|
28
|
+
const result = formatDate('2024-01-15');
|
|
29
|
+
expect(result).toContain('2024');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should format a timestamp', () => {
|
|
33
|
+
const timestamp = new Date(2024, 0, 15).getTime();
|
|
34
|
+
const result = formatDate(timestamp);
|
|
35
|
+
expect(result).toContain('2024');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should accept custom options', () => {
|
|
39
|
+
const date = new Date(2024, 0, 15);
|
|
40
|
+
const result = formatDate(date, { weekday: 'long' });
|
|
41
|
+
expect(result).toContain('Monday');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('formatDateTime', () => {
|
|
46
|
+
it('should format date with time', () => {
|
|
47
|
+
const date = new Date(2024, 0, 15, 14, 30);
|
|
48
|
+
const result = formatDateTime(date);
|
|
49
|
+
expect(result).toContain('2024');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should handle date strings', () => {
|
|
53
|
+
const result = formatDateTime('2024-01-15T14:30:00');
|
|
54
|
+
expect(result).toContain('2024');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should handle timestamps', () => {
|
|
58
|
+
const timestamp = new Date(2024, 0, 15, 14, 30).getTime();
|
|
59
|
+
const result = formatDateTime(timestamp);
|
|
60
|
+
expect(result).toContain('2024');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('formatNumber', () => {
|
|
65
|
+
it('should format a number with locale', () => {
|
|
66
|
+
const result = formatNumber(1234567.89);
|
|
67
|
+
expect(result).toContain('1');
|
|
68
|
+
expect(result.length).toBeGreaterThan(5);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should accept custom options', () => {
|
|
72
|
+
const result = formatNumber(1234.5678, { maximumFractionDigits: 2 });
|
|
73
|
+
expect(result).toContain('1,234.57');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('formatCurrency', () => {
|
|
78
|
+
it('should format currency in USD by default', () => {
|
|
79
|
+
const result = formatCurrency(1234.56);
|
|
80
|
+
expect(result).toContain('$');
|
|
81
|
+
expect(result).toContain('1,234.56');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should format currency in specified currency', () => {
|
|
85
|
+
const result = formatCurrency(1234.56, 'EUR');
|
|
86
|
+
expect(result).toContain('1,234.56');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('formatPercent', () => {
|
|
91
|
+
it('should format a percentage', () => {
|
|
92
|
+
const result = formatPercent(75);
|
|
93
|
+
expect(result).toBe('75%');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should handle decimal percentages', () => {
|
|
97
|
+
const result = formatPercent(33.33);
|
|
98
|
+
expect(result).toContain('33');
|
|
99
|
+
expect(result).toContain('%');
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('formatRelativeTime', () => {
|
|
104
|
+
it('should return a string for past date', () => {
|
|
105
|
+
const baseDate = new Date(2024, 5, 15, 12, 0, 0);
|
|
106
|
+
const pastDate = new Date(2024, 5, 10, 12, 0, 0);
|
|
107
|
+
const result = formatRelativeTime(pastDate, baseDate);
|
|
108
|
+
expect(typeof result).toBe('string');
|
|
109
|
+
expect(result.length).toBeGreaterThan(0);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should return a string for future date', () => {
|
|
113
|
+
const baseDate = new Date(2024, 5, 15, 12, 0, 0);
|
|
114
|
+
const futureDate = new Date(2024, 5, 20, 12, 0, 0);
|
|
115
|
+
const result = formatRelativeTime(futureDate, baseDate);
|
|
116
|
+
expect(typeof result).toBe('string');
|
|
117
|
+
expect(result.length).toBeGreaterThan(0);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should handle Date objects', () => {
|
|
121
|
+
const result = formatRelativeTime(new Date());
|
|
122
|
+
expect(typeof result).toBe('string');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should handle date strings', () => {
|
|
126
|
+
const result = formatRelativeTime('2024-01-15');
|
|
127
|
+
expect(typeof result).toBe('string');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should handle timestamps', () => {
|
|
131
|
+
const result = formatRelativeTime(Date.now());
|
|
132
|
+
expect(typeof result).toBe('string');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should format seconds', () => {
|
|
136
|
+
const baseDate = new Date(2024, 5, 15, 12, 0, 30);
|
|
137
|
+
const pastDate = new Date(2024, 5, 15, 12, 0, 0);
|
|
138
|
+
const result = formatRelativeTime(pastDate, baseDate);
|
|
139
|
+
expect(result).toBe('30 seconds ago');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should format minutes', () => {
|
|
143
|
+
const baseDate = new Date(2024, 5, 15, 12, 30, 0);
|
|
144
|
+
const pastDate = new Date(2024, 5, 15, 12, 0, 0);
|
|
145
|
+
const result = formatRelativeTime(pastDate, baseDate);
|
|
146
|
+
expect(result).toBe('30 minutes ago');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should format hours', () => {
|
|
150
|
+
const baseDate = new Date(2024, 5, 15, 15, 0, 0);
|
|
151
|
+
const pastDate = new Date(2024, 5, 15, 12, 0, 0);
|
|
152
|
+
const result = formatRelativeTime(pastDate, baseDate);
|
|
153
|
+
expect(result).toBe('3 hours ago');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('should format months', () => {
|
|
157
|
+
const baseDate = new Date(2024, 5, 15);
|
|
158
|
+
const pastDate = new Date(2024, 3, 15);
|
|
159
|
+
const result = formatRelativeTime(pastDate, baseDate);
|
|
160
|
+
expect(result).toBe('2 months ago');
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe('formatCompactNumber', () => {
|
|
165
|
+
it('should format large numbers compactly', () => {
|
|
166
|
+
const result = formatCompactNumber(1500000);
|
|
167
|
+
expect(result).toBe('1.5M');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should format thousands', () => {
|
|
171
|
+
const result = formatCompactNumber(2500);
|
|
172
|
+
expect(result).toBe('2.5K');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should format small numbers normally', () => {
|
|
176
|
+
const result = formatCompactNumber(123);
|
|
177
|
+
expect(result).toBe('123');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe('formatList', () => {
|
|
182
|
+
it('should format a list with conjunction', () => {
|
|
183
|
+
const result = formatList(['apple', 'banana', 'cherry']);
|
|
184
|
+
expect(result).toBe('apple, banana, and cherry');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should format a list with disjunction', () => {
|
|
188
|
+
const result = formatList(['red', 'green', 'blue'], 'disjunction');
|
|
189
|
+
expect(result).toBe('red, green, or blue');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('should handle single item list', () => {
|
|
193
|
+
const result = formatList(['apple']);
|
|
194
|
+
expect(result).toBe('apple');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should handle two item list', () => {
|
|
198
|
+
const result = formatList(['apple', 'banana']);
|
|
199
|
+
expect(result).toBe('apple and banana');
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { getCurrentLanguage } from './index';
|
|
2
|
+
|
|
3
|
+
export const formatDate = (
|
|
4
|
+
date: Date | string | number,
|
|
5
|
+
options?: Intl.DateTimeFormatOptions
|
|
6
|
+
): string => {
|
|
7
|
+
const locale = getCurrentLanguage();
|
|
8
|
+
const dateObj = typeof date === 'string' || typeof date === 'number' ? new Date(date) : date;
|
|
9
|
+
|
|
10
|
+
const defaultOptions: Intl.DateTimeFormatOptions = {
|
|
11
|
+
year: 'numeric',
|
|
12
|
+
month: 'short',
|
|
13
|
+
day: 'numeric',
|
|
14
|
+
...options,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return new Intl.DateTimeFormat(locale, defaultOptions).format(dateObj);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const formatDateTime = (
|
|
21
|
+
date: Date | string | number,
|
|
22
|
+
options?: Intl.DateTimeFormatOptions
|
|
23
|
+
): string => {
|
|
24
|
+
const locale = getCurrentLanguage();
|
|
25
|
+
const dateObj = typeof date === 'string' || typeof date === 'number' ? new Date(date) : date;
|
|
26
|
+
|
|
27
|
+
const defaultOptions: Intl.DateTimeFormatOptions = {
|
|
28
|
+
year: 'numeric',
|
|
29
|
+
month: 'short',
|
|
30
|
+
day: 'numeric',
|
|
31
|
+
hour: '2-digit',
|
|
32
|
+
minute: '2-digit',
|
|
33
|
+
...options,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return new Intl.DateTimeFormat(locale, defaultOptions).format(dateObj);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const formatNumber = (
|
|
40
|
+
value: number,
|
|
41
|
+
options?: Intl.NumberFormatOptions
|
|
42
|
+
): string => {
|
|
43
|
+
const locale = getCurrentLanguage();
|
|
44
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const formatCurrency = (
|
|
48
|
+
value: number,
|
|
49
|
+
currency: string = 'USD',
|
|
50
|
+
options?: Intl.NumberFormatOptions
|
|
51
|
+
): string => {
|
|
52
|
+
const locale = getCurrentLanguage();
|
|
53
|
+
|
|
54
|
+
const defaultOptions: Intl.NumberFormatOptions = {
|
|
55
|
+
style: 'currency',
|
|
56
|
+
currency,
|
|
57
|
+
minimumFractionDigits: 2,
|
|
58
|
+
maximumFractionDigits: 2,
|
|
59
|
+
...options,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return new Intl.NumberFormat(locale, defaultOptions).format(value);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const formatPercent = (
|
|
66
|
+
value: number,
|
|
67
|
+
options?: Intl.NumberFormatOptions
|
|
68
|
+
): string => {
|
|
69
|
+
const locale = getCurrentLanguage();
|
|
70
|
+
|
|
71
|
+
const defaultOptions: Intl.NumberFormatOptions = {
|
|
72
|
+
style: 'percent',
|
|
73
|
+
minimumFractionDigits: 0,
|
|
74
|
+
maximumFractionDigits: 2,
|
|
75
|
+
...options,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return new Intl.NumberFormat(locale, defaultOptions).format(value / 100);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const formatRelativeTime = (
|
|
82
|
+
date: Date | string | number,
|
|
83
|
+
baseDate: Date = new Date()
|
|
84
|
+
): string => {
|
|
85
|
+
const locale = getCurrentLanguage();
|
|
86
|
+
const dateObj = typeof date === 'string' || typeof date === 'number' ? new Date(date) : date;
|
|
87
|
+
|
|
88
|
+
const diffInSeconds = Math.trunc((dateObj.getTime() - baseDate.getTime()) / 1000);
|
|
89
|
+
const diffInMinutes = Math.trunc(diffInSeconds / 60);
|
|
90
|
+
const diffInHours = Math.trunc(diffInMinutes / 60);
|
|
91
|
+
const diffInDays = Math.trunc(diffInHours / 24);
|
|
92
|
+
const diffInMonths = Math.trunc(diffInDays / 30);
|
|
93
|
+
const diffInYears = Math.trunc(diffInDays / 365);
|
|
94
|
+
|
|
95
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
|
|
96
|
+
|
|
97
|
+
if (Math.abs(diffInYears) >= 1) {
|
|
98
|
+
return rtf.format(diffInYears, 'year');
|
|
99
|
+
}
|
|
100
|
+
if (Math.abs(diffInMonths) >= 1) {
|
|
101
|
+
return rtf.format(diffInMonths, 'month');
|
|
102
|
+
}
|
|
103
|
+
if (Math.abs(diffInDays) >= 1) {
|
|
104
|
+
return rtf.format(diffInDays, 'day');
|
|
105
|
+
}
|
|
106
|
+
if (Math.abs(diffInHours) >= 1) {
|
|
107
|
+
return rtf.format(diffInHours, 'hour');
|
|
108
|
+
}
|
|
109
|
+
if (Math.abs(diffInMinutes) >= 1) {
|
|
110
|
+
return rtf.format(diffInMinutes, 'minute');
|
|
111
|
+
}
|
|
112
|
+
return rtf.format(diffInSeconds, 'second');
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const formatCompactNumber = (value: number): string => {
|
|
116
|
+
const locale = getCurrentLanguage();
|
|
117
|
+
|
|
118
|
+
return new Intl.NumberFormat(locale, {
|
|
119
|
+
notation: 'compact',
|
|
120
|
+
maximumFractionDigits: 1,
|
|
121
|
+
}).format(value);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const formatList = (
|
|
125
|
+
items: string[],
|
|
126
|
+
type: 'conjunction' | 'disjunction' = 'conjunction'
|
|
127
|
+
): string => {
|
|
128
|
+
const locale = getCurrentLanguage();
|
|
129
|
+
return new Intl.ListFormat(locale, { style: 'long', type }).format(items);
|
|
130
|
+
};
|