@open-mercato/core 0.5.1-develop.2949.009dcdd2d5 → 0.5.1-develop.2954.610bab2d08
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/dist/helpers/integration/salesUi.js +25 -23
- package/dist/helpers/integration/salesUi.js.map +2 -2
- package/dist/modules/api_docs/frontend/docs/api/Explorer.js +24 -24
- package/dist/modules/api_docs/frontend/docs/api/Explorer.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentPartitionSettings.js +15 -7
- package/dist/modules/attachments/components/AttachmentPartitionSettings.js.map +2 -2
- package/dist/modules/attachments/fields/attachment.js +4 -6
- package/dist/modules/attachments/fields/attachment.js.map +2 -2
- package/dist/modules/auth/api/users/route.js +63 -23
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/backend/users/create/page.js +26 -26
- package/dist/modules/auth/backend/users/create/page.js.map +2 -2
- package/dist/modules/business_rules/components/ActionRow.js +36 -25
- package/dist/modules/business_rules/components/ActionRow.js.map +2 -2
- package/dist/modules/business_rules/components/ConditionGroup.js +14 -5
- package/dist/modules/business_rules/components/ConditionGroup.js.map +2 -2
- package/dist/modules/business_rules/components/ConditionRow.js +19 -10
- package/dist/modules/business_rules/components/ConditionRow.js.map +2 -2
- package/dist/modules/business_rules/components/RuleSetMembers.js +16 -10
- package/dist/modules/business_rules/components/RuleSetMembers.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +30 -34
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +220 -223
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/components/PriceKindSettings.js +20 -19
- package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductUomSection.js +42 -37
- package/dist/modules/catalog/components/products/ProductUomSection.js.map +2 -2
- package/dist/modules/catalog/components/products/VariantBuilder.js +22 -18
- package/dist/modules/catalog/components/products/VariantBuilder.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js +18 -26
- 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 +4 -6
- package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +2 -2
- package/dist/modules/customer_accounts/widgets/injection/account-status/widget.client.js +5 -4
- package/dist/modules/customer_accounts/widgets/injection/account-status/widget.client.js.map +2 -2
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js +19 -7
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/page.js +24 -21
- package/dist/modules/customers/backend/customers/deals/pipeline/page.js.map +2 -2
- package/dist/modules/customers/components/AddressEditor.js +24 -7
- package/dist/modules/customers/components/AddressEditor.js.map +2 -2
- package/dist/modules/customers/components/AddressFormatSettings.js +35 -25
- package/dist/modules/customers/components/AddressFormatSettings.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivityForm.js +20 -12
- package/dist/modules/customers/components/detail/ActivityForm.js.map +2 -2
- package/dist/modules/customers/components/detail/AnnualRevenueField.js +2 -2
- package/dist/modules/customers/components/detail/AnnualRevenueField.js.map +2 -2
- package/dist/modules/customers/components/detail/DealForm.js +19 -14
- package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
- package/dist/modules/customers/components/formConfig.js +16 -12
- package/dist/modules/customers/components/formConfig.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js +3 -2
- package/dist/modules/customers/widgets/dashboard/customer-todos/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/new-customers/widget.client.js +18 -10
- package/dist/modules/customers/widgets/dashboard/new-customers/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/new-deals/widget.client.js +3 -2
- package/dist/modules/customers/widgets/dashboard/new-deals/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/dashboard/next-interactions/widget.client.js +3 -2
- package/dist/modules/customers/widgets/dashboard/next-interactions/widget.client.js.map +2 -2
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js +27 -28
- package/dist/modules/dashboards/components/WidgetVisibilityEditor.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.client.js +14 -6
- package/dist/modules/dashboards/widgets/dashboard/orders-by-status/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.client.js +14 -6
- package/dist/modules/dashboards/widgets/dashboard/revenue-trend/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.client.js +3 -2
- package/dist/modules/dashboards/widgets/dashboard/sales-by-region/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.client.js +3 -2
- package/dist/modules/dashboards/widgets/dashboard/top-customers/widget.client.js.map +2 -2
- package/dist/modules/dashboards/widgets/dashboard/top-products/widget.client.js +17 -8
- package/dist/modules/dashboards/widgets/dashboard/top-products/widget.client.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +40 -23
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js +15 -6
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js.map +2 -2
- package/dist/modules/dictionaries/components/AppearanceSelector.js +4 -4
- package/dist/modules/dictionaries/components/AppearanceSelector.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js +4 -5
- package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryEntrySelect.js +22 -14
- package/dist/modules/dictionaries/components/DictionaryEntrySelect.js.map +2 -2
- package/dist/modules/dictionaries/fields/dictionary.js +18 -13
- package/dist/modules/dictionaries/fields/dictionary.js.map +2 -2
- package/dist/modules/entities/components/EncryptionManager.js +23 -19
- package/dist/modules/entities/components/EncryptionManager.js.map +2 -2
- package/dist/modules/feature_toggles/components/formConfig.js +17 -9
- package/dist/modules/feature_toggles/components/formConfig.js.map +2 -2
- package/dist/modules/feature_toggles/components/overrideFormConfig.js +17 -9
- package/dist/modules/feature_toggles/components/overrideFormConfig.js.map +2 -2
- package/dist/modules/inbox_ops/backend/inbox-ops/settings/page.js +15 -8
- package/dist/modules/inbox_ops/backend/inbox-ops/settings/page.js.map +2 -2
- package/dist/modules/inbox_ops/components/proposals/EditActionDialog.js +37 -22
- package/dist/modules/inbox_ops/components/proposals/EditActionDialog.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/[id]/page.js +22 -17
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +12 -6
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +2 -2
- package/dist/modules/planner/components/AvailabilityRulesEditor.js +19 -12
- package/dist/modules/planner/components/AvailabilityRulesEditor.js.map +2 -2
- package/dist/modules/resources/components/ResourceCrudForm.js +15 -10
- package/dist/modules/resources/components/ResourceCrudForm.js.map +3 -3
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +15 -18
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/components/ProviderFieldInput.js +23 -20
- package/dist/modules/sales/components/ProviderFieldInput.js.map +2 -2
- package/dist/modules/sales/components/ShippingMethodsSettings.js +25 -17
- package/dist/modules/sales/components/ShippingMethodsSettings.js.map +3 -3
- package/dist/modules/sales/components/channels/ChannelOfferForm.js +35 -42
- package/dist/modules/sales/components/channels/ChannelOfferForm.js.map +2 -2
- package/dist/modules/sales/components/documents/AddressesSection.js +87 -90
- package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
- package/dist/modules/sales/components/documents/AdjustmentDialog.js +17 -6
- package/dist/modules/sales/components/documents/AdjustmentDialog.js.map +3 -3
- package/dist/modules/sales/components/documents/LineItemDialog.js +42 -25
- package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentForm.js +96 -87
- package/dist/modules/sales/components/documents/SalesDocumentForm.js.map +2 -2
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js +20 -11
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js.map +2 -2
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js +20 -11
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js.map +2 -2
- package/dist/modules/shipping_carriers/lib/shipment-wizard/components/ConfigureStep.js +36 -22
- package/dist/modules/shipping_carriers/lib/shipment-wizard/components/ConfigureStep.js.map +2 -2
- package/dist/modules/staff/components/TeamMemberForm.js +14 -9
- package/dist/modules/staff/components/TeamMemberForm.js.map +3 -3
- package/dist/modules/workflows/backend/tasks/[id]/page.js +42 -21
- package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
- package/dist/modules/workflows/components/ActivitiesEditor.js +14 -6
- package/dist/modules/workflows/components/ActivitiesEditor.js.map +3 -3
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js +25 -17
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +3 -3
- package/dist/modules/workflows/components/EdgeEditDialog.js +48 -45
- package/dist/modules/workflows/components/EdgeEditDialog.js.map +2 -2
- package/dist/modules/workflows/components/NodeEditDialog.js +90 -90
- package/dist/modules/workflows/components/NodeEditDialog.js.map +2 -2
- package/dist/modules/workflows/components/StepsEditor.js +14 -6
- package/dist/modules/workflows/components/StepsEditor.js.map +3 -3
- package/dist/modules/workflows/components/TransitionsEditor.js +31 -26
- package/dist/modules/workflows/components/TransitionsEditor.js.map +3 -3
- package/dist/modules/workflows/components/fields/ActivityArrayEditor.js +19 -11
- package/dist/modules/workflows/components/fields/ActivityArrayEditor.js.map +3 -3
- package/dist/modules/workflows/components/fields/BusinessRuleConditionsEditor.js +12 -14
- package/dist/modules/workflows/components/fields/BusinessRuleConditionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/FormFieldArrayEditor.js +24 -16
- package/dist/modules/workflows/components/fields/FormFieldArrayEditor.js.map +3 -3
- package/dist/modules/workflows/components/fields/StartPreConditionsEditor.js +12 -13
- package/dist/modules/workflows/components/fields/StartPreConditionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileTaskForm.js +12 -8
- package/dist/modules/workflows/components/mobile/MobileTaskForm.js.map +2 -2
- package/dist/modules/workflows/frontend/checkout-demo/page.js +43 -46
- package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
- package/package.json +3 -3
- package/src/helpers/integration/salesUi.ts +40 -30
- package/src/modules/api_docs/frontend/docs/api/Explorer.tsx +25 -19
- package/src/modules/attachments/components/AttachmentPartitionSettings.tsx +21 -11
- package/src/modules/attachments/fields/attachment.tsx +4 -6
- package/src/modules/auth/api/users/route.ts +75 -25
- package/src/modules/auth/backend/users/create/page.tsx +16 -20
- package/src/modules/business_rules/components/ActionRow.tsx +51 -32
- package/src/modules/business_rules/components/ConditionGroup.tsx +20 -9
- package/src/modules/business_rules/components/ConditionRow.tsx +24 -15
- package/src/modules/business_rules/components/RuleSetMembers.tsx +23 -13
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +47 -53
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +84 -87
- package/src/modules/catalog/components/PriceKindSettings.tsx +9 -9
- package/src/modules/catalog/components/products/ProductUomSection.tsx +85 -83
- package/src/modules/catalog/components/products/VariantBuilder.tsx +49 -33
- package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/page.tsx +12 -27
- package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +4 -6
- package/src/modules/customer_accounts/widgets/injection/account-status/widget.client.tsx +5 -4
- package/src/modules/customers/backend/config/customers/pipeline-stages/page.tsx +28 -15
- package/src/modules/customers/backend/customers/deals/pipeline/page.tsx +37 -26
- package/src/modules/customers/components/AddressEditor.tsx +30 -16
- package/src/modules/customers/components/AddressFormatSettings.tsx +25 -19
- package/src/modules/customers/components/detail/ActivityForm.tsx +35 -23
- package/src/modules/customers/components/detail/AnnualRevenueField.tsx +2 -2
- package/src/modules/customers/components/detail/DealForm.tsx +33 -20
- package/src/modules/customers/components/formConfig.tsx +25 -17
- package/src/modules/customers/widgets/dashboard/customer-todos/widget.client.tsx +3 -2
- package/src/modules/customers/widgets/dashboard/new-customers/widget.client.tsx +21 -11
- package/src/modules/customers/widgets/dashboard/new-deals/widget.client.tsx +3 -2
- package/src/modules/customers/widgets/dashboard/next-interactions/widget.client.tsx +3 -2
- package/src/modules/dashboards/components/WidgetVisibilityEditor.tsx +17 -22
- package/src/modules/dashboards/widgets/dashboard/orders-by-status/widget.client.tsx +17 -7
- package/src/modules/dashboards/widgets/dashboard/revenue-trend/widget.client.tsx +20 -10
- package/src/modules/dashboards/widgets/dashboard/sales-by-region/widget.client.tsx +3 -2
- package/src/modules/dashboards/widgets/dashboard/top-customers/widget.client.tsx +3 -2
- package/src/modules/dashboards/widgets/dashboard/top-products/widget.client.tsx +20 -9
- package/src/modules/data_sync/backend/data-sync/page.tsx +64 -38
- package/src/modules/data_sync/components/IntegrationScheduleTab.tsx +18 -7
- package/src/modules/dictionaries/components/AppearanceSelector.tsx +4 -4
- package/src/modules/dictionaries/components/DictionaryEntriesEditor.tsx +3 -4
- package/src/modules/dictionaries/components/DictionaryEntrySelect.tsx +27 -21
- package/src/modules/dictionaries/fields/dictionary.tsx +36 -23
- package/src/modules/entities/components/EncryptionManager.tsx +49 -33
- package/src/modules/feature_toggles/components/formConfig.tsx +20 -10
- package/src/modules/feature_toggles/components/overrideFormConfig.tsx +20 -10
- package/src/modules/inbox_ops/backend/inbox-ops/settings/page.tsx +19 -10
- package/src/modules/inbox_ops/components/proposals/EditActionDialog.tsx +49 -26
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +20 -11
- package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +19 -9
- package/src/modules/planner/components/AvailabilityRulesEditor.tsx +34 -21
- package/src/modules/resources/components/ResourceCrudForm.tsx +24 -15
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +12 -15
- package/src/modules/sales/components/ProviderFieldInput.tsx +26 -17
- package/src/modules/sales/components/ShippingMethodsSettings.tsx +28 -20
- package/src/modules/sales/components/channels/ChannelOfferForm.tsx +51 -46
- package/src/modules/sales/components/documents/AddressesSection.tsx +78 -76
- package/src/modules/sales/components/documents/AdjustmentDialog.tsx +27 -15
- package/src/modules/sales/components/documents/LineItemDialog.tsx +69 -51
- package/src/modules/sales/components/documents/SalesDocumentForm.tsx +98 -87
- package/src/modules/sales/widgets/dashboard/new-orders/widget.client.tsx +23 -12
- package/src/modules/sales/widgets/dashboard/new-quotes/widget.client.tsx +23 -12
- package/src/modules/shipping_carriers/lib/shipment-wizard/components/ConfigureStep.tsx +35 -19
- package/src/modules/staff/components/TeamMemberForm.tsx +23 -14
- package/src/modules/workflows/backend/tasks/[id]/page.tsx +51 -23
- package/src/modules/workflows/components/ActivitiesEditor.tsx +20 -10
- package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +28 -18
- package/src/modules/workflows/components/EdgeEditDialog.tsx +51 -40
- package/src/modules/workflows/components/NodeEditDialog.tsx +81 -77
- package/src/modules/workflows/components/StepsEditor.tsx +20 -10
- package/src/modules/workflows/components/TransitionsEditor.tsx +61 -44
- package/src/modules/workflows/components/fields/ActivityArrayEditor.tsx +22 -12
- package/src/modules/workflows/components/fields/BusinessRuleConditionsEditor.tsx +9 -13
- package/src/modules/workflows/components/fields/FormFieldArrayEditor.tsx +27 -17
- package/src/modules/workflows/components/fields/StartPreConditionsEditor.tsx +9 -12
- package/src/modules/workflows/components/mobile/MobileTaskForm.tsx +19 -11
- package/src/modules/workflows/frontend/checkout-demo/page.tsx +71 -60
|
@@ -11,6 +11,8 @@ import { OrganizationSelect } from "@open-mercato/core/modules/directory/compone
|
|
|
11
11
|
import { TenantSelect } from "@open-mercato/core/modules/directory/components/TenantSelect";
|
|
12
12
|
import { fetchRoleOptions } from "@open-mercato/core/modules/auth/backend/users/roleOptions";
|
|
13
13
|
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
14
|
+
import { RadioGroup } from "@open-mercato/ui/primitives/radio";
|
|
15
|
+
import { RadioField } from "@open-mercato/ui/primitives/radio-field";
|
|
14
16
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
15
17
|
import { formatPasswordRequirements, getPasswordPolicy } from "@open-mercato/shared/lib/auth/passwordPolicy";
|
|
16
18
|
function TenantAwareOrganizationSelectInput({
|
|
@@ -329,32 +331,30 @@ function DashboardWidgetSelector({
|
|
|
329
331
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
330
332
|
error && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive", children: error }),
|
|
331
333
|
!error && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
332
|
-
/* @__PURE__ */ jsxs(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
] })
|
|
357
|
-
] }),
|
|
334
|
+
/* @__PURE__ */ jsxs(
|
|
335
|
+
RadioGroup,
|
|
336
|
+
{
|
|
337
|
+
className: "flex flex-row items-center gap-3 rounded-md border bg-muted/30 px-3 py-2",
|
|
338
|
+
value: mode,
|
|
339
|
+
onValueChange: (next) => onModeChange(next),
|
|
340
|
+
children: [
|
|
341
|
+
/* @__PURE__ */ jsx(
|
|
342
|
+
RadioField,
|
|
343
|
+
{
|
|
344
|
+
value: "inherit",
|
|
345
|
+
label: t("auth.users.widgets.mode.inherit", "Inherit from roles")
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
/* @__PURE__ */ jsx(
|
|
349
|
+
RadioField,
|
|
350
|
+
{
|
|
351
|
+
value: "override",
|
|
352
|
+
label: t("auth.users.widgets.mode.override", "Override for this user")
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
),
|
|
358
358
|
mode === "override" && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: catalog.map((widget) => /* @__PURE__ */ jsxs("label", { className: "flex items-start gap-3 rounded-md border px-3 py-2 hover:border-primary/40", children: [
|
|
359
359
|
/* @__PURE__ */ jsx(
|
|
360
360
|
"input",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/auth/backend/users/create/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { E } from '#generated/entities.ids.generated'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm, type CrudField, type CrudFormGroup, type CrudFieldOption } from '@open-mercato/ui/backend/CrudForm'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { collectCustomFieldValues } from '@open-mercato/ui/backend/utils/customFieldValues'\nimport { OrganizationSelect } from '@open-mercato/core/modules/directory/components/OrganizationSelect'\nimport { TenantSelect } from '@open-mercato/core/modules/directory/components/TenantSelect'\nimport { fetchRoleOptions } from '@open-mercato/core/modules/auth/backend/users/roleOptions'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { formatPasswordRequirements, getPasswordPolicy } from '@open-mercato/shared/lib/auth/passwordPolicy'\n\ntype CreateUserFormValues = {\n email: string\n password: string\n tenantId: string | null\n organizationId: string | null\n roles: string[]\n} & Record<string, unknown>\n\ntype UserListResponse = {\n isSuperAdmin?: boolean\n}\n\ntype WidgetCatalogResponse = {\n items?: Array<{ id?: string | null; title?: string | null; description?: string | null }>\n}\n\ntype TenantAwareOrganizationSelectProps = {\n fieldId: string\n value: string | null\n setValue: (value: string | null) => void\n tenantId: string | null\n includeInactiveIds?: Iterable<string | null | undefined>\n}\n\nfunction TenantAwareOrganizationSelectInput({\n fieldId,\n value,\n setValue,\n tenantId,\n includeInactiveIds,\n}: TenantAwareOrganizationSelectProps) {\n const prevTenantRef = React.useRef<string | null>(tenantId)\n const hydratedRef = React.useRef(false)\n const handleChange = React.useCallback((next: string | null) => {\n setValue(next ?? null)\n }, [setValue])\n\n React.useEffect(() => {\n if (!hydratedRef.current) {\n hydratedRef.current = true\n prevTenantRef.current = tenantId\n return\n }\n if (prevTenantRef.current !== tenantId) {\n prevTenantRef.current = tenantId\n setValue(null)\n }\n }, [tenantId, setValue])\n\n return (\n <OrganizationSelect\n id={fieldId}\n value={value}\n onChange={handleChange}\n required\n includeEmptyOption\n className=\"w-full h-9 rounded border px-2 text-sm\"\n tenantId={tenantId}\n includeInactiveIds={includeInactiveIds}\n />\n )\n}\n\nexport default function CreateUserPage() {\n const t = useT()\n const [widgetCatalog, setWidgetCatalog] = React.useState<Array<{ id: string; title: string; description: string | null }>>([])\n const [widgetLoading, setWidgetLoading] = React.useState(true)\n const [widgetError, setWidgetError] = React.useState<string | null>(null)\n const [widgetMode, setWidgetMode] = React.useState<'inherit' | 'override'>('inherit')\n const [selectedWidgets, setSelectedWidgets] = React.useState<string[]>([])\n const [selectedTenantId, setSelectedTenantId] = React.useState<string | null>(null)\n const [actorIsSuperAdmin, setActorIsSuperAdmin] = React.useState(false)\n const [actorResolved, setActorResolved] = React.useState(false)\n const [sendInviteEmail, setSendInviteEmail] = React.useState(false)\n const passwordPolicy = React.useMemo(() => getPasswordPolicy(), [])\n const passwordRequirements = React.useMemo(\n () => formatPasswordRequirements(passwordPolicy, t),\n [passwordPolicy, t],\n )\n const passwordDescription = React.useMemo(() => (\n passwordRequirements\n ? t('auth.password.requirements.help', 'Password requirements: {requirements}', { requirements: passwordRequirements })\n : undefined\n ), [passwordRequirements, t])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadCatalog() {\n setWidgetLoading(true)\n setWidgetError(null)\n try {\n const { ok, result } = await apiCall<WidgetCatalogResponse>('/api/dashboards/widgets/catalog')\n if (!ok) throw new Error('request_failed')\n if (!cancelled) {\n const rawItems: unknown[] = Array.isArray(result?.items) ? result?.items ?? [] : []\n const normalized = rawItems\n .map((item: unknown) => {\n if (!item || typeof item !== 'object') return null\n const entry = item as Record<string, unknown>\n const idValue = entry.id\n const titleValue = entry.title\n const descriptionValue = entry.description\n const id = typeof idValue === 'string' ? idValue : null\n if (!id || !id.length) return null\n const title = typeof titleValue === 'string' && titleValue.length > 0 ? titleValue : id\n const description = typeof descriptionValue === 'string' && descriptionValue.length > 0 ? descriptionValue : null\n return { id, title, description }\n })\n .filter((item): item is { id: string; title: string; description: string | null } => item !== null)\n setWidgetCatalog(normalized)\n }\n } catch (err) {\n console.error('Failed to load dashboard widget catalog', err)\n if (!cancelled) {\n setWidgetError(t(\n 'auth.users.widgets.errors.load',\n 'Unable to load dashboard widgets. You can configure them later from the user page.',\n ))\n }\n } finally {\n if (!cancelled) setWidgetLoading(false)\n }\n }\n loadCatalog()\n return () => { cancelled = true }\n }, [t])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadActor() {\n try {\n const { ok, result } = await apiCall<UserListResponse>('/api/auth/users?page=1&pageSize=1')\n if (!cancelled && ok) setActorIsSuperAdmin(Boolean(result?.isSuperAdmin))\n } catch (err) {\n console.error('Failed to resolve actor super admin flag', err)\n } finally {\n if (!cancelled) setActorResolved(true)\n }\n }\n loadActor()\n return () => { cancelled = true }\n }, [])\n\n const toggleWidget = React.useCallback((id: string) => {\n setSelectedWidgets((prev) => (prev.includes(id) ? prev.filter((value) => value !== id) : [...prev, id]))\n }, [])\n\n // Block role loading until we know whether the actor is a super admin. Without this guard the\n // initial (non-super-admin) branch fires before the flag resolves and the server returns roles\n // from other tenants because the real caller is a super admin without tenantId scoping.\n const loadRoleOptions = React.useCallback(async (query?: string): Promise<CrudFieldOption[]> => {\n if (!actorResolved) return []\n if (actorIsSuperAdmin) {\n if (!selectedTenantId) return []\n return fetchRoleOptions(query, { tenantId: selectedTenantId })\n }\n return fetchRoleOptions(query)\n }, [actorIsSuperAdmin, actorResolved, selectedTenantId])\n\n const fields: CrudField[] = React.useMemo(() => {\n const items: CrudField[] = [\n { id: 'email', label: t('auth.users.form.field.email', 'Email'), type: 'text', required: true },\n {\n id: 'sendInviteEmail',\n label: t('auth.users.form.field.sendInviteEmail', 'Send password setup link via email'),\n type: 'custom',\n component: () => (\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n className=\"size-4\"\n checked={sendInviteEmail}\n onChange={(e) => setSendInviteEmail(e.target.checked)}\n />\n {t('auth.users.form.field.sendInviteEmailHint', 'Invite user to set their own password via a secure email link')}\n </label>\n ),\n },\n ...(!sendInviteEmail ? [{\n id: 'password',\n label: t('auth.users.form.field.password', 'Password'),\n type: 'password' as const,\n required: true,\n description: passwordDescription,\n }] : []),\n ]\n if (actorIsSuperAdmin) {\n items.push({\n id: 'tenantId',\n label: t('auth.users.form.field.tenant', 'Tenant'),\n type: 'custom',\n required: true,\n component: ({ value, setValue }) => {\n const normalizedValue = typeof value === 'string'\n ? value\n : (typeof selectedTenantId === 'string' ? selectedTenantId : null)\n return (\n <TenantSelect\n id=\"tenantId\"\n value={normalizedValue}\n onChange={(next) => {\n const resolved = next ?? null\n setValue(resolved)\n setSelectedTenantId(resolved)\n }}\n includeEmptyOption\n className=\"w-full h-9 rounded border px-2 text-sm\"\n required\n />\n )\n },\n })\n }\n items.push({\n id: 'organizationId',\n label: t('auth.users.form.field.organization', 'Organization'),\n type: 'custom',\n required: true,\n component: ({ id, value, setValue }) => {\n const normalizedValue = typeof value === 'string' ? value : null\n return (\n <TenantAwareOrganizationSelectInput\n fieldId={id}\n value={normalizedValue}\n setValue={(next) => setValue(next ?? null)}\n tenantId={selectedTenantId}\n />\n )\n },\n })\n items.push({ id: 'roles', label: t('auth.users.form.field.roles', 'Roles'), type: 'tags', loadOptions: loadRoleOptions })\n return items\n }, [actorIsSuperAdmin, loadRoleOptions, passwordDescription, selectedTenantId, sendInviteEmail, t])\n\n const detailFieldIds = React.useMemo(() => {\n const base: string[] = sendInviteEmail\n ? ['email', 'sendInviteEmail', 'organizationId', 'roles']\n : ['email', 'sendInviteEmail', 'password', 'organizationId', 'roles']\n if (actorIsSuperAdmin) {\n const orgIdx = base.indexOf('organizationId')\n base.splice(orgIdx, 0, 'tenantId')\n }\n return base\n }, [actorIsSuperAdmin, sendInviteEmail])\n\n const groups: CrudFormGroup[] = React.useMemo(() => [\n { id: 'details', title: t('auth.users.form.group.details', 'Details'), column: 1, fields: detailFieldIds },\n {\n id: 'acl',\n title: t('auth.users.form.group.access', 'Access'),\n column: 1,\n component: () => (\n <div className=\"text-sm text-muted-foreground\">\n {t('auth.users.form.aclHint', 'ACL can be edited after creating the user.')}\n </div>\n ),\n },\n { id: 'custom', title: t('auth.users.form.group.customFields', 'Custom Data'), column: 2, kind: 'customFields' },\n {\n id: 'dashboardWidgets',\n title: t('auth.users.form.group.widgets', 'Dashboard Widgets'),\n column: 2,\n component: () => (\n <DashboardWidgetSelector\n catalog={widgetCatalog}\n loading={widgetLoading}\n error={widgetError}\n mode={widgetMode}\n onModeChange={setWidgetMode}\n selected={selectedWidgets}\n onToggle={toggleWidget}\n />\n ),\n },\n ], [detailFieldIds, t, widgetCatalog, widgetError, widgetLoading, widgetMode, selectedWidgets, toggleWidget])\n\n const initialValues = React.useMemo<Partial<CreateUserFormValues>>(\n () => ({\n email: '',\n password: '',\n tenantId: null,\n organizationId: null,\n roles: [],\n }),\n [],\n )\n\n return (\n <Page>\n <PageBody>\n <CrudForm<CreateUserFormValues>\n title={t('auth.users.form.title.create', 'Create User')}\n backHref=\"/backend/users\"\n fields={fields}\n groups={groups}\n entityId={E.auth.user}\n initialValues={initialValues}\n submitLabel={t('auth.users.form.action.create', 'Create')}\n cancelHref=\"/backend/users\"\n successRedirect={`/backend/users?flash=${encodeURIComponent(\n sendInviteEmail\n ? t('auth.users.flash.createdWithInvite', 'User created and invitation sent')\n : t('auth.users.flash.created', 'User created')\n )}&type=success`}\n onSubmit={async (values) => {\n const customFields = collectCustomFieldValues(values)\n const payload: Record<string, unknown> = {\n email: values.email,\n organizationId: values.organizationId ? values.organizationId : null,\n roles: Array.isArray(values.roles) ? values.roles : [],\n ...(Object.keys(customFields).length ? { customFields } : {}),\n }\n if (sendInviteEmail) {\n payload.sendInviteEmail = true\n } else {\n payload.password = values.password\n }\n if (actorIsSuperAdmin) {\n const rawTenant = typeof values.tenantId === 'string' ? values.tenantId.trim() : null\n payload.tenantId = rawTenant && rawTenant.length ? rawTenant : null\n }\n const { result: created } = await createCrud<{ id?: string; _warning?: string }>('auth/users', payload)\n const newUserId = typeof created?.id === 'string' ? created.id : null\n if (created?._warning === 'invite_email_failed') {\n const msg = t('auth.users.flash.createdEmailFailed', 'User created but invitation email could not be sent. You can resend it from the user page.')\n window.location.href = `/backend/users?flash=${encodeURIComponent(msg)}&type=warning`\n return\n }\n\n if (widgetMode === 'override' && newUserId) {\n await updateCrud('dashboards/users/widgets', {\n userId: newUserId,\n mode: 'override',\n widgetIds: selectedWidgets,\n organizationId: values.organizationId ? values.organizationId : null,\n tenantId: actorIsSuperAdmin\n ? (typeof values.tenantId === 'string' && values.tenantId.length ? values.tenantId : null)\n : null,\n }, {\n errorMessage: t('auth.users.form.errors.widgetsAssign', 'Failed to assign dashboard widgets to the new user'),\n })\n }\n }}\n />\n </PageBody>\n </Page>\n )\n}\n\nfunction DashboardWidgetSelector({\n catalog,\n loading,\n error,\n mode,\n onModeChange,\n selected,\n onToggle,\n}: {\n catalog: Array<{ id: string; title: string; description: string | null }>\n loading: boolean\n error: string | null\n mode: 'inherit' | 'override'\n onModeChange: (mode: 'inherit' | 'override') => void\n selected: string[]\n onToggle: (id: string) => void\n}) {\n const t = useT()\n if (loading) {\n return (\n <div className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <Spinner size=\"sm\" /> {t('auth.users.widgets.loading', 'Loading widgets\u2026')}\n </div>\n )\n }\n\n return (\n <div className=\"space-y-3\">\n {error && (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive\">{error}</div>\n )}\n {!error && (\n <>\n <div className=\"flex items-center gap-3 rounded-md border bg-muted/30 px-3 py-2\">\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"radio\"\n value=\"inherit\"\n checked={mode === 'inherit'}\n onChange={() => onModeChange('inherit')}\n />\n {t('auth.users.widgets.mode.inherit', 'Inherit from roles')}\n </label>\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"radio\"\n value=\"override\"\n checked={mode === 'override'}\n onChange={() => onModeChange('override')}\n />\n {t('auth.users.widgets.mode.override', 'Override for this user')}\n </label>\n </div>\n {mode === 'override' && (\n <div className=\"space-y-2\">\n {catalog.map((widget) => (\n <label key={widget.id} className=\"flex items-start gap-3 rounded-md border px-3 py-2 hover:border-primary/40\">\n <input\n type=\"checkbox\"\n className=\"mt-1 size-4\"\n checked={selected.includes(widget.id)}\n onChange={() => onToggle(widget.id)}\n />\n <div>\n <div className=\"text-sm font-medium leading-none\">{widget.title}</div>\n {widget.description ? <div className=\"text-xs text-muted-foreground\">{widget.description}</div> : null}\n </div>\n </label>\n ))}\n </div>\n )}\n {mode === 'inherit' && (\n <div className=\"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground\">\n {t('auth.users.widgets.mode.hint', 'New users inherit widgets from their assigned roles. Override to pick a custom set.')}\n </div>\n )}\n </>\n )}\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { E } from '#generated/entities.ids.generated'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm, type CrudField, type CrudFormGroup, type CrudFieldOption } from '@open-mercato/ui/backend/CrudForm'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { createCrud, updateCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { collectCustomFieldValues } from '@open-mercato/ui/backend/utils/customFieldValues'\nimport { OrganizationSelect } from '@open-mercato/core/modules/directory/components/OrganizationSelect'\nimport { TenantSelect } from '@open-mercato/core/modules/directory/components/TenantSelect'\nimport { fetchRoleOptions } from '@open-mercato/core/modules/auth/backend/users/roleOptions'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { RadioGroup } from '@open-mercato/ui/primitives/radio'\nimport { RadioField } from '@open-mercato/ui/primitives/radio-field'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { formatPasswordRequirements, getPasswordPolicy } from '@open-mercato/shared/lib/auth/passwordPolicy'\n\ntype CreateUserFormValues = {\n email: string\n password: string\n tenantId: string | null\n organizationId: string | null\n roles: string[]\n} & Record<string, unknown>\n\ntype UserListResponse = {\n isSuperAdmin?: boolean\n}\n\ntype WidgetCatalogResponse = {\n items?: Array<{ id?: string | null; title?: string | null; description?: string | null }>\n}\n\ntype TenantAwareOrganizationSelectProps = {\n fieldId: string\n value: string | null\n setValue: (value: string | null) => void\n tenantId: string | null\n includeInactiveIds?: Iterable<string | null | undefined>\n}\n\nfunction TenantAwareOrganizationSelectInput({\n fieldId,\n value,\n setValue,\n tenantId,\n includeInactiveIds,\n}: TenantAwareOrganizationSelectProps) {\n const prevTenantRef = React.useRef<string | null>(tenantId)\n const hydratedRef = React.useRef(false)\n const handleChange = React.useCallback((next: string | null) => {\n setValue(next ?? null)\n }, [setValue])\n\n React.useEffect(() => {\n if (!hydratedRef.current) {\n hydratedRef.current = true\n prevTenantRef.current = tenantId\n return\n }\n if (prevTenantRef.current !== tenantId) {\n prevTenantRef.current = tenantId\n setValue(null)\n }\n }, [tenantId, setValue])\n\n return (\n <OrganizationSelect\n id={fieldId}\n value={value}\n onChange={handleChange}\n required\n includeEmptyOption\n className=\"w-full h-9 rounded border px-2 text-sm\"\n tenantId={tenantId}\n includeInactiveIds={includeInactiveIds}\n />\n )\n}\n\nexport default function CreateUserPage() {\n const t = useT()\n const [widgetCatalog, setWidgetCatalog] = React.useState<Array<{ id: string; title: string; description: string | null }>>([])\n const [widgetLoading, setWidgetLoading] = React.useState(true)\n const [widgetError, setWidgetError] = React.useState<string | null>(null)\n const [widgetMode, setWidgetMode] = React.useState<'inherit' | 'override'>('inherit')\n const [selectedWidgets, setSelectedWidgets] = React.useState<string[]>([])\n const [selectedTenantId, setSelectedTenantId] = React.useState<string | null>(null)\n const [actorIsSuperAdmin, setActorIsSuperAdmin] = React.useState(false)\n const [actorResolved, setActorResolved] = React.useState(false)\n const [sendInviteEmail, setSendInviteEmail] = React.useState(false)\n const passwordPolicy = React.useMemo(() => getPasswordPolicy(), [])\n const passwordRequirements = React.useMemo(\n () => formatPasswordRequirements(passwordPolicy, t),\n [passwordPolicy, t],\n )\n const passwordDescription = React.useMemo(() => (\n passwordRequirements\n ? t('auth.password.requirements.help', 'Password requirements: {requirements}', { requirements: passwordRequirements })\n : undefined\n ), [passwordRequirements, t])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadCatalog() {\n setWidgetLoading(true)\n setWidgetError(null)\n try {\n const { ok, result } = await apiCall<WidgetCatalogResponse>('/api/dashboards/widgets/catalog')\n if (!ok) throw new Error('request_failed')\n if (!cancelled) {\n const rawItems: unknown[] = Array.isArray(result?.items) ? result?.items ?? [] : []\n const normalized = rawItems\n .map((item: unknown) => {\n if (!item || typeof item !== 'object') return null\n const entry = item as Record<string, unknown>\n const idValue = entry.id\n const titleValue = entry.title\n const descriptionValue = entry.description\n const id = typeof idValue === 'string' ? idValue : null\n if (!id || !id.length) return null\n const title = typeof titleValue === 'string' && titleValue.length > 0 ? titleValue : id\n const description = typeof descriptionValue === 'string' && descriptionValue.length > 0 ? descriptionValue : null\n return { id, title, description }\n })\n .filter((item): item is { id: string; title: string; description: string | null } => item !== null)\n setWidgetCatalog(normalized)\n }\n } catch (err) {\n console.error('Failed to load dashboard widget catalog', err)\n if (!cancelled) {\n setWidgetError(t(\n 'auth.users.widgets.errors.load',\n 'Unable to load dashboard widgets. You can configure them later from the user page.',\n ))\n }\n } finally {\n if (!cancelled) setWidgetLoading(false)\n }\n }\n loadCatalog()\n return () => { cancelled = true }\n }, [t])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadActor() {\n try {\n const { ok, result } = await apiCall<UserListResponse>('/api/auth/users?page=1&pageSize=1')\n if (!cancelled && ok) setActorIsSuperAdmin(Boolean(result?.isSuperAdmin))\n } catch (err) {\n console.error('Failed to resolve actor super admin flag', err)\n } finally {\n if (!cancelled) setActorResolved(true)\n }\n }\n loadActor()\n return () => { cancelled = true }\n }, [])\n\n const toggleWidget = React.useCallback((id: string) => {\n setSelectedWidgets((prev) => (prev.includes(id) ? prev.filter((value) => value !== id) : [...prev, id]))\n }, [])\n\n // Block role loading until we know whether the actor is a super admin. Without this guard the\n // initial (non-super-admin) branch fires before the flag resolves and the server returns roles\n // from other tenants because the real caller is a super admin without tenantId scoping.\n const loadRoleOptions = React.useCallback(async (query?: string): Promise<CrudFieldOption[]> => {\n if (!actorResolved) return []\n if (actorIsSuperAdmin) {\n if (!selectedTenantId) return []\n return fetchRoleOptions(query, { tenantId: selectedTenantId })\n }\n return fetchRoleOptions(query)\n }, [actorIsSuperAdmin, actorResolved, selectedTenantId])\n\n const fields: CrudField[] = React.useMemo(() => {\n const items: CrudField[] = [\n { id: 'email', label: t('auth.users.form.field.email', 'Email'), type: 'text', required: true },\n {\n id: 'sendInviteEmail',\n label: t('auth.users.form.field.sendInviteEmail', 'Send password setup link via email'),\n type: 'custom',\n component: () => (\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n className=\"size-4\"\n checked={sendInviteEmail}\n onChange={(e) => setSendInviteEmail(e.target.checked)}\n />\n {t('auth.users.form.field.sendInviteEmailHint', 'Invite user to set their own password via a secure email link')}\n </label>\n ),\n },\n ...(!sendInviteEmail ? [{\n id: 'password',\n label: t('auth.users.form.field.password', 'Password'),\n type: 'password' as const,\n required: true,\n description: passwordDescription,\n }] : []),\n ]\n if (actorIsSuperAdmin) {\n items.push({\n id: 'tenantId',\n label: t('auth.users.form.field.tenant', 'Tenant'),\n type: 'custom',\n required: true,\n component: ({ value, setValue }) => {\n const normalizedValue = typeof value === 'string'\n ? value\n : (typeof selectedTenantId === 'string' ? selectedTenantId : null)\n return (\n <TenantSelect\n id=\"tenantId\"\n value={normalizedValue}\n onChange={(next) => {\n const resolved = next ?? null\n setValue(resolved)\n setSelectedTenantId(resolved)\n }}\n includeEmptyOption\n className=\"w-full h-9 rounded border px-2 text-sm\"\n required\n />\n )\n },\n })\n }\n items.push({\n id: 'organizationId',\n label: t('auth.users.form.field.organization', 'Organization'),\n type: 'custom',\n required: true,\n component: ({ id, value, setValue }) => {\n const normalizedValue = typeof value === 'string' ? value : null\n return (\n <TenantAwareOrganizationSelectInput\n fieldId={id}\n value={normalizedValue}\n setValue={(next) => setValue(next ?? null)}\n tenantId={selectedTenantId}\n />\n )\n },\n })\n items.push({ id: 'roles', label: t('auth.users.form.field.roles', 'Roles'), type: 'tags', loadOptions: loadRoleOptions })\n return items\n }, [actorIsSuperAdmin, loadRoleOptions, passwordDescription, selectedTenantId, sendInviteEmail, t])\n\n const detailFieldIds = React.useMemo(() => {\n const base: string[] = sendInviteEmail\n ? ['email', 'sendInviteEmail', 'organizationId', 'roles']\n : ['email', 'sendInviteEmail', 'password', 'organizationId', 'roles']\n if (actorIsSuperAdmin) {\n const orgIdx = base.indexOf('organizationId')\n base.splice(orgIdx, 0, 'tenantId')\n }\n return base\n }, [actorIsSuperAdmin, sendInviteEmail])\n\n const groups: CrudFormGroup[] = React.useMemo(() => [\n { id: 'details', title: t('auth.users.form.group.details', 'Details'), column: 1, fields: detailFieldIds },\n {\n id: 'acl',\n title: t('auth.users.form.group.access', 'Access'),\n column: 1,\n component: () => (\n <div className=\"text-sm text-muted-foreground\">\n {t('auth.users.form.aclHint', 'ACL can be edited after creating the user.')}\n </div>\n ),\n },\n { id: 'custom', title: t('auth.users.form.group.customFields', 'Custom Data'), column: 2, kind: 'customFields' },\n {\n id: 'dashboardWidgets',\n title: t('auth.users.form.group.widgets', 'Dashboard Widgets'),\n column: 2,\n component: () => (\n <DashboardWidgetSelector\n catalog={widgetCatalog}\n loading={widgetLoading}\n error={widgetError}\n mode={widgetMode}\n onModeChange={setWidgetMode}\n selected={selectedWidgets}\n onToggle={toggleWidget}\n />\n ),\n },\n ], [detailFieldIds, t, widgetCatalog, widgetError, widgetLoading, widgetMode, selectedWidgets, toggleWidget])\n\n const initialValues = React.useMemo<Partial<CreateUserFormValues>>(\n () => ({\n email: '',\n password: '',\n tenantId: null,\n organizationId: null,\n roles: [],\n }),\n [],\n )\n\n return (\n <Page>\n <PageBody>\n <CrudForm<CreateUserFormValues>\n title={t('auth.users.form.title.create', 'Create User')}\n backHref=\"/backend/users\"\n fields={fields}\n groups={groups}\n entityId={E.auth.user}\n initialValues={initialValues}\n submitLabel={t('auth.users.form.action.create', 'Create')}\n cancelHref=\"/backend/users\"\n successRedirect={`/backend/users?flash=${encodeURIComponent(\n sendInviteEmail\n ? t('auth.users.flash.createdWithInvite', 'User created and invitation sent')\n : t('auth.users.flash.created', 'User created')\n )}&type=success`}\n onSubmit={async (values) => {\n const customFields = collectCustomFieldValues(values)\n const payload: Record<string, unknown> = {\n email: values.email,\n organizationId: values.organizationId ? values.organizationId : null,\n roles: Array.isArray(values.roles) ? values.roles : [],\n ...(Object.keys(customFields).length ? { customFields } : {}),\n }\n if (sendInviteEmail) {\n payload.sendInviteEmail = true\n } else {\n payload.password = values.password\n }\n if (actorIsSuperAdmin) {\n const rawTenant = typeof values.tenantId === 'string' ? values.tenantId.trim() : null\n payload.tenantId = rawTenant && rawTenant.length ? rawTenant : null\n }\n const { result: created } = await createCrud<{ id?: string; _warning?: string }>('auth/users', payload)\n const newUserId = typeof created?.id === 'string' ? created.id : null\n if (created?._warning === 'invite_email_failed') {\n const msg = t('auth.users.flash.createdEmailFailed', 'User created but invitation email could not be sent. You can resend it from the user page.')\n window.location.href = `/backend/users?flash=${encodeURIComponent(msg)}&type=warning`\n return\n }\n\n if (widgetMode === 'override' && newUserId) {\n await updateCrud('dashboards/users/widgets', {\n userId: newUserId,\n mode: 'override',\n widgetIds: selectedWidgets,\n organizationId: values.organizationId ? values.organizationId : null,\n tenantId: actorIsSuperAdmin\n ? (typeof values.tenantId === 'string' && values.tenantId.length ? values.tenantId : null)\n : null,\n }, {\n errorMessage: t('auth.users.form.errors.widgetsAssign', 'Failed to assign dashboard widgets to the new user'),\n })\n }\n }}\n />\n </PageBody>\n </Page>\n )\n}\n\nfunction DashboardWidgetSelector({\n catalog,\n loading,\n error,\n mode,\n onModeChange,\n selected,\n onToggle,\n}: {\n catalog: Array<{ id: string; title: string; description: string | null }>\n loading: boolean\n error: string | null\n mode: 'inherit' | 'override'\n onModeChange: (mode: 'inherit' | 'override') => void\n selected: string[]\n onToggle: (id: string) => void\n}) {\n const t = useT()\n if (loading) {\n return (\n <div className=\"flex items-center gap-2 text-sm text-muted-foreground\">\n <Spinner size=\"sm\" /> {t('auth.users.widgets.loading', 'Loading widgets\u2026')}\n </div>\n )\n }\n\n return (\n <div className=\"space-y-3\">\n {error && (\n <div className=\"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive\">{error}</div>\n )}\n {!error && (\n <>\n <RadioGroup\n className=\"flex flex-row items-center gap-3 rounded-md border bg-muted/30 px-3 py-2\"\n value={mode}\n onValueChange={(next) => onModeChange(next as 'inherit' | 'override')}\n >\n <RadioField\n value=\"inherit\"\n label={t('auth.users.widgets.mode.inherit', 'Inherit from roles')}\n />\n <RadioField\n value=\"override\"\n label={t('auth.users.widgets.mode.override', 'Override for this user')}\n />\n </RadioGroup>\n {mode === 'override' && (\n <div className=\"space-y-2\">\n {catalog.map((widget) => (\n <label key={widget.id} className=\"flex items-start gap-3 rounded-md border px-3 py-2 hover:border-primary/40\">\n <input\n type=\"checkbox\"\n className=\"mt-1 size-4\"\n checked={selected.includes(widget.id)}\n onChange={() => onToggle(widget.id)}\n />\n <div>\n <div className=\"text-sm font-medium leading-none\">{widget.title}</div>\n {widget.description ? <div className=\"text-xs text-muted-foreground\">{widget.description}</div> : null}\n </div>\n </label>\n ))}\n </div>\n )}\n {mode === 'inherit' && (\n <div className=\"rounded-md border bg-muted/30 px-3 py-2 text-xs text-muted-foreground\">\n {t('auth.users.widgets.mode.hint', 'New users inherit widgets from their assigned roles. Override to pick a custom set.')}\n </div>\n )}\n </>\n )}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAmEI,SA2UI,UA3UJ,KAqHM,YArHN;AAlEJ,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAA0E;AACnF,SAAS,eAAe;AACxB,SAAS,YAAY,kBAAkB;AACvC,SAAS,gCAAgC;AACzC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,4BAA4B,yBAAyB;AA0B9D,SAAS,mCAAmC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,QAAM,gBAAgB,MAAM,OAAsB,QAAQ;AAC1D,QAAM,cAAc,MAAM,OAAO,KAAK;AACtC,QAAM,eAAe,MAAM,YAAY,CAAC,SAAwB;AAC9D,aAAS,QAAQ,IAAI;AAAA,EACvB,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,UAAU,MAAM;AACpB,QAAI,CAAC,YAAY,SAAS;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ACvE;AAAA;AAAA;AAAA,MACF;AAAA,MACC,SAAS,cACR,oBAAC,SAAI,WAAU,aACZ,kBAAQ,IAAI,CAAC,WACZ,qBAAC,WAAsB,WAAU,8EAC/B;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,SAAS,SAAS,SAAS,OAAO,EAAE;AAAA,YACpC,UAAU,MAAM,SAAS,OAAO,EAAE;AAAA;AAAA,QACpC;AAAA,QACA,qBAAC,SACC;AAAA,8BAAC,SAAI,WAAU,oCAAoC,iBAAO,OAAM;AAAA,UAC/D,OAAO,cAAc,oBAAC,SAAI,WAAU,iCAAiC,iBAAO,aAAY,IAAS;AAAA,WACpG;AAAA,WAVU,OAAO,EAWnB,CACD,GACH;AAAA,MAED,SAAS,aACR,oBAAC,SAAI,WAAU,yEACZ,YAAE,gCAAgC,qFAAqF,GAC1H;AAAA,OAEJ;AAAA,KAEJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { X, ChevronUp, ChevronDown } from "lucide-react";
|
|
4
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
5
|
+
import {
|
|
6
|
+
Select,
|
|
7
|
+
SelectContent,
|
|
8
|
+
SelectItem,
|
|
9
|
+
SelectTrigger,
|
|
10
|
+
SelectValue
|
|
11
|
+
} from "@open-mercato/ui/primitives/select";
|
|
4
12
|
import { getActionTypeOptions, getRequiredConfigFields, getOptionalConfigFields } from "./utils/actionValidation.js";
|
|
5
13
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
6
14
|
function ActionRow({
|
|
@@ -45,13 +53,13 @@ function ActionRow({
|
|
|
45
53
|
required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: t("business_rules.components.actionRow.actionType.required") })
|
|
46
54
|
] }),
|
|
47
55
|
/* @__PURE__ */ jsx(
|
|
48
|
-
|
|
56
|
+
Input,
|
|
49
57
|
{
|
|
50
58
|
type: "text",
|
|
51
59
|
value,
|
|
52
60
|
onChange: (e) => handleConfigChange(field, e.target.value.split(",").map((s) => s.trim())),
|
|
53
61
|
placeholder: t("business_rules.components.actionRow.config.recipients.placeholder"),
|
|
54
|
-
className: "col-span-3
|
|
62
|
+
className: "col-span-3"
|
|
55
63
|
}
|
|
56
64
|
),
|
|
57
65
|
/* @__PURE__ */ jsx("div", { className: "col-span-4 col-start-2", children: /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("business_rules.components.actionRow.config.recipients.help") }) })
|
|
@@ -61,16 +69,18 @@ function ActionRow({
|
|
|
61
69
|
return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 gap-2 items-center", children: [
|
|
62
70
|
/* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-foreground col-span-1", children: t("business_rules.components.actionRow.config.level") }),
|
|
63
71
|
/* @__PURE__ */ jsxs(
|
|
64
|
-
|
|
72
|
+
Select,
|
|
65
73
|
{
|
|
66
74
|
value: value || "info",
|
|
67
|
-
|
|
68
|
-
className: "col-span-3 px-2 py-1.5 text-sm border border-border rounded bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
75
|
+
onValueChange: (next) => handleConfigChange(field, next),
|
|
69
76
|
children: [
|
|
70
|
-
/* @__PURE__ */ jsx(
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "col-span-3", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
78
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
79
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "info", children: t("business_rules.components.actionRow.config.level.info") }),
|
|
80
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "warn", children: t("business_rules.components.actionRow.config.level.warn") }),
|
|
81
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "error", children: t("business_rules.components.actionRow.config.level.error") }),
|
|
82
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "debug", children: t("business_rules.components.actionRow.config.level.debug") })
|
|
83
|
+
] })
|
|
74
84
|
]
|
|
75
85
|
}
|
|
76
86
|
)
|
|
@@ -80,17 +90,19 @@ function ActionRow({
|
|
|
80
90
|
return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 gap-2 items-center", children: [
|
|
81
91
|
/* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-foreground col-span-1", children: t("business_rules.components.actionRow.config.method") }),
|
|
82
92
|
/* @__PURE__ */ jsxs(
|
|
83
|
-
|
|
93
|
+
Select,
|
|
84
94
|
{
|
|
85
95
|
value: value || "POST",
|
|
86
|
-
|
|
87
|
-
className: "col-span-3 px-2 py-1.5 text-sm border border-border rounded bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
96
|
+
onValueChange: (next) => handleConfigChange(field, next),
|
|
88
97
|
children: [
|
|
89
|
-
/* @__PURE__ */ jsx(
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "col-span-3", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
99
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
100
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "GET", children: "GET" }),
|
|
101
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "POST", children: "POST" }),
|
|
102
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "PUT", children: "PUT" }),
|
|
103
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "PATCH", children: "PATCH" }),
|
|
104
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "DELETE", children: "DELETE" })
|
|
105
|
+
] })
|
|
94
106
|
]
|
|
95
107
|
}
|
|
96
108
|
)
|
|
@@ -123,13 +135,13 @@ function ActionRow({
|
|
|
123
135
|
required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: t("business_rules.components.actionRow.actionType.required") })
|
|
124
136
|
] }),
|
|
125
137
|
/* @__PURE__ */ jsx(
|
|
126
|
-
|
|
138
|
+
Input,
|
|
127
139
|
{
|
|
128
140
|
type: "text",
|
|
129
141
|
value,
|
|
130
142
|
onChange: (e) => handleConfigChange(field, e.target.value),
|
|
131
143
|
placeholder: t("business_rules.components.actionRow.config.field.placeholder", { field }),
|
|
132
|
-
className: "col-span-3
|
|
144
|
+
className: "col-span-3"
|
|
133
145
|
}
|
|
134
146
|
)
|
|
135
147
|
] }, field);
|
|
@@ -143,14 +155,13 @@ function ActionRow({
|
|
|
143
155
|
/* @__PURE__ */ jsx("span", { className: "text-red-500", children: t("business_rules.components.actionRow.actionType.required") })
|
|
144
156
|
] }),
|
|
145
157
|
/* @__PURE__ */ jsxs(
|
|
146
|
-
|
|
158
|
+
Select,
|
|
147
159
|
{
|
|
148
|
-
value: action.type ||
|
|
149
|
-
|
|
150
|
-
className: "col-span-3 px-2 py-1.5 text-sm border border-border rounded bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring font-medium",
|
|
160
|
+
value: action.type || void 0,
|
|
161
|
+
onValueChange: (value) => handleTypeChange({ target: { value } }),
|
|
151
162
|
children: [
|
|
152
|
-
/* @__PURE__ */ jsx(
|
|
153
|
-
actionTypes.map((type) => /* @__PURE__ */ jsx(
|
|
163
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "col-span-3 font-medium", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("business_rules.components.actionRow.actionType.placeholder") }) }),
|
|
164
|
+
/* @__PURE__ */ jsx(SelectContent, { children: actionTypes.map((type) => /* @__PURE__ */ jsx(SelectItem, { value: type.value, children: type.label }, type.value)) })
|
|
154
165
|
]
|
|
155
166
|
}
|
|
156
167
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/business_rules/components/ActionRow.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { X, ChevronUp, ChevronDown } from 'lucide-react'\nimport type { Action } from './utils/actionValidation'\nimport { getActionTypeOptions, getRequiredConfigFields, getOptionalConfigFields } from './utils/actionValidation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type ActionRowProps = {\n action: Action\n index: number\n onChange: (index: number, action: Action) => void\n onDelete: (index: number) => void\n onMoveUp?: (index: number) => void\n onMoveDown?: (index: number) => void\n canMoveUp?: boolean\n canMoveDown?: boolean\n error?: string\n}\n\nexport function ActionRow({\n action,\n index,\n onChange,\n onDelete,\n onMoveUp,\n onMoveDown,\n canMoveUp,\n canMoveDown,\n error,\n}: ActionRowProps) {\n const t = useT()\n const actionTypes = getActionTypeOptions(t)\n const requiredFields = getRequiredConfigFields(action.type)\n const optionalFields = getOptionalConfigFields(action.type)\n\n const handleTypeChange = (e: React.ChangeEvent<HTMLSelectElement>) => {\n onChange(index, {\n ...action,\n type: e.target.value,\n config: {}, // Reset config when type changes\n })\n }\n\n const handleConfigChange = (field: string, value: any) => {\n onChange(index, {\n ...action,\n config: {\n ...(action.config || {}),\n [field]: value,\n },\n })\n }\n\n const renderConfigField = (field: string, required: boolean) => {\n const value = action.config?.[field] || ''\n\n // Special handling for different field types\n if (field === 'recipients' && action.type === 'NOTIFY') {\n return (\n <div key={field} className=\"grid grid-cols-4 gap-2 items-start\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">\n {t('business_rules.components.actionRow.config.recipients')} {required && <span className=\"text-red-500\">{t('business_rules.components.actionRow.actionType.required')}</span>}\n </label>\n <
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { X, ChevronUp, ChevronDown } from 'lucide-react'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport type { Action } from './utils/actionValidation'\nimport { getActionTypeOptions, getRequiredConfigFields, getOptionalConfigFields } from './utils/actionValidation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type ActionRowProps = {\n action: Action\n index: number\n onChange: (index: number, action: Action) => void\n onDelete: (index: number) => void\n onMoveUp?: (index: number) => void\n onMoveDown?: (index: number) => void\n canMoveUp?: boolean\n canMoveDown?: boolean\n error?: string\n}\n\nexport function ActionRow({\n action,\n index,\n onChange,\n onDelete,\n onMoveUp,\n onMoveDown,\n canMoveUp,\n canMoveDown,\n error,\n}: ActionRowProps) {\n const t = useT()\n const actionTypes = getActionTypeOptions(t)\n const requiredFields = getRequiredConfigFields(action.type)\n const optionalFields = getOptionalConfigFields(action.type)\n\n const handleTypeChange = (e: React.ChangeEvent<HTMLSelectElement>) => {\n onChange(index, {\n ...action,\n type: e.target.value,\n config: {}, // Reset config when type changes\n })\n }\n\n const handleConfigChange = (field: string, value: any) => {\n onChange(index, {\n ...action,\n config: {\n ...(action.config || {}),\n [field]: value,\n },\n })\n }\n\n const renderConfigField = (field: string, required: boolean) => {\n const value = action.config?.[field] || ''\n\n // Special handling for different field types\n if (field === 'recipients' && action.type === 'NOTIFY') {\n return (\n <div key={field} className=\"grid grid-cols-4 gap-2 items-start\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">\n {t('business_rules.components.actionRow.config.recipients')} {required && <span className=\"text-red-500\">{t('business_rules.components.actionRow.actionType.required')}</span>}\n </label>\n <Input\n type=\"text\"\n value={value}\n onChange={(e) => handleConfigChange(field, e.target.value.split(',').map((s) => s.trim()))}\n placeholder={t('business_rules.components.actionRow.config.recipients.placeholder')}\n className=\"col-span-3\"\n />\n <div className=\"col-span-4 col-start-2\">\n <p className=\"text-xs text-muted-foreground\">{t('business_rules.components.actionRow.config.recipients.help')}</p>\n </div>\n </div>\n )\n }\n\n if (field === 'level' && action.type === 'LOG') {\n return (\n <div key={field} className=\"grid grid-cols-4 gap-2 items-center\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">{t('business_rules.components.actionRow.config.level')}</label>\n <Select\n value={value || 'info'}\n onValueChange={(next) => handleConfigChange(field, next)}\n >\n <SelectTrigger size=\"sm\" className=\"col-span-3\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"info\">{t('business_rules.components.actionRow.config.level.info')}</SelectItem>\n <SelectItem value=\"warn\">{t('business_rules.components.actionRow.config.level.warn')}</SelectItem>\n <SelectItem value=\"error\">{t('business_rules.components.actionRow.config.level.error')}</SelectItem>\n <SelectItem value=\"debug\">{t('business_rules.components.actionRow.config.level.debug')}</SelectItem>\n </SelectContent>\n </Select>\n </div>\n )\n }\n\n if (field === 'method' && action.type === 'CALL_WEBHOOK') {\n return (\n <div key={field} className=\"grid grid-cols-4 gap-2 items-center\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">{t('business_rules.components.actionRow.config.method')}</label>\n <Select\n value={value || 'POST'}\n onValueChange={(next) => handleConfigChange(field, next)}\n >\n <SelectTrigger size=\"sm\" className=\"col-span-3\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"GET\">GET</SelectItem>\n <SelectItem value=\"POST\">POST</SelectItem>\n <SelectItem value=\"PUT\">PUT</SelectItem>\n <SelectItem value=\"PATCH\">PATCH</SelectItem>\n <SelectItem value=\"DELETE\">DELETE</SelectItem>\n </SelectContent>\n </Select>\n </div>\n )\n }\n\n if (field === 'message') {\n return (\n <div key={field} className=\"grid grid-cols-4 gap-2 items-start\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">\n {t('business_rules.components.actionRow.config.message')} {required && <span className=\"text-red-500\">{t('business_rules.components.actionRow.actionType.required')}</span>}\n </label>\n <textarea\n value={value}\n onChange={(e) => handleConfigChange(field, e.target.value)}\n placeholder={t('business_rules.components.actionRow.config.message.placeholder')}\n rows={2}\n className=\"col-span-3 px-2 py-1.5 text-sm border border-border rounded bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n />\n <div className=\"col-span-4 col-start-2\">\n <p className=\"text-xs text-muted-foreground\">{t('business_rules.components.actionRow.config.message.help')}</p>\n </div>\n </div>\n )\n }\n\n // Default text input\n return (\n <div key={field} className=\"grid grid-cols-4 gap-2 items-center\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">\n {field} {required && <span className=\"text-red-500\">{t('business_rules.components.actionRow.actionType.required')}</span>}\n </label>\n <Input\n type=\"text\"\n value={value}\n onChange={(e) => handleConfigChange(field, e.target.value)}\n placeholder={t('business_rules.components.actionRow.config.field.placeholder', { field })}\n className=\"col-span-3\"\n />\n </div>\n )\n }\n\n return (\n <div className=\"flex items-start gap-2 p-3 bg-muted rounded border border-border\">\n <div className=\"flex-1 space-y-2\">\n {/* Action Type */}\n <div className=\"grid grid-cols-4 gap-2 items-center\">\n <label className=\"text-xs font-medium text-foreground col-span-1\">\n {t('business_rules.components.actionRow.actionType')} <span className=\"text-red-500\">{t('business_rules.components.actionRow.actionType.required')}</span>\n </label>\n <Select\n value={action.type || undefined}\n onValueChange={(value) => handleTypeChange({ target: { value } } as React.ChangeEvent<HTMLSelectElement>)}\n >\n <SelectTrigger size=\"sm\" className=\"col-span-3 font-medium\">\n <SelectValue placeholder={t('business_rules.components.actionRow.actionType.placeholder')} />\n </SelectTrigger>\n <SelectContent>\n {actionTypes.map((type) => (\n <SelectItem key={type.value} value={type.value}>\n {type.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Config Fields */}\n {action.type && (\n <>\n {requiredFields.map((field) => renderConfigField(field, true))}\n {optionalFields.map((field) => renderConfigField(field, false))}\n </>\n )}\n\n {/* Error Display */}\n {error && (\n <div className=\"mt-2\">\n <p className=\"text-xs text-red-600\">{error}</p>\n </div>\n )}\n </div>\n\n {/* Control Buttons */}\n <div className=\"flex flex-col gap-1\">\n {onMoveUp && (\n <button\n type=\"button\"\n onClick={() => onMoveUp(index)}\n disabled={!canMoveUp}\n className=\"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n title={t('business_rules.components.actionRow.moveUp')}\n >\n <ChevronUp className=\"w-4 h-4\" />\n </button>\n )}\n {onMoveDown && (\n <button\n type=\"button\"\n onClick={() => onMoveDown(index)}\n disabled={!canMoveDown}\n className=\"p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n title={t('business_rules.components.actionRow.moveDown')}\n >\n <ChevronDown className=\"w-4 h-4\" />\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => onDelete(index)}\n className=\"p-1 text-muted-foreground hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors\"\n title={t('business_rules.components.actionRow.delete')}\n >\n <X className=\"w-4 h-4\" />\n </button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAqEU,SA8HA,UA7H4E,KAD5E;AAlEV,SAAS,GAAG,WAAW,mBAAmB;AAC1C,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,sBAAsB,yBAAyB,+BAA+B;AACvF,SAAS,YAAY;AAcd,SAAS,UAAU;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmB;AACjB,QAAM,IAAI,KAAK;AACf,QAAM,cAAc,qBAAqB,CAAC;AAC1C,QAAM,iBAAiB,wBAAwB,OAAO,IAAI;AAC1D,QAAM,iBAAiB,wBAAwB,OAAO,IAAI;AAE1D,QAAM,mBAAmB,CAAC,MAA4C;AACpE,aAAS,OAAO;AAAA,MACd,GAAG;AAAA,MACH,MAAM,EAAE,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,eAAK,SADS,KAAK,KAEtB,CACD,GACH;AAAA;AAAA;AAAA,QACF;AAAA,SACF;AAAA,MAGC,OAAO,QACN,iCACG;AAAA,uBAAe,IAAI,CAAC,UAAU,kBAAkB,OAAO,IAAI,CAAC;AAAA,QAC5D,eAAe,IAAI,CAAC,UAAU,kBAAkB,OAAO,KAAK,CAAC;AAAA,SAChE;AAAA,MAID,SACC,oBAAC,SAAI,WAAU,QACb,8BAAC,OAAE,WAAU,wBAAwB,iBAAM,GAC7C;AAAA,OAEJ;AAAA,IAGA,qBAAC,SAAI,WAAU,uBACZ;AAAA,kBACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,MAAM,SAAS,KAAK;AAAA,UAC7B,UAAU,CAAC;AAAA,UACX,WAAU;AAAA,UACV,OAAO,EAAE,4CAA4C;AAAA,UAErD,8BAAC,aAAU,WAAU,WAAU;AAAA;AAAA,MACjC;AAAA,MAED,cACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,MAAM,WAAW,KAAK;AAAA,UAC/B,UAAU,CAAC;AAAA,UACX,WAAU;AAAA,UACV,OAAO,EAAE,8CAA8C;AAAA,UAEvD,8BAAC,eAAY,WAAU,WAAU;AAAA;AAAA,MACnC;AAAA,MAEF;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,MAAM,SAAS,KAAK;AAAA,UAC7B,WAAU;AAAA,UACV,OAAO,EAAE,4CAA4C;AAAA,UAErD,8BAAC,KAAE,WAAU,WAAU;AAAA;AAAA,MACzB;AAAA,OACF;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Plus, X } from "lucide-react";
|
|
4
4
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
5
|
+
import {
|
|
6
|
+
Select,
|
|
7
|
+
SelectContent,
|
|
8
|
+
SelectItem,
|
|
9
|
+
SelectTrigger,
|
|
10
|
+
SelectValue
|
|
11
|
+
} from "@open-mercato/ui/primitives/select";
|
|
5
12
|
import { ConditionRow } from "./ConditionRow.js";
|
|
6
13
|
import { isGroupCondition, getLogicalOperators } from "./utils/conditionValidation.js";
|
|
7
14
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
@@ -80,13 +87,15 @@ function ConditionGroup({ group, onChange, onDelete, depth, maxDepth = 5, entity
|
|
|
80
87
|
children: [
|
|
81
88
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-3", children: [
|
|
82
89
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: t("business_rules.components.conditionGroup.group", { depth: depth + 1 }) }),
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
90
|
+
/* @__PURE__ */ jsxs(
|
|
91
|
+
Select,
|
|
85
92
|
{
|
|
86
93
|
value: group.operator,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
onValueChange: (value) => handleOperatorChange({ target: { value } }),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "w-auto min-w-[6rem] font-semibold", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
97
|
+
/* @__PURE__ */ jsx(SelectContent, { children: logicalOperators.map((op) => /* @__PURE__ */ jsx(SelectItem, { value: op.value, children: op.label }, op.value)) })
|
|
98
|
+
]
|
|
90
99
|
}
|
|
91
100
|
),
|
|
92
101
|
/* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/business_rules/components/ConditionGroup.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Plus, X } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { ConditionRow } from './ConditionRow'\nimport type { GroupCondition, ConditionExpression, SimpleCondition } from './utils/conditionValidation'\nimport type { LogicalOperator } from './../data/validators'\nimport { isGroupCondition, getLogicalOperators } from './utils/conditionValidation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type ConditionGroupProps = {\n group: GroupCondition\n onChange: (group: GroupCondition) => void\n onDelete?: () => void\n depth: number\n maxDepth?: number\n entityType?: string\n}\n\nconst DEPTH_COLORS = [\n 'border-blue-300 bg-blue-50 dark:border-blue-700 dark:bg-blue-950/50',\n 'border-green-300 bg-green-50 dark:border-green-700 dark:bg-green-950/50',\n 'border-purple-300 bg-purple-50 dark:border-purple-700 dark:bg-purple-950/50',\n 'border-orange-300 bg-orange-50 dark:border-orange-700 dark:bg-orange-950/50',\n 'border-pink-300 bg-pink-50 dark:border-pink-700 dark:bg-pink-950/50',\n]\n\nexport function ConditionGroup({ group, onChange, onDelete, depth, maxDepth = 5, entityType }: ConditionGroupProps) {\n const t = useT()\n const logicalOperators = getLogicalOperators(t)\n const colorClass = DEPTH_COLORS[depth % DEPTH_COLORS.length]\n\n const handleOperatorChange = (e: React.ChangeEvent<HTMLSelectElement>) => {\n onChange({\n ...group,\n operator: e.target.value as LogicalOperator,\n })\n }\n\n const handleRuleChange = (index: number, updatedRule: ConditionExpression) => {\n const newRules = [...group.rules]\n newRules[index] = updatedRule\n onChange({\n ...group,\n rules: newRules,\n })\n }\n\n const handleDeleteRule = (index: number) => {\n const newRules = group.rules.filter((_, i) => i !== index)\n if (newRules.length === 0) {\n // If no rules left, delete the group itself\n onDelete?.()\n } else {\n onChange({\n ...group,\n rules: newRules,\n })\n }\n }\n\n const addSimpleCondition = () => {\n const newCondition: SimpleCondition = {\n field: '',\n operator: '=',\n value: null,\n }\n onChange({\n ...group,\n rules: [...group.rules, newCondition],\n })\n }\n\n const addConditionGroup = () => {\n if (depth >= maxDepth) {\n alert(t('business_rules.components.conditionGroup.maxDepthReached', { maxDepth }))\n return\n }\n\n const newGroup: GroupCondition = {\n operator: 'AND',\n rules: [\n {\n field: '',\n operator: '=',\n value: null,\n },\n ],\n }\n onChange({\n ...group,\n rules: [...group.rules, newGroup],\n })\n }\n\n return (\n <div\n className={`p-3 rounded border-2 ${colorClass}`}\n style={{ marginLeft: depth > 0 ? `${depth * 16}px` : '0' }}\n >\n {/* Group Header */}\n <div className=\"flex items-center gap-2 mb-3\">\n <span className=\"text-xs font-medium text-muted-foreground\">\n {t('business_rules.components.conditionGroup.group', { depth: depth + 1 })}\n </span>\n <
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Plus, X } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { ConditionRow } from './ConditionRow'\nimport type { GroupCondition, ConditionExpression, SimpleCondition } from './utils/conditionValidation'\nimport type { LogicalOperator } from './../data/validators'\nimport { isGroupCondition, getLogicalOperators } from './utils/conditionValidation'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport type ConditionGroupProps = {\n group: GroupCondition\n onChange: (group: GroupCondition) => void\n onDelete?: () => void\n depth: number\n maxDepth?: number\n entityType?: string\n}\n\nconst DEPTH_COLORS = [\n 'border-blue-300 bg-blue-50 dark:border-blue-700 dark:bg-blue-950/50',\n 'border-green-300 bg-green-50 dark:border-green-700 dark:bg-green-950/50',\n 'border-purple-300 bg-purple-50 dark:border-purple-700 dark:bg-purple-950/50',\n 'border-orange-300 bg-orange-50 dark:border-orange-700 dark:bg-orange-950/50',\n 'border-pink-300 bg-pink-50 dark:border-pink-700 dark:bg-pink-950/50',\n]\n\nexport function ConditionGroup({ group, onChange, onDelete, depth, maxDepth = 5, entityType }: ConditionGroupProps) {\n const t = useT()\n const logicalOperators = getLogicalOperators(t)\n const colorClass = DEPTH_COLORS[depth % DEPTH_COLORS.length]\n\n const handleOperatorChange = (e: React.ChangeEvent<HTMLSelectElement>) => {\n onChange({\n ...group,\n operator: e.target.value as LogicalOperator,\n })\n }\n\n const handleRuleChange = (index: number, updatedRule: ConditionExpression) => {\n const newRules = [...group.rules]\n newRules[index] = updatedRule\n onChange({\n ...group,\n rules: newRules,\n })\n }\n\n const handleDeleteRule = (index: number) => {\n const newRules = group.rules.filter((_, i) => i !== index)\n if (newRules.length === 0) {\n // If no rules left, delete the group itself\n onDelete?.()\n } else {\n onChange({\n ...group,\n rules: newRules,\n })\n }\n }\n\n const addSimpleCondition = () => {\n const newCondition: SimpleCondition = {\n field: '',\n operator: '=',\n value: null,\n }\n onChange({\n ...group,\n rules: [...group.rules, newCondition],\n })\n }\n\n const addConditionGroup = () => {\n if (depth >= maxDepth) {\n alert(t('business_rules.components.conditionGroup.maxDepthReached', { maxDepth }))\n return\n }\n\n const newGroup: GroupCondition = {\n operator: 'AND',\n rules: [\n {\n field: '',\n operator: '=',\n value: null,\n },\n ],\n }\n onChange({\n ...group,\n rules: [...group.rules, newGroup],\n })\n }\n\n return (\n <div\n className={`p-3 rounded border-2 ${colorClass}`}\n style={{ marginLeft: depth > 0 ? `${depth * 16}px` : '0' }}\n >\n {/* Group Header */}\n <div className=\"flex items-center gap-2 mb-3\">\n <span className=\"text-xs font-medium text-muted-foreground\">\n {t('business_rules.components.conditionGroup.group', { depth: depth + 1 })}\n </span>\n <Select\n value={group.operator}\n onValueChange={(value) => handleOperatorChange({ target: { value } } as React.ChangeEvent<HTMLSelectElement>)}\n >\n <SelectTrigger size=\"sm\" className=\"w-auto min-w-[6rem] font-semibold\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {logicalOperators.map((op) => (\n <SelectItem key={op.value} value={op.value}>\n {op.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n <span className=\"text-xs text-muted-foreground\">\n ({t('business_rules.components.conditionGroup.ruleCount', { count: group.rules.length })})\n </span>\n\n {onDelete && (\n <button\n type=\"button\"\n onClick={onDelete}\n className=\"ml-auto p-1 text-muted-foreground hover:text-status-error-text hover:bg-status-error-bg rounded transition-colors\"\n title={t('business_rules.components.conditionGroup.deleteGroup')}\n >\n <X className=\"w-4 h-4\" />\n </button>\n )}\n </div>\n\n {/* Rules */}\n <div className=\"space-y-2\">\n {group.rules.map((rule, index) => (\n <div key={index}>\n {isGroupCondition(rule) ? (\n // Recursive: Nested Group\n <ConditionGroup\n group={rule}\n onChange={(updatedGroup) => handleRuleChange(index, updatedGroup)}\n onDelete={() => handleDeleteRule(index)}\n depth={depth + 1}\n maxDepth={maxDepth}\n entityType={entityType}\n />\n ) : (\n // Base Case: Simple Condition\n <ConditionRow\n condition={rule}\n onChange={(updatedCondition) => handleRuleChange(index, updatedCondition)}\n onDelete={() => handleDeleteRule(index)}\n entityType={entityType}\n />\n )}\n </div>\n ))}\n </div>\n\n {/* Add Buttons */}\n <div className=\"flex gap-2 mt-3\">\n <Button\n type=\"button\"\n onClick={addSimpleCondition}\n variant=\"outline\"\n size=\"sm\"\n className=\"text-xs\"\n >\n <Plus className=\"w-3 h-3 mr-1\" />\n {t('business_rules.components.conditionGroup.addCondition')}\n </Button>\n\n {depth < maxDepth && (\n <Button\n type=\"button\"\n onClick={addConditionGroup}\n variant=\"outline\"\n size=\"sm\"\n className=\"text-xs\"\n >\n <Plus className=\"w-3 h-3 mr-1\" />\n {t('business_rules.components.conditionGroup.addGroup', { depth: depth + 2 })}\n </Button>\n )}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA8GQ,cAGA,YAHA;AA3GR,SAAS,MAAM,SAAS;AACxB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB,2BAA2B;AACtD,SAAS,YAAY;AAWrB,MAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AA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O,YAAY;AAAA,cAChE,UAAU,MAAM,iBAAiB,KAAK;AAAA,cACtC,OAAO,QAAQ;AAAA,cACf;AAAA,cACA;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,UAGA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,cACX,UAAU,CAAC,qBAAqB,iBAAiB,OAAO,gBAAgB;AAAA,cACxE,UAAU,MAAM,iBAAiB,KAAK;AAAA,cACtC;AAAA;AAAA,UACF;AAAA,aAlBM,KAoBV,CACD,GACH;AAAA,QAGA,qBAAC,SAAI,WAAU,mBACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS;AAAA,cACT,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,WAAU;AAAA,cAEV;AAAA,oCAAC,QAAK,WAAU,gBAAe;AAAA,gBAC9B,EAAE,uDAAuD;AAAA;AAAA;AAAA,UAC5D;AAAA,UAEC,QAAQ,YACP;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS;AAAA,cACT,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,WAAU;AAAA,cAEV;AAAA,oCAAC,QAAK,WAAU,gBAAe;AAAA,gBAC9B,EAAE,qDAAqD,EAAE,OAAO,QAAQ,EAAE,CAAC;AAAA;AAAA;AAAA,UAC9E;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
5
|
+
import {
|
|
6
|
+
Select,
|
|
7
|
+
SelectContent,
|
|
8
|
+
SelectItem,
|
|
9
|
+
SelectTrigger,
|
|
10
|
+
SelectValue
|
|
11
|
+
} from "@open-mercato/ui/primitives/select";
|
|
4
12
|
import { X } from "lucide-react";
|
|
5
13
|
import { getComparisonOperators, isValidFieldPath } from "./utils/conditionValidation.js";
|
|
6
14
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
@@ -45,26 +53,28 @@ function ConditionRow({ condition, onChange, onDelete, error }) {
|
|
|
45
53
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
46
54
|
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-foreground mb-1", children: t("business_rules.components.conditionRow.field") }),
|
|
47
55
|
/* @__PURE__ */ jsx(
|
|
48
|
-
|
|
56
|
+
Input,
|
|
49
57
|
{
|
|
50
58
|
type: "text",
|
|
51
59
|
value: condition.field || "",
|
|
52
60
|
onChange: handleFieldChange,
|
|
53
61
|
placeholder: t("business_rules.components.conditionRow.field.placeholder"),
|
|
54
|
-
|
|
62
|
+
"aria-invalid": fieldError ? true : void 0
|
|
55
63
|
}
|
|
56
64
|
),
|
|
57
65
|
fieldError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-600 mt-0.5", children: t("business_rules.components.conditionRow.field.invalidPath") })
|
|
58
66
|
] }),
|
|
59
67
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
60
68
|
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium text-foreground mb-1", children: t("business_rules.components.conditionRow.operator") }),
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
|
|
69
|
+
/* @__PURE__ */ jsxs(
|
|
70
|
+
Select,
|
|
63
71
|
{
|
|
64
72
|
value: condition.operator || "=",
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
onValueChange: (value) => handleOperatorChange({ target: { value } }),
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
76
|
+
/* @__PURE__ */ jsx(SelectContent, { children: operators.map((op) => /* @__PURE__ */ jsx(SelectItem, { value: op.value, children: op.label }, op.value)) })
|
|
77
|
+
]
|
|
68
78
|
}
|
|
69
79
|
)
|
|
70
80
|
] }),
|
|
@@ -83,13 +93,12 @@ function ConditionRow({ condition, onChange, onDelete, error }) {
|
|
|
83
93
|
)
|
|
84
94
|
] }),
|
|
85
95
|
/* @__PURE__ */ jsx(
|
|
86
|
-
|
|
96
|
+
Input,
|
|
87
97
|
{
|
|
88
98
|
type: "text",
|
|
89
99
|
value: useFieldComparison ? condition.valueField || "" : condition.value === null || condition.value === void 0 ? "" : typeof condition.value === "string" ? condition.value : JSON.stringify(condition.value),
|
|
90
100
|
onChange: useFieldComparison ? handleValueFieldChange : handleValueChange,
|
|
91
|
-
placeholder: useFieldComparison ? t("business_rules.components.conditionRow.field.comparisonPlaceholder") : t("business_rules.components.conditionRow.value.placeholder")
|
|
92
|
-
className: "w-full px-2 py-1.5 text-sm border border-border rounded bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
101
|
+
placeholder: useFieldComparison ? t("business_rules.components.conditionRow.field.comparisonPlaceholder") : t("business_rules.components.conditionRow.value.placeholder")
|
|
93
102
|
}
|
|
94
103
|
),
|
|
95
104
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: useFieldComparison ? t("business_rules.components.conditionRow.field.comparisonHelp") : t("business_rules.components.conditionRow.value.help") })
|