@open-mercato/core 0.6.6-develop.6094.1.28b081ea16 → 0.6.6-develop.6126.1.0b9392fdae
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,242 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Building2, ChevronDown, User, X } from 'lucide-react'
|
|
5
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
6
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
8
|
+
import { IconButton } from '@open-mercato/ui/primitives/icon-button'
|
|
9
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
10
|
+
import type { EditorRelatedTo } from '../../../lib/calendar/editorPayload'
|
|
11
|
+
import {
|
|
12
|
+
fetchDealsForEntity,
|
|
13
|
+
searchRelatedEntities,
|
|
14
|
+
type DealOption,
|
|
15
|
+
type RelatedEntityOption,
|
|
16
|
+
} from './lookups'
|
|
17
|
+
import { CONTROL_BORDER, DROPDOWN_PANEL_CLASS, PersonChip, UppercaseBadge } from './inputs'
|
|
18
|
+
|
|
19
|
+
const OPTION_ROW_CLASS =
|
|
20
|
+
'h-auto w-full justify-start gap-2 whitespace-normal px-2 py-1.5 text-left text-sm font-normal text-foreground'
|
|
21
|
+
|
|
22
|
+
export function RelatedToField({
|
|
23
|
+
label,
|
|
24
|
+
value,
|
|
25
|
+
deal,
|
|
26
|
+
onChange,
|
|
27
|
+
onDealChange,
|
|
28
|
+
error,
|
|
29
|
+
}: {
|
|
30
|
+
label: string
|
|
31
|
+
value: EditorRelatedTo | null
|
|
32
|
+
deal: DealOption | null
|
|
33
|
+
onChange(next: EditorRelatedTo | null): void
|
|
34
|
+
onDealChange(next: DealOption | null): void
|
|
35
|
+
error?: string | null
|
|
36
|
+
}) {
|
|
37
|
+
const t = useT()
|
|
38
|
+
const [open, setOpen] = React.useState(false)
|
|
39
|
+
const [query, setQuery] = React.useState('')
|
|
40
|
+
const [options, setOptions] = React.useState<RelatedEntityOption[]>([])
|
|
41
|
+
const [deals, setDeals] = React.useState<DealOption[]>([])
|
|
42
|
+
const [loading, setLoading] = React.useState(false)
|
|
43
|
+
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (!open) return
|
|
46
|
+
const controller = new AbortController()
|
|
47
|
+
let cancelled = false
|
|
48
|
+
const timer = window.setTimeout(async () => {
|
|
49
|
+
setLoading(true)
|
|
50
|
+
try {
|
|
51
|
+
const trimmed = query.trim()
|
|
52
|
+
const [people, companies] = await Promise.all([
|
|
53
|
+
searchRelatedEntities('person', trimmed, controller.signal),
|
|
54
|
+
searchRelatedEntities('company', trimmed, controller.signal),
|
|
55
|
+
])
|
|
56
|
+
if (cancelled) return
|
|
57
|
+
setOptions([...people, ...companies])
|
|
58
|
+
} catch {
|
|
59
|
+
if (!cancelled) setOptions([])
|
|
60
|
+
} finally {
|
|
61
|
+
if (!cancelled) setLoading(false)
|
|
62
|
+
}
|
|
63
|
+
}, 200)
|
|
64
|
+
return () => {
|
|
65
|
+
cancelled = true
|
|
66
|
+
controller.abort()
|
|
67
|
+
window.clearTimeout(timer)
|
|
68
|
+
}
|
|
69
|
+
}, [open, query])
|
|
70
|
+
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
if (!open || !value || value.kind === 'unknown') {
|
|
73
|
+
setDeals([])
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
const controller = new AbortController()
|
|
77
|
+
let cancelled = false
|
|
78
|
+
fetchDealsForEntity({ id: value.id, kind: value.kind }, controller.signal)
|
|
79
|
+
.then((items) => { if (!cancelled) setDeals(items) })
|
|
80
|
+
.catch(() => { if (!cancelled) setDeals([]) })
|
|
81
|
+
return () => {
|
|
82
|
+
cancelled = true
|
|
83
|
+
controller.abort()
|
|
84
|
+
}
|
|
85
|
+
}, [open, value])
|
|
86
|
+
|
|
87
|
+
const kindLabel = (kind: RelatedEntityOption['kind']) =>
|
|
88
|
+
kind === 'person'
|
|
89
|
+
? t('customers.deals.detail.tabs.peopleSingular', 'Person')
|
|
90
|
+
: t('customers.deals.detail.tabs.companySingular', 'Company')
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
className="relative w-full"
|
|
95
|
+
onBlur={(event) => {
|
|
96
|
+
if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setOpen(false)
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<div
|
|
100
|
+
className={cn(
|
|
101
|
+
'flex h-10 w-full items-center rounded-md bg-background pl-2.5 pr-3',
|
|
102
|
+
error ? 'border border-status-error-border' : CONTROL_BORDER,
|
|
103
|
+
)}
|
|
104
|
+
>
|
|
105
|
+
<Button
|
|
106
|
+
type="button"
|
|
107
|
+
variant="ghost"
|
|
108
|
+
aria-haspopup="listbox"
|
|
109
|
+
aria-expanded={open}
|
|
110
|
+
aria-label={label}
|
|
111
|
+
onClick={() => setOpen((previous) => !previous)}
|
|
112
|
+
className="h-full min-w-0 flex-1 justify-between rounded-none bg-transparent p-0 text-left shadow-none hover:bg-transparent"
|
|
113
|
+
>
|
|
114
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
115
|
+
{value ? (
|
|
116
|
+
<PersonChip
|
|
117
|
+
compact
|
|
118
|
+
name={value.label || value.id}
|
|
119
|
+
/>
|
|
120
|
+
) : (
|
|
121
|
+
<span className="truncate text-sm text-muted-foreground">
|
|
122
|
+
{t('customers.calendar.editor.relatedToPlaceholder', 'Search people or companies…')}
|
|
123
|
+
</span>
|
|
124
|
+
)}
|
|
125
|
+
</span>
|
|
126
|
+
<span className="flex shrink-0 items-center">
|
|
127
|
+
{deal ? (
|
|
128
|
+
<UppercaseBadge className="h-7 bg-status-info-bg text-status-info-text">
|
|
129
|
+
{t('customers.calendar.editor.dealBadge', '{name} · Deal', { name: deal.label })}
|
|
130
|
+
</UppercaseBadge>
|
|
131
|
+
) : null}
|
|
132
|
+
<span aria-hidden className="h-px w-2" />
|
|
133
|
+
<ChevronDown aria-hidden className="size-4 opacity-60" />
|
|
134
|
+
</span>
|
|
135
|
+
</Button>
|
|
136
|
+
{value ? (
|
|
137
|
+
<IconButton
|
|
138
|
+
variant="ghost"
|
|
139
|
+
size="xs"
|
|
140
|
+
onClick={() => {
|
|
141
|
+
onChange(null)
|
|
142
|
+
onDealChange(null)
|
|
143
|
+
}}
|
|
144
|
+
aria-label={t('customers.calendar.editor.removeRelated', 'Clear related record')}
|
|
145
|
+
className="ms-1 shrink-0 text-muted-foreground"
|
|
146
|
+
>
|
|
147
|
+
<X aria-hidden className="size-3.5" />
|
|
148
|
+
</IconButton>
|
|
149
|
+
) : null}
|
|
150
|
+
</div>
|
|
151
|
+
{open ? (
|
|
152
|
+
<div role="listbox" aria-label={label} className={DROPDOWN_PANEL_CLASS}>
|
|
153
|
+
<Input
|
|
154
|
+
type="text"
|
|
155
|
+
value={query}
|
|
156
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
157
|
+
placeholder={t('customers.calendar.editor.relatedToPlaceholder', 'Search people or companies…')}
|
|
158
|
+
aria-label={t('customers.calendar.editor.relatedToPlaceholder', 'Search people or companies…')}
|
|
159
|
+
autoFocus
|
|
160
|
+
size="sm"
|
|
161
|
+
className="mb-1"
|
|
162
|
+
/>
|
|
163
|
+
{loading ? (
|
|
164
|
+
<p className="px-2 py-3 text-center text-xs text-muted-foreground">
|
|
165
|
+
{t('customers.calendar.editor.searching', 'Searching…')}
|
|
166
|
+
</p>
|
|
167
|
+
) : null}
|
|
168
|
+
{!loading && options.length === 0 ? (
|
|
169
|
+
<p className="px-2 py-3 text-center text-xs text-muted-foreground">
|
|
170
|
+
{t('customers.calendar.editor.noResults', 'No results')}
|
|
171
|
+
</p>
|
|
172
|
+
) : null}
|
|
173
|
+
{!loading
|
|
174
|
+
? options.map((option) => (
|
|
175
|
+
<Button
|
|
176
|
+
key={`${option.kind}:${option.id}`}
|
|
177
|
+
type="button"
|
|
178
|
+
variant="ghost"
|
|
179
|
+
role="option"
|
|
180
|
+
aria-selected={value?.id === option.id}
|
|
181
|
+
onClick={() => {
|
|
182
|
+
onChange({ id: option.id, kind: option.kind, label: option.label })
|
|
183
|
+
if (value?.id !== option.id) onDealChange(null)
|
|
184
|
+
setQuery('')
|
|
185
|
+
}}
|
|
186
|
+
className={OPTION_ROW_CLASS}
|
|
187
|
+
>
|
|
188
|
+
{option.kind === 'company'
|
|
189
|
+
? <Building2 aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
|
|
190
|
+
: <User aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />}
|
|
191
|
+
<span className="min-w-0 flex-1 truncate">
|
|
192
|
+
{option.label}
|
|
193
|
+
{option.subtitle ? <span className="ml-1.5 text-xs text-muted-foreground">{option.subtitle}</span> : null}
|
|
194
|
+
</span>
|
|
195
|
+
<span className="shrink-0 text-xs text-muted-foreground">{kindLabel(option.kind)}</span>
|
|
196
|
+
</Button>
|
|
197
|
+
))
|
|
198
|
+
: null}
|
|
199
|
+
{value && deals.length > 0 ? (
|
|
200
|
+
<>
|
|
201
|
+
<p className="px-2 pb-1 pt-2 text-overline font-medium uppercase text-muted-foreground">
|
|
202
|
+
{t('customers.calendar.editor.dealsSection', 'Deals')}
|
|
203
|
+
</p>
|
|
204
|
+
<Button
|
|
205
|
+
type="button"
|
|
206
|
+
variant="ghost"
|
|
207
|
+
role="option"
|
|
208
|
+
aria-selected={deal === null}
|
|
209
|
+
onClick={() => {
|
|
210
|
+
onDealChange(null)
|
|
211
|
+
setOpen(false)
|
|
212
|
+
}}
|
|
213
|
+
className={OPTION_ROW_CLASS}
|
|
214
|
+
>
|
|
215
|
+
{t('customers.calendar.editor.dealNone', 'No deal')}
|
|
216
|
+
</Button>
|
|
217
|
+
{deals.map((option) => (
|
|
218
|
+
<Button
|
|
219
|
+
key={option.id}
|
|
220
|
+
type="button"
|
|
221
|
+
variant="ghost"
|
|
222
|
+
role="option"
|
|
223
|
+
aria-selected={deal?.id === option.id}
|
|
224
|
+
onClick={() => {
|
|
225
|
+
onDealChange(option)
|
|
226
|
+
setOpen(false)
|
|
227
|
+
}}
|
|
228
|
+
className={OPTION_ROW_CLASS}
|
|
229
|
+
>
|
|
230
|
+
<span className="min-w-0 flex-1 truncate">{option.label}</span>
|
|
231
|
+
<UppercaseBadge className="bg-status-info-bg text-status-info-text">
|
|
232
|
+
{t('customers.calendar.editor.dealBadgeSuffix', 'Deal')}
|
|
233
|
+
</UppercaseBadge>
|
|
234
|
+
</Button>
|
|
235
|
+
))}
|
|
236
|
+
</>
|
|
237
|
+
) : null}
|
|
238
|
+
</div>
|
|
239
|
+
) : null}
|
|
240
|
+
</div>
|
|
241
|
+
)
|
|
242
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
5
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
7
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
8
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@open-mercato/ui/primitives/select'
|
|
9
|
+
import type { EditorRepeatEndType, EditorRepeatFreq } from '../../../lib/calendar/editorPayload'
|
|
10
|
+
import { DateControl, LABEL_CLASS } from './inputs'
|
|
11
|
+
import { SegmentGroup } from './SegmentGroup'
|
|
12
|
+
|
|
13
|
+
const DAY_LABEL_KEYS = [
|
|
14
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.mon', letterFallback: 'M', ariaKey: 'customers.calendar.day.mon', ariaFallback: 'MON' },
|
|
15
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.tue', letterFallback: 'T', ariaKey: 'customers.calendar.day.tue', ariaFallback: 'TUE' },
|
|
16
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.wed', letterFallback: 'W', ariaKey: 'customers.calendar.day.wed', ariaFallback: 'WED' },
|
|
17
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.thu', letterFallback: 'T', ariaKey: 'customers.calendar.day.thu', ariaFallback: 'THU' },
|
|
18
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.fri', letterFallback: 'F', ariaKey: 'customers.calendar.day.fri', ariaFallback: 'FRI' },
|
|
19
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.sat', letterFallback: 'S', ariaKey: 'customers.calendar.day.sat', ariaFallback: 'SAT' },
|
|
20
|
+
{ letterKey: 'customers.calendar.editor.repeat.days.sun', letterFallback: 'S', ariaKey: 'customers.calendar.day.sun', ariaFallback: 'SUN' },
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
export function RepeatField({
|
|
24
|
+
freq,
|
|
25
|
+
days,
|
|
26
|
+
endType,
|
|
27
|
+
count,
|
|
28
|
+
untilDate,
|
|
29
|
+
locale,
|
|
30
|
+
onFreqChange,
|
|
31
|
+
onToggleDay,
|
|
32
|
+
onEndTypeChange,
|
|
33
|
+
onCountChange,
|
|
34
|
+
onUntilDateChange,
|
|
35
|
+
}: {
|
|
36
|
+
freq: EditorRepeatFreq
|
|
37
|
+
days: boolean[]
|
|
38
|
+
endType: EditorRepeatEndType
|
|
39
|
+
count: number
|
|
40
|
+
untilDate: string
|
|
41
|
+
locale: string
|
|
42
|
+
onFreqChange(next: EditorRepeatFreq): void
|
|
43
|
+
onToggleDay(index: number): void
|
|
44
|
+
onEndTypeChange(next: EditorRepeatEndType): void
|
|
45
|
+
onCountChange(next: number): void
|
|
46
|
+
onUntilDateChange(next: string): void
|
|
47
|
+
}) {
|
|
48
|
+
const t = useT()
|
|
49
|
+
const freqLabel = t('customers.calendar.editor.repeat.label', 'Repeat')
|
|
50
|
+
return (
|
|
51
|
+
<div className="flex w-full flex-col gap-2.5">
|
|
52
|
+
<span className={LABEL_CLASS}>{freqLabel}</span>
|
|
53
|
+
<Select
|
|
54
|
+
value={freq}
|
|
55
|
+
onValueChange={(value) => onFreqChange(value as EditorRepeatFreq)}
|
|
56
|
+
>
|
|
57
|
+
<SelectTrigger aria-label={freqLabel}>
|
|
58
|
+
<SelectValue />
|
|
59
|
+
</SelectTrigger>
|
|
60
|
+
<SelectContent>
|
|
61
|
+
<SelectItem value="none">{t('customers.calendar.editor.repeat.freq.none', 'Does not repeat')}</SelectItem>
|
|
62
|
+
<SelectItem value="daily">{t('customers.calendar.editor.repeat.freq.daily', 'Daily')}</SelectItem>
|
|
63
|
+
<SelectItem value="weekly">{t('customers.calendar.editor.repeat.freq.weekly', 'Weekly')}</SelectItem>
|
|
64
|
+
</SelectContent>
|
|
65
|
+
</Select>
|
|
66
|
+
{freq === 'weekly' ? (
|
|
67
|
+
<div className="flex items-start gap-1.5">
|
|
68
|
+
{DAY_LABEL_KEYS.map((day, index) => {
|
|
69
|
+
const isActive = Boolean(days[index])
|
|
70
|
+
return (
|
|
71
|
+
<Button
|
|
72
|
+
key={day.ariaKey}
|
|
73
|
+
type="button"
|
|
74
|
+
variant={isActive ? 'default' : 'outline'}
|
|
75
|
+
aria-pressed={isActive}
|
|
76
|
+
aria-label={t(day.ariaKey, day.ariaFallback)}
|
|
77
|
+
onClick={() => onToggleDay(index)}
|
|
78
|
+
className={cn(
|
|
79
|
+
'size-9 px-0 text-xs font-medium',
|
|
80
|
+
!isActive && 'text-muted-foreground',
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
{t(day.letterKey, day.letterFallback)}
|
|
84
|
+
</Button>
|
|
85
|
+
)
|
|
86
|
+
})}
|
|
87
|
+
</div>
|
|
88
|
+
) : null}
|
|
89
|
+
{freq !== 'none' ? (
|
|
90
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
91
|
+
<span className={LABEL_CLASS}>{t('customers.calendar.editor.repeat.ends', 'Ends')}</span>
|
|
92
|
+
<SegmentGroup
|
|
93
|
+
ariaLabel={t('customers.calendar.editor.repeat.ends', 'Ends')}
|
|
94
|
+
value={endType}
|
|
95
|
+
onChange={onEndTypeChange}
|
|
96
|
+
options={[
|
|
97
|
+
{ value: 'never', label: t('customers.calendar.editor.repeat.never', 'Never') },
|
|
98
|
+
{ value: 'date', label: t('customers.calendar.editor.repeat.onDate', 'On date') },
|
|
99
|
+
{ value: 'count', label: t('customers.calendar.editor.repeat.after', 'After') },
|
|
100
|
+
]}
|
|
101
|
+
/>
|
|
102
|
+
{endType === 'date' ? (
|
|
103
|
+
<DateControl
|
|
104
|
+
className="w-44"
|
|
105
|
+
value={untilDate || ''}
|
|
106
|
+
onChange={onUntilDateChange}
|
|
107
|
+
ariaLabel={t('customers.calendar.editor.repeat.onDate', 'On date')}
|
|
108
|
+
locale={locale}
|
|
109
|
+
/>
|
|
110
|
+
) : null}
|
|
111
|
+
{endType === 'count' ? (
|
|
112
|
+
<span className="flex items-center gap-2">
|
|
113
|
+
<Input
|
|
114
|
+
type="number"
|
|
115
|
+
min={1}
|
|
116
|
+
max={365}
|
|
117
|
+
value={count}
|
|
118
|
+
onChange={(event) => {
|
|
119
|
+
const next = Number(event.target.value)
|
|
120
|
+
if (Number.isInteger(next) && next >= 1) onCountChange(next)
|
|
121
|
+
}}
|
|
122
|
+
aria-label={t('customers.calendar.editor.repeat.after', 'After')}
|
|
123
|
+
className="h-9 w-20"
|
|
124
|
+
/>
|
|
125
|
+
<span className={LABEL_CLASS}>{t('customers.calendar.editor.repeat.times', 'times')}</span>
|
|
126
|
+
</span>
|
|
127
|
+
) : null}
|
|
128
|
+
</div>
|
|
129
|
+
) : null}
|
|
130
|
+
</div>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
5
|
+
import type { EditorDateLabel } from '../../../lib/calendar/editorPayload'
|
|
6
|
+
import { AllDayToggle, DateControl, LABEL_CLASS, TimeControl } from './inputs'
|
|
7
|
+
|
|
8
|
+
const DATE_LABEL_TEXT: Record<EditorDateLabel, { key: string; fallback: string }> = {
|
|
9
|
+
starts: { key: 'customers.calendar.editor.dates.starts', fallback: 'Starts' },
|
|
10
|
+
when: { key: 'customers.calendar.editor.dates.when', fallback: 'When' },
|
|
11
|
+
sent: { key: 'customers.calendar.editor.dates.sent', fallback: 'Sent' },
|
|
12
|
+
logged: { key: 'customers.calendar.editor.dates.logged', fallback: 'Logged' },
|
|
13
|
+
due: { key: 'customers.calendar.editor.dates.due', fallback: 'Due' },
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DateTimeRow({
|
|
17
|
+
label,
|
|
18
|
+
date,
|
|
19
|
+
time,
|
|
20
|
+
showTime,
|
|
21
|
+
locale,
|
|
22
|
+
onDateChange,
|
|
23
|
+
onTimeChange,
|
|
24
|
+
}: {
|
|
25
|
+
label: string
|
|
26
|
+
date: string
|
|
27
|
+
time: string
|
|
28
|
+
showTime: boolean
|
|
29
|
+
locale: string
|
|
30
|
+
onDateChange(next: string): void
|
|
31
|
+
onTimeChange(next: string): void
|
|
32
|
+
}) {
|
|
33
|
+
return (
|
|
34
|
+
<div className="flex w-full items-end gap-2.5">
|
|
35
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1.5">
|
|
36
|
+
<span className={LABEL_CLASS}>{label}</span>
|
|
37
|
+
<DateControl value={date} onChange={onDateChange} ariaLabel={label} locale={locale} />
|
|
38
|
+
</div>
|
|
39
|
+
{showTime ? <TimeControl value={time} onChange={onTimeChange} ariaLabel={label} /> : null}
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function ScheduleSection({
|
|
45
|
+
dateLabel,
|
|
46
|
+
hasAllDay,
|
|
47
|
+
hasEnd,
|
|
48
|
+
allDay,
|
|
49
|
+
date,
|
|
50
|
+
startTime,
|
|
51
|
+
endDate,
|
|
52
|
+
endTime,
|
|
53
|
+
locale,
|
|
54
|
+
endsError,
|
|
55
|
+
onAllDayChange,
|
|
56
|
+
onDateChange,
|
|
57
|
+
onStartTimeChange,
|
|
58
|
+
onEndDateChange,
|
|
59
|
+
onEndTimeChange,
|
|
60
|
+
}: {
|
|
61
|
+
dateLabel: EditorDateLabel
|
|
62
|
+
hasAllDay: boolean
|
|
63
|
+
hasEnd: boolean
|
|
64
|
+
allDay: boolean
|
|
65
|
+
date: string
|
|
66
|
+
startTime: string
|
|
67
|
+
endDate: string
|
|
68
|
+
endTime: string
|
|
69
|
+
locale: string
|
|
70
|
+
endsError?: string | null
|
|
71
|
+
onAllDayChange(next: boolean): void
|
|
72
|
+
onDateChange(next: string): void
|
|
73
|
+
onStartTimeChange(next: string): void
|
|
74
|
+
onEndDateChange(next: string): void
|
|
75
|
+
onEndTimeChange(next: string): void
|
|
76
|
+
}) {
|
|
77
|
+
const t = useT()
|
|
78
|
+
const showTime = !(hasAllDay && allDay)
|
|
79
|
+
return (
|
|
80
|
+
<div className="flex w-full flex-col gap-2.5">
|
|
81
|
+
{hasAllDay ? (
|
|
82
|
+
<div className="flex w-full items-center justify-between">
|
|
83
|
+
<span className={LABEL_CLASS}>{t('customers.calendar.editor.allDay', 'All day')}</span>
|
|
84
|
+
<AllDayToggle checked={allDay} onCheckedChange={onAllDayChange} label={t('customers.calendar.editor.allDay', 'All day')} />
|
|
85
|
+
</div>
|
|
86
|
+
) : null}
|
|
87
|
+
<DateTimeRow
|
|
88
|
+
label={t(DATE_LABEL_TEXT[dateLabel].key, DATE_LABEL_TEXT[dateLabel].fallback)}
|
|
89
|
+
date={date}
|
|
90
|
+
time={startTime}
|
|
91
|
+
showTime={showTime}
|
|
92
|
+
locale={locale}
|
|
93
|
+
onDateChange={onDateChange}
|
|
94
|
+
onTimeChange={onStartTimeChange}
|
|
95
|
+
/>
|
|
96
|
+
{hasEnd ? (
|
|
97
|
+
<DateTimeRow
|
|
98
|
+
label={t('customers.calendar.editor.dates.ends', 'Ends')}
|
|
99
|
+
date={endDate}
|
|
100
|
+
time={endTime}
|
|
101
|
+
showTime={showTime}
|
|
102
|
+
locale={locale}
|
|
103
|
+
onDateChange={onEndDateChange}
|
|
104
|
+
onTimeChange={onEndTimeChange}
|
|
105
|
+
/>
|
|
106
|
+
) : null}
|
|
107
|
+
{endsError ? <p className="text-xs text-status-error-text">{endsError}</p> : null}
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
|
|
7
|
+
export type SegmentOption<T extends string> = { value: T; label: string }
|
|
8
|
+
|
|
9
|
+
export function SegmentGroup<T extends string>({
|
|
10
|
+
options,
|
|
11
|
+
value,
|
|
12
|
+
onChange,
|
|
13
|
+
size = 'sm',
|
|
14
|
+
ariaLabel,
|
|
15
|
+
}: {
|
|
16
|
+
options: Array<SegmentOption<T>>
|
|
17
|
+
value: T
|
|
18
|
+
onChange(next: T): void
|
|
19
|
+
size?: 'sm' | 'md'
|
|
20
|
+
ariaLabel: string
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
role="group"
|
|
25
|
+
aria-label={ariaLabel}
|
|
26
|
+
className="inline-flex max-w-full items-start overflow-x-auto rounded-md border border-border bg-background"
|
|
27
|
+
>
|
|
28
|
+
{options.map((option, index) => {
|
|
29
|
+
const isActive = option.value === value
|
|
30
|
+
return (
|
|
31
|
+
<Button
|
|
32
|
+
key={option.value}
|
|
33
|
+
type="button"
|
|
34
|
+
variant="ghost"
|
|
35
|
+
aria-pressed={isActive}
|
|
36
|
+
onClick={() => onChange(option.value)}
|
|
37
|
+
className={cn(
|
|
38
|
+
'h-auto rounded-none border-0 text-sm font-medium leading-5 shadow-none',
|
|
39
|
+
size === 'md' ? 'px-4 py-2' : 'px-3.5 py-1.5',
|
|
40
|
+
index > 0 && 'border-l border-border',
|
|
41
|
+
isActive ? 'bg-muted text-foreground hover:bg-muted' : 'bg-background text-muted-foreground',
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
{option.label}
|
|
45
|
+
</Button>
|
|
46
|
+
)
|
|
47
|
+
})}
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|