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,1533 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
2
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useTranslation } from "@/lib/i18n";
|
|
4
|
+
import { Button } from "@moving-walls/design-system";
|
|
5
|
+
import { Input } from "@moving-walls/design-system";
|
|
6
|
+
import { Badge } from "@moving-walls/design-system";
|
|
7
|
+
import { Checkbox } from "@moving-walls/design-system";
|
|
8
|
+
import {
|
|
9
|
+
SelectRoot,
|
|
10
|
+
SelectContent,
|
|
11
|
+
SelectItem,
|
|
12
|
+
SelectTrigger,
|
|
13
|
+
SelectValue,
|
|
14
|
+
} from "@moving-walls/design-system";
|
|
15
|
+
import { PlannerInventoryCard } from "../planner-inventory-card";
|
|
16
|
+
import { AdvancedFiltersPanel, type AdvancedFilterValues } from "../../inventory/advanced-filters-panel";
|
|
17
|
+
import { InventoryDetailsSheet, type InventoryDetailsItem } from "../../inventory/inventory-details-sheet";
|
|
18
|
+
import { InventorySettingsMenu } from "../../inventory/inventory-settings-menu";
|
|
19
|
+
import { InventoryAvailabilityView, type AvailabilityInventoryItem } from "../../inventory/inventory-availability-view";
|
|
20
|
+
import { CSVUploadModal } from "../../inventory/csv-upload-modal";
|
|
21
|
+
import { InventoryMapView } from "../../inventory/inventory-map-view";
|
|
22
|
+
import { CampaignForecastPanel } from "../campaign-forecast-panel";
|
|
23
|
+
import {
|
|
24
|
+
ChevronDown,
|
|
25
|
+
ChevronUp,
|
|
26
|
+
Grid3X3,
|
|
27
|
+
Monitor,
|
|
28
|
+
Package,
|
|
29
|
+
Search,
|
|
30
|
+
Network,
|
|
31
|
+
Loader2,
|
|
32
|
+
SlidersHorizontal,
|
|
33
|
+
List,
|
|
34
|
+
Sparkles,
|
|
35
|
+
AlertCircle,
|
|
36
|
+
RotateCcw,
|
|
37
|
+
} from "lucide-react";
|
|
38
|
+
import { cn } from "@moving-walls/design-system";
|
|
39
|
+
import {
|
|
40
|
+
searchInventories,
|
|
41
|
+
type InventoryItem as APIInventoryItem,
|
|
42
|
+
type InventoryPlanning,
|
|
43
|
+
} from "@/lib/inventory-api";
|
|
44
|
+
import {
|
|
45
|
+
getRecommendationResults,
|
|
46
|
+
type RecommendedInventory,
|
|
47
|
+
} from "@/lib/recommendation-api";
|
|
48
|
+
|
|
49
|
+
interface InventoryStepProps {
|
|
50
|
+
data?: any;
|
|
51
|
+
lineItemData?: any;
|
|
52
|
+
lineItemId?: string;
|
|
53
|
+
targeting?: any;
|
|
54
|
+
recommendationRunId?: string;
|
|
55
|
+
country?: string;
|
|
56
|
+
onComplete: (data: { inventories: string[]; inventoryObjects: any[] }) => void;
|
|
57
|
+
onBack?: () => void;
|
|
58
|
+
isLoading?: boolean;
|
|
59
|
+
isPlannerRestricted?: boolean;
|
|
60
|
+
formId?: string;
|
|
61
|
+
dealMode?: "DIRECT" | "PROGRAMMATIC";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface InventoryItem {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
address: string;
|
|
68
|
+
additionalDetails?: string;
|
|
69
|
+
tags: Array<{
|
|
70
|
+
label: string;
|
|
71
|
+
variant:
|
|
72
|
+
| "primary"
|
|
73
|
+
| "secondary"
|
|
74
|
+
| "success"
|
|
75
|
+
| "warning"
|
|
76
|
+
| "error"
|
|
77
|
+
| "outline";
|
|
78
|
+
}>;
|
|
79
|
+
operatingHours: string;
|
|
80
|
+
estimatedCostPerDay: number;
|
|
81
|
+
currency: string;
|
|
82
|
+
type: "screen" | "network" | "package";
|
|
83
|
+
planning?: InventoryPlanning;
|
|
84
|
+
publisherName?: string;
|
|
85
|
+
screens?: number;
|
|
86
|
+
thumbnail?: string;
|
|
87
|
+
size?: string;
|
|
88
|
+
format?: string;
|
|
89
|
+
mediaType?: string;
|
|
90
|
+
operationMode?: string;
|
|
91
|
+
execution?: string;
|
|
92
|
+
finalScore?: number;
|
|
93
|
+
why?: string;
|
|
94
|
+
availability?: {
|
|
95
|
+
availableDays?: number;
|
|
96
|
+
totalDays?: number;
|
|
97
|
+
availabilityPercentage?: number;
|
|
98
|
+
summary?: string;
|
|
99
|
+
};
|
|
100
|
+
componentScores?: {
|
|
101
|
+
geoFit?: number;
|
|
102
|
+
availability?: number;
|
|
103
|
+
budgetFit?: number;
|
|
104
|
+
audienceFit?: number;
|
|
105
|
+
brandFit?: number;
|
|
106
|
+
qualityFit?: number;
|
|
107
|
+
timeFit?: number;
|
|
108
|
+
};
|
|
109
|
+
location?: {
|
|
110
|
+
cityName?: string;
|
|
111
|
+
stateName?: string;
|
|
112
|
+
countryName?: string;
|
|
113
|
+
};
|
|
114
|
+
referenceId?: string;
|
|
115
|
+
latitude?: number;
|
|
116
|
+
longitude?: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function mapAPIInventoryToLocal(apiItem: APIInventoryItem): InventoryItem {
|
|
120
|
+
const tags: InventoryItem["tags"] = [];
|
|
121
|
+
|
|
122
|
+
if (apiItem.type) {
|
|
123
|
+
tags.push({
|
|
124
|
+
label: apiItem.type === "digital" ? "Digital" : apiItem.type,
|
|
125
|
+
variant: "primary",
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
tags.push({ label: "DOOH", variant: "secondary" });
|
|
129
|
+
if (apiItem.venueType) {
|
|
130
|
+
const venueVariant = apiItem.venueType.toLowerCase().includes("retail")
|
|
131
|
+
? "warning"
|
|
132
|
+
: apiItem.venueType.toLowerCase().includes("transit")
|
|
133
|
+
? "success"
|
|
134
|
+
: apiItem.venueType.toLowerCase().includes("outdoor")
|
|
135
|
+
? "outline"
|
|
136
|
+
: "secondary";
|
|
137
|
+
tags.push({ label: apiItem.venueType, variant: venueVariant });
|
|
138
|
+
}
|
|
139
|
+
if (apiItem.size) {
|
|
140
|
+
tags.push({ label: apiItem.size, variant: "warning" });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
id: apiItem.id,
|
|
145
|
+
name: apiItem.name,
|
|
146
|
+
address: apiItem.address || "Location not specified",
|
|
147
|
+
additionalDetails: apiItem.publisherName
|
|
148
|
+
? `Publisher: ${apiItem.publisherName}`
|
|
149
|
+
: undefined,
|
|
150
|
+
tags,
|
|
151
|
+
operatingHours: apiItem.operatingHours || "24/7",
|
|
152
|
+
estimatedCostPerDay: apiItem.planning?.pricing?.estimatedCost || 2500,
|
|
153
|
+
currency: "MYR",
|
|
154
|
+
type: "screen",
|
|
155
|
+
planning: apiItem.planning,
|
|
156
|
+
publisherName: apiItem.publisherName,
|
|
157
|
+
screens: 1,
|
|
158
|
+
thumbnail: apiItem.thumbnail,
|
|
159
|
+
size: apiItem.size || "N/A",
|
|
160
|
+
format: "OOH",
|
|
161
|
+
mediaType:
|
|
162
|
+
apiItem.type === "digital" ? "Digital" : apiItem.type || "Digital",
|
|
163
|
+
operationMode: "N/A",
|
|
164
|
+
execution: "placeholder",
|
|
165
|
+
latitude: apiItem.latitude,
|
|
166
|
+
longitude: apiItem.longitude,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function mapRecommendationToLocal(rec: RecommendedInventory): InventoryItem {
|
|
171
|
+
const tags: InventoryItem["tags"] = [];
|
|
172
|
+
|
|
173
|
+
if (rec.inventoryDetails?.type) {
|
|
174
|
+
tags.push({
|
|
175
|
+
label:
|
|
176
|
+
rec.inventoryDetails.type === "digital"
|
|
177
|
+
? "Digital"
|
|
178
|
+
: rec.inventoryDetails.type,
|
|
179
|
+
variant: "primary",
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
tags.push({ label: "DOOH", variant: "secondary" });
|
|
183
|
+
|
|
184
|
+
if (
|
|
185
|
+
rec.inventoryDetails?.venueTypes &&
|
|
186
|
+
rec.inventoryDetails.venueTypes.length > 0
|
|
187
|
+
) {
|
|
188
|
+
const venueType = rec.inventoryDetails.venueTypes[0];
|
|
189
|
+
const venueVariant = venueType.toLowerCase().includes("retail")
|
|
190
|
+
? "warning"
|
|
191
|
+
: venueType.toLowerCase().includes("transit")
|
|
192
|
+
? "success"
|
|
193
|
+
: venueType.toLowerCase().includes("outdoor")
|
|
194
|
+
? "outline"
|
|
195
|
+
: "secondary";
|
|
196
|
+
tags.push({ label: venueType, variant: venueVariant });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (rec.inventoryDetails?.sizes && rec.inventoryDetails.sizes.length > 0) {
|
|
200
|
+
tags.push({ label: rec.inventoryDetails.sizes[0], variant: "warning" });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (rec.finalScore !== undefined) {
|
|
204
|
+
const scorePercent = rec.finalScore * 100;
|
|
205
|
+
const scoreLabel = `Score: ${scorePercent.toFixed(0)}`;
|
|
206
|
+
tags.push({ label: scoreLabel, variant: "success" });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const locationParts: string[] = [];
|
|
210
|
+
if (rec.inventoryDetails?.location?.cityName) {
|
|
211
|
+
locationParts.push(rec.inventoryDetails.location.cityName);
|
|
212
|
+
}
|
|
213
|
+
if (rec.inventoryDetails?.location?.stateName) {
|
|
214
|
+
locationParts.push(rec.inventoryDetails.location.stateName);
|
|
215
|
+
}
|
|
216
|
+
const locationStr = locationParts.length > 0
|
|
217
|
+
? locationParts.join(', ')
|
|
218
|
+
: rec.inventoryDetails?.address || "Location not specified";
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
id: rec.inventoryId,
|
|
222
|
+
name: rec.name,
|
|
223
|
+
address: locationStr,
|
|
224
|
+
additionalDetails: rec.why || (rec.inventoryDetails?.mediaOwnerName
|
|
225
|
+
? `Publisher: ${rec.inventoryDetails.mediaOwnerName}`
|
|
226
|
+
: undefined),
|
|
227
|
+
tags,
|
|
228
|
+
operatingHours: "24/7",
|
|
229
|
+
estimatedCostPerDay: rec.cost?.estimatedCost || 2500,
|
|
230
|
+
currency: rec.cost?.currency || "MYR",
|
|
231
|
+
type: "screen",
|
|
232
|
+
planning: rec.forecast
|
|
233
|
+
? {
|
|
234
|
+
capacity: {
|
|
235
|
+
campaignDays: rec.availability?.totalSlots || 30,
|
|
236
|
+
available: {
|
|
237
|
+
slots: 0,
|
|
238
|
+
playTimeSec: 0,
|
|
239
|
+
maxImpressions: rec.forecast.estimatedImpressions || 0,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
allocation: {
|
|
243
|
+
slots: 0,
|
|
244
|
+
playTimeSec: 0,
|
|
245
|
+
sov: rec.forecast.estimatedSov || 0,
|
|
246
|
+
sot: 0,
|
|
247
|
+
},
|
|
248
|
+
estimates: {
|
|
249
|
+
impressions: rec.forecast.estimatedImpressions || 0,
|
|
250
|
+
reach: rec.forecast.estimatedReach || 0,
|
|
251
|
+
frequency: rec.forecast.estimatedFrequency || 0,
|
|
252
|
+
},
|
|
253
|
+
pricing: {
|
|
254
|
+
cpm: rec.cost?.costPerImpression
|
|
255
|
+
? rec.cost.costPerImpression * 1000
|
|
256
|
+
: 0,
|
|
257
|
+
estimatedCost: rec.cost?.estimatedCost || 0,
|
|
258
|
+
},
|
|
259
|
+
}
|
|
260
|
+
: undefined,
|
|
261
|
+
publisherName: rec.inventoryDetails?.mediaOwnerName,
|
|
262
|
+
screens: 1,
|
|
263
|
+
thumbnail: undefined,
|
|
264
|
+
size: rec.inventoryDetails?.sizes?.[0] || "N/A",
|
|
265
|
+
format: rec.inventoryDetails?.format || "OOH",
|
|
266
|
+
mediaType:
|
|
267
|
+
rec.inventoryDetails?.type === "digital"
|
|
268
|
+
? "Digital"
|
|
269
|
+
: rec.inventoryDetails?.type || "Digital",
|
|
270
|
+
operationMode: "N/A",
|
|
271
|
+
execution: "placeholder",
|
|
272
|
+
finalScore: rec.finalScore !== undefined ? rec.finalScore * 100 : undefined,
|
|
273
|
+
why: rec.why,
|
|
274
|
+
availability: rec.availability ? {
|
|
275
|
+
availableDays: rec.availability.availableSlots,
|
|
276
|
+
totalDays: rec.availability.totalSlots,
|
|
277
|
+
availabilityPercentage: rec.availability.availabilityPercentage !== undefined
|
|
278
|
+
? rec.availability.availabilityPercentage * 100
|
|
279
|
+
: undefined,
|
|
280
|
+
summary: undefined,
|
|
281
|
+
} : undefined,
|
|
282
|
+
componentScores: rec.componentScores ? {
|
|
283
|
+
geoFit: rec.componentScores.geoFit !== undefined ? rec.componentScores.geoFit * 100 : undefined,
|
|
284
|
+
availability: rec.componentScores.availability !== undefined ? rec.componentScores.availability * 100 : undefined,
|
|
285
|
+
budgetFit: rec.componentScores.budgetFit !== undefined ? rec.componentScores.budgetFit * 100 : undefined,
|
|
286
|
+
audienceFit: rec.componentScores.audienceFit !== undefined ? rec.componentScores.audienceFit * 100 : undefined,
|
|
287
|
+
brandFit: rec.componentScores.brandFit !== undefined ? rec.componentScores.brandFit * 100 : undefined,
|
|
288
|
+
qualityFit: rec.componentScores.qualityFit !== undefined ? rec.componentScores.qualityFit * 100 : undefined,
|
|
289
|
+
timeFit: rec.componentScores.timeFit !== undefined ? rec.componentScores.timeFit * 100 : undefined,
|
|
290
|
+
} : undefined,
|
|
291
|
+
location: rec.inventoryDetails?.location ? {
|
|
292
|
+
cityName: rec.inventoryDetails.location.cityName,
|
|
293
|
+
stateName: rec.inventoryDetails.location.stateName,
|
|
294
|
+
countryName: rec.inventoryDetails.location.countryName,
|
|
295
|
+
} : undefined,
|
|
296
|
+
referenceId: rec.referenceId,
|
|
297
|
+
latitude: rec.inventoryDetails?.location?.locationCoordinates?.latitude,
|
|
298
|
+
longitude: rec.inventoryDetails?.location?.locationCoordinates?.longitude,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function mapRecommendationToAPIInventory(
|
|
303
|
+
rec: RecommendedInventory,
|
|
304
|
+
): APIInventoryItem {
|
|
305
|
+
const availableDays = rec.availability?.availableDays ?? rec.availability?.availableSlots ?? 0;
|
|
306
|
+
const totalDays = rec.availability?.totalDays ?? rec.availability?.totalSlots ?? 30;
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
id: rec.inventoryId,
|
|
310
|
+
name: rec.name,
|
|
311
|
+
address: rec.inventoryDetails?.address,
|
|
312
|
+
venueType: rec.inventoryDetails?.venueTypes?.[0],
|
|
313
|
+
size: rec.inventoryDetails?.sizes?.[0],
|
|
314
|
+
publisherName: rec.inventoryDetails?.mediaOwnerName,
|
|
315
|
+
mediaOwnerName: rec.inventoryDetails?.mediaOwnerName,
|
|
316
|
+
mediaOwnerId: rec.inventoryDetails?.mediaOwnerId,
|
|
317
|
+
type: rec.inventoryDetails?.type,
|
|
318
|
+
planning: rec.forecast ? {
|
|
319
|
+
capacity: {
|
|
320
|
+
campaignDays: totalDays,
|
|
321
|
+
available: {
|
|
322
|
+
slots: availableDays,
|
|
323
|
+
playTimeSec: 0,
|
|
324
|
+
maxImpressions: rec.forecast.estimatedImpressions || 0,
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
allocation: {
|
|
328
|
+
slots: availableDays,
|
|
329
|
+
playTimeSec: 0,
|
|
330
|
+
sov: rec.forecast.estimatedSov || 0,
|
|
331
|
+
sot: 0,
|
|
332
|
+
},
|
|
333
|
+
estimates: {
|
|
334
|
+
impressions: rec.forecast.estimatedImpressions || 0,
|
|
335
|
+
reach: rec.forecast.estimatedReach || 0,
|
|
336
|
+
frequency: rec.forecast.estimatedFrequency || 0,
|
|
337
|
+
},
|
|
338
|
+
pricing: {
|
|
339
|
+
cpm: rec.cost?.costPerImpression ? rec.cost.costPerImpression * 1000 : 0,
|
|
340
|
+
estimatedCost: rec.cost?.estimatedCost || 0,
|
|
341
|
+
},
|
|
342
|
+
} : undefined,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
type InventoryTab = "screens" | "networks" | "packages";
|
|
347
|
+
type GroupByOption = "none" | "publisher" | "location" | "type";
|
|
348
|
+
|
|
349
|
+
interface InventoryGroup {
|
|
350
|
+
name: string;
|
|
351
|
+
inventories: InventoryItem[];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export function InventoryStep({
|
|
355
|
+
data,
|
|
356
|
+
lineItemData,
|
|
357
|
+
lineItemId,
|
|
358
|
+
targeting,
|
|
359
|
+
recommendationRunId: propRunId,
|
|
360
|
+
country = "JP",
|
|
361
|
+
onComplete,
|
|
362
|
+
onBack,
|
|
363
|
+
isLoading,
|
|
364
|
+
isPlannerRestricted = false,
|
|
365
|
+
formId = "inventory-step-form",
|
|
366
|
+
dealMode = "DIRECT",
|
|
367
|
+
}: InventoryStepProps) {
|
|
368
|
+
const { t } = useTranslation("lineItems");
|
|
369
|
+
const [activeTab, setActiveTab] = useState<InventoryTab>("screens");
|
|
370
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
371
|
+
const [debouncedSearch, setDebouncedSearch] = useState("");
|
|
372
|
+
const [selectedInventories, setSelectedInventories] = useState<string[]>([]);
|
|
373
|
+
const [inventoriesData, setInventoriesData] = useState<InventoryItem[]>([]);
|
|
374
|
+
const [apiInventoriesMap, setApiInventoriesMap] = useState<
|
|
375
|
+
Map<string, APIInventoryItem>
|
|
376
|
+
>(new Map());
|
|
377
|
+
const [viewDetailsInventory, setViewDetailsInventory] =
|
|
378
|
+
useState<InventoryItem | null>(null);
|
|
379
|
+
const [isViewDetailsOpen, setIsViewDetailsOpen] = useState(false);
|
|
380
|
+
const [pageSize] = useState(25);
|
|
381
|
+
const [aiRecommendationCollapsed, setAiRecommendationCollapsed] = useState(false);
|
|
382
|
+
const [skipRecommendations, setSkipRecommendations] = useState(false);
|
|
383
|
+
const [isAdvancedFiltersOpen, setIsAdvancedFiltersOpen] = useState(false);
|
|
384
|
+
const [advancedFilters, setAdvancedFilters] = useState<AdvancedFilterValues | null>(null);
|
|
385
|
+
const [isAvailabilityViewOpen, setIsAvailabilityViewOpen] = useState(false);
|
|
386
|
+
const [groupBy, setGroupBy] = useState<GroupByOption>("none");
|
|
387
|
+
const [expandedGroups, setExpandedGroups] = useState<Record<string, boolean>>({});
|
|
388
|
+
const [isCsvUploadOpen, setIsCsvUploadOpen] = useState(false);
|
|
389
|
+
const [viewMode, setViewMode] = useState<"list" | "map">("list");
|
|
390
|
+
|
|
391
|
+
const flightStartDate =
|
|
392
|
+
lineItemData?.startDate || lineItemData?.start_date || "12 Nov 2025";
|
|
393
|
+
const flightEndDate =
|
|
394
|
+
lineItemData?.endDate || lineItemData?.end_date || "24 Nov 2025";
|
|
395
|
+
|
|
396
|
+
const formatDateForAPI = (dateStr: string): string => {
|
|
397
|
+
try {
|
|
398
|
+
const date = new Date(dateStr);
|
|
399
|
+
if (isNaN(date.getTime())) {
|
|
400
|
+
return new Date().toISOString().split("T")[0];
|
|
401
|
+
}
|
|
402
|
+
return date.toISOString().split("T")[0];
|
|
403
|
+
} catch {
|
|
404
|
+
return new Date().toISOString().split("T")[0];
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
const timer = setTimeout(() => {
|
|
410
|
+
setDebouncedSearch(searchQuery);
|
|
411
|
+
}, 300);
|
|
412
|
+
return () => clearTimeout(timer);
|
|
413
|
+
}, [searchQuery]);
|
|
414
|
+
|
|
415
|
+
const hasRecommendations = !!propRunId;
|
|
416
|
+
|
|
417
|
+
console.log('[Inventory] propRunId received:', propRunId, 'hasRecommendations:', hasRecommendations);
|
|
418
|
+
|
|
419
|
+
const loadMoreRef = useRef<HTMLDivElement>(null);
|
|
420
|
+
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
|
421
|
+
|
|
422
|
+
const {
|
|
423
|
+
data: recommendationResponse,
|
|
424
|
+
isLoading: isLoadingRecommendations,
|
|
425
|
+
error: recommendationError,
|
|
426
|
+
refetch: refetchRecommendations,
|
|
427
|
+
fetchNextPage: fetchNextRecommendations,
|
|
428
|
+
hasNextPage: hasNextRecommendations,
|
|
429
|
+
isFetchingNextPage: isFetchingNextRecommendations,
|
|
430
|
+
} =
|
|
431
|
+
useInfiniteQuery({
|
|
432
|
+
queryKey: [
|
|
433
|
+
"recommendation-results",
|
|
434
|
+
propRunId,
|
|
435
|
+
pageSize,
|
|
436
|
+
],
|
|
437
|
+
queryFn: async ({ pageParam = 0 }) => {
|
|
438
|
+
if (!propRunId) return null;
|
|
439
|
+
|
|
440
|
+
const result = await getRecommendationResults(
|
|
441
|
+
propRunId,
|
|
442
|
+
pageParam,
|
|
443
|
+
pageSize,
|
|
444
|
+
["finalScore,desc"],
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
return {
|
|
448
|
+
data: result.recommendations.map(mapRecommendationToAPIInventory),
|
|
449
|
+
recommendations: result.recommendations,
|
|
450
|
+
pagination: {
|
|
451
|
+
page: result.pagination.page,
|
|
452
|
+
pageSize: result.pagination.size,
|
|
453
|
+
totalCount: result.pagination.totalElements,
|
|
454
|
+
totalPages: result.pagination.totalPages,
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
},
|
|
458
|
+
getNextPageParam: (lastPage) => {
|
|
459
|
+
if (!lastPage?.pagination) return undefined;
|
|
460
|
+
const { page, totalPages } = lastPage.pagination;
|
|
461
|
+
return page + 1 < totalPages ? page + 1 : undefined;
|
|
462
|
+
},
|
|
463
|
+
initialPageParam: 0,
|
|
464
|
+
enabled: !!propRunId && !skipRecommendations,
|
|
465
|
+
staleTime: 0,
|
|
466
|
+
refetchOnMount: 'always',
|
|
467
|
+
retry: 1,
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
const {
|
|
471
|
+
data: legacyInventoriesResponse,
|
|
472
|
+
isLoading: isLoadingLegacyInventories,
|
|
473
|
+
fetchNextPage: fetchNextLegacy,
|
|
474
|
+
hasNextPage: hasNextLegacy,
|
|
475
|
+
isFetchingNextPage: isFetchingNextLegacy,
|
|
476
|
+
} = useInfiniteQuery({
|
|
477
|
+
queryKey: ["legacy-inventories", debouncedSearch, pageSize],
|
|
478
|
+
queryFn: async ({ pageParam = 1 }) => {
|
|
479
|
+
const result = await searchInventories(
|
|
480
|
+
{
|
|
481
|
+
archived: false,
|
|
482
|
+
searchText: debouncedSearch || undefined,
|
|
483
|
+
},
|
|
484
|
+
pageParam,
|
|
485
|
+
pageSize,
|
|
486
|
+
);
|
|
487
|
+
return result;
|
|
488
|
+
},
|
|
489
|
+
getNextPageParam: (lastPage) => {
|
|
490
|
+
if (!lastPage?.pagination) return undefined;
|
|
491
|
+
const { page, totalPages } = lastPage.pagination;
|
|
492
|
+
return page < totalPages ? page + 1 : undefined;
|
|
493
|
+
},
|
|
494
|
+
initialPageParam: 1,
|
|
495
|
+
enabled: !hasRecommendations || skipRecommendations,
|
|
496
|
+
staleTime: 0,
|
|
497
|
+
refetchOnMount: 'always',
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
const useRecommendations = hasRecommendations && recommendationResponse && !skipRecommendations;
|
|
501
|
+
const hasRecommendationError = hasRecommendations && !!recommendationError && !skipRecommendations;
|
|
502
|
+
const isInRecommendationMode = hasRecommendations && !skipRecommendations;
|
|
503
|
+
|
|
504
|
+
// Flatten paginated data from infinite queries
|
|
505
|
+
const apiInventories = useMemo(() => {
|
|
506
|
+
if (useRecommendations && recommendationResponse?.pages) {
|
|
507
|
+
return recommendationResponse.pages.flatMap(page => page?.data || []);
|
|
508
|
+
}
|
|
509
|
+
if (legacyInventoriesResponse?.pages) {
|
|
510
|
+
return legacyInventoriesResponse.pages.flatMap(page => page?.data || []);
|
|
511
|
+
}
|
|
512
|
+
return [];
|
|
513
|
+
}, [useRecommendations, recommendationResponse, legacyInventoriesResponse]);
|
|
514
|
+
|
|
515
|
+
const recommendations = useMemo(() => {
|
|
516
|
+
if (useRecommendations && recommendationResponse?.pages) {
|
|
517
|
+
return recommendationResponse.pages.flatMap(page => page?.recommendations || []);
|
|
518
|
+
}
|
|
519
|
+
return [];
|
|
520
|
+
}, [useRecommendations, recommendationResponse]);
|
|
521
|
+
|
|
522
|
+
const totalItems = useMemo(() => {
|
|
523
|
+
if (useRecommendations && recommendationResponse?.pages?.[0]?.pagination) {
|
|
524
|
+
return recommendationResponse.pages[0].pagination.totalCount || 0;
|
|
525
|
+
}
|
|
526
|
+
if (legacyInventoriesResponse?.pages?.[0]?.pagination) {
|
|
527
|
+
return legacyInventoriesResponse.pages[0].pagination.totalCount || 0;
|
|
528
|
+
}
|
|
529
|
+
return 0;
|
|
530
|
+
}, [useRecommendations, recommendationResponse, legacyInventoriesResponse]);
|
|
531
|
+
|
|
532
|
+
const totalPages = useMemo(() => {
|
|
533
|
+
if (useRecommendations && recommendationResponse?.pages?.[0]?.pagination) {
|
|
534
|
+
return recommendationResponse.pages[0].pagination.totalPages || 1;
|
|
535
|
+
}
|
|
536
|
+
if (legacyInventoriesResponse?.pages?.[0]?.pagination) {
|
|
537
|
+
return legacyInventoriesResponse.pages[0].pagination.totalPages || 1;
|
|
538
|
+
}
|
|
539
|
+
return 1;
|
|
540
|
+
}, [useRecommendations, recommendationResponse, legacyInventoriesResponse]);
|
|
541
|
+
|
|
542
|
+
const isLoadingInventories =
|
|
543
|
+
(isInRecommendationMode && isLoadingRecommendations) ||
|
|
544
|
+
(!isInRecommendationMode && isLoadingLegacyInventories);
|
|
545
|
+
const isFetchingMore = isFetchingNextRecommendations || isFetchingNextLegacy;
|
|
546
|
+
const hasMore = useRecommendations ? hasNextRecommendations : hasNextLegacy;
|
|
547
|
+
const fetchNextPage = useRecommendations ? fetchNextRecommendations : fetchNextLegacy;
|
|
548
|
+
const recommendationCount = recommendationResponse?.pages?.[0]?.pagination?.totalCount || 0;
|
|
549
|
+
|
|
550
|
+
// Infinite scroll observer - trigger when sentinel becomes visible in container
|
|
551
|
+
const lastFetchTimeRef = useRef(0);
|
|
552
|
+
const initialLoadCompleteRef = useRef(false);
|
|
553
|
+
|
|
554
|
+
// Mark initial load as complete once we have data
|
|
555
|
+
useEffect(() => {
|
|
556
|
+
if (!isLoadingInventories && (recommendations.length > 0 || apiInventories.length > 0)) {
|
|
557
|
+
// Delay marking as complete to prevent immediate trigger
|
|
558
|
+
const timer = setTimeout(() => {
|
|
559
|
+
initialLoadCompleteRef.current = true;
|
|
560
|
+
}, 500);
|
|
561
|
+
return () => clearTimeout(timer);
|
|
562
|
+
}
|
|
563
|
+
}, [isLoadingInventories, recommendations.length, apiInventories.length]);
|
|
564
|
+
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
// Don't set up observer until we have initial data
|
|
567
|
+
if (isLoadingInventories) return;
|
|
568
|
+
|
|
569
|
+
const container = scrollContainerRef.current;
|
|
570
|
+
if (!container) return;
|
|
571
|
+
|
|
572
|
+
const observer = new IntersectionObserver(
|
|
573
|
+
(entries) => {
|
|
574
|
+
const isIntersecting = entries[0].isIntersecting;
|
|
575
|
+
const now = Date.now();
|
|
576
|
+
|
|
577
|
+
// Only fetch if:
|
|
578
|
+
// 1. Sentinel is visible
|
|
579
|
+
// 2. We have more pages
|
|
580
|
+
// 3. Not already fetching
|
|
581
|
+
// 4. Initial load is complete (prevents auto-load on first render)
|
|
582
|
+
// 5. At least 300ms has passed since last fetch (debounce)
|
|
583
|
+
if (
|
|
584
|
+
isIntersecting &&
|
|
585
|
+
hasMore &&
|
|
586
|
+
!isFetchingMore &&
|
|
587
|
+
initialLoadCompleteRef.current &&
|
|
588
|
+
now - lastFetchTimeRef.current > 300
|
|
589
|
+
) {
|
|
590
|
+
lastFetchTimeRef.current = now;
|
|
591
|
+
fetchNextPage();
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
root: container,
|
|
596
|
+
threshold: 0.1,
|
|
597
|
+
rootMargin: '100px' // Pre-fetch when within 100px of the sentinel
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
|
|
601
|
+
if (loadMoreRef.current) {
|
|
602
|
+
observer.observe(loadMoreRef.current);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return () => observer.disconnect();
|
|
606
|
+
}, [hasMore, isFetchingMore, fetchNextPage, isLoadingInventories, recommendations.length, apiInventories.length]);
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
// Prioritize recommendation data when in recommendation mode and data is available
|
|
611
|
+
if (hasRecommendations && !skipRecommendations && recommendations.length > 0) {
|
|
612
|
+
console.log('[Inventory] Setting inventoriesData from recommendations:', recommendations.length);
|
|
613
|
+
const mappedInventories = recommendations.map(mapRecommendationToLocal);
|
|
614
|
+
setInventoriesData(mappedInventories);
|
|
615
|
+
|
|
616
|
+
setApiInventoriesMap((prev) => {
|
|
617
|
+
const merged = new Map(prev);
|
|
618
|
+
recommendations.forEach((rec: RecommendedInventory) => {
|
|
619
|
+
merged.set(rec.inventoryId, mapRecommendationToAPIInventory(rec));
|
|
620
|
+
});
|
|
621
|
+
return merged;
|
|
622
|
+
});
|
|
623
|
+
} else if ((!hasRecommendations || skipRecommendations) && apiInventories && apiInventories.length > 0) {
|
|
624
|
+
console.log('[Inventory] Setting inventoriesData from legacy:', apiInventories.length);
|
|
625
|
+
const mappedInventories = apiInventories.map(mapAPIInventoryToLocal);
|
|
626
|
+
setInventoriesData(mappedInventories);
|
|
627
|
+
|
|
628
|
+
setApiInventoriesMap((prev) => {
|
|
629
|
+
const merged = new Map(prev);
|
|
630
|
+
apiInventories.forEach((item: APIInventoryItem) => {
|
|
631
|
+
merged.set(item.id, item);
|
|
632
|
+
});
|
|
633
|
+
return merged;
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}, [recommendations, apiInventories, hasRecommendations, skipRecommendations]);
|
|
637
|
+
|
|
638
|
+
useEffect(() => {
|
|
639
|
+
if (data) {
|
|
640
|
+
console.log("📦 InventoryStep received data:", data);
|
|
641
|
+
console.log("📦 Inventories to select:", data.inventories);
|
|
642
|
+
if (data.inventories && Array.isArray(data.inventories)) {
|
|
643
|
+
setSelectedInventories(data.inventories);
|
|
644
|
+
}
|
|
645
|
+
if (
|
|
646
|
+
data.inventoryObjects &&
|
|
647
|
+
Array.isArray(data.inventoryObjects) &&
|
|
648
|
+
data.inventoryObjects.length > 0
|
|
649
|
+
) {
|
|
650
|
+
const existingMapped: InventoryItem[] = data.inventoryObjects.map(
|
|
651
|
+
(inv: any) => {
|
|
652
|
+
const tags: InventoryItem["tags"] = [];
|
|
653
|
+
if (inv.venueType) {
|
|
654
|
+
const venueVariant = inv.venueType
|
|
655
|
+
.toLowerCase()
|
|
656
|
+
.includes("retail")
|
|
657
|
+
? "warning"
|
|
658
|
+
: inv.venueType.toLowerCase().includes("transit")
|
|
659
|
+
? "success"
|
|
660
|
+
: "secondary";
|
|
661
|
+
tags.push({ label: inv.venueType, variant: venueVariant });
|
|
662
|
+
}
|
|
663
|
+
if (inv.size) {
|
|
664
|
+
tags.push({ label: inv.size, variant: "outline" });
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return {
|
|
668
|
+
id: inv.id || inv.inventoryId,
|
|
669
|
+
name: inv.name || `Inventory ${inv.id}`,
|
|
670
|
+
type: "screen" as const,
|
|
671
|
+
address: inv.address || inv.venueType || "Location",
|
|
672
|
+
tags,
|
|
673
|
+
operatingHours: inv.operatingHours || "24/7",
|
|
674
|
+
estimatedCostPerDay: 2500,
|
|
675
|
+
currency: "MYR",
|
|
676
|
+
};
|
|
677
|
+
},
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
setInventoriesData((prev) => {
|
|
681
|
+
const existingIds = new Set(prev.map((p) => p.id));
|
|
682
|
+
const newItems = existingMapped.filter(
|
|
683
|
+
(item) => !existingIds.has(item.id),
|
|
684
|
+
);
|
|
685
|
+
return [...prev, ...newItems];
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
setApiInventoriesMap((prev) => {
|
|
689
|
+
const merged = new Map(prev);
|
|
690
|
+
data.inventoryObjects.forEach((inv: any) => {
|
|
691
|
+
merged.set(inv.id || inv.inventoryId, inv as APIInventoryItem);
|
|
692
|
+
});
|
|
693
|
+
return merged;
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}, [data]);
|
|
698
|
+
|
|
699
|
+
const filteredInventories = useMemo(() => {
|
|
700
|
+
let filtered = inventoriesData;
|
|
701
|
+
|
|
702
|
+
if (activeTab === "screens") {
|
|
703
|
+
filtered = filtered.filter((inv) => inv.type === "screen");
|
|
704
|
+
} else if (activeTab === "networks") {
|
|
705
|
+
filtered = filtered.filter((inv) => inv.type === "network");
|
|
706
|
+
} else if (activeTab === "packages") {
|
|
707
|
+
filtered = filtered.filter((inv) => inv.type === "package");
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (debouncedSearch && useRecommendations) {
|
|
711
|
+
const searchLower = debouncedSearch.toLowerCase();
|
|
712
|
+
filtered = filtered.filter(
|
|
713
|
+
(inv) =>
|
|
714
|
+
inv.name.toLowerCase().includes(searchLower) ||
|
|
715
|
+
inv.address.toLowerCase().includes(searchLower) ||
|
|
716
|
+
inv.publisherName?.toLowerCase().includes(searchLower) ||
|
|
717
|
+
inv.tags.some((tag) => tag.label.toLowerCase().includes(searchLower)),
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (advancedFilters) {
|
|
722
|
+
if (advancedFilters.state) {
|
|
723
|
+
const stateLower = advancedFilters.state.toLowerCase();
|
|
724
|
+
filtered = filtered.filter(
|
|
725
|
+
(inv) =>
|
|
726
|
+
inv.location?.stateName?.toLowerCase().includes(stateLower) ||
|
|
727
|
+
inv.address.toLowerCase().includes(stateLower)
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
if (advancedFilters.city) {
|
|
731
|
+
const cityLower = advancedFilters.city.toLowerCase();
|
|
732
|
+
filtered = filtered.filter(
|
|
733
|
+
(inv) =>
|
|
734
|
+
inv.location?.cityName?.toLowerCase().includes(cityLower) ||
|
|
735
|
+
inv.address.toLowerCase().includes(cityLower)
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (advancedFilters.mediaOwner) {
|
|
740
|
+
const ownerLower = advancedFilters.mediaOwner.toLowerCase();
|
|
741
|
+
filtered = filtered.filter(
|
|
742
|
+
(inv) => inv.publisherName?.toLowerCase().includes(ownerLower)
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
if (advancedFilters.inventoryType) {
|
|
746
|
+
const typeLower = advancedFilters.inventoryType.toLowerCase();
|
|
747
|
+
filtered = filtered.filter(
|
|
748
|
+
(inv) => inv.mediaType?.toLowerCase().includes(typeLower) ||
|
|
749
|
+
inv.tags.some((tag) => tag.label.toLowerCase().includes(typeLower))
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
if (advancedFilters.size) {
|
|
753
|
+
const sizeLower = advancedFilters.size.toLowerCase();
|
|
754
|
+
filtered = filtered.filter(
|
|
755
|
+
(inv) => inv.size?.toLowerCase().includes(sizeLower)
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
if (advancedFilters.modeOfOperation) {
|
|
759
|
+
const modeLower = advancedFilters.modeOfOperation.toLowerCase();
|
|
760
|
+
filtered = filtered.filter(
|
|
761
|
+
(inv) => inv.operationMode?.toLowerCase().includes(modeLower)
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return filtered;
|
|
767
|
+
}, [activeTab, inventoriesData, debouncedSearch, useRecommendations, advancedFilters]);
|
|
768
|
+
|
|
769
|
+
const groupInventories = (inventories: InventoryItem[], groupByOption: GroupByOption): InventoryGroup[] => {
|
|
770
|
+
if (groupByOption === "none") {
|
|
771
|
+
return [{ name: "All Inventories", inventories }];
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
const groups: Record<string, InventoryItem[]> = {};
|
|
775
|
+
|
|
776
|
+
inventories.forEach((inv) => {
|
|
777
|
+
let groupKey: string;
|
|
778
|
+
|
|
779
|
+
switch (groupByOption) {
|
|
780
|
+
case "publisher":
|
|
781
|
+
groupKey = inv.publisherName || "Unknown Publisher";
|
|
782
|
+
break;
|
|
783
|
+
case "location":
|
|
784
|
+
if (inv.location?.cityName && inv.location?.stateName) {
|
|
785
|
+
groupKey = `${inv.location.cityName}, ${inv.location.stateName}`;
|
|
786
|
+
} else if (inv.location?.cityName) {
|
|
787
|
+
groupKey = inv.location.cityName;
|
|
788
|
+
} else if (inv.location?.stateName) {
|
|
789
|
+
groupKey = inv.location.stateName;
|
|
790
|
+
} else if (inv.address) {
|
|
791
|
+
const addressParts = inv.address.split(',');
|
|
792
|
+
groupKey = addressParts.length > 1 ? addressParts.slice(-2).join(',').trim() : inv.address;
|
|
793
|
+
} else {
|
|
794
|
+
groupKey = "Unknown Location";
|
|
795
|
+
}
|
|
796
|
+
break;
|
|
797
|
+
case "type":
|
|
798
|
+
groupKey = inv.mediaType || "Unknown Type";
|
|
799
|
+
break;
|
|
800
|
+
default:
|
|
801
|
+
groupKey = "Other";
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (!groups[groupKey]) {
|
|
805
|
+
groups[groupKey] = [];
|
|
806
|
+
}
|
|
807
|
+
groups[groupKey].push(inv);
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
return Object.entries(groups)
|
|
811
|
+
.map(([name, inventories]) => ({ name, inventories }))
|
|
812
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
const groupedInventories = useMemo(() => {
|
|
816
|
+
return groupInventories(filteredInventories, groupBy);
|
|
817
|
+
}, [filteredInventories, groupBy]);
|
|
818
|
+
|
|
819
|
+
const toggleGroupExpanded = (groupName: string) => {
|
|
820
|
+
setExpandedGroups((prev) => ({
|
|
821
|
+
...prev,
|
|
822
|
+
[groupName]: !prev[groupName],
|
|
823
|
+
}));
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
const isGroupExpanded = (groupName: string) => {
|
|
827
|
+
return expandedGroups[groupName] !== false;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
const handleSelectGroup = (group: InventoryGroup) => {
|
|
831
|
+
const groupIds = group.inventories.map((inv) => inv.id);
|
|
832
|
+
const allSelected = groupIds.every((id) => selectedInventories.includes(id));
|
|
833
|
+
|
|
834
|
+
if (allSelected) {
|
|
835
|
+
setSelectedInventories((prev) => prev.filter((id) => !groupIds.includes(id)));
|
|
836
|
+
} else {
|
|
837
|
+
const newIds = groupIds.filter((id) => !selectedInventories.includes(id));
|
|
838
|
+
setSelectedInventories((prev) => [...prev, ...newIds]);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
const isGroupAllSelected = (group: InventoryGroup) => {
|
|
843
|
+
return group.inventories.length > 0 && group.inventories.every((inv) => selectedInventories.includes(inv.id));
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
const isGroupPartiallySelected = (group: InventoryGroup) => {
|
|
847
|
+
const selectedCount = group.inventories.filter((inv) => selectedInventories.includes(inv.id)).length;
|
|
848
|
+
return selectedCount > 0 && selectedCount < group.inventories.length;
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
const selectionCounts = useMemo(() => {
|
|
852
|
+
const screens = selectedInventories.filter((id) =>
|
|
853
|
+
inventoriesData.find((inv) => inv.id === id && inv.type === "screen"),
|
|
854
|
+
).length;
|
|
855
|
+
const networks = selectedInventories.filter((id) =>
|
|
856
|
+
inventoriesData.find((inv) => inv.id === id && inv.type === "network"),
|
|
857
|
+
).length;
|
|
858
|
+
const packages = selectedInventories.filter((id) =>
|
|
859
|
+
inventoriesData.find((inv) => inv.id === id && inv.type === "package"),
|
|
860
|
+
).length;
|
|
861
|
+
|
|
862
|
+
return {
|
|
863
|
+
total: selectedInventories.length,
|
|
864
|
+
screens,
|
|
865
|
+
networks,
|
|
866
|
+
packages,
|
|
867
|
+
};
|
|
868
|
+
}, [selectedInventories, inventoriesData]);
|
|
869
|
+
|
|
870
|
+
const isAllCurrentTabSelected = useMemo(() => {
|
|
871
|
+
return (
|
|
872
|
+
filteredInventories.length > 0 &&
|
|
873
|
+
filteredInventories.every((inv) => selectedInventories.includes(inv.id))
|
|
874
|
+
);
|
|
875
|
+
}, [filteredInventories, selectedInventories]);
|
|
876
|
+
|
|
877
|
+
const aggregatedForecast = useMemo(() => {
|
|
878
|
+
let totalImpressions = 0;
|
|
879
|
+
let totalReach = 0;
|
|
880
|
+
let totalSlots = 0;
|
|
881
|
+
let totalCost = 0;
|
|
882
|
+
let totalCpm = 0;
|
|
883
|
+
let sovSum = 0;
|
|
884
|
+
let sotSum = 0;
|
|
885
|
+
let count = 0;
|
|
886
|
+
|
|
887
|
+
const selectedInventoryObjects = selectedInventories
|
|
888
|
+
.map((id) => apiInventoriesMap.get(id))
|
|
889
|
+
.filter((inv): inv is APIInventoryItem => inv !== undefined);
|
|
890
|
+
|
|
891
|
+
selectedInventoryObjects.forEach((inv) => {
|
|
892
|
+
if (inv?.planning) {
|
|
893
|
+
totalImpressions += inv.planning.estimates?.impressions || 0;
|
|
894
|
+
totalReach += inv.planning.estimates?.reach || 0;
|
|
895
|
+
totalSlots += inv.planning.allocation?.slots || 0;
|
|
896
|
+
totalCost += inv.planning.pricing?.estimatedCost || 0;
|
|
897
|
+
totalCpm += inv.planning.pricing?.cpm || 0;
|
|
898
|
+
sovSum += inv.planning.allocation?.sov || 0;
|
|
899
|
+
sotSum += inv.planning.allocation?.sot || 0;
|
|
900
|
+
count++;
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
|
|
904
|
+
const avgFrequency = totalReach > 0 ? totalImpressions / totalReach : 0;
|
|
905
|
+
const avgCpm = count > 0 ? totalCpm / count : 0;
|
|
906
|
+
const avgEcpm = totalImpressions > 0 ? (totalCost / totalImpressions) * 1000 : 0;
|
|
907
|
+
const avgSov = count > 0 ? (sovSum / count) * 100 : 0;
|
|
908
|
+
const avgSot = count > 0 ? (sotSum / count) * 100 : 0;
|
|
909
|
+
|
|
910
|
+
return {
|
|
911
|
+
impressions: totalImpressions,
|
|
912
|
+
reach: totalReach,
|
|
913
|
+
frequency: avgFrequency,
|
|
914
|
+
adPlays: totalSlots,
|
|
915
|
+
sov: avgSov,
|
|
916
|
+
cpm: avgCpm,
|
|
917
|
+
ecpm: avgEcpm,
|
|
918
|
+
totalCost: totalCost,
|
|
919
|
+
sot: avgSot,
|
|
920
|
+
};
|
|
921
|
+
}, [selectedInventories, apiInventoriesMap]);
|
|
922
|
+
|
|
923
|
+
const handleSelectAll = () => {
|
|
924
|
+
if (isAllCurrentTabSelected) {
|
|
925
|
+
const idsToRemove = filteredInventories.map((inv) => inv.id);
|
|
926
|
+
setSelectedInventories((prev) =>
|
|
927
|
+
prev.filter((id) => !idsToRemove.includes(id)),
|
|
928
|
+
);
|
|
929
|
+
} else {
|
|
930
|
+
const newIds = filteredInventories
|
|
931
|
+
.map((inv) => inv.id)
|
|
932
|
+
.filter((id) => !selectedInventories.includes(id));
|
|
933
|
+
setSelectedInventories((prev) => [...prev, ...newIds]);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
const handleInventoryToggle = (inventoryId: string) => {
|
|
938
|
+
setSelectedInventories((prev) =>
|
|
939
|
+
prev.includes(inventoryId)
|
|
940
|
+
? prev.filter((id) => id !== inventoryId)
|
|
941
|
+
: [...prev, inventoryId],
|
|
942
|
+
);
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
const handleNext = () => {
|
|
946
|
+
const selectedInventoryObjects = selectedInventories
|
|
947
|
+
.map((id) => apiInventoriesMap.get(id))
|
|
948
|
+
.filter((inv): inv is APIInventoryItem => inv !== undefined)
|
|
949
|
+
.map((inv) => {
|
|
950
|
+
return {
|
|
951
|
+
...inv,
|
|
952
|
+
id: inv.id,
|
|
953
|
+
name: inv.name,
|
|
954
|
+
};
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
// Calculate aggregated planning from selected inventories for DIRECT mode
|
|
958
|
+
let aggregatedPlanning = undefined;
|
|
959
|
+
// Always calculate planning if any inventory has planning data (for DIRECT deals)
|
|
960
|
+
const hasPlanning = selectedInventoryObjects.some((inv) => inv?.planning);
|
|
961
|
+
if (hasPlanning) {
|
|
962
|
+
let totalImpressions = 0;
|
|
963
|
+
let totalReach = 0;
|
|
964
|
+
let totalSlots = 0;
|
|
965
|
+
let totalPlayTimeSec = 0;
|
|
966
|
+
let totalCost = 0;
|
|
967
|
+
let totalCpm = 0;
|
|
968
|
+
let sovSum = 0;
|
|
969
|
+
let sotSum = 0;
|
|
970
|
+
let campaignDays = 0;
|
|
971
|
+
let availableSlots = 0;
|
|
972
|
+
let availablePlayTimeSec = 0;
|
|
973
|
+
let availableMaxImpressions = 0;
|
|
974
|
+
let count = 0;
|
|
975
|
+
|
|
976
|
+
selectedInventoryObjects.forEach((inv) => {
|
|
977
|
+
if (inv?.planning) {
|
|
978
|
+
totalImpressions += inv.planning.estimates?.impressions || 0;
|
|
979
|
+
totalReach += inv.planning.estimates?.reach || 0;
|
|
980
|
+
totalSlots += inv.planning.allocation?.slots || 0;
|
|
981
|
+
totalPlayTimeSec += inv.planning.allocation?.playTimeSec || 0;
|
|
982
|
+
totalCost += inv.planning.pricing?.estimatedCost || 0;
|
|
983
|
+
totalCpm += inv.planning.pricing?.cpm || 0;
|
|
984
|
+
// sov/sot are fractions (0-1) per swagger spec
|
|
985
|
+
sovSum += inv.planning.allocation?.sov || 0;
|
|
986
|
+
sotSum += inv.planning.allocation?.sot || 0;
|
|
987
|
+
campaignDays = Math.max(campaignDays, inv.planning.capacity?.campaignDays || 0);
|
|
988
|
+
// Aggregate capacity.available fields
|
|
989
|
+
availableSlots += inv.planning.capacity?.available?.slots || 0;
|
|
990
|
+
availablePlayTimeSec += inv.planning.capacity?.available?.playTimeSec || 0;
|
|
991
|
+
availableMaxImpressions += inv.planning.capacity?.available?.maxImpressions || 0;
|
|
992
|
+
count++;
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
const avgFrequency = totalReach > 0 ? totalImpressions / totalReach : 0;
|
|
997
|
+
const avgCpm = count > 0 ? totalCpm / count : 0;
|
|
998
|
+
// Average sov/sot as fractions (0-1 scale)
|
|
999
|
+
const avgSov = count > 0 ? sovSum / count : 0;
|
|
1000
|
+
const avgSot = count > 0 ? sotSum / count : 0;
|
|
1001
|
+
|
|
1002
|
+
aggregatedPlanning = {
|
|
1003
|
+
capacity: {
|
|
1004
|
+
campaignDays,
|
|
1005
|
+
available: {
|
|
1006
|
+
slots: availableSlots,
|
|
1007
|
+
playTimeSec: availablePlayTimeSec,
|
|
1008
|
+
maxImpressions: availableMaxImpressions,
|
|
1009
|
+
},
|
|
1010
|
+
},
|
|
1011
|
+
allocation: {
|
|
1012
|
+
slots: totalSlots,
|
|
1013
|
+
playTimeSec: totalPlayTimeSec,
|
|
1014
|
+
sov: avgSov,
|
|
1015
|
+
sot: avgSot,
|
|
1016
|
+
},
|
|
1017
|
+
estimates: {
|
|
1018
|
+
impressions: totalImpressions,
|
|
1019
|
+
reach: totalReach,
|
|
1020
|
+
frequency: avgFrequency,
|
|
1021
|
+
},
|
|
1022
|
+
pricing: {
|
|
1023
|
+
cpm: avgCpm,
|
|
1024
|
+
estimatedCost: totalCost,
|
|
1025
|
+
},
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
const outputData = {
|
|
1030
|
+
inventories: selectedInventories,
|
|
1031
|
+
inventoryObjects: selectedInventoryObjects,
|
|
1032
|
+
planning: aggregatedPlanning,
|
|
1033
|
+
};
|
|
1034
|
+
console.log("✅ Inventory selection submitted:", outputData);
|
|
1035
|
+
onComplete(outputData);
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
const handleFormSubmit = (e: React.FormEvent) => {
|
|
1039
|
+
e.preventDefault();
|
|
1040
|
+
handleNext();
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
const getTabLabel = (): string => {
|
|
1044
|
+
switch (activeTab) {
|
|
1045
|
+
case "screens":
|
|
1046
|
+
return t('wizard.inventory.screens');
|
|
1047
|
+
case "networks":
|
|
1048
|
+
return t('wizard.inventory.networks');
|
|
1049
|
+
case "packages":
|
|
1050
|
+
return t('wizard.inventory.packages');
|
|
1051
|
+
default:
|
|
1052
|
+
return t('wizard.inventory.items');
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
return (
|
|
1057
|
+
<form
|
|
1058
|
+
id={formId}
|
|
1059
|
+
onSubmit={handleFormSubmit}
|
|
1060
|
+
className="flex flex-col h-full"
|
|
1061
|
+
>
|
|
1062
|
+
{isPlannerRestricted && (
|
|
1063
|
+
<div className="mb-4 p-3 bg-purple-50 border border-purple-200 rounded-lg">
|
|
1064
|
+
<p className="text-sm text-purple-700 font-medium">{t('wizard.common.readOnly')}</p>
|
|
1065
|
+
<p className="text-xs text-purple-600">
|
|
1066
|
+
{t('wizard.inventory.plannerRestrictedDesc')}
|
|
1067
|
+
</p>
|
|
1068
|
+
</div>
|
|
1069
|
+
)}
|
|
1070
|
+
<div className="flex-1 flex gap-6">
|
|
1071
|
+
<div className="flex-1 flex flex-col min-w-0">
|
|
1072
|
+
<div className="flex items-center justify-between mb-4">
|
|
1073
|
+
<div className="flex items-center gap-2">
|
|
1074
|
+
<Grid3X3 className="h-5 w-5 text-mw-neutral-500" />
|
|
1075
|
+
<div>
|
|
1076
|
+
<h2 className="text-base font-semibold text-mw-neutral-900 dark:text-white">
|
|
1077
|
+
{t("wizard.inventory.title")}
|
|
1078
|
+
</h2>
|
|
1079
|
+
<p className="text-xs text-mw-neutral-500">
|
|
1080
|
+
{t("wizard.inventory.subtitle")}
|
|
1081
|
+
</p>
|
|
1082
|
+
</div>
|
|
1083
|
+
</div>
|
|
1084
|
+
<div className="flex items-center gap-2">
|
|
1085
|
+
<div className="relative flex-1 min-w-[200px]">
|
|
1086
|
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-mw-neutral-400" />
|
|
1087
|
+
<Input
|
|
1088
|
+
placeholder={t("wizard.common.searchHere")}
|
|
1089
|
+
value={searchQuery}
|
|
1090
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
1091
|
+
onKeyDown={(e) => {
|
|
1092
|
+
if (e.key === "Enter") {
|
|
1093
|
+
e.preventDefault();
|
|
1094
|
+
}
|
|
1095
|
+
}}
|
|
1096
|
+
className="pl-10 pr-3 py-2 text-sm border-mw-neutral-200 dark:border-mw-neutral-700 w-[250px]"
|
|
1097
|
+
/>
|
|
1098
|
+
</div>
|
|
1099
|
+
<Button
|
|
1100
|
+
type="button"
|
|
1101
|
+
variant="outline"
|
|
1102
|
+
size="sm"
|
|
1103
|
+
isIconOnly
|
|
1104
|
+
title={t("wizard.inventory.listView")}
|
|
1105
|
+
>
|
|
1106
|
+
<List className="h-4 w-4" />
|
|
1107
|
+
</Button>
|
|
1108
|
+
<Button
|
|
1109
|
+
type="button"
|
|
1110
|
+
variant="outline"
|
|
1111
|
+
size="sm"
|
|
1112
|
+
isIconOnly
|
|
1113
|
+
title={t("wizard.inventory.advancedFilter")}
|
|
1114
|
+
onClick={() => setIsAdvancedFiltersOpen(true)}
|
|
1115
|
+
>
|
|
1116
|
+
<SlidersHorizontal className="h-4 w-4" />
|
|
1117
|
+
</Button>
|
|
1118
|
+
<InventorySettingsMenu
|
|
1119
|
+
onMapViewClick={() => {
|
|
1120
|
+
setViewMode(viewMode === "map" ? "list" : "map");
|
|
1121
|
+
}}
|
|
1122
|
+
onAvailabilityClick={() => {
|
|
1123
|
+
setIsAvailabilityViewOpen(true);
|
|
1124
|
+
}}
|
|
1125
|
+
onUploadCSVClick={() => {
|
|
1126
|
+
setIsCsvUploadOpen(true);
|
|
1127
|
+
}}
|
|
1128
|
+
/>
|
|
1129
|
+
</div>
|
|
1130
|
+
</div>
|
|
1131
|
+
|
|
1132
|
+
{isInRecommendationMode && (
|
|
1133
|
+
<>
|
|
1134
|
+
{isLoadingRecommendations && !recommendationResponse && (
|
|
1135
|
+
<div className="mb-4 rounded-lg overflow-hidden bg-gradient-to-r from-purple-600 via-purple-500 to-indigo-500 p-4">
|
|
1136
|
+
<div className="flex items-start gap-3">
|
|
1137
|
+
<div className="flex-shrink-0">
|
|
1138
|
+
<Sparkles className="h-6 w-6 text-white animate-pulse" />
|
|
1139
|
+
</div>
|
|
1140
|
+
<div className="flex-1">
|
|
1141
|
+
<div className="flex items-center justify-between mb-2">
|
|
1142
|
+
<h3 className="text-white font-semibold text-sm">
|
|
1143
|
+
{t('wizard.ai.smartSuggestion')}
|
|
1144
|
+
</h3>
|
|
1145
|
+
<Button
|
|
1146
|
+
type="button"
|
|
1147
|
+
variant="ghost"
|
|
1148
|
+
size="sm"
|
|
1149
|
+
onClick={() => setSkipRecommendations(true)}
|
|
1150
|
+
className="text-white/80 hover:text-white hover:bg-white/10 text-xs h-7 px-3"
|
|
1151
|
+
>
|
|
1152
|
+
{t('wizard.ai.skipForNow')}
|
|
1153
|
+
</Button>
|
|
1154
|
+
</div>
|
|
1155
|
+
<p className="text-white/90 text-xs mb-3">
|
|
1156
|
+
{t('wizard.ai.workingOnGeoFitness')}
|
|
1157
|
+
</p>
|
|
1158
|
+
<div className="w-full h-1.5 bg-white/20 rounded-full overflow-hidden">
|
|
1159
|
+
<div
|
|
1160
|
+
className="h-full bg-white rounded-full animate-pulse"
|
|
1161
|
+
style={{
|
|
1162
|
+
width: '60%',
|
|
1163
|
+
animation: 'pulse 1.5s ease-in-out infinite, progress 2s ease-in-out infinite'
|
|
1164
|
+
}}
|
|
1165
|
+
/>
|
|
1166
|
+
</div>
|
|
1167
|
+
</div>
|
|
1168
|
+
</div>
|
|
1169
|
+
</div>
|
|
1170
|
+
)}
|
|
1171
|
+
|
|
1172
|
+
{hasRecommendationError && (
|
|
1173
|
+
<div className="mb-4 rounded-lg overflow-hidden bg-gradient-to-r from-purple-600 via-purple-500 to-indigo-500 p-4">
|
|
1174
|
+
<div className="flex items-start gap-3">
|
|
1175
|
+
<div className="flex-shrink-0">
|
|
1176
|
+
<Sparkles className="h-6 w-6 text-white" />
|
|
1177
|
+
</div>
|
|
1178
|
+
<div className="flex-1">
|
|
1179
|
+
<h3 className="text-white font-semibold text-sm mb-1">
|
|
1180
|
+
{t('wizard.ai.smartSuggestion')}
|
|
1181
|
+
</h3>
|
|
1182
|
+
<div className="flex items-start gap-2 mb-3">
|
|
1183
|
+
<AlertCircle className="h-4 w-4 text-white/80 flex-shrink-0 mt-0.5" />
|
|
1184
|
+
<p className="text-white/90 text-xs leading-relaxed">
|
|
1185
|
+
{t('wizard.ai.errorMessage')}
|
|
1186
|
+
</p>
|
|
1187
|
+
</div>
|
|
1188
|
+
<div className="flex items-center gap-2">
|
|
1189
|
+
<Button
|
|
1190
|
+
type="button"
|
|
1191
|
+
variant="outline"
|
|
1192
|
+
size="sm"
|
|
1193
|
+
onClick={() => {
|
|
1194
|
+
setSkipRecommendations(true);
|
|
1195
|
+
}}
|
|
1196
|
+
className="bg-transparent border-white/50 text-white hover:bg-white/10 text-xs h-7 px-3"
|
|
1197
|
+
>
|
|
1198
|
+
{t('wizard.ai.showAllInventories')}
|
|
1199
|
+
</Button>
|
|
1200
|
+
<Button
|
|
1201
|
+
type="button"
|
|
1202
|
+
size="sm"
|
|
1203
|
+
onClick={() => refetchRecommendations()}
|
|
1204
|
+
className="bg-blue-500 hover:bg-blue-600 text-white text-xs h-7 px-3"
|
|
1205
|
+
>
|
|
1206
|
+
<RotateCcw className="h-3 w-3 mr-1" />
|
|
1207
|
+
{t('wizard.ai.retry')}
|
|
1208
|
+
</Button>
|
|
1209
|
+
</div>
|
|
1210
|
+
</div>
|
|
1211
|
+
</div>
|
|
1212
|
+
</div>
|
|
1213
|
+
)}
|
|
1214
|
+
|
|
1215
|
+
{recommendationResponse && !hasRecommendationError && recommendationCount > 0 && (
|
|
1216
|
+
<div className="mb-4 rounded-lg overflow-hidden bg-gradient-to-r from-purple-600 via-purple-500 to-indigo-500">
|
|
1217
|
+
<div
|
|
1218
|
+
className="p-4 cursor-pointer"
|
|
1219
|
+
onClick={() => setAiRecommendationCollapsed(!aiRecommendationCollapsed)}
|
|
1220
|
+
>
|
|
1221
|
+
<div className="flex items-center justify-between">
|
|
1222
|
+
<div className="flex items-center gap-3">
|
|
1223
|
+
<Sparkles className="h-5 w-5 text-white" />
|
|
1224
|
+
<div>
|
|
1225
|
+
<div className="flex items-center gap-2">
|
|
1226
|
+
<h3 className="text-white font-semibold text-sm">
|
|
1227
|
+
{t('wizard.ai.smartRecommendation')}
|
|
1228
|
+
</h3>
|
|
1229
|
+
<Badge
|
|
1230
|
+
variant="success"
|
|
1231
|
+
size="sm"
|
|
1232
|
+
className="bg-green-500/90 text-white text-[10px] px-2"
|
|
1233
|
+
>
|
|
1234
|
+
{t('wizard.ai.inventoriesRecommended', { count: recommendationCount })}
|
|
1235
|
+
</Badge>
|
|
1236
|
+
</div>
|
|
1237
|
+
<p className="text-white/80 text-xs mt-0.5">
|
|
1238
|
+
{t('wizard.ai.basedOnCampaignDetails')}
|
|
1239
|
+
</p>
|
|
1240
|
+
</div>
|
|
1241
|
+
</div>
|
|
1242
|
+
<div className="flex items-center gap-2">
|
|
1243
|
+
{aiRecommendationCollapsed ? (
|
|
1244
|
+
<ChevronDown className="h-5 w-5 text-white/70" />
|
|
1245
|
+
) : (
|
|
1246
|
+
<ChevronUp className="h-5 w-5 text-white/70" />
|
|
1247
|
+
)}
|
|
1248
|
+
</div>
|
|
1249
|
+
</div>
|
|
1250
|
+
</div>
|
|
1251
|
+
</div>
|
|
1252
|
+
)}
|
|
1253
|
+
</>
|
|
1254
|
+
)}
|
|
1255
|
+
|
|
1256
|
+
<div className="flex items-center justify-between mb-3">
|
|
1257
|
+
<div className="flex items-center gap-2">
|
|
1258
|
+
<Checkbox
|
|
1259
|
+
checked={isAllCurrentTabSelected}
|
|
1260
|
+
onChange={handleSelectAll}
|
|
1261
|
+
disabled={isPlannerRestricted}
|
|
1262
|
+
/>
|
|
1263
|
+
<span
|
|
1264
|
+
className={cn(
|
|
1265
|
+
"text-sm text-mw-neutral-700 dark:text-mw-neutral-300",
|
|
1266
|
+
isPlannerRestricted && "opacity-60",
|
|
1267
|
+
)}
|
|
1268
|
+
>
|
|
1269
|
+
{t("wizard.common.selectAll")}
|
|
1270
|
+
</span>
|
|
1271
|
+
<Badge variant="primary" size="sm" className="ml-1">
|
|
1272
|
+
{selectionCounts.total}/{filteredInventories.length}
|
|
1273
|
+
</Badge>
|
|
1274
|
+
</div>
|
|
1275
|
+
<div className="flex items-center gap-2 text-sm text-mw-neutral-500">
|
|
1276
|
+
<span>{t("wizard.common.groupBy")}:</span>
|
|
1277
|
+
<SelectRoot value={groupBy} onValueChange={(value) => setGroupBy(value as GroupByOption)}>
|
|
1278
|
+
<SelectTrigger className="h-8 w-[160px] text-xs">
|
|
1279
|
+
<SelectValue />
|
|
1280
|
+
</SelectTrigger>
|
|
1281
|
+
<SelectContent>
|
|
1282
|
+
<SelectItem value="none">{t("wizard.common.allInventories")}</SelectItem>
|
|
1283
|
+
<SelectItem value="publisher">{t("wizard.common.publisher")}</SelectItem>
|
|
1284
|
+
<SelectItem value="location">{t("wizard.common.location")}</SelectItem>
|
|
1285
|
+
<SelectItem value="type">{t("wizard.common.type")}</SelectItem>
|
|
1286
|
+
</SelectContent>
|
|
1287
|
+
</SelectRoot>
|
|
1288
|
+
</div>
|
|
1289
|
+
</div>
|
|
1290
|
+
|
|
1291
|
+
{viewMode === "map" ? (
|
|
1292
|
+
<div className="flex-1 min-h-[400px] max-h-[500px] rounded-lg overflow-hidden border border-mw-neutral-200 dark:border-mw-neutral-700">
|
|
1293
|
+
<InventoryMapView
|
|
1294
|
+
inventories={filteredInventories.map((inv) => ({
|
|
1295
|
+
id: inv.id,
|
|
1296
|
+
name: inv.name,
|
|
1297
|
+
address: inv.address,
|
|
1298
|
+
tags: inv.tags,
|
|
1299
|
+
thumbnail: inv.thumbnail,
|
|
1300
|
+
type: inv.type,
|
|
1301
|
+
format: inv.format,
|
|
1302
|
+
mediaType: inv.mediaType,
|
|
1303
|
+
size: inv.size,
|
|
1304
|
+
publisherName: inv.publisherName,
|
|
1305
|
+
latitude: inv.latitude,
|
|
1306
|
+
longitude: inv.longitude,
|
|
1307
|
+
}))}
|
|
1308
|
+
selectedInventories={selectedInventories}
|
|
1309
|
+
onSelectInventory={(id) => {
|
|
1310
|
+
if (!isPlannerRestricted) {
|
|
1311
|
+
handleInventoryToggle(id);
|
|
1312
|
+
}
|
|
1313
|
+
}}
|
|
1314
|
+
onInventoryToggle={(id) => {
|
|
1315
|
+
if (!isPlannerRestricted) {
|
|
1316
|
+
handleInventoryToggle(id);
|
|
1317
|
+
}
|
|
1318
|
+
}}
|
|
1319
|
+
onViewDetails={(inv) => {
|
|
1320
|
+
const fullInv = filteredInventories.find((i) => i.id === inv.id);
|
|
1321
|
+
if (fullInv) {
|
|
1322
|
+
setViewDetailsInventory(fullInv);
|
|
1323
|
+
setIsViewDetailsOpen(true);
|
|
1324
|
+
}
|
|
1325
|
+
}}
|
|
1326
|
+
/>
|
|
1327
|
+
</div>
|
|
1328
|
+
) : (
|
|
1329
|
+
<div ref={scrollContainerRef} className="flex-1 overflow-y-auto space-y-3 max-h-[500px] pr-2">
|
|
1330
|
+
{isLoadingInventories ? (
|
|
1331
|
+
<div className="flex items-center justify-center py-8">
|
|
1332
|
+
<Loader2 className="h-6 w-6 animate-spin text-mw-primary-500" />
|
|
1333
|
+
<span className="ml-2 text-mw-neutral-500">
|
|
1334
|
+
{t("wizard.inventory.loadingInventories")}
|
|
1335
|
+
</span>
|
|
1336
|
+
</div>
|
|
1337
|
+
) : filteredInventories.length === 0 ? (
|
|
1338
|
+
<div className="text-center py-8 text-mw-neutral-500">
|
|
1339
|
+
No {getTabLabel().toLowerCase()} found
|
|
1340
|
+
</div>
|
|
1341
|
+
) : groupBy === "none" ? (
|
|
1342
|
+
filteredInventories.map((inventory) => (
|
|
1343
|
+
<PlannerInventoryCard
|
|
1344
|
+
key={inventory.id}
|
|
1345
|
+
id={inventory.id}
|
|
1346
|
+
name={inventory.name}
|
|
1347
|
+
location={inventory.address}
|
|
1348
|
+
tags={inventory.tags}
|
|
1349
|
+
planning={inventory.planning}
|
|
1350
|
+
screens={inventory.screens}
|
|
1351
|
+
owner={inventory.publisherName}
|
|
1352
|
+
publisherName={inventory.publisherName}
|
|
1353
|
+
thumbnail={inventory.thumbnail}
|
|
1354
|
+
currency={inventory.currency}
|
|
1355
|
+
isSelected={selectedInventories.includes(inventory.id)}
|
|
1356
|
+
onToggleSelect={
|
|
1357
|
+
isPlannerRestricted
|
|
1358
|
+
? undefined
|
|
1359
|
+
: () => handleInventoryToggle(inventory.id)
|
|
1360
|
+
}
|
|
1361
|
+
onViewDetails={() => {
|
|
1362
|
+
setViewDetailsInventory(inventory);
|
|
1363
|
+
setIsViewDetailsOpen(true);
|
|
1364
|
+
}}
|
|
1365
|
+
isReadOnly={isPlannerRestricted}
|
|
1366
|
+
referenceId={inventory.referenceId}
|
|
1367
|
+
estimatedCost={inventory.estimatedCostPerDay}
|
|
1368
|
+
finalScore={inventory.finalScore}
|
|
1369
|
+
why={inventory.why}
|
|
1370
|
+
availability={inventory.availability}
|
|
1371
|
+
componentScores={inventory.componentScores}
|
|
1372
|
+
showPlanningData={dealMode === "DIRECT"}
|
|
1373
|
+
/>
|
|
1374
|
+
))
|
|
1375
|
+
) : (
|
|
1376
|
+
groupedInventories.map((group) => (
|
|
1377
|
+
<div key={group.name} className="border border-mw-neutral-200 dark:border-mw-neutral-700 rounded-lg overflow-hidden">
|
|
1378
|
+
<div
|
|
1379
|
+
className="flex items-center justify-between px-4 py-3 bg-mw-neutral-50 dark:bg-mw-neutral-800 cursor-pointer hover:bg-mw-neutral-100 dark:hover:bg-mw-neutral-750"
|
|
1380
|
+
onClick={() => toggleGroupExpanded(group.name)}
|
|
1381
|
+
>
|
|
1382
|
+
<div className="flex items-center gap-3">
|
|
1383
|
+
<Checkbox
|
|
1384
|
+
checked={isGroupAllSelected(group)}
|
|
1385
|
+
onChange={(e) => {
|
|
1386
|
+
e.stopPropagation();
|
|
1387
|
+
handleSelectGroup(group);
|
|
1388
|
+
}}
|
|
1389
|
+
onClick={(e) => e.stopPropagation()}
|
|
1390
|
+
disabled={isPlannerRestricted}
|
|
1391
|
+
className={cn(isGroupPartiallySelected(group) && "data-[state=checked]:bg-mw-primary-300")}
|
|
1392
|
+
/>
|
|
1393
|
+
<div className="flex items-center gap-2">
|
|
1394
|
+
<span className="font-medium text-sm text-mw-neutral-900 dark:text-white">
|
|
1395
|
+
{group.name}
|
|
1396
|
+
</span>
|
|
1397
|
+
<Badge variant="secondary" size="sm" className="text-xs">
|
|
1398
|
+
{group.inventories.length} {group.inventories.length === 1 ? 'item' : 'items'}
|
|
1399
|
+
</Badge>
|
|
1400
|
+
</div>
|
|
1401
|
+
</div>
|
|
1402
|
+
<Button
|
|
1403
|
+
type="button"
|
|
1404
|
+
variant="ghost"
|
|
1405
|
+
size="sm"
|
|
1406
|
+
isIconOnly
|
|
1407
|
+
onClick={(e) => {
|
|
1408
|
+
e.stopPropagation();
|
|
1409
|
+
toggleGroupExpanded(group.name);
|
|
1410
|
+
}}
|
|
1411
|
+
>
|
|
1412
|
+
{isGroupExpanded(group.name) ? (
|
|
1413
|
+
<ChevronUp className="h-4 w-4 text-mw-neutral-500" />
|
|
1414
|
+
) : (
|
|
1415
|
+
<ChevronDown className="h-4 w-4 text-mw-neutral-500" />
|
|
1416
|
+
)}
|
|
1417
|
+
</Button>
|
|
1418
|
+
</div>
|
|
1419
|
+
{isGroupExpanded(group.name) && (
|
|
1420
|
+
<div className="p-3 space-y-3 bg-white dark:bg-mw-neutral-900">
|
|
1421
|
+
{group.inventories.map((inventory) => (
|
|
1422
|
+
<PlannerInventoryCard
|
|
1423
|
+
key={inventory.id}
|
|
1424
|
+
id={inventory.id}
|
|
1425
|
+
name={inventory.name}
|
|
1426
|
+
location={inventory.address}
|
|
1427
|
+
tags={inventory.tags}
|
|
1428
|
+
planning={inventory.planning}
|
|
1429
|
+
screens={inventory.screens}
|
|
1430
|
+
owner={inventory.publisherName}
|
|
1431
|
+
publisherName={inventory.publisherName}
|
|
1432
|
+
thumbnail={inventory.thumbnail}
|
|
1433
|
+
currency={inventory.currency}
|
|
1434
|
+
isSelected={selectedInventories.includes(inventory.id)}
|
|
1435
|
+
onToggleSelect={
|
|
1436
|
+
isPlannerRestricted
|
|
1437
|
+
? undefined
|
|
1438
|
+
: () => handleInventoryToggle(inventory.id)
|
|
1439
|
+
}
|
|
1440
|
+
onViewDetails={() => {
|
|
1441
|
+
setViewDetailsInventory(inventory);
|
|
1442
|
+
setIsViewDetailsOpen(true);
|
|
1443
|
+
}}
|
|
1444
|
+
isReadOnly={isPlannerRestricted}
|
|
1445
|
+
referenceId={inventory.referenceId}
|
|
1446
|
+
estimatedCost={inventory.estimatedCostPerDay}
|
|
1447
|
+
finalScore={inventory.finalScore}
|
|
1448
|
+
why={inventory.why}
|
|
1449
|
+
availability={inventory.availability}
|
|
1450
|
+
componentScores={inventory.componentScores}
|
|
1451
|
+
showPlanningData={dealMode === "DIRECT"}
|
|
1452
|
+
/>
|
|
1453
|
+
))}
|
|
1454
|
+
</div>
|
|
1455
|
+
)}
|
|
1456
|
+
</div>
|
|
1457
|
+
))
|
|
1458
|
+
)}
|
|
1459
|
+
|
|
1460
|
+
{/* Infinite scroll trigger - must be inside scrollable container */}
|
|
1461
|
+
<div ref={loadMoreRef} className="h-4" />
|
|
1462
|
+
</div>
|
|
1463
|
+
)}
|
|
1464
|
+
|
|
1465
|
+
{isFetchingMore && (
|
|
1466
|
+
<div className="flex items-center justify-center py-4">
|
|
1467
|
+
<Loader2 className="h-5 w-5 animate-spin text-mw-primary-500" />
|
|
1468
|
+
<span className="ml-2 text-sm text-mw-neutral-600 dark:text-mw-neutral-400">
|
|
1469
|
+
Loading more...
|
|
1470
|
+
</span>
|
|
1471
|
+
</div>
|
|
1472
|
+
)}
|
|
1473
|
+
|
|
1474
|
+
{totalItems > 0 && (
|
|
1475
|
+
<div className="flex items-center justify-center pt-3 border-t border-mw-neutral-100 dark:border-mw-neutral-800 mt-auto">
|
|
1476
|
+
<span className="text-[12px] text-mw-neutral-600 dark:text-mw-neutral-400">
|
|
1477
|
+
Showing {apiInventories.length} of {totalItems} inventories
|
|
1478
|
+
</span>
|
|
1479
|
+
</div>
|
|
1480
|
+
)}
|
|
1481
|
+
</div>
|
|
1482
|
+
|
|
1483
|
+
<div className="w-[220px] flex-shrink-0">
|
|
1484
|
+
<CampaignForecastPanel
|
|
1485
|
+
forecast={aggregatedForecast}
|
|
1486
|
+
currency="JPY"
|
|
1487
|
+
/>
|
|
1488
|
+
</div>
|
|
1489
|
+
</div>
|
|
1490
|
+
|
|
1491
|
+
<InventoryDetailsSheet
|
|
1492
|
+
inventory={viewDetailsInventory as InventoryDetailsItem | null}
|
|
1493
|
+
open={isViewDetailsOpen}
|
|
1494
|
+
onOpenChange={setIsViewDetailsOpen}
|
|
1495
|
+
/>
|
|
1496
|
+
|
|
1497
|
+
<AdvancedFiltersPanel
|
|
1498
|
+
isOpen={isAdvancedFiltersOpen}
|
|
1499
|
+
onClose={() => setIsAdvancedFiltersOpen(false)}
|
|
1500
|
+
onApply={(filters) => {
|
|
1501
|
+
setAdvancedFilters(filters);
|
|
1502
|
+
console.log("Applied advanced filters:", filters);
|
|
1503
|
+
}}
|
|
1504
|
+
initialValues={advancedFilters || undefined}
|
|
1505
|
+
/>
|
|
1506
|
+
|
|
1507
|
+
<InventoryAvailabilityView
|
|
1508
|
+
inventories={inventoriesData.map((inv): AvailabilityInventoryItem => ({
|
|
1509
|
+
id: inv.id,
|
|
1510
|
+
name: inv.name,
|
|
1511
|
+
address: inv.address,
|
|
1512
|
+
publisherName: inv.publisherName,
|
|
1513
|
+
}))}
|
|
1514
|
+
dateRange={{
|
|
1515
|
+
startDate: formatDateForAPI(flightStartDate),
|
|
1516
|
+
endDate: formatDateForAPI(flightEndDate),
|
|
1517
|
+
}}
|
|
1518
|
+
open={isAvailabilityViewOpen}
|
|
1519
|
+
onOpenChange={setIsAvailabilityViewOpen}
|
|
1520
|
+
/>
|
|
1521
|
+
|
|
1522
|
+
<CSVUploadModal
|
|
1523
|
+
open={isCsvUploadOpen}
|
|
1524
|
+
onOpenChange={setIsCsvUploadOpen}
|
|
1525
|
+
onComplete={(importedData) => {
|
|
1526
|
+
console.log("CSV imported:", importedData);
|
|
1527
|
+
setIsCsvUploadOpen(false);
|
|
1528
|
+
}}
|
|
1529
|
+
onCancel={() => setIsCsvUploadOpen(false)}
|
|
1530
|
+
/>
|
|
1531
|
+
</form>
|
|
1532
|
+
);
|
|
1533
|
+
}
|