@open-mercato/core 0.6.6-develop.6094.1.28b081ea16 → 0.6.6-develop.6121.1.5797a901b3
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/.turbo/turbo-build.log +1 -1
- package/dist/generated/entities/catalog_product/index.js +52 -0
- package/dist/generated/entities/catalog_product/index.js.map +2 -2
- package/dist/generated/entities/catalog_product_variant/index.js +4 -0
- package/dist/generated/entities/catalog_product_variant/index.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +28 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/catalog/api/products/route.js +103 -33
- package/dist/modules/catalog/api/products/route.js.map +2 -2
- package/dist/modules/catalog/api/variants/route.js +4 -0
- package/dist/modules/catalog/api/variants/route.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +46 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js +4 -0
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js +2 -0
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +42 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +251 -14
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/variants.js +72 -1
- package/dist/modules/catalog/commands/variants.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductComplianceSection.js +500 -0
- package/dist/modules/catalog/components/products/ProductComplianceSection.js.map +7 -0
- package/dist/modules/catalog/components/products/VariantBuilder.js +39 -1
- package/dist/modules/catalog/components/products/VariantBuilder.js.map +2 -2
- package/dist/modules/catalog/components/products/productForm.js +164 -2
- package/dist/modules/catalog/components/products/productForm.js.map +2 -2
- package/dist/modules/catalog/components/products/variantForm.js +2 -0
- package/dist/modules/catalog/components/products/variantForm.js.map +2 -2
- package/dist/modules/catalog/data/entities.js +93 -0
- package/dist/modules/catalog/data/entities.js.map +2 -2
- package/dist/modules/catalog/data/types.js +28 -0
- package/dist/modules/catalog/data/types.js.map +2 -2
- package/dist/modules/catalog/data/validators.js +100 -5
- package/dist/modules/catalog/data/validators.js.map +2 -2
- package/dist/modules/catalog/lib/gtin.js +61 -0
- package/dist/modules/catalog/lib/gtin.js.map +7 -0
- package/dist/modules/catalog/migrations/Migration20260611090000.js +17 -0
- package/dist/modules/catalog/migrations/Migration20260611090000.js.map +7 -0
- package/dist/modules/catalog/translations.js +1 -1
- package/dist/modules/catalog/translations.js.map +2 -2
- package/dist/modules/configs/api/cache/route.js +60 -10
- package/dist/modules/configs/api/cache/route.js.map +3 -3
- package/dist/modules/configs/components/CachePanel.js +52 -29
- package/dist/modules/configs/components/CachePanel.js.map +2 -2
- package/dist/modules/currencies/api/currencies/options/route.js +18 -4
- package/dist/modules/currencies/api/currencies/options/route.js.map +2 -2
- package/dist/modules/currencies/services/rateFetchingService.js +35 -18
- package/dist/modules/currencies/services/rateFetchingService.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js +16 -16
- package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js +1 -1
- package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +2 -2
- package/dist/modules/customers/backend/calendar/page.js +10 -0
- package/dist/modules/customers/backend/calendar/page.js.map +7 -0
- package/dist/modules/customers/backend/calendar/page.meta.js +25 -0
- package/dist/modules/customers/backend/calendar/page.meta.js.map +7 -0
- package/dist/modules/customers/cli.js +1 -0
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/components/calendar/AgendaList.js +182 -0
- package/dist/modules/customers/components/calendar/AgendaList.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js +331 -0
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarFooter.js +48 -0
- package/dist/modules/customers/components/calendar/CalendarFooter.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarHeader.js +36 -0
- package/dist/modules/customers/components/calendar/CalendarHeader.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarScreen.js +516 -0
- package/dist/modules/customers/components/calendar/CalendarScreen.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarSettingsModal.js +163 -0
- package/dist/modules/customers/components/calendar/CalendarSettingsModal.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarTabs.js +60 -0
- package/dist/modules/customers/components/calendar/CalendarTabs.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarToolbar.js +262 -0
- package/dist/modules/customers/components/calendar/CalendarToolbar.js.map +7 -0
- package/dist/modules/customers/components/calendar/EventBlock.js +149 -0
- package/dist/modules/customers/components/calendar/EventBlock.js.map +7 -0
- package/dist/modules/customers/components/calendar/EventPeekPopover.js +72 -0
- package/dist/modules/customers/components/calendar/EventPeekPopover.js.map +7 -0
- package/dist/modules/customers/components/calendar/MonthGrid.js +214 -0
- package/dist/modules/customers/components/calendar/MonthGrid.js.map +7 -0
- package/dist/modules/customers/components/calendar/ShortcutsDialog.js +44 -0
- package/dist/modules/customers/components/calendar/ShortcutsDialog.js.map +7 -0
- package/dist/modules/customers/components/calendar/TimeGrid.js +410 -0
- package/dist/modules/customers/components/calendar/TimeGrid.js.map +7 -0
- package/dist/modules/customers/components/calendar/UpcomingCards.js +175 -0
- package/dist/modules/customers/components/calendar/UpcomingCards.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/CategoryField.js +75 -0
- package/dist/modules/customers/components/calendar/editor/CategoryField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/LocationField.js +30 -0
- package/dist/modules/customers/components/calendar/editor/LocationField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/PeopleField.js +135 -0
- package/dist/modules/customers/components/calendar/editor/PeopleField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/RelatedToField.js +218 -0
- package/dist/modules/customers/components/calendar/editor/RelatedToField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/RepeatField.js +119 -0
- package/dist/modules/customers/components/calendar/editor/RepeatField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/ScheduleSection.js +83 -0
- package/dist/modules/customers/components/calendar/editor/ScheduleSection.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/SegmentGroup.js +44 -0
- package/dist/modules/customers/components/calendar/editor/SegmentGroup.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/hooks.js +132 -0
- package/dist/modules/customers/components/calendar/editor/hooks.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/inputs.js +160 -0
- package/dist/modules/customers/components/calendar/editor/inputs.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/lookups.js +107 -0
- package/dist/modules/customers/components/calendar/editor/lookups.js.map +7 -0
- package/dist/modules/customers/components/calendar/types.js +30 -0
- package/dist/modules/customers/components/calendar/types.js.map +7 -0
- package/dist/modules/customers/components/calendar/useCalendarItems.js +131 -0
- package/dist/modules/customers/components/calendar/useCalendarItems.js.map +7 -0
- package/dist/modules/customers/components/calendar/useCalendarPreferences.js +41 -0
- package/dist/modules/customers/components/calendar/useCalendarPreferences.js.map +7 -0
- package/dist/modules/customers/lib/calendar/categories.js +28 -0
- package/dist/modules/customers/lib/calendar/categories.js.map +7 -0
- package/dist/modules/customers/lib/calendar/conflicts.js +72 -0
- package/dist/modules/customers/lib/calendar/conflicts.js.map +7 -0
- package/dist/modules/customers/lib/calendar/editorPayload.js +271 -0
- package/dist/modules/customers/lib/calendar/editorPayload.js.map +7 -0
- package/dist/modules/customers/lib/calendar/grid.js +48 -0
- package/dist/modules/customers/lib/calendar/grid.js.map +7 -0
- package/dist/modules/customers/lib/calendar/layout.js +39 -0
- package/dist/modules/customers/lib/calendar/layout.js.map +7 -0
- package/dist/modules/customers/lib/calendar/mapItem.js +79 -0
- package/dist/modules/customers/lib/calendar/mapItem.js.map +7 -0
- package/dist/modules/customers/lib/calendar/preferences.js +71 -0
- package/dist/modules/customers/lib/calendar/preferences.js.map +7 -0
- package/dist/modules/customers/lib/calendar/range.js +46 -0
- package/dist/modules/customers/lib/calendar/range.js.map +7 -0
- package/dist/modules/customers/lib/calendar/recurrence.js +113 -0
- package/dist/modules/customers/lib/calendar/recurrence.js.map +7 -0
- package/dist/modules/dashboards/services/widgetDataService.js +5 -5
- package/dist/modules/dashboards/services/widgetDataService.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +61 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +33 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js +61 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/route.js +33 -1
- package/dist/modules/dictionaries/api/route.js.map +2 -2
- package/dist/modules/feature_toggles/lib/queries.js +36 -52
- package/dist/modules/feature_toggles/lib/queries.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/[perspectiveId]/route.js +32 -1
- package/dist/modules/perspectives/api/[tableId]/[perspectiveId]/route.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/roles/[roleId]/route.js +32 -1
- package/dist/modules/perspectives/api/[tableId]/roles/[roleId]/route.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/route.js +73 -2
- package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
- package/dist/modules/perspectives/services/perspectiveService.js +5 -3
- package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
- package/dist/modules/planner/api/access.js +9 -0
- package/dist/modules/planner/api/access.js.map +2 -2
- package/dist/modules/planner/api/availability-date-specific.js +22 -1
- package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
- package/dist/modules/planner/api/availability-weekly.js +22 -1
- package/dist/modules/planner/api/availability-weekly.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/assign/route.js +39 -0
- package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/unassign/route.js +39 -0
- package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
- package/dist/modules/sales/api/settings/document-numbers/route.js +33 -1
- package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
- package/dist/modules/sales/api/settings/order-editing/route.js +35 -3
- package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js +41 -0
- package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js +41 -0
- package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/self/route.js +40 -0
- package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js +41 -0
- package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js +41 -0
- package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js +61 -1
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
- package/dist/modules/translations/api/context.js +7 -0
- package/dist/modules/translations/api/context.js.map +2 -2
- package/dist/modules/translations/api/put/locales.js +33 -1
- package/dist/modules/translations/api/put/locales.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +6 -7
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.js.map +1 -1
- package/dist/modules/workflows/components/EdgeEditDialog.js.map +1 -1
- package/dist/modules/workflows/components/EdgeEditDialogCrudForm.js.map +1 -1
- package/dist/modules/workflows/components/NodeEditDialog.js.map +1 -1
- package/dist/modules/workflows/components/NodeEditDialogCrudForm.js.map +1 -1
- package/dist/modules/workflows/components/WorkflowGraph.js.map +1 -1
- package/dist/modules/workflows/components/WorkflowGraphImpl.js +17 -9
- package/dist/modules/workflows/components/WorkflowGraphImpl.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileVisualEditor.js.map +1 -1
- package/dist/modules/workflows/frontend/checkout-demo/deriveCurrentStep.js +8 -0
- package/dist/modules/workflows/frontend/checkout-demo/deriveCurrentStep.js.map +7 -0
- package/dist/modules/workflows/frontend/checkout-demo/page.js +2 -20
- package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
- package/dist/modules/workflows/lib/graph-utils.js +8 -0
- package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
- package/generated/entities/catalog_product/index.ts +26 -0
- package/generated/entities/catalog_product_variant/index.ts +2 -0
- package/generated/entity-fields-registry.ts +28 -0
- package/package.json +7 -7
- package/src/modules/catalog/api/products/route.ts +123 -39
- package/src/modules/catalog/api/variants/route.ts +4 -0
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +43 -0
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +14 -0
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/create/page.tsx +2 -0
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +41 -0
- package/src/modules/catalog/commands/products.ts +307 -2
- package/src/modules/catalog/commands/variants.ts +90 -1
- package/src/modules/catalog/components/products/ProductComplianceSection.tsx +497 -0
- package/src/modules/catalog/components/products/VariantBuilder.tsx +43 -0
- package/src/modules/catalog/components/products/productForm.ts +262 -0
- package/src/modules/catalog/components/products/variantForm.ts +4 -0
- package/src/modules/catalog/data/entities.ts +97 -0
- package/src/modules/catalog/data/types.ts +36 -0
- package/src/modules/catalog/data/validators.ts +159 -3
- package/src/modules/catalog/i18n/de.json +64 -0
- package/src/modules/catalog/i18n/en.json +64 -0
- package/src/modules/catalog/i18n/es.json +64 -0
- package/src/modules/catalog/i18n/pl.json +64 -0
- package/src/modules/catalog/lib/gtin.ts +66 -0
- package/src/modules/catalog/migrations/.snapshot-open-mercato.json +457 -0
- package/src/modules/catalog/migrations/Migration20260611090000.ts +17 -0
- package/src/modules/catalog/translations.ts +1 -1
- package/src/modules/configs/api/cache/route.ts +72 -10
- package/src/modules/configs/components/CachePanel.tsx +59 -29
- package/src/modules/currencies/api/currencies/options/route.ts +22 -4
- package/src/modules/currencies/services/rateFetchingService.ts +63 -26
- package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/page.tsx +18 -18
- package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +1 -1
- package/src/modules/customer_accounts/i18n/de.json +1 -1
- package/src/modules/customer_accounts/i18n/en.json +1 -1
- package/src/modules/customer_accounts/i18n/es.json +1 -1
- package/src/modules/customer_accounts/i18n/pl.json +1 -1
- package/src/modules/customers/backend/calendar/page.meta.ts +23 -0
- package/src/modules/customers/backend/calendar/page.tsx +12 -0
- package/src/modules/customers/cli.ts +1 -0
- package/src/modules/customers/components/calendar/AgendaList.tsx +219 -0
- package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +386 -0
- package/src/modules/customers/components/calendar/CalendarFooter.tsx +61 -0
- package/src/modules/customers/components/calendar/CalendarHeader.tsx +40 -0
- package/src/modules/customers/components/calendar/CalendarScreen.tsx +590 -0
- package/src/modules/customers/components/calendar/CalendarSettingsModal.tsx +207 -0
- package/src/modules/customers/components/calendar/CalendarTabs.tsx +63 -0
- package/src/modules/customers/components/calendar/CalendarToolbar.tsx +295 -0
- package/src/modules/customers/components/calendar/EventBlock.tsx +205 -0
- package/src/modules/customers/components/calendar/EventPeekPopover.tsx +100 -0
- package/src/modules/customers/components/calendar/MonthGrid.tsx +236 -0
- package/src/modules/customers/components/calendar/ShortcutsDialog.tsx +57 -0
- package/src/modules/customers/components/calendar/TimeGrid.tsx +510 -0
- package/src/modules/customers/components/calendar/UpcomingCards.tsx +220 -0
- package/src/modules/customers/components/calendar/editor/CategoryField.tsx +79 -0
- package/src/modules/customers/components/calendar/editor/LocationField.tsx +37 -0
- package/src/modules/customers/components/calendar/editor/PeopleField.tsx +148 -0
- package/src/modules/customers/components/calendar/editor/RelatedToField.tsx +242 -0
- package/src/modules/customers/components/calendar/editor/RepeatField.tsx +132 -0
- package/src/modules/customers/components/calendar/editor/ScheduleSection.tsx +110 -0
- package/src/modules/customers/components/calendar/editor/SegmentGroup.tsx +50 -0
- package/src/modules/customers/components/calendar/editor/hooks.ts +162 -0
- package/src/modules/customers/components/calendar/editor/inputs.tsx +158 -0
- package/src/modules/customers/components/calendar/editor/lookups.ts +160 -0
- package/src/modules/customers/components/calendar/types.ts +163 -0
- package/src/modules/customers/components/calendar/useCalendarItems.ts +162 -0
- package/src/modules/customers/components/calendar/useCalendarPreferences.ts +52 -0
- package/src/modules/customers/i18n/de.json +195 -0
- package/src/modules/customers/i18n/en.json +195 -0
- package/src/modules/customers/i18n/es.json +195 -0
- package/src/modules/customers/i18n/pl.json +195 -0
- package/src/modules/customers/lib/calendar/categories.ts +26 -0
- package/src/modules/customers/lib/calendar/conflicts.ts +117 -0
- package/src/modules/customers/lib/calendar/editorPayload.ts +388 -0
- package/src/modules/customers/lib/calendar/grid.ts +50 -0
- package/src/modules/customers/lib/calendar/layout.ts +47 -0
- package/src/modules/customers/lib/calendar/mapItem.ts +94 -0
- package/src/modules/customers/lib/calendar/preferences.ts +95 -0
- package/src/modules/customers/lib/calendar/range.ts +45 -0
- package/src/modules/customers/lib/calendar/recurrence.ts +137 -0
- package/src/modules/dashboards/services/widgetDataService.ts +8 -6
- package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +61 -1
- package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +33 -1
- package/src/modules/dictionaries/api/[dictionaryId]/route.ts +65 -1
- package/src/modules/dictionaries/api/route.ts +36 -1
- package/src/modules/feature_toggles/lib/queries.ts +41 -60
- package/src/modules/perspectives/api/[tableId]/[perspectiveId]/route.ts +34 -1
- package/src/modules/perspectives/api/[tableId]/roles/[roleId]/route.ts +34 -1
- package/src/modules/perspectives/api/[tableId]/route.ts +107 -32
- package/src/modules/perspectives/services/perspectiveService.ts +9 -5
- package/src/modules/planner/api/access.ts +9 -0
- package/src/modules/planner/api/availability-date-specific.ts +22 -1
- package/src/modules/planner/api/availability-weekly.ts +22 -1
- package/src/modules/resources/api/resources/tags/assign/route.ts +42 -0
- package/src/modules/resources/api/resources/tags/unassign/route.ts +42 -0
- package/src/modules/sales/api/settings/document-numbers/route.ts +35 -1
- package/src/modules/sales/api/settings/order-editing/route.ts +37 -3
- package/src/modules/staff/api/leave-requests/accept/route.ts +45 -0
- package/src/modules/staff/api/leave-requests/reject/route.ts +45 -0
- package/src/modules/staff/api/team-members/self/route.ts +43 -0
- package/src/modules/staff/api/team-members/tags/assign/route.ts +45 -0
- package/src/modules/staff/api/team-members/tags/unassign/route.ts +45 -0
- package/src/modules/translations/api/[entityType]/[entityId]/route.ts +65 -1
- package/src/modules/translations/api/context.ts +7 -0
- package/src/modules/translations/api/put/locales.ts +35 -1
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +11 -9
- package/src/modules/workflows/backend/instances/[id]/page.tsx +1 -1
- package/src/modules/workflows/components/EdgeEditDialog.tsx +1 -1
- package/src/modules/workflows/components/EdgeEditDialogCrudForm.tsx +1 -1
- package/src/modules/workflows/components/NodeEditDialog.tsx +1 -1
- package/src/modules/workflows/components/NodeEditDialogCrudForm.tsx +1 -1
- package/src/modules/workflows/components/WorkflowGraph.tsx +2 -2
- package/src/modules/workflows/components/WorkflowGraphImpl.tsx +27 -13
- package/src/modules/workflows/components/mobile/MobileVisualEditor.tsx +3 -3
- package/src/modules/workflows/frontend/checkout-demo/deriveCurrentStep.ts +12 -0
- package/src/modules/workflows/frontend/checkout-demo/page.tsx +3 -23
- package/src/modules/workflows/lib/graph-utils.ts +21 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { addDays } from "date-fns/addDays";
|
|
5
|
+
import { format } from "date-fns/format";
|
|
6
|
+
import { isToday } from "date-fns/isToday";
|
|
7
|
+
import { isTomorrow } from "date-fns/isTomorrow";
|
|
8
|
+
import { startOfDay } from "date-fns/startOfDay";
|
|
9
|
+
import { CalendarClock } from "lucide-react";
|
|
10
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
11
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
12
|
+
import { Avatar } from "@open-mercato/ui/primitives/avatar";
|
|
13
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
14
|
+
import { EmptyState } from "@open-mercato/ui/primitives/empty-state";
|
|
15
|
+
const MAX_AVATARS_PER_ROW = 2;
|
|
16
|
+
const CATEGORY_BADGE_CLASS = {
|
|
17
|
+
meeting: "bg-status-info-bg text-status-info-text",
|
|
18
|
+
event: "bg-status-warning-bg text-status-warning-text",
|
|
19
|
+
task: "bg-primary text-primary-foreground",
|
|
20
|
+
other: "bg-status-neutral-bg text-status-neutral-text"
|
|
21
|
+
};
|
|
22
|
+
const CATEGORY_LABEL = {
|
|
23
|
+
meeting: { key: "customers.calendar.category.meeting", fallback: "Meeting" },
|
|
24
|
+
event: { key: "customers.calendar.category.event", fallback: "Event" },
|
|
25
|
+
task: { key: "customers.calendar.category.task", fallback: "Task" },
|
|
26
|
+
other: { key: "customers.calendar.category.other", fallback: "Other" }
|
|
27
|
+
};
|
|
28
|
+
function dayKeyOf(date) {
|
|
29
|
+
return format(date, "yyyy-MM-dd");
|
|
30
|
+
}
|
|
31
|
+
function formatUrlHost(location) {
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(location.startsWith("http") ? location : `https://${location}`);
|
|
34
|
+
return url.hostname;
|
|
35
|
+
} catch {
|
|
36
|
+
return location;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function formatTime(date) {
|
|
40
|
+
return date.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
41
|
+
}
|
|
42
|
+
function groupLabelOf(date) {
|
|
43
|
+
return date.toLocaleDateString(void 0, { weekday: "long", month: "short", day: "numeric" });
|
|
44
|
+
}
|
|
45
|
+
function deriveTypeLabel(interactionType) {
|
|
46
|
+
const normalized = interactionType.replace(/[-_]+/g, " ").trim();
|
|
47
|
+
if (!normalized) return interactionType;
|
|
48
|
+
return normalized.charAt(0).toUpperCase() + normalized.slice(1);
|
|
49
|
+
}
|
|
50
|
+
function participantLabel(participant) {
|
|
51
|
+
return participant.name ?? participant.email ?? participant.userId;
|
|
52
|
+
}
|
|
53
|
+
function buildDayGroups(anchor, horizonDays, items) {
|
|
54
|
+
const sorted = [...items].sort((first, second) => first.start.getTime() - second.start.getTime());
|
|
55
|
+
const byDay = /* @__PURE__ */ new Map();
|
|
56
|
+
for (const item of sorted) {
|
|
57
|
+
const key = dayKeyOf(item.start);
|
|
58
|
+
const bucket = byDay.get(key);
|
|
59
|
+
if (bucket) bucket.push(item);
|
|
60
|
+
else byDay.set(key, [item]);
|
|
61
|
+
}
|
|
62
|
+
const firstDay = startOfDay(anchor);
|
|
63
|
+
const groups = [];
|
|
64
|
+
for (let offset = 0; offset <= horizonDays; offset += 1) {
|
|
65
|
+
const day = addDays(firstDay, offset);
|
|
66
|
+
const dayItems = byDay.get(dayKeyOf(day));
|
|
67
|
+
if (dayItems && dayItems.length > 0) groups.push({ date: day, items: dayItems });
|
|
68
|
+
}
|
|
69
|
+
return groups;
|
|
70
|
+
}
|
|
71
|
+
function AgendaDayHeader({ date, count }) {
|
|
72
|
+
const t = useT();
|
|
73
|
+
const todayMarker = isToday(date);
|
|
74
|
+
const tomorrowMarker = !todayMarker && isTomorrow(date);
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2 bg-muted/50 px-3 py-2.5 sm:px-5", children: [
|
|
76
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold text-foreground", children: groupLabelOf(date) }),
|
|
77
|
+
todayMarker || tomorrowMarker ? /* @__PURE__ */ jsx("span", { className: cn("text-xs font-medium", todayMarker ? "text-foreground" : "text-muted-foreground"), children: `\xB7 ${todayMarker ? t("customers.calendar.agenda.today", "Today") : t("customers.calendar.agenda.tomorrow", "Tomorrow")}` }) : null,
|
|
78
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "w-2.5 shrink-0" }),
|
|
79
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: count === 1 ? t("customers.calendar.agenda.eventCount", "1 event") : t("customers.calendar.agenda.eventsCount", "{count} events", { count }) })
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
function AgendaRow({
|
|
83
|
+
item,
|
|
84
|
+
typeLabels,
|
|
85
|
+
onItemClick
|
|
86
|
+
}) {
|
|
87
|
+
const t = useT();
|
|
88
|
+
const canceled = item.status === "canceled";
|
|
89
|
+
const done = item.status === "done";
|
|
90
|
+
const typeLabel = typeLabels?.[item.interactionType] ?? deriveTypeLabel(item.interactionType);
|
|
91
|
+
const platformLabels = {
|
|
92
|
+
zoom: t("customers.calendar.platformFull.zoom", "Zoom"),
|
|
93
|
+
meet: t("customers.calendar.platformFull.meet", "Google Meet"),
|
|
94
|
+
slack: t("customers.calendar.platformFull.slack", "Slack"),
|
|
95
|
+
teams: t("customers.calendar.platformFull.teams", "Microsoft Teams")
|
|
96
|
+
};
|
|
97
|
+
const locationLabel = item.platform ? platformLabels[item.platform] : item.locationKind === "url" && item.location ? formatUrlHost(item.location) : item.location;
|
|
98
|
+
const startLabel = item.allDay ? t("customers.calendar.grid.allDay", "All day") : formatTime(item.start);
|
|
99
|
+
const endLabel = item.allDay ? null : formatTime(item.end);
|
|
100
|
+
const ariaTime = item.allDay ? startLabel : `${startLabel} \u2013 ${endLabel}`;
|
|
101
|
+
return /* @__PURE__ */ jsxs(
|
|
102
|
+
Button,
|
|
103
|
+
{
|
|
104
|
+
type: "button",
|
|
105
|
+
variant: "ghost",
|
|
106
|
+
"aria-label": `${item.title} \xB7 ${ariaTime}`,
|
|
107
|
+
onClick: () => onItemClick(item),
|
|
108
|
+
className: cn(
|
|
109
|
+
"h-auto w-full justify-start whitespace-normal rounded-none bg-background px-3 py-3 text-left transition-colors hover:bg-muted/30 sm:gap-3.5 sm:px-5",
|
|
110
|
+
canceled && "opacity-60"
|
|
111
|
+
),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-16 shrink-0 flex-col gap-0.5 sm:w-[86px]", children: [
|
|
114
|
+
/* @__PURE__ */ jsx("span", { className: cn("truncate text-sm font-semibold leading-4", done || canceled ? "text-muted-foreground" : "text-foreground"), children: startLabel }),
|
|
115
|
+
endLabel ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: endLabel }) : null
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsx(
|
|
118
|
+
"span",
|
|
119
|
+
{
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
className: cn("h-9 w-1 shrink-0 rounded-full", !item.color && "bg-muted-foreground/40"),
|
|
122
|
+
style: item.color ? { backgroundColor: item.color } : void 0
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
"span",
|
|
128
|
+
{
|
|
129
|
+
className: cn(
|
|
130
|
+
"truncate text-sm font-semibold",
|
|
131
|
+
done || canceled ? "text-muted-foreground" : "text-foreground",
|
|
132
|
+
canceled && "line-through"
|
|
133
|
+
),
|
|
134
|
+
children: item.title
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: locationLabel ? `${typeLabel} \xB7 ${locationLabel}` : typeLabel })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
140
|
+
item.participants.length > 0 ? /* @__PURE__ */ jsxs("span", { className: "hidden items-center gap-0.5 sm:flex", children: [
|
|
141
|
+
item.participants.slice(0, MAX_AVATARS_PER_ROW).map((participant) => /* @__PURE__ */ jsx(Avatar, { size: "xs", label: participantLabel(participant) }, participant.userId)),
|
|
142
|
+
item.participants.length > MAX_AVATARS_PER_ROW ? /* @__PURE__ */ jsxs("span", { className: "ps-0.5 text-xs font-medium text-muted-foreground", children: [
|
|
143
|
+
"+",
|
|
144
|
+
item.participants.length - MAX_AVATARS_PER_ROW
|
|
145
|
+
] }) : null
|
|
146
|
+
] }) : null,
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
className: cn(
|
|
151
|
+
"inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-overline font-medium uppercase tracking-wide",
|
|
152
|
+
CATEGORY_BADGE_CLASS[item.category]
|
|
153
|
+
),
|
|
154
|
+
children: t(CATEGORY_LABEL[item.category].key, CATEGORY_LABEL[item.category].fallback)
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
function AgendaList({ anchor, horizonDays, items, typeLabels, onItemClick }) {
|
|
163
|
+
const t = useT();
|
|
164
|
+
const groups = React.useMemo(() => buildDayGroups(anchor, horizonDays, items), [anchor, horizonDays, items]);
|
|
165
|
+
if (groups.length === 0) {
|
|
166
|
+
return /* @__PURE__ */ jsx(
|
|
167
|
+
EmptyState,
|
|
168
|
+
{
|
|
169
|
+
icon: /* @__PURE__ */ jsx(CalendarClock, { className: "h-6 w-6", "aria-hidden": "true" }),
|
|
170
|
+
title: t("customers.calendar.empty.agenda", "Nothing scheduled in this period")
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col divide-y divide-border overflow-hidden border border-border bg-background", children: groups.map((group) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
175
|
+
/* @__PURE__ */ jsx(AgendaDayHeader, { date: group.date, count: group.items.length }),
|
|
176
|
+
group.items.map((item) => /* @__PURE__ */ jsx(AgendaRow, { item, typeLabels, onItemClick }, item.id))
|
|
177
|
+
] }, dayKeyOf(group.date))) });
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
AgendaList
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=AgendaList.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/components/calendar/AgendaList.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { addDays } from 'date-fns/addDays'\nimport { format } from 'date-fns/format'\nimport { isToday } from 'date-fns/isToday'\nimport { isTomorrow } from 'date-fns/isTomorrow'\nimport { startOfDay } from 'date-fns/startOfDay'\nimport { CalendarClock } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { Avatar } from '@open-mercato/ui/primitives/avatar'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { EmptyState } from '@open-mercato/ui/primitives/empty-state'\nimport type { AgendaListProps, CalendarCategory, CalendarItem } from './types'\n\nconst MAX_AVATARS_PER_ROW = 2\n\nconst CATEGORY_BADGE_CLASS: Record<CalendarCategory, string> = {\n meeting: 'bg-status-info-bg text-status-info-text',\n event: 'bg-status-warning-bg text-status-warning-text',\n task: 'bg-primary text-primary-foreground',\n other: 'bg-status-neutral-bg text-status-neutral-text',\n}\n\nconst CATEGORY_LABEL: Record<CalendarCategory, { key: string; fallback: string }> = {\n meeting: { key: 'customers.calendar.category.meeting', fallback: 'Meeting' },\n event: { key: 'customers.calendar.category.event', fallback: 'Event' },\n task: { key: 'customers.calendar.category.task', fallback: 'Task' },\n other: { key: 'customers.calendar.category.other', fallback: 'Other' },\n}\n\ntype AgendaDayGroup = { date: Date; items: CalendarItem[] }\n\nfunction dayKeyOf(date: Date): string {\n return format(date, 'yyyy-MM-dd')\n}\n\nfunction formatUrlHost(location: string): string {\n try {\n const url = new URL(location.startsWith('http') ? location : `https://${location}`)\n return url.hostname\n } catch {\n return location\n }\n}\n\nfunction formatTime(date: Date): string {\n return date.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })\n}\n\nfunction groupLabelOf(date: Date): string {\n return date.toLocaleDateString(undefined, { weekday: 'long', month: 'short', day: 'numeric' })\n}\n\nfunction deriveTypeLabel(interactionType: string): string {\n const normalized = interactionType.replace(/[-_]+/g, ' ').trim()\n if (!normalized) return interactionType\n return normalized.charAt(0).toUpperCase() + normalized.slice(1)\n}\n\nfunction participantLabel(participant: CalendarItem['participants'][number]): string {\n return participant.name ?? participant.email ?? participant.userId\n}\n\nfunction buildDayGroups(anchor: Date, horizonDays: number, items: CalendarItem[]): AgendaDayGroup[] {\n const sorted = [...items].sort((first, second) => first.start.getTime() - second.start.getTime())\n const byDay = new Map<string, CalendarItem[]>()\n for (const item of sorted) {\n const key = dayKeyOf(item.start)\n const bucket = byDay.get(key)\n if (bucket) bucket.push(item)\n else byDay.set(key, [item])\n }\n const firstDay = startOfDay(anchor)\n const groups: AgendaDayGroup[] = []\n for (let offset = 0; offset <= horizonDays; offset += 1) {\n const day = addDays(firstDay, offset)\n const dayItems = byDay.get(dayKeyOf(day))\n if (dayItems && dayItems.length > 0) groups.push({ date: day, items: dayItems })\n }\n return groups\n}\n\nfunction AgendaDayHeader({ date, count }: { date: Date; count: number }) {\n const t = useT()\n const todayMarker = isToday(date)\n const tomorrowMarker = !todayMarker && isTomorrow(date)\n return (\n <div className=\"flex w-full items-center gap-2 bg-muted/50 px-3 py-2.5 sm:px-5\">\n <span className=\"text-sm font-semibold text-foreground\">{groupLabelOf(date)}</span>\n {todayMarker || tomorrowMarker ? (\n <span className={cn('text-xs font-medium', todayMarker ? 'text-foreground' : 'text-muted-foreground')}>\n {`\u00B7 ${todayMarker ? t('customers.calendar.agenda.today', 'Today') : t('customers.calendar.agenda.tomorrow', 'Tomorrow')}`}\n </span>\n ) : null}\n <span aria-hidden=\"true\" className=\"w-2.5 shrink-0\" />\n <span className=\"text-xs font-medium text-muted-foreground\">\n {count === 1\n ? t('customers.calendar.agenda.eventCount', '1 event')\n : t('customers.calendar.agenda.eventsCount', '{count} events', { count })}\n </span>\n </div>\n )\n}\n\nfunction AgendaRow({\n item,\n typeLabels,\n onItemClick,\n}: {\n item: CalendarItem\n typeLabels?: Record<string, string>\n onItemClick: (item: CalendarItem) => void\n}) {\n const t = useT()\n const canceled = item.status === 'canceled'\n const done = item.status === 'done'\n const typeLabel = typeLabels?.[item.interactionType] ?? deriveTypeLabel(item.interactionType)\n const platformLabels: Record<string, string> = {\n zoom: t('customers.calendar.platformFull.zoom', 'Zoom'),\n meet: t('customers.calendar.platformFull.meet', 'Google Meet'),\n slack: t('customers.calendar.platformFull.slack', 'Slack'),\n teams: t('customers.calendar.platformFull.teams', 'Microsoft Teams'),\n }\n const locationLabel = item.platform\n ? platformLabels[item.platform]\n : item.locationKind === 'url' && item.location\n ? formatUrlHost(item.location)\n : item.location\n const startLabel = item.allDay ? t('customers.calendar.grid.allDay', 'All day') : formatTime(item.start)\n const endLabel = item.allDay ? null : formatTime(item.end)\n const ariaTime = item.allDay ? startLabel : `${startLabel} \u2013 ${endLabel}`\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n aria-label={`${item.title} \u00B7 ${ariaTime}`}\n onClick={() => onItemClick(item)}\n className={cn(\n 'h-auto w-full justify-start whitespace-normal rounded-none bg-background px-3 py-3 text-left transition-colors hover:bg-muted/30 sm:gap-3.5 sm:px-5',\n canceled && 'opacity-60',\n )}\n >\n <div className=\"flex w-16 shrink-0 flex-col gap-0.5 sm:w-[86px]\">\n <span className={cn('truncate text-sm font-semibold leading-4', done || canceled ? 'text-muted-foreground' : 'text-foreground')}>\n {startLabel}\n </span>\n {endLabel ? <span className=\"truncate text-xs text-muted-foreground\">{endLabel}</span> : null}\n </div>\n <span\n aria-hidden=\"true\"\n className={cn('h-9 w-1 shrink-0 rounded-full', !item.color && 'bg-muted-foreground/40')}\n style={item.color ? { backgroundColor: item.color } : undefined}\n />\n <div className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span\n className={cn(\n 'truncate text-sm font-semibold',\n done || canceled ? 'text-muted-foreground' : 'text-foreground',\n canceled && 'line-through',\n )}\n >\n {item.title}\n </span>\n <span className=\"truncate text-xs text-muted-foreground\">\n {locationLabel ? `${typeLabel} \u00B7 ${locationLabel}` : typeLabel}\n </span>\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {item.participants.length > 0 ? (\n <span className=\"hidden items-center gap-0.5 sm:flex\">\n {item.participants.slice(0, MAX_AVATARS_PER_ROW).map((participant) => (\n <Avatar key={participant.userId} size=\"xs\" label={participantLabel(participant)} />\n ))}\n {item.participants.length > MAX_AVATARS_PER_ROW ? (\n <span className=\"ps-0.5 text-xs font-medium text-muted-foreground\">\n +{item.participants.length - MAX_AVATARS_PER_ROW}\n </span>\n ) : null}\n </span>\n ) : null}\n <span\n className={cn(\n 'inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-overline font-medium uppercase tracking-wide',\n CATEGORY_BADGE_CLASS[item.category],\n )}\n >\n {t(CATEGORY_LABEL[item.category].key, CATEGORY_LABEL[item.category].fallback)}\n </span>\n </div>\n </Button>\n )\n}\n\nexport function AgendaList({ anchor, horizonDays, items, typeLabels, onItemClick }: AgendaListProps) {\n const t = useT()\n const groups = React.useMemo(() => buildDayGroups(anchor, horizonDays, items), [anchor, horizonDays, items])\n if (groups.length === 0) {\n return (\n <EmptyState\n icon={<CalendarClock className=\"h-6 w-6\" aria-hidden=\"true\" />}\n title={t('customers.calendar.empty.agenda', 'Nothing scheduled in this period')}\n />\n )\n }\n return (\n <div className=\"flex w-full flex-col divide-y divide-border overflow-hidden border border-border bg-background\">\n {groups.map((group) => (\n <React.Fragment key={dayKeyOf(group.date)}>\n <AgendaDayHeader date={group.date} count={group.items.length} />\n {group.items.map((item) => (\n <AgendaRow key={item.id} item={item} typeLabels={typeLabels} onItemClick={onItemClick} />\n ))}\n </React.Fragment>\n ))}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAyFI,SACE,KADF;AAvFJ,YAAY,WAAW;AACvB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAG3B,MAAM,sBAAsB;AAE5B,MAAM,uBAAyD;AAAA,EAC7D,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;AAEA,MAAM,iBAA8E;AAAA,EAClF,SAAS,EAAE,KAAK,uCAAuC,UAAU,UAAU;AAAA,EAC3E,OAAO,EAAE,KAAK,qCAAqC,UAAU,QAAQ;AAAA,EACrE,MAAM,EAAE,KAAK,oCAAoC,UAAU,OAAO;AAAA,EAClE,OAAO,EAAE,KAAK,qCAAqC,UAAU,QAAQ;AACvE;AAIA,SAAS,SAAS,MAAoB;AACpC,SAAO,OAAO,MAAM,YAAY;AAClC;AAEA,SAAS,cAAc,UAA0B;AAC/C,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,SAAS,WAAW,MAAM,IAAI,WAAW,WAAW,QAAQ,EAAE;AAClF,WAAO,IAAI;AAAA,EACb,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,KAAK,aAAa,SAAS;AAAA,eAC/B,IACE;AAAA,aACN,IACE;AAAA,UACJ;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,qBAAqB,KAAK,QAAQ;AAAA,cACpC;AAAA,cAEC,YAAE,eAAe,KAAK,QAAQ,EAAE,KAAK,eAAe,KAAK,QAAQ,EAAE,QAAQ;AAAA;AAAA,UAC9E;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEO,SAAS,WAAW,EAAE,QAAQ,aAAa,OAAO,YAAY,YAAY,GAAoB;AACnG,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,MAAM,QAAQ,MAAM,eAAe,QAAQ,aAAa,KAAK,GAAG,CAAC,QAAQ,aAAa,KAAK,CAAC;AAC3G,MAAI,OAAO,WAAW,GAAG;AACvB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,oBAAC,iBAAc,WAAU,WAAU,eAAY,QAAO;AAAA,QAC5D,OAAO,EAAE,mCAAmC,kCAAkC;AAAA;AAAA,IAChF;AAAA,EAEJ;AACA,SACE,oBAAC,SAAI,WAAU,kGACZ,iBAAO,IAAI,CAAC,UACX,qBAAC,MAAM,UAAN,EACC;AAAA,wBAAC,mBAAgB,MAAM,MAAM,MAAM,OAAO,MAAM,MAAM,QAAQ;AAAA,IAC7D,MAAM,MAAM,IAAI,CAAC,SAChB,oBAAC,aAAwB,MAAY,YAAwB,eAA7C,KAAK,EAAkE,CACxF;AAAA,OAJkB,SAAS,MAAM,IAAI,CAKxC,CACD,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Calendar, X } from "lucide-react";
|
|
5
|
+
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
6
|
+
import { useLocale, useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
|
+
import { apiCallOrThrow, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
|
|
8
|
+
import { buildOptimisticLockHeader, extractOptimisticLockConflict } from "@open-mercato/ui/backend/utils/optimisticLock";
|
|
9
|
+
import { mapCrudServerErrorToFormErrors } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
10
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
11
|
+
import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
|
|
12
|
+
import { Alert, AlertDescription, AlertTitle } from "@open-mercato/ui/primitives/alert";
|
|
13
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
14
|
+
import { Dialog, DialogContent, DialogTitle } from "@open-mercato/ui/primitives/dialog";
|
|
15
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
16
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
17
|
+
import { Textarea } from "@open-mercato/ui/primitives/textarea";
|
|
18
|
+
import { useDialogKeyHandler } from "@open-mercato/ui/hooks/useDialogKeyHandler";
|
|
19
|
+
import {
|
|
20
|
+
buildEditorCategoryOptions,
|
|
21
|
+
buildInteractionPayload,
|
|
22
|
+
computeDurationMinutes,
|
|
23
|
+
createDefaultFormState,
|
|
24
|
+
defaultRepeatDaysForDateInput,
|
|
25
|
+
EDITOR_KINDS,
|
|
26
|
+
KIND_CONFIG,
|
|
27
|
+
parseItemToFormState,
|
|
28
|
+
resolveSavedOwnerUserId
|
|
29
|
+
} from "../../lib/calendar/editorPayload.js";
|
|
30
|
+
import { Field } from "./editor/inputs.js";
|
|
31
|
+
import { SegmentGroup } from "./editor/SegmentGroup.js";
|
|
32
|
+
import { RelatedToField } from "./editor/RelatedToField.js";
|
|
33
|
+
import { CategoryField } from "./editor/CategoryField.js";
|
|
34
|
+
import { RepeatField } from "./editor/RepeatField.js";
|
|
35
|
+
import { PeopleField } from "./editor/PeopleField.js";
|
|
36
|
+
import { ScheduleSection } from "./editor/ScheduleSection.js";
|
|
37
|
+
import { LocationField } from "./editor/LocationField.js";
|
|
38
|
+
import { useConflictProbe, useEditorLabelResolution } from "./editor/hooks.js";
|
|
39
|
+
const PEOPLE_FIELD_TEXT = {
|
|
40
|
+
attendees: { labelKey: "customers.calendar.editor.attendees", label: "Attendees", placeholderKey: "customers.calendar.editor.addPeoplePlaceholder", placeholder: "Add staff or customer\u2026" },
|
|
41
|
+
participants: { labelKey: "customers.calendar.editor.participants", label: "Participants", placeholderKey: "customers.calendar.editor.addPeoplePlaceholder", placeholder: "Add staff or customer\u2026" },
|
|
42
|
+
to: { labelKey: "customers.calendar.editor.to", label: "To", placeholderKey: "customers.calendar.editor.addRecipientPlaceholder", placeholder: "Add recipient\u2026" }
|
|
43
|
+
};
|
|
44
|
+
function CalendarEventEditor({ open, mode, item, defaultDate, defaultRange, typeLabels, typeColors, surfacedTypes, eventCategories, conflictScope, currentUserId, onOpenChange, onSaved }) {
|
|
45
|
+
const t = useT();
|
|
46
|
+
const locale = useLocale();
|
|
47
|
+
const [form, setForm] = React.useState(() => createDefaultFormState(defaultDate ?? null, void 0, defaultRange ?? null));
|
|
48
|
+
const [fieldErrors, setFieldErrors] = React.useState({});
|
|
49
|
+
const [saving, setSaving] = React.useState(false);
|
|
50
|
+
const openKeyRef = React.useRef(null);
|
|
51
|
+
const isEdit = mode === "edit" && Boolean(item?.id);
|
|
52
|
+
const config = KIND_CONFIG[form.kind];
|
|
53
|
+
const update = React.useCallback((patch) => {
|
|
54
|
+
setForm((previous) => ({ ...previous, ...patch }));
|
|
55
|
+
}, []);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
if (!open) {
|
|
58
|
+
openKeyRef.current = null;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const key = `${mode}:${item?.id ?? "new"}`;
|
|
62
|
+
if (openKeyRef.current === key) return;
|
|
63
|
+
openKeyRef.current = key;
|
|
64
|
+
setForm(
|
|
65
|
+
mode === "edit" && item ? parseItemToFormState(item) : createDefaultFormState(defaultDate ?? null, void 0, defaultRange ?? null)
|
|
66
|
+
);
|
|
67
|
+
setFieldErrors({});
|
|
68
|
+
}, [open, mode, item, defaultDate, defaultRange]);
|
|
69
|
+
useEditorLabelResolution(open, form, update);
|
|
70
|
+
const draftOwnerUserId = resolveSavedOwnerUserId(config, form, isEdit, item?.ownerUserId ?? null);
|
|
71
|
+
const conflict = useConflictProbe(open, form, config, isEdit && item ? item.raw.id : null, draftOwnerUserId, conflictScope ?? "all", currentUserId ?? null);
|
|
72
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({
|
|
73
|
+
contextId: "customers-calendar-event-editor",
|
|
74
|
+
blockedMessage: t("ui.forms.flash.saveBlocked", "Save blocked by validation")
|
|
75
|
+
});
|
|
76
|
+
const handleSave = React.useCallback(async () => {
|
|
77
|
+
const errors = {};
|
|
78
|
+
if (!form.title.trim()) errors.title = t("customers.calendar.editor.validation.titleRequired", "Title is required");
|
|
79
|
+
if (!form.relatedTo) errors.relatedTo = t("customers.calendar.editor.validation.relatedToRequired", "Select a person or company to link this event");
|
|
80
|
+
if (config.hasEnd && !form.allDay && computeDurationMinutes(form) === null) {
|
|
81
|
+
errors.ends = t("customers.calendar.editor.validation.endsBeforeStarts", "End must be after start");
|
|
82
|
+
}
|
|
83
|
+
setFieldErrors(errors);
|
|
84
|
+
if (Object.keys(errors).length > 0) return;
|
|
85
|
+
setSaving(true);
|
|
86
|
+
try {
|
|
87
|
+
const payload = buildInteractionPayload(form, { mode, id: item?.id });
|
|
88
|
+
await runMutation({
|
|
89
|
+
operation: () => {
|
|
90
|
+
const call = () => apiCallOrThrow("/api/customers/interactions", {
|
|
91
|
+
method: isEdit ? "PUT" : "POST",
|
|
92
|
+
headers: { "content-type": "application/json" },
|
|
93
|
+
body: JSON.stringify(payload)
|
|
94
|
+
});
|
|
95
|
+
return isEdit ? withScopedApiRequestHeaders(buildOptimisticLockHeader(item?.updatedAt), call) : call();
|
|
96
|
+
},
|
|
97
|
+
mutationPayload: {
|
|
98
|
+
operation: isEdit ? "updateCalendarEvent" : "createCalendarEvent",
|
|
99
|
+
interactionId: item?.id ?? null,
|
|
100
|
+
interactionType: form.category ?? form.kind
|
|
101
|
+
},
|
|
102
|
+
context: {
|
|
103
|
+
formId: "customers-calendar-event-editor",
|
|
104
|
+
resourceKind: "customers.interaction",
|
|
105
|
+
resourceId: item?.id ?? "new",
|
|
106
|
+
retryLastMutation
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
flash(t("customers.calendar.editor.saved", "Event saved"), "success");
|
|
110
|
+
onOpenChange(false);
|
|
111
|
+
requestAnimationFrame(() => {
|
|
112
|
+
onSaved();
|
|
113
|
+
});
|
|
114
|
+
} catch (err) {
|
|
115
|
+
if (extractOptimisticLockConflict(err)) {
|
|
116
|
+
onOpenChange(false);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const { message } = mapCrudServerErrorToFormErrors(err);
|
|
120
|
+
const key = typeof message === "string" ? message.trim() : "";
|
|
121
|
+
flash(key ? t(key, key) : t("customers.calendar.editor.error", "Failed to save event"), "error");
|
|
122
|
+
} finally {
|
|
123
|
+
setSaving(false);
|
|
124
|
+
}
|
|
125
|
+
}, [config.hasEnd, form, isEdit, item?.id, mode, onOpenChange, onSaved, retryLastMutation, runMutation, t]);
|
|
126
|
+
const handleKeyDown = useDialogKeyHandler({ onConfirm: handleSave, disabled: saving });
|
|
127
|
+
const categoryOptions = React.useMemo(
|
|
128
|
+
() => buildEditorCategoryOptions({
|
|
129
|
+
typeLabels,
|
|
130
|
+
surfacedTypes: surfacedTypes ?? [],
|
|
131
|
+
eventCategories: eventCategories ?? [],
|
|
132
|
+
selectedValue: form.category ?? form.kind,
|
|
133
|
+
selectedFallbackLabel: t(`customers.calendar.editor.types.${form.kind}`, form.kind)
|
|
134
|
+
}),
|
|
135
|
+
[typeLabels, surfacedTypes, eventCategories, form.category, form.kind, t]
|
|
136
|
+
);
|
|
137
|
+
const titleLabel = form.kind === "email" ? t("customers.calendar.editor.titleLabel.email", "Subject") : form.kind === "note" ? t("customers.calendar.editor.titleLabel.note", "Note") : t("customers.calendar.editor.titleLabel.generic", "Title");
|
|
138
|
+
const dialogTitle = isEdit ? t("customers.calendar.editor.title.edit", "Edit event") : t("customers.calendar.editor.title.create", "New event");
|
|
139
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
|
|
140
|
+
DialogContent,
|
|
141
|
+
{
|
|
142
|
+
onKeyDown: handleKeyDown,
|
|
143
|
+
"aria-describedby": void 0,
|
|
144
|
+
dismissible: false,
|
|
145
|
+
className: "flex h-dvh max-h-dvh w-screen max-w-none flex-col gap-0 overflow-hidden rounded-none border-0 bg-background p-0 shadow-xl sm:h-auto sm:max-h-screen sm:w-full sm:max-w-md sm:rounded-2xl sm:border-0",
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(DialogTitle, { children: dialogTitle }) }),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-3 border-b border-border bg-background py-4 pl-5 pr-4", children: [
|
|
149
|
+
/* @__PURE__ */ jsx(Calendar, { "aria-hidden": true, className: "size-6 shrink-0 text-foreground", strokeWidth: 1.75 }),
|
|
150
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 flex-1 text-sm font-medium leading-5 text-foreground", children: dialogTitle }),
|
|
151
|
+
/* @__PURE__ */ jsx(
|
|
152
|
+
IconButton,
|
|
153
|
+
{
|
|
154
|
+
variant: "ghost",
|
|
155
|
+
size: "sm",
|
|
156
|
+
onClick: () => onOpenChange(false),
|
|
157
|
+
"aria-label": t("customers.calendar.editor.close", "Close"),
|
|
158
|
+
className: "shrink-0 text-muted-foreground",
|
|
159
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "size-5" })
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-5 px-4 py-5 sm:px-6 sm:py-6", children: [
|
|
164
|
+
conflict ? /* @__PURE__ */ jsxs(Alert, { variant: "warning", className: "rounded-lg", children: [
|
|
165
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: t("customers.calendar.editor.conflictTitle", "Calendar conflict") }),
|
|
166
|
+
/* @__PURE__ */ jsx(AlertDescription, { children: conflict })
|
|
167
|
+
] }) : null,
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
SegmentGroup,
|
|
170
|
+
{
|
|
171
|
+
ariaLabel: t("customers.calendar.editor.typeSwitcher", "Event type"),
|
|
172
|
+
value: form.kind,
|
|
173
|
+
onChange: (kind) => update({ kind, category: null }),
|
|
174
|
+
options: EDITOR_KINDS.map((kind) => ({ value: kind, label: t(`customers.calendar.editor.types.${kind}`, kind) }))
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx(Field, { label: titleLabel, error: fieldErrors.title, children: /* @__PURE__ */ jsx(
|
|
178
|
+
Input,
|
|
179
|
+
{
|
|
180
|
+
type: "text",
|
|
181
|
+
value: form.title,
|
|
182
|
+
onChange: (event) => update({ title: event.target.value }),
|
|
183
|
+
placeholder: t("customers.calendar.editor.titlePlaceholder", "Add a title\u2026"),
|
|
184
|
+
"aria-label": titleLabel,
|
|
185
|
+
autoFocus: true,
|
|
186
|
+
size: "lg"
|
|
187
|
+
}
|
|
188
|
+
) }),
|
|
189
|
+
/* @__PURE__ */ jsx(Field, { label: t("customers.calendar.editor.relatedTo", "Related to"), error: fieldErrors.relatedTo, children: /* @__PURE__ */ jsx(
|
|
190
|
+
RelatedToField,
|
|
191
|
+
{
|
|
192
|
+
label: t("customers.calendar.editor.relatedTo", "Related to"),
|
|
193
|
+
value: form.relatedTo,
|
|
194
|
+
deal: form.dealId && form.dealLabel ? { id: form.dealId, label: form.dealLabel } : null,
|
|
195
|
+
onChange: (relatedTo) => update({ relatedTo }),
|
|
196
|
+
onDealChange: (deal) => update({ dealId: deal?.id ?? null, dealLabel: deal?.label ?? null }),
|
|
197
|
+
error: fieldErrors.relatedTo
|
|
198
|
+
}
|
|
199
|
+
) }),
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
ScheduleSection,
|
|
202
|
+
{
|
|
203
|
+
dateLabel: config.dateLabel,
|
|
204
|
+
hasAllDay: config.hasAllDay,
|
|
205
|
+
hasEnd: config.hasEnd,
|
|
206
|
+
allDay: form.allDay,
|
|
207
|
+
date: form.date,
|
|
208
|
+
startTime: form.startTime,
|
|
209
|
+
endDate: form.endDate,
|
|
210
|
+
endTime: form.endTime,
|
|
211
|
+
locale,
|
|
212
|
+
endsError: fieldErrors.ends,
|
|
213
|
+
onAllDayChange: (allDay) => update({ allDay }),
|
|
214
|
+
onDateChange: (date) => {
|
|
215
|
+
const untouchedDefault = JSON.stringify(form.repeatDays) === JSON.stringify(defaultRepeatDaysForDateInput(form.date));
|
|
216
|
+
update(
|
|
217
|
+
untouchedDefault ? { date, repeatDays: defaultRepeatDaysForDateInput(date) } : { date }
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
onStartTimeChange: (startTime) => update({ startTime }),
|
|
221
|
+
onEndDateChange: (endDate) => update({ endDate }),
|
|
222
|
+
onEndTimeChange: (endTime) => update({ endTime })
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
config.hasRepeat ? /* @__PURE__ */ jsx(
|
|
226
|
+
RepeatField,
|
|
227
|
+
{
|
|
228
|
+
freq: form.repeatFreq,
|
|
229
|
+
days: form.repeatDays,
|
|
230
|
+
endType: form.repeatEndType,
|
|
231
|
+
count: form.repeatCount,
|
|
232
|
+
untilDate: form.repeatUntilDate,
|
|
233
|
+
locale,
|
|
234
|
+
onFreqChange: (repeatFreq) => update(
|
|
235
|
+
repeatFreq === "weekly" ? { repeatFreq, repeatDays: defaultRepeatDaysForDateInput(form.date) } : { repeatFreq }
|
|
236
|
+
),
|
|
237
|
+
onToggleDay: (index) => update({ repeatDays: form.repeatDays.map((active, dayIndex) => dayIndex === index ? !active : active) }),
|
|
238
|
+
onEndTypeChange: (repeatEndType) => update({ repeatEndType }),
|
|
239
|
+
onCountChange: (repeatCount) => update({ repeatCount }),
|
|
240
|
+
onUntilDateChange: (repeatUntilDate) => update({ repeatUntilDate })
|
|
241
|
+
}
|
|
242
|
+
) : null,
|
|
243
|
+
/* @__PURE__ */ jsx(Field, { label: t("customers.calendar.editor.category", "Category"), children: /* @__PURE__ */ jsx(
|
|
244
|
+
CategoryField,
|
|
245
|
+
{
|
|
246
|
+
label: t("customers.calendar.editor.category", "Category"),
|
|
247
|
+
value: form.category ?? form.kind,
|
|
248
|
+
options: categoryOptions,
|
|
249
|
+
colors: typeColors,
|
|
250
|
+
onChange: (category) => update({ category })
|
|
251
|
+
}
|
|
252
|
+
) }),
|
|
253
|
+
config.location ? /* @__PURE__ */ jsx(LocationField, { variant: config.location, value: form.location, onChange: (location) => update({ location }) }) : null,
|
|
254
|
+
config.people && config.people !== "assignee" ? /* @__PURE__ */ jsx(Field, { label: t(PEOPLE_FIELD_TEXT[config.people].labelKey, PEOPLE_FIELD_TEXT[config.people].label), children: /* @__PURE__ */ jsx(
|
|
255
|
+
PeopleField,
|
|
256
|
+
{
|
|
257
|
+
mode: "multi",
|
|
258
|
+
includeCustomers: true,
|
|
259
|
+
placeholder: t(PEOPLE_FIELD_TEXT[config.people].placeholderKey, PEOPLE_FIELD_TEXT[config.people].placeholder),
|
|
260
|
+
ariaLabel: t(PEOPLE_FIELD_TEXT[config.people].labelKey, PEOPLE_FIELD_TEXT[config.people].label),
|
|
261
|
+
value: form.participants,
|
|
262
|
+
onChange: (participants) => update({ participants })
|
|
263
|
+
}
|
|
264
|
+
) }) : null,
|
|
265
|
+
config.hasPriority ? /* @__PURE__ */ jsx(Field, { label: t("customers.calendar.editor.priority.label", "Priority"), children: /* @__PURE__ */ jsx(
|
|
266
|
+
SegmentGroup,
|
|
267
|
+
{
|
|
268
|
+
size: "md",
|
|
269
|
+
ariaLabel: t("customers.calendar.editor.priority.label", "Priority"),
|
|
270
|
+
value: form.priority,
|
|
271
|
+
onChange: (priority) => update({ priority }),
|
|
272
|
+
options: [
|
|
273
|
+
{ value: "low", label: t("customers.calendar.editor.priority.low", "Low") },
|
|
274
|
+
{ value: "medium", label: t("customers.calendar.editor.priority.medium", "Medium") },
|
|
275
|
+
{ value: "high", label: t("customers.calendar.editor.priority.high", "High") }
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
) }) : null,
|
|
279
|
+
config.people === "assignee" ? /* @__PURE__ */ jsx(Field, { label: t("customers.calendar.editor.assignee", "Assignee"), children: /* @__PURE__ */ jsx(
|
|
280
|
+
PeopleField,
|
|
281
|
+
{
|
|
282
|
+
mode: "single",
|
|
283
|
+
includeCustomers: false,
|
|
284
|
+
placeholder: t("customers.calendar.editor.assigneePlaceholder", "Assign to a team member\u2026"),
|
|
285
|
+
ariaLabel: t("customers.calendar.editor.assignee", "Assignee"),
|
|
286
|
+
value: form.assigneeUserId ? [{ userId: form.assigneeUserId, name: form.assigneeName ?? form.assigneeUserId, isCustomer: false }] : [],
|
|
287
|
+
onChange: (entries) => {
|
|
288
|
+
const next = entries[entries.length - 1] ?? null;
|
|
289
|
+
update({ assigneeUserId: next?.userId ?? null, assigneeName: next?.name ?? null });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
) }) : null,
|
|
293
|
+
/* @__PURE__ */ jsx(Field, { label: t("customers.calendar.editor.description", "Description"), children: /* @__PURE__ */ jsx(
|
|
294
|
+
Textarea,
|
|
295
|
+
{
|
|
296
|
+
value: form.description,
|
|
297
|
+
onChange: (event) => update({ description: event.target.value }),
|
|
298
|
+
placeholder: t("customers.calendar.editor.descriptionPlaceholder", "Add details\u2026"),
|
|
299
|
+
"aria-label": t("customers.calendar.editor.description", "Description"),
|
|
300
|
+
className: "h-24 resize-none"
|
|
301
|
+
}
|
|
302
|
+
) })
|
|
303
|
+
] }) }),
|
|
304
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center justify-end gap-3 border-t border-border bg-background px-5 py-4", children: [
|
|
305
|
+
/* @__PURE__ */ jsx(
|
|
306
|
+
Button,
|
|
307
|
+
{
|
|
308
|
+
type: "button",
|
|
309
|
+
variant: "outline",
|
|
310
|
+
onClick: () => onOpenChange(false),
|
|
311
|
+
children: t("customers.calendar.editor.cancel", "Cancel")
|
|
312
|
+
}
|
|
313
|
+
),
|
|
314
|
+
/* @__PURE__ */ jsx(
|
|
315
|
+
Button,
|
|
316
|
+
{
|
|
317
|
+
type: "button",
|
|
318
|
+
onClick: handleSave,
|
|
319
|
+
disabled: saving,
|
|
320
|
+
children: saving ? t("customers.calendar.editor.saving", "Saving\u2026") : t("customers.calendar.editor.save", "Save event")
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
] })
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
) });
|
|
327
|
+
}
|
|
328
|
+
export {
|
|
329
|
+
CalendarEventEditor
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=CalendarEventEditor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/components/calendar/CalendarEventEditor.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Calendar, X } from 'lucide-react'\nimport { VisuallyHidden } from '@radix-ui/react-visually-hidden'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport { apiCallOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader, extractOptimisticLockConflict } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { mapCrudServerErrorToFormErrors } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { Alert, AlertDescription, AlertTitle } from '@open-mercato/ui/primitives/alert'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Dialog, DialogContent, DialogTitle } from '@open-mercato/ui/primitives/dialog'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { useDialogKeyHandler } from '@open-mercato/ui/hooks/useDialogKeyHandler'\nimport {\n buildEditorCategoryOptions,\n buildInteractionPayload,\n computeDurationMinutes,\n createDefaultFormState,\n defaultRepeatDaysForDateInput,\n EDITOR_KINDS,\n KIND_CONFIG,\n parseItemToFormState,\n resolveSavedOwnerUserId,\n type EditorFormState,\n type EditorKind,\n type EditorPriority,\n} from '../../lib/calendar/editorPayload'\nimport type { ConflictScope } from '../../lib/calendar/preferences'\nimport type { CalendarItem } from './types'\nimport { Field } from './editor/inputs'\nimport { SegmentGroup } from './editor/SegmentGroup'\nimport { RelatedToField } from './editor/RelatedToField'\nimport { CategoryField } from './editor/CategoryField'\nimport { RepeatField } from './editor/RepeatField'\nimport { PeopleField } from './editor/PeopleField'\nimport { ScheduleSection } from './editor/ScheduleSection'\nimport { LocationField } from './editor/LocationField'\nimport { useConflictProbe, useEditorLabelResolution } from './editor/hooks'\n\nexport interface CalendarEventEditorProps {\n open: boolean\n mode: 'create' | 'edit'\n item?: CalendarItem | null\n defaultDate?: Date\n defaultRange?: { start: Date; end: Date } | null\n typeLabels: Record<string, string>\n typeColors: Record<string, string | null>\n surfacedTypes?: string[]\n eventCategories?: string[]\n conflictScope?: ConflictScope\n currentUserId?: string | null\n onOpenChange(open: boolean): void\n onSaved(): void\n}\n\ntype FieldErrors = { title?: string; relatedTo?: string; ends?: string }\n\nconst PEOPLE_FIELD_TEXT = {\n attendees: { labelKey: 'customers.calendar.editor.attendees', label: 'Attendees', placeholderKey: 'customers.calendar.editor.addPeoplePlaceholder', placeholder: 'Add staff or customer\u2026' },\n participants: { labelKey: 'customers.calendar.editor.participants', label: 'Participants', placeholderKey: 'customers.calendar.editor.addPeoplePlaceholder', placeholder: 'Add staff or customer\u2026' },\n to: { labelKey: 'customers.calendar.editor.to', label: 'To', placeholderKey: 'customers.calendar.editor.addRecipientPlaceholder', placeholder: 'Add recipient\u2026' },\n} as const\n\nexport function CalendarEventEditor({ open, mode, item, defaultDate, defaultRange, typeLabels, typeColors, surfacedTypes, eventCategories, conflictScope, currentUserId, onOpenChange, onSaved }: CalendarEventEditorProps) {\n const t = useT()\n const locale = useLocale()\n const [form, setForm] = React.useState<EditorFormState>(() => createDefaultFormState(defaultDate ?? null, undefined, defaultRange ?? null))\n const [fieldErrors, setFieldErrors] = React.useState<FieldErrors>({})\n const [saving, setSaving] = React.useState(false)\n const openKeyRef = React.useRef<string | null>(null)\n const isEdit = mode === 'edit' && Boolean(item?.id)\n const config = KIND_CONFIG[form.kind]\n\n const update = React.useCallback((patch: Partial<EditorFormState>) => {\n setForm((previous) => ({ ...previous, ...patch }))\n }, [])\n\n React.useEffect(() => {\n if (!open) {\n openKeyRef.current = null\n return\n }\n const key = `${mode}:${item?.id ?? 'new'}`\n if (openKeyRef.current === key) return\n openKeyRef.current = key\n setForm(\n mode === 'edit' && item\n ? parseItemToFormState(item)\n : createDefaultFormState(defaultDate ?? null, undefined, defaultRange ?? null),\n )\n setFieldErrors({})\n }, [open, mode, item, defaultDate, defaultRange])\n\n useEditorLabelResolution(open, form, update)\n // Probe against the owner the interaction will actually be SAVED with so the\n // editor warning matches the grid's post-save conflict rings: tasks own via\n // their assignee, other kinds stay ownerless on create / keep the existing\n // owner on edit (conflicts then come from shared participants).\n const draftOwnerUserId = resolveSavedOwnerUserId(config, form, isEdit, item?.ownerUserId ?? null)\n // Self-exclude by the underlying interaction id (raw.id): findEditorConflictItems\n // drops candidates by raw.id, and every expanded occurrence of a recurring series\n // shares it \u2014 so the edited record never conflicts with itself. (asEditableItem\n // already normalizes a clicked occurrence's id to raw.id, so these match today;\n // raw.id keeps it correct even if a future edit path skips that normalization.)\n const conflict = useConflictProbe(open, form, config, isEdit && item ? item.raw.id : null, draftOwnerUserId, conflictScope ?? 'all', currentUserId ?? null)\n\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n resourceId: string\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: 'customers-calendar-event-editor',\n blockedMessage: t('ui.forms.flash.saveBlocked', 'Save blocked by validation'),\n })\n\n const handleSave = React.useCallback(async () => {\n const errors: FieldErrors = {}\n if (!form.title.trim()) errors.title = t('customers.calendar.editor.validation.titleRequired', 'Title is required')\n if (!form.relatedTo) errors.relatedTo = t('customers.calendar.editor.validation.relatedToRequired', 'Select a person or company to link this event')\n if (config.hasEnd && !form.allDay && computeDurationMinutes(form) === null) {\n errors.ends = t('customers.calendar.editor.validation.endsBeforeStarts', 'End must be after start')\n }\n setFieldErrors(errors)\n if (Object.keys(errors).length > 0) return\n setSaving(true)\n try {\n const payload = buildInteractionPayload(form, { mode, id: item?.id })\n await runMutation({\n operation: () => {\n const call = () =>\n apiCallOrThrow('/api/customers/interactions', {\n method: isEdit ? 'PUT' : 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(payload),\n })\n return isEdit ? withScopedApiRequestHeaders(buildOptimisticLockHeader(item?.updatedAt), call) : call()\n },\n mutationPayload: {\n operation: isEdit ? 'updateCalendarEvent' : 'createCalendarEvent',\n interactionId: item?.id ?? null,\n interactionType: form.category ?? form.kind,\n },\n context: {\n formId: 'customers-calendar-event-editor',\n resourceKind: 'customers.interaction',\n resourceId: item?.id ?? 'new',\n retryLastMutation,\n },\n })\n flash(t('customers.calendar.editor.saved', 'Event saved'), 'success')\n onOpenChange(false)\n requestAnimationFrame(() => { onSaved() })\n } catch (err) {\n // An optimistic-lock 409 is surfaced as the persistent conflict bar by\n // useGuardedMutation (surfaceRecordConflict) \u2014 close without re-flashing.\n if (extractOptimisticLockConflict(err)) {\n onOpenChange(false)\n return\n }\n const { message } = mapCrudServerErrorToFormErrors(err)\n const key = typeof message === 'string' ? message.trim() : ''\n flash(key ? t(key, key) : t('customers.calendar.editor.error', 'Failed to save event'), 'error')\n } finally {\n setSaving(false)\n }\n }, [config.hasEnd, form, isEdit, item?.id, mode, onOpenChange, onSaved, retryLastMutation, runMutation, t])\n\n const handleKeyDown = useDialogKeyHandler({ onConfirm: handleSave, disabled: saving })\n\n const categoryOptions = React.useMemo(\n () =>\n buildEditorCategoryOptions({\n typeLabels,\n surfacedTypes: surfacedTypes ?? [],\n eventCategories: eventCategories ?? [],\n selectedValue: form.category ?? form.kind,\n selectedFallbackLabel: t(`customers.calendar.editor.types.${form.kind}`, form.kind),\n }),\n [typeLabels, surfacedTypes, eventCategories, form.category, form.kind, t],\n )\n\n const titleLabel = form.kind === 'email'\n ? t('customers.calendar.editor.titleLabel.email', 'Subject')\n : form.kind === 'note'\n ? t('customers.calendar.editor.titleLabel.note', 'Note')\n : t('customers.calendar.editor.titleLabel.generic', 'Title')\n const dialogTitle = isEdit ? t('customers.calendar.editor.title.edit', 'Edit event') : t('customers.calendar.editor.title.create', 'New event')\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent\n onKeyDown={handleKeyDown}\n aria-describedby={undefined}\n dismissible={false}\n className=\"flex h-dvh max-h-dvh w-screen max-w-none flex-col gap-0 overflow-hidden rounded-none border-0 bg-background p-0 shadow-xl sm:h-auto sm:max-h-screen sm:w-full sm:max-w-md sm:rounded-2xl sm:border-0\"\n >\n <VisuallyHidden>\n <DialogTitle>{dialogTitle}</DialogTitle>\n </VisuallyHidden>\n <div className=\"flex shrink-0 items-center gap-3 border-b border-border bg-background py-4 pl-5 pr-4\">\n <Calendar aria-hidden className=\"size-6 shrink-0 text-foreground\" strokeWidth={1.75} />\n <p className=\"min-w-0 flex-1 text-sm font-medium leading-5 text-foreground\">{dialogTitle}</p>\n <IconButton\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => onOpenChange(false)}\n aria-label={t('customers.calendar.editor.close', 'Close')}\n className=\"shrink-0 text-muted-foreground\"\n >\n <X aria-hidden className=\"size-5\" />\n </IconButton>\n </div>\n <div className=\"flex-1 overflow-y-auto\">\n <div className=\"flex flex-col items-start gap-5 px-4 py-5 sm:px-6 sm:py-6\">\n {conflict ? (\n <Alert variant=\"warning\" className=\"rounded-lg\">\n <AlertTitle>{t('customers.calendar.editor.conflictTitle', 'Calendar conflict')}</AlertTitle>\n <AlertDescription>{conflict}</AlertDescription>\n </Alert>\n ) : null}\n <SegmentGroup<EditorKind>\n ariaLabel={t('customers.calendar.editor.typeSwitcher', 'Event type')}\n value={form.kind}\n onChange={(kind) => update({ kind, category: null })}\n options={EDITOR_KINDS.map((kind) => ({ value: kind, label: t(`customers.calendar.editor.types.${kind}`, kind) }))}\n />\n <Field label={titleLabel} error={fieldErrors.title}>\n <Input\n type=\"text\"\n value={form.title}\n onChange={(event) => update({ title: event.target.value })}\n placeholder={t('customers.calendar.editor.titlePlaceholder', 'Add a title\u2026')}\n aria-label={titleLabel}\n autoFocus\n size=\"lg\"\n />\n </Field>\n <Field label={t('customers.calendar.editor.relatedTo', 'Related to')} error={fieldErrors.relatedTo}>\n <RelatedToField\n label={t('customers.calendar.editor.relatedTo', 'Related to')}\n value={form.relatedTo}\n deal={form.dealId && form.dealLabel ? { id: form.dealId, label: form.dealLabel } : null}\n onChange={(relatedTo) => update({ relatedTo })}\n onDealChange={(deal) => update({ dealId: deal?.id ?? null, dealLabel: deal?.label ?? null })}\n error={fieldErrors.relatedTo}\n />\n </Field>\n <ScheduleSection\n dateLabel={config.dateLabel}\n hasAllDay={config.hasAllDay}\n hasEnd={config.hasEnd}\n allDay={form.allDay}\n date={form.date}\n startTime={form.startTime}\n endDate={form.endDate}\n endTime={form.endTime}\n locale={locale}\n endsError={fieldErrors.ends}\n onAllDayChange={(allDay) => update({ allDay })}\n onDateChange={(date) => {\n const untouchedDefault =\n JSON.stringify(form.repeatDays) === JSON.stringify(defaultRepeatDaysForDateInput(form.date))\n update(\n untouchedDefault\n ? { date, repeatDays: defaultRepeatDaysForDateInput(date) }\n : { date },\n )\n }}\n onStartTimeChange={(startTime) => update({ startTime })}\n onEndDateChange={(endDate) => update({ endDate })}\n onEndTimeChange={(endTime) => update({ endTime })}\n />\n {config.hasRepeat ? (\n <RepeatField\n freq={form.repeatFreq}\n days={form.repeatDays}\n endType={form.repeatEndType}\n count={form.repeatCount}\n untilDate={form.repeatUntilDate}\n locale={locale}\n onFreqChange={(repeatFreq) =>\n update(\n repeatFreq === 'weekly'\n ? { repeatFreq, repeatDays: defaultRepeatDaysForDateInput(form.date) }\n : { repeatFreq },\n )}\n onToggleDay={(index) =>\n update({ repeatDays: form.repeatDays.map((active, dayIndex) => (dayIndex === index ? !active : active)) })}\n onEndTypeChange={(repeatEndType) => update({ repeatEndType })}\n onCountChange={(repeatCount) => update({ repeatCount })}\n onUntilDateChange={(repeatUntilDate) => update({ repeatUntilDate })}\n />\n ) : null}\n <Field label={t('customers.calendar.editor.category', 'Category')}>\n <CategoryField\n label={t('customers.calendar.editor.category', 'Category')}\n value={form.category ?? form.kind}\n options={categoryOptions}\n colors={typeColors}\n onChange={(category) => update({ category })}\n />\n </Field>\n {config.location ? (\n <LocationField variant={config.location} value={form.location} onChange={(location) => update({ location })} />\n ) : null}\n {config.people && config.people !== 'assignee' ? (\n <Field label={t(PEOPLE_FIELD_TEXT[config.people].labelKey, PEOPLE_FIELD_TEXT[config.people].label)}>\n <PeopleField\n mode=\"multi\"\n includeCustomers\n placeholder={t(PEOPLE_FIELD_TEXT[config.people].placeholderKey, PEOPLE_FIELD_TEXT[config.people].placeholder)}\n ariaLabel={t(PEOPLE_FIELD_TEXT[config.people].labelKey, PEOPLE_FIELD_TEXT[config.people].label)}\n value={form.participants}\n onChange={(participants) => update({ participants })}\n />\n </Field>\n ) : null}\n {config.hasPriority ? (\n <Field label={t('customers.calendar.editor.priority.label', 'Priority')}>\n <SegmentGroup<EditorPriority>\n size=\"md\"\n ariaLabel={t('customers.calendar.editor.priority.label', 'Priority')}\n value={form.priority}\n onChange={(priority) => update({ priority })}\n options={[\n { value: 'low', label: t('customers.calendar.editor.priority.low', 'Low') },\n { value: 'medium', label: t('customers.calendar.editor.priority.medium', 'Medium') },\n { value: 'high', label: t('customers.calendar.editor.priority.high', 'High') },\n ]}\n />\n </Field>\n ) : null}\n {config.people === 'assignee' ? (\n <Field label={t('customers.calendar.editor.assignee', 'Assignee')}>\n <PeopleField\n mode=\"single\"\n includeCustomers={false}\n placeholder={t('customers.calendar.editor.assigneePlaceholder', 'Assign to a team member\u2026')}\n ariaLabel={t('customers.calendar.editor.assignee', 'Assignee')}\n value={form.assigneeUserId\n ? [{ userId: form.assigneeUserId, name: form.assigneeName ?? form.assigneeUserId, isCustomer: false }]\n : []}\n onChange={(entries) => {\n const next = entries[entries.length - 1] ?? null\n update({ assigneeUserId: next?.userId ?? null, assigneeName: next?.name ?? null })\n }}\n />\n </Field>\n ) : null}\n <Field label={t('customers.calendar.editor.description', 'Description')}>\n <Textarea\n value={form.description}\n onChange={(event) => update({ description: event.target.value })}\n placeholder={t('customers.calendar.editor.descriptionPlaceholder', 'Add details\u2026')}\n aria-label={t('customers.calendar.editor.description', 'Description')}\n className=\"h-24 resize-none\"\n />\n </Field>\n </div>\n </div>\n <div className=\"flex shrink-0 items-center justify-end gap-3 border-t border-border bg-background px-5 py-4\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => onOpenChange(false)}\n >\n {t('customers.calendar.editor.cancel', 'Cancel')}\n </Button>\n <Button\n type=\"button\"\n onClick={handleSave}\n disabled={saving}\n >\n {saving ? t('customers.calendar.editor.saving', 'Saving\u2026') : t('customers.calendar.editor.save', 'Save event')}\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
+
"mappings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