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,639 @@
|
|
|
1
|
+
import { useState, useCallback, useRef, useMemo } from 'react';
|
|
2
|
+
import Papa from 'papaparse';
|
|
3
|
+
import {
|
|
4
|
+
Dialog,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogHeader,
|
|
7
|
+
DialogTitle,
|
|
8
|
+
} from '@moving-walls/design-system';
|
|
9
|
+
import { Button, cn } from '@moving-walls/design-system';
|
|
10
|
+
import { Select } from '@moving-walls/design-system';
|
|
11
|
+
import { Badge } from '@moving-walls/design-system';
|
|
12
|
+
import {
|
|
13
|
+
Upload,
|
|
14
|
+
FileSpreadsheet,
|
|
15
|
+
X,
|
|
16
|
+
ChevronLeft,
|
|
17
|
+
ChevronRight,
|
|
18
|
+
Check,
|
|
19
|
+
AlertCircle,
|
|
20
|
+
CheckCircle,
|
|
21
|
+
Loader2,
|
|
22
|
+
FileText,
|
|
23
|
+
Table2,
|
|
24
|
+
AlertTriangle,
|
|
25
|
+
} from 'lucide-react';
|
|
26
|
+
|
|
27
|
+
type Step = 'upload' | 'mapping' | 'validation' | 'complete';
|
|
28
|
+
|
|
29
|
+
interface ColumnMapping {
|
|
30
|
+
name: string | null;
|
|
31
|
+
address: string | null;
|
|
32
|
+
latitude: string | null;
|
|
33
|
+
longitude: string | null;
|
|
34
|
+
mediaOwner: string | null;
|
|
35
|
+
type: string | null;
|
|
36
|
+
size: string | null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface ValidationError {
|
|
40
|
+
row: number;
|
|
41
|
+
column: string;
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ParsedInventoryItem {
|
|
46
|
+
name?: string;
|
|
47
|
+
address?: string;
|
|
48
|
+
latitude?: number;
|
|
49
|
+
longitude?: number;
|
|
50
|
+
mediaOwner?: string;
|
|
51
|
+
type?: string;
|
|
52
|
+
size?: string;
|
|
53
|
+
[key: string]: string | number | undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface CSVUploadModalProps {
|
|
57
|
+
open: boolean;
|
|
58
|
+
onOpenChange: (open: boolean) => void;
|
|
59
|
+
onComplete?: (data: ParsedInventoryItem[]) => void;
|
|
60
|
+
onCancel?: () => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const REQUIRED_FIELDS = ['name', 'address', 'latitude', 'longitude'];
|
|
64
|
+
const OPTIONAL_FIELDS = ['mediaOwner', 'type', 'size'];
|
|
65
|
+
const ALL_FIELDS = [...REQUIRED_FIELDS, ...OPTIONAL_FIELDS];
|
|
66
|
+
|
|
67
|
+
const FIELD_LABELS: Record<string, string> = {
|
|
68
|
+
name: 'Name',
|
|
69
|
+
address: 'Address',
|
|
70
|
+
latitude: 'Latitude',
|
|
71
|
+
longitude: 'Longitude',
|
|
72
|
+
mediaOwner: 'Media Owner',
|
|
73
|
+
type: 'Type',
|
|
74
|
+
size: 'Size',
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const STEP_TITLES: Record<Step, string> = {
|
|
78
|
+
upload: 'Upload CSV',
|
|
79
|
+
mapping: 'Preview & Mapping',
|
|
80
|
+
validation: 'Validation',
|
|
81
|
+
complete: 'Import Complete',
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
function autoDetectColumn(headers: string[], targetField: string): string | null {
|
|
85
|
+
const patterns: Record<string, RegExp[]> = {
|
|
86
|
+
name: [/^name$/i, /^screen.?name$/i, /^inventory.?name$/i, /^title$/i],
|
|
87
|
+
address: [/^address$/i, /^location$/i, /^street$/i, /^full.?address$/i],
|
|
88
|
+
latitude: [/^lat$/i, /^latitude$/i, /^lat.?coord$/i],
|
|
89
|
+
longitude: [/^lon$/i, /^lng$/i, /^longitude$/i, /^long$/i, /^lon.?coord$/i],
|
|
90
|
+
mediaOwner: [/^media.?owner$/i, /^owner$/i, /^publisher$/i, /^vendor$/i],
|
|
91
|
+
type: [/^type$/i, /^screen.?type$/i, /^format$/i, /^category$/i],
|
|
92
|
+
size: [/^size$/i, /^dimension$/i, /^resolution$/i, /^screen.?size$/i],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const fieldPatterns = patterns[targetField] || [];
|
|
96
|
+
for (const header of headers) {
|
|
97
|
+
for (const pattern of fieldPatterns) {
|
|
98
|
+
if (pattern.test(header)) {
|
|
99
|
+
return header;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function CSVUploadModal({
|
|
107
|
+
open,
|
|
108
|
+
onOpenChange,
|
|
109
|
+
onComplete,
|
|
110
|
+
onCancel,
|
|
111
|
+
}: CSVUploadModalProps) {
|
|
112
|
+
const [currentStep, setCurrentStep] = useState<Step>('upload');
|
|
113
|
+
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
|
114
|
+
const [dragActive, setDragActive] = useState(false);
|
|
115
|
+
const [parsedData, setParsedData] = useState<Record<string, string>[]>([]);
|
|
116
|
+
const [headers, setHeaders] = useState<string[]>([]);
|
|
117
|
+
const [columnMapping, setColumnMapping] = useState<ColumnMapping>({
|
|
118
|
+
name: null,
|
|
119
|
+
address: null,
|
|
120
|
+
latitude: null,
|
|
121
|
+
longitude: null,
|
|
122
|
+
mediaOwner: null,
|
|
123
|
+
type: null,
|
|
124
|
+
size: null,
|
|
125
|
+
});
|
|
126
|
+
const [validationErrors, setValidationErrors] = useState<ValidationError[]>([]);
|
|
127
|
+
const [isValidating, setIsValidating] = useState(false);
|
|
128
|
+
const [importedCount, setImportedCount] = useState(0);
|
|
129
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
130
|
+
|
|
131
|
+
const handleDrag = useCallback((e: React.DragEvent) => {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
if (e.type === 'dragenter' || e.type === 'dragover') {
|
|
135
|
+
setDragActive(true);
|
|
136
|
+
} else if (e.type === 'dragleave') {
|
|
137
|
+
setDragActive(false);
|
|
138
|
+
}
|
|
139
|
+
}, []);
|
|
140
|
+
|
|
141
|
+
const parseCSVFile = (file: File) => {
|
|
142
|
+
Papa.parse(file, {
|
|
143
|
+
header: true,
|
|
144
|
+
skipEmptyLines: true,
|
|
145
|
+
complete: (results) => {
|
|
146
|
+
const data = results.data as Record<string, string>[];
|
|
147
|
+
const csvHeaders = results.meta.fields || [];
|
|
148
|
+
|
|
149
|
+
setParsedData(data);
|
|
150
|
+
setHeaders(csvHeaders);
|
|
151
|
+
|
|
152
|
+
const autoMapping: ColumnMapping = {
|
|
153
|
+
name: autoDetectColumn(csvHeaders, 'name'),
|
|
154
|
+
address: autoDetectColumn(csvHeaders, 'address'),
|
|
155
|
+
latitude: autoDetectColumn(csvHeaders, 'latitude'),
|
|
156
|
+
longitude: autoDetectColumn(csvHeaders, 'longitude'),
|
|
157
|
+
mediaOwner: autoDetectColumn(csvHeaders, 'mediaOwner'),
|
|
158
|
+
type: autoDetectColumn(csvHeaders, 'type'),
|
|
159
|
+
size: autoDetectColumn(csvHeaders, 'size'),
|
|
160
|
+
};
|
|
161
|
+
setColumnMapping(autoMapping);
|
|
162
|
+
setCurrentStep('mapping');
|
|
163
|
+
},
|
|
164
|
+
error: (error) => {
|
|
165
|
+
console.error('CSV parsing error:', error);
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const handleDrop = useCallback((e: React.DragEvent) => {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
setDragActive(false);
|
|
174
|
+
|
|
175
|
+
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
|
176
|
+
const file = e.dataTransfer.files[0];
|
|
177
|
+
if (file.type === 'text/csv' || file.name.endsWith('.csv')) {
|
|
178
|
+
setSelectedFile(file);
|
|
179
|
+
parseCSVFile(file);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, []);
|
|
183
|
+
|
|
184
|
+
const handleFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
185
|
+
if (e.target.files && e.target.files[0]) {
|
|
186
|
+
const file = e.target.files[0];
|
|
187
|
+
setSelectedFile(file);
|
|
188
|
+
parseCSVFile(file);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const handleMappingChange = (field: keyof ColumnMapping, value: string | null) => {
|
|
193
|
+
setColumnMapping((prev) => ({
|
|
194
|
+
...prev,
|
|
195
|
+
[field]: value === '' ? null : value,
|
|
196
|
+
}));
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const validateData = useCallback(() => {
|
|
200
|
+
setIsValidating(true);
|
|
201
|
+
const errors: ValidationError[] = [];
|
|
202
|
+
|
|
203
|
+
parsedData.forEach((row, index) => {
|
|
204
|
+
const rowNum = index + 2;
|
|
205
|
+
|
|
206
|
+
if (columnMapping.name) {
|
|
207
|
+
const nameValue = row[columnMapping.name];
|
|
208
|
+
if (!nameValue || nameValue.trim() === '') {
|
|
209
|
+
errors.push({ row: rowNum, column: 'Name', message: 'Name is required' });
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
errors.push({ row: rowNum, column: 'Name', message: 'Name column not mapped' });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (columnMapping.latitude) {
|
|
216
|
+
const latValue = row[columnMapping.latitude];
|
|
217
|
+
if (latValue) {
|
|
218
|
+
const lat = parseFloat(latValue);
|
|
219
|
+
if (isNaN(lat) || lat < -90 || lat > 90) {
|
|
220
|
+
errors.push({ row: rowNum, column: 'Latitude', message: `Invalid latitude value: ${latValue}` });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (columnMapping.longitude) {
|
|
226
|
+
const lngValue = row[columnMapping.longitude];
|
|
227
|
+
if (lngValue) {
|
|
228
|
+
const lng = parseFloat(lngValue);
|
|
229
|
+
if (isNaN(lng) || lng < -180 || lng > 180) {
|
|
230
|
+
errors.push({ row: rowNum, column: 'Longitude', message: `Invalid longitude value: ${lngValue}` });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
setValidationErrors(errors);
|
|
237
|
+
setIsValidating(false);
|
|
238
|
+
setCurrentStep('validation');
|
|
239
|
+
}, [parsedData, columnMapping]);
|
|
240
|
+
|
|
241
|
+
const handleImport = useCallback(() => {
|
|
242
|
+
const importedItems: ParsedInventoryItem[] = parsedData.map((row) => ({
|
|
243
|
+
name: columnMapping.name ? row[columnMapping.name] : undefined,
|
|
244
|
+
address: columnMapping.address ? row[columnMapping.address] : undefined,
|
|
245
|
+
latitude: columnMapping.latitude ? parseFloat(row[columnMapping.latitude]) : undefined,
|
|
246
|
+
longitude: columnMapping.longitude ? parseFloat(row[columnMapping.longitude]) : undefined,
|
|
247
|
+
mediaOwner: columnMapping.mediaOwner ? row[columnMapping.mediaOwner] : undefined,
|
|
248
|
+
type: columnMapping.type ? row[columnMapping.type] : undefined,
|
|
249
|
+
size: columnMapping.size ? row[columnMapping.size] : undefined,
|
|
250
|
+
}));
|
|
251
|
+
|
|
252
|
+
setImportedCount(importedItems.length);
|
|
253
|
+
setCurrentStep('complete');
|
|
254
|
+
onComplete?.(importedItems);
|
|
255
|
+
}, [parsedData, columnMapping, onComplete]);
|
|
256
|
+
|
|
257
|
+
const handleClose = useCallback(() => {
|
|
258
|
+
setCurrentStep('upload');
|
|
259
|
+
setSelectedFile(null);
|
|
260
|
+
setParsedData([]);
|
|
261
|
+
setHeaders([]);
|
|
262
|
+
setColumnMapping({
|
|
263
|
+
name: null,
|
|
264
|
+
address: null,
|
|
265
|
+
latitude: null,
|
|
266
|
+
longitude: null,
|
|
267
|
+
mediaOwner: null,
|
|
268
|
+
type: null,
|
|
269
|
+
size: null,
|
|
270
|
+
});
|
|
271
|
+
setValidationErrors([]);
|
|
272
|
+
setImportedCount(0);
|
|
273
|
+
onOpenChange(false);
|
|
274
|
+
}, [onOpenChange]);
|
|
275
|
+
|
|
276
|
+
const handleCancel = useCallback(() => {
|
|
277
|
+
onCancel?.();
|
|
278
|
+
handleClose();
|
|
279
|
+
}, [onCancel, handleClose]);
|
|
280
|
+
|
|
281
|
+
const handleBack = useCallback(() => {
|
|
282
|
+
if (currentStep === 'mapping') {
|
|
283
|
+
setCurrentStep('upload');
|
|
284
|
+
setSelectedFile(null);
|
|
285
|
+
setParsedData([]);
|
|
286
|
+
setHeaders([]);
|
|
287
|
+
} else if (currentStep === 'validation') {
|
|
288
|
+
setCurrentStep('mapping');
|
|
289
|
+
}
|
|
290
|
+
}, [currentStep]);
|
|
291
|
+
|
|
292
|
+
const previewData = useMemo(() => parsedData.slice(0, 5), [parsedData]);
|
|
293
|
+
|
|
294
|
+
const mappedFieldsCount = useMemo(() => {
|
|
295
|
+
return Object.values(columnMapping).filter((v) => v !== null).length;
|
|
296
|
+
}, [columnMapping]);
|
|
297
|
+
|
|
298
|
+
const requiredFieldsMapped = useMemo(() => {
|
|
299
|
+
return REQUIRED_FIELDS.every(
|
|
300
|
+
(field) => columnMapping[field as keyof ColumnMapping] !== null
|
|
301
|
+
);
|
|
302
|
+
}, [columnMapping]);
|
|
303
|
+
|
|
304
|
+
const renderUploadStep = () => (
|
|
305
|
+
<div className="space-y-6 py-6">
|
|
306
|
+
<div
|
|
307
|
+
className={cn(
|
|
308
|
+
'border-2 border-dashed rounded-lg p-8 text-center transition-colors cursor-pointer',
|
|
309
|
+
dragActive
|
|
310
|
+
? 'border-mw-primary-500 bg-mw-primary-50'
|
|
311
|
+
: 'border-mw-neutral-300 hover:border-mw-neutral-400'
|
|
312
|
+
)}
|
|
313
|
+
onDragEnter={handleDrag}
|
|
314
|
+
onDragLeave={handleDrag}
|
|
315
|
+
onDragOver={handleDrag}
|
|
316
|
+
onDrop={handleDrop}
|
|
317
|
+
onClick={() => fileInputRef.current?.click()}
|
|
318
|
+
>
|
|
319
|
+
<Upload className="h-12 w-12 text-mw-neutral-400 mx-auto mb-4" />
|
|
320
|
+
<p className="text-sm text-mw-neutral-700 mb-2">
|
|
321
|
+
Drag and drop your CSV file here, or{' '}
|
|
322
|
+
<span className="text-mw-primary-500 font-medium">click to browse</span>
|
|
323
|
+
</p>
|
|
324
|
+
<p className="text-xs text-mw-neutral-500">Supported format: CSV</p>
|
|
325
|
+
<input
|
|
326
|
+
ref={fileInputRef}
|
|
327
|
+
type="file"
|
|
328
|
+
accept=".csv"
|
|
329
|
+
onChange={handleFileSelect}
|
|
330
|
+
className="hidden"
|
|
331
|
+
/>
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<div className="flex justify-end gap-3">
|
|
335
|
+
<Button variant="outline" onClick={handleCancel}>
|
|
336
|
+
Cancel
|
|
337
|
+
</Button>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
const renderMappingStep = () => (
|
|
343
|
+
<div className="space-y-6 py-4">
|
|
344
|
+
<div className="flex items-center gap-3 p-3 bg-mw-neutral-50 rounded-lg">
|
|
345
|
+
<FileText className="h-5 w-5 text-mw-primary-500" />
|
|
346
|
+
<div>
|
|
347
|
+
<p className="text-sm font-medium text-mw-neutral-900">{selectedFile?.name}</p>
|
|
348
|
+
<p className="text-xs text-mw-neutral-500">
|
|
349
|
+
{parsedData.length} rows found • {headers.length} columns detected
|
|
350
|
+
</p>
|
|
351
|
+
</div>
|
|
352
|
+
</div>
|
|
353
|
+
|
|
354
|
+
<div className="space-y-4">
|
|
355
|
+
<h4 className="text-sm font-medium text-mw-neutral-900">Column Mapping</h4>
|
|
356
|
+
<div className="grid grid-cols-2 gap-4">
|
|
357
|
+
{ALL_FIELDS.map((field) => (
|
|
358
|
+
<div key={field} className="space-y-1.5">
|
|
359
|
+
<label className="text-xs font-medium text-mw-neutral-700 flex items-center gap-1">
|
|
360
|
+
{FIELD_LABELS[field]}
|
|
361
|
+
{REQUIRED_FIELDS.includes(field) && (
|
|
362
|
+
<span className="text-mw-error-500">*</span>
|
|
363
|
+
)}
|
|
364
|
+
</label>
|
|
365
|
+
<Select
|
|
366
|
+
value={columnMapping[field as keyof ColumnMapping] || ''}
|
|
367
|
+
onChange={(e) =>
|
|
368
|
+
handleMappingChange(field as keyof ColumnMapping, e.target.value)
|
|
369
|
+
}
|
|
370
|
+
options={headers.map((header) => ({ value: header, label: header }))}
|
|
371
|
+
placeholder="Select column..."
|
|
372
|
+
className="w-full"
|
|
373
|
+
/>
|
|
374
|
+
</div>
|
|
375
|
+
))}
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
|
|
379
|
+
<div className="space-y-2">
|
|
380
|
+
<div className="flex items-center justify-between">
|
|
381
|
+
<h4 className="text-sm font-medium text-mw-neutral-900">Preview</h4>
|
|
382
|
+
<Badge variant="secondary" className="text-xs">
|
|
383
|
+
Showing first 5 of {parsedData.length} rows
|
|
384
|
+
</Badge>
|
|
385
|
+
</div>
|
|
386
|
+
<div className="border rounded-lg overflow-x-auto">
|
|
387
|
+
<table className="w-full text-xs">
|
|
388
|
+
<thead className="bg-mw-neutral-50">
|
|
389
|
+
<tr>
|
|
390
|
+
{headers.slice(0, 6).map((header) => (
|
|
391
|
+
<th
|
|
392
|
+
key={header}
|
|
393
|
+
className="px-3 py-2 text-left font-medium text-mw-neutral-700 whitespace-nowrap"
|
|
394
|
+
>
|
|
395
|
+
{header}
|
|
396
|
+
</th>
|
|
397
|
+
))}
|
|
398
|
+
{headers.length > 6 && (
|
|
399
|
+
<th className="px-3 py-2 text-left font-medium text-mw-neutral-500">
|
|
400
|
+
+{headers.length - 6} more
|
|
401
|
+
</th>
|
|
402
|
+
)}
|
|
403
|
+
</tr>
|
|
404
|
+
</thead>
|
|
405
|
+
<tbody className="divide-y divide-mw-neutral-200">
|
|
406
|
+
{previewData.map((row, idx) => (
|
|
407
|
+
<tr key={idx}>
|
|
408
|
+
{headers.slice(0, 6).map((header) => (
|
|
409
|
+
<td
|
|
410
|
+
key={header}
|
|
411
|
+
className="px-3 py-2 text-mw-neutral-600 whitespace-nowrap max-w-[150px] truncate"
|
|
412
|
+
>
|
|
413
|
+
{row[header] || '-'}
|
|
414
|
+
</td>
|
|
415
|
+
))}
|
|
416
|
+
{headers.length > 6 && <td className="px-3 py-2">...</td>}
|
|
417
|
+
</tr>
|
|
418
|
+
))}
|
|
419
|
+
</tbody>
|
|
420
|
+
</table>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
|
|
424
|
+
<div className="flex justify-between gap-3 pt-2">
|
|
425
|
+
<Button variant="outline" onClick={handleBack}>
|
|
426
|
+
<ChevronLeft className="h-4 w-4 mr-1" />
|
|
427
|
+
Back
|
|
428
|
+
</Button>
|
|
429
|
+
<div className="flex gap-3">
|
|
430
|
+
<Button variant="outline" onClick={handleCancel}>
|
|
431
|
+
Cancel
|
|
432
|
+
</Button>
|
|
433
|
+
<Button onClick={validateData} disabled={!requiredFieldsMapped}>
|
|
434
|
+
Next
|
|
435
|
+
<ChevronRight className="h-4 w-4 ml-1" />
|
|
436
|
+
</Button>
|
|
437
|
+
</div>
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
const renderValidationStep = () => (
|
|
443
|
+
<div className="space-y-6 py-4">
|
|
444
|
+
{isValidating ? (
|
|
445
|
+
<div className="flex flex-col items-center justify-center py-12">
|
|
446
|
+
<Loader2 className="h-8 w-8 text-mw-primary-500 animate-spin mb-4" />
|
|
447
|
+
<p className="text-sm text-mw-neutral-600">Validating data...</p>
|
|
448
|
+
</div>
|
|
449
|
+
) : (
|
|
450
|
+
<>
|
|
451
|
+
<div
|
|
452
|
+
className={cn(
|
|
453
|
+
'p-4 rounded-lg flex items-start gap-3',
|
|
454
|
+
validationErrors.length === 0
|
|
455
|
+
? 'bg-mw-success-50'
|
|
456
|
+
: 'bg-mw-warning-50'
|
|
457
|
+
)}
|
|
458
|
+
>
|
|
459
|
+
{validationErrors.length === 0 ? (
|
|
460
|
+
<>
|
|
461
|
+
<CheckCircle className="h-5 w-5 text-mw-success-600 mt-0.5" />
|
|
462
|
+
<div>
|
|
463
|
+
<p className="text-sm font-medium text-mw-success-700">
|
|
464
|
+
Validation Successful
|
|
465
|
+
</p>
|
|
466
|
+
<p className="text-xs text-mw-success-600 mt-1">
|
|
467
|
+
All {parsedData.length} rows passed validation and are ready to import.
|
|
468
|
+
</p>
|
|
469
|
+
</div>
|
|
470
|
+
</>
|
|
471
|
+
) : (
|
|
472
|
+
<>
|
|
473
|
+
<AlertTriangle className="h-5 w-5 text-mw-warning-600 mt-0.5" />
|
|
474
|
+
<div>
|
|
475
|
+
<p className="text-sm font-medium text-mw-warning-700">
|
|
476
|
+
Validation Warnings
|
|
477
|
+
</p>
|
|
478
|
+
<p className="text-xs text-mw-warning-600 mt-1">
|
|
479
|
+
Found {validationErrors.length} issue(s) in the data. You can proceed or go back to fix.
|
|
480
|
+
</p>
|
|
481
|
+
</div>
|
|
482
|
+
</>
|
|
483
|
+
)}
|
|
484
|
+
</div>
|
|
485
|
+
|
|
486
|
+
{validationErrors.length > 0 && (
|
|
487
|
+
<div className="space-y-2">
|
|
488
|
+
<h4 className="text-sm font-medium text-mw-neutral-900">
|
|
489
|
+
Issues Found
|
|
490
|
+
</h4>
|
|
491
|
+
<div className="border rounded-lg max-h-[200px] overflow-y-auto">
|
|
492
|
+
<table className="w-full text-xs">
|
|
493
|
+
<thead className="bg-mw-neutral-50 sticky top-0">
|
|
494
|
+
<tr>
|
|
495
|
+
<th className="px-3 py-2 text-left font-medium text-mw-neutral-700">
|
|
496
|
+
Row
|
|
497
|
+
</th>
|
|
498
|
+
<th className="px-3 py-2 text-left font-medium text-mw-neutral-700">
|
|
499
|
+
Column
|
|
500
|
+
</th>
|
|
501
|
+
<th className="px-3 py-2 text-left font-medium text-mw-neutral-700">
|
|
502
|
+
Issue
|
|
503
|
+
</th>
|
|
504
|
+
</tr>
|
|
505
|
+
</thead>
|
|
506
|
+
<tbody className="divide-y divide-mw-neutral-200">
|
|
507
|
+
{validationErrors.slice(0, 50).map((error, idx) => (
|
|
508
|
+
<tr key={idx}>
|
|
509
|
+
<td className="px-3 py-2 text-mw-neutral-600">
|
|
510
|
+
{error.row}
|
|
511
|
+
</td>
|
|
512
|
+
<td className="px-3 py-2 text-mw-neutral-600">
|
|
513
|
+
{error.column}
|
|
514
|
+
</td>
|
|
515
|
+
<td className="px-3 py-2 text-mw-error-600">
|
|
516
|
+
{error.message}
|
|
517
|
+
</td>
|
|
518
|
+
</tr>
|
|
519
|
+
))}
|
|
520
|
+
</tbody>
|
|
521
|
+
</table>
|
|
522
|
+
</div>
|
|
523
|
+
{validationErrors.length > 50 && (
|
|
524
|
+
<p className="text-xs text-mw-neutral-500">
|
|
525
|
+
Showing first 50 of {validationErrors.length} issues
|
|
526
|
+
</p>
|
|
527
|
+
)}
|
|
528
|
+
</div>
|
|
529
|
+
)}
|
|
530
|
+
|
|
531
|
+
<div className="p-3 bg-mw-neutral-50 rounded-lg">
|
|
532
|
+
<div className="flex items-center justify-between text-sm">
|
|
533
|
+
<span className="text-mw-neutral-600">Total rows to import:</span>
|
|
534
|
+
<span className="font-medium text-mw-neutral-900">
|
|
535
|
+
{parsedData.length}
|
|
536
|
+
</span>
|
|
537
|
+
</div>
|
|
538
|
+
</div>
|
|
539
|
+
|
|
540
|
+
<div className="flex justify-between gap-3 pt-2">
|
|
541
|
+
<Button variant="outline" onClick={handleBack}>
|
|
542
|
+
<ChevronLeft className="h-4 w-4 mr-1" />
|
|
543
|
+
Back
|
|
544
|
+
</Button>
|
|
545
|
+
<div className="flex gap-3">
|
|
546
|
+
<Button variant="outline" onClick={handleCancel}>
|
|
547
|
+
Cancel
|
|
548
|
+
</Button>
|
|
549
|
+
<Button onClick={handleImport}>
|
|
550
|
+
Import {parsedData.length} Items
|
|
551
|
+
<Check className="h-4 w-4 ml-1" />
|
|
552
|
+
</Button>
|
|
553
|
+
</div>
|
|
554
|
+
</div>
|
|
555
|
+
</>
|
|
556
|
+
)}
|
|
557
|
+
</div>
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
const renderCompleteStep = () => (
|
|
561
|
+
<div className="space-y-6 py-8">
|
|
562
|
+
<div className="flex flex-col items-center text-center">
|
|
563
|
+
<div className="h-16 w-16 rounded-full bg-mw-success-100 flex items-center justify-center mb-4">
|
|
564
|
+
<CheckCircle className="h-8 w-8 text-mw-success-600" />
|
|
565
|
+
</div>
|
|
566
|
+
<h3 className="text-lg font-semibold text-mw-neutral-900 mb-2">
|
|
567
|
+
Import Successful!
|
|
568
|
+
</h3>
|
|
569
|
+
<p className="text-sm text-mw-neutral-600">
|
|
570
|
+
Successfully imported {importedCount} inventory items.
|
|
571
|
+
</p>
|
|
572
|
+
</div>
|
|
573
|
+
|
|
574
|
+
<div className="flex justify-center">
|
|
575
|
+
<Button onClick={handleClose}>Close</Button>
|
|
576
|
+
</div>
|
|
577
|
+
</div>
|
|
578
|
+
);
|
|
579
|
+
|
|
580
|
+
const renderStepContent = () => {
|
|
581
|
+
switch (currentStep) {
|
|
582
|
+
case 'upload':
|
|
583
|
+
return renderUploadStep();
|
|
584
|
+
case 'mapping':
|
|
585
|
+
return renderMappingStep();
|
|
586
|
+
case 'validation':
|
|
587
|
+
return renderValidationStep();
|
|
588
|
+
case 'complete':
|
|
589
|
+
return renderCompleteStep();
|
|
590
|
+
default:
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
const stepIndicators = ['upload', 'mapping', 'validation', 'complete'] as const;
|
|
596
|
+
const currentStepIndex = stepIndicators.indexOf(currentStep);
|
|
597
|
+
|
|
598
|
+
return (
|
|
599
|
+
<Dialog open={open} onOpenChange={handleClose}>
|
|
600
|
+
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
|
601
|
+
<DialogHeader className="pb-4 border-b">
|
|
602
|
+
<div className="flex items-center justify-between">
|
|
603
|
+
<div className="flex items-center gap-3">
|
|
604
|
+
<div className="h-10 w-10 rounded-lg bg-mw-primary-100 flex items-center justify-center">
|
|
605
|
+
<FileSpreadsheet className="h-5 w-5 text-mw-primary-600" />
|
|
606
|
+
</div>
|
|
607
|
+
<div>
|
|
608
|
+
<DialogTitle>{STEP_TITLES[currentStep]}</DialogTitle>
|
|
609
|
+
<p className="text-xs text-mw-neutral-500 mt-0.5">
|
|
610
|
+
Step {currentStepIndex + 1} of 4
|
|
611
|
+
</p>
|
|
612
|
+
</div>
|
|
613
|
+
</div>
|
|
614
|
+
<Button variant="ghost" size="sm" onClick={handleClose}>
|
|
615
|
+
<X className="w-4 h-4" />
|
|
616
|
+
</Button>
|
|
617
|
+
</div>
|
|
618
|
+
|
|
619
|
+
<div className="flex items-center gap-2 mt-4">
|
|
620
|
+
{stepIndicators.map((step, idx) => (
|
|
621
|
+
<div key={step} className="flex items-center flex-1">
|
|
622
|
+
<div
|
|
623
|
+
className={cn(
|
|
624
|
+
'h-2 flex-1 rounded-full transition-colors',
|
|
625
|
+
idx <= currentStepIndex
|
|
626
|
+
? 'bg-mw-primary-500'
|
|
627
|
+
: 'bg-mw-neutral-200'
|
|
628
|
+
)}
|
|
629
|
+
/>
|
|
630
|
+
</div>
|
|
631
|
+
))}
|
|
632
|
+
</div>
|
|
633
|
+
</DialogHeader>
|
|
634
|
+
|
|
635
|
+
{renderStepContent()}
|
|
636
|
+
</DialogContent>
|
|
637
|
+
</Dialog>
|
|
638
|
+
);
|
|
639
|
+
}
|