@open-mercato/core 0.6.8-develop.6910.1.560e304de2 → 0.6.8-develop.6912.1.36161dc9ac

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.
Files changed (140) hide show
  1. package/dist/modules/api_keys/backend/api-keys/page.js.map +1 -1
  2. package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
  3. package/dist/modules/attachments/components/AttachmentPartitionSettings.js.map +1 -1
  4. package/dist/modules/audit_logs/components/AccessLogsTable.js.map +1 -1
  5. package/dist/modules/audit_logs/components/AuditLogsActions.js.map +1 -1
  6. package/dist/modules/auth/backend/roles/page.js.map +2 -2
  7. package/dist/modules/auth/backend/users/page.js.map +2 -2
  8. package/dist/modules/business_rules/backend/logs/page.js.map +1 -1
  9. package/dist/modules/business_rules/backend/rules/page.js.map +1 -1
  10. package/dist/modules/business_rules/backend/sets/page.js.map +1 -1
  11. package/dist/modules/catalog/components/PriceKindSettings.js.map +1 -1
  12. package/dist/modules/catalog/components/categories/CategoriesDataTable.js.map +1 -1
  13. package/dist/modules/catalog/components/products/ProductsDataTable.js.map +2 -2
  14. package/dist/modules/communication_channels/backend/communication_channels/channels/page.js.map +1 -1
  15. package/dist/modules/communication_channels/backend/profile/communication-channels/page.js.map +1 -1
  16. package/dist/modules/currencies/backend/currencies/page.js.map +1 -1
  17. package/dist/modules/currencies/backend/exchange-rates/page.js.map +1 -1
  18. package/dist/modules/customer_accounts/backend/customer_accounts/roles/page.js.map +1 -1
  19. package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +1 -1
  20. package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
  21. package/dist/modules/customers/backend/customers/deals/page.js.map +1 -1
  22. package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
  23. package/dist/modules/customers/components/CustomerTodosTable.js.map +1 -1
  24. package/dist/modules/data_sync/backend/data-sync/page.js.map +1 -1
  25. package/dist/modules/dictionaries/components/DictionaryTable.js.map +2 -2
  26. package/dist/modules/directory/backend/directory/organizations/page.js.map +1 -1
  27. package/dist/modules/directory/backend/directory/tenants/page.js.map +2 -2
  28. package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js.map +2 -2
  29. package/dist/modules/entities/components/SystemEntitiesTable.js.map +2 -2
  30. package/dist/modules/entities/components/UserEntitiesTable.js.map +2 -2
  31. package/dist/modules/feature_toggles/components/FeatureTogglesTable.js.map +2 -2
  32. package/dist/modules/feature_toggles/components/OverridesTable.js.map +2 -2
  33. package/dist/modules/inbox_ops/backend/inbox-ops/log/page.js.map +1 -1
  34. package/dist/modules/inbox_ops/backend/inbox-ops/page.js.map +1 -1
  35. package/dist/modules/messages/components/MessagesInboxPageClient.js.map +1 -1
  36. package/dist/modules/payment_gateways/backend/payment-gateways/page.js.map +1 -1
  37. package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
  38. package/dist/modules/query_index/components/QueryIndexesTable.js.map +2 -2
  39. package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
  40. package/dist/modules/resources/backend/resources/resources/page.js.map +1 -1
  41. package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
  42. package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
  43. package/dist/modules/sales/components/AdjustmentKindSettings.js.map +1 -1
  44. package/dist/modules/sales/components/PaymentMethodsSettings.js.map +1 -1
  45. package/dist/modules/sales/components/ShippingMethodsSettings.js.map +1 -1
  46. package/dist/modules/sales/components/TaxRatesSettings.js.map +1 -1
  47. package/dist/modules/sales/components/channels/SalesChannelOffersPanel.js.map +2 -2
  48. package/dist/modules/sales/components/documents/AdjustmentsSection.js.map +1 -1
  49. package/dist/modules/sales/components/documents/PaymentsSection.js.map +1 -1
  50. package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
  51. package/dist/modules/sales/components/documents/SalesOrderDraftLines.js.map +1 -1
  52. package/dist/modules/staff/backend/staff/leave-requests/page.js.map +2 -2
  53. package/dist/modules/staff/backend/staff/my-leave-requests/page.js.map +2 -2
  54. package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
  55. package/dist/modules/staff/backend/staff/team-roles/page.js.map +1 -1
  56. package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
  57. package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
  58. package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +2 -2
  59. package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +2 -2
  60. package/dist/modules/wms/components/backend/WmsInventoryConsolePage.js.map +2 -2
  61. package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +1 -1
  62. package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +1 -1
  63. package/dist/modules/wms/components/backend/WmsLotsListPage.js.map +2 -2
  64. package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +1 -1
  65. package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +1 -1
  66. package/dist/modules/workflows/backend/definitions/page.js.map +1 -1
  67. package/dist/modules/workflows/backend/events/page.js.map +1 -1
  68. package/dist/modules/workflows/backend/instances/page.js.map +1 -1
  69. package/dist/modules/workflows/backend/tasks/page.js.map +1 -1
  70. package/jest.config.cjs +1 -1
  71. package/package.json +7 -7
  72. package/src/modules/api_keys/backend/api-keys/page.tsx +1 -1
  73. package/src/modules/attachments/components/AttachmentLibrary.tsx +2 -1
  74. package/src/modules/attachments/components/AttachmentPartitionSettings.tsx +1 -1
  75. package/src/modules/audit_logs/components/AccessLogsTable.tsx +1 -1
  76. package/src/modules/audit_logs/components/AuditLogsActions.tsx +1 -1
  77. package/src/modules/auth/backend/roles/page.tsx +2 -1
  78. package/src/modules/auth/backend/users/page.tsx +2 -1
  79. package/src/modules/business_rules/backend/logs/page.tsx +1 -1
  80. package/src/modules/business_rules/backend/rules/page.tsx +1 -1
  81. package/src/modules/business_rules/backend/sets/page.tsx +1 -1
  82. package/src/modules/catalog/components/PriceKindSettings.tsx +1 -1
  83. package/src/modules/catalog/components/categories/CategoriesDataTable.tsx +1 -1
  84. package/src/modules/catalog/components/products/ProductsDataTable.tsx +2 -1
  85. package/src/modules/communication_channels/backend/communication_channels/channels/page.tsx +1 -1
  86. package/src/modules/communication_channels/backend/profile/communication-channels/page.tsx +1 -1
  87. package/src/modules/currencies/backend/currencies/page.tsx +1 -1
  88. package/src/modules/currencies/backend/exchange-rates/page.tsx +1 -1
  89. package/src/modules/customer_accounts/backend/customer_accounts/roles/page.tsx +1 -1
  90. package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +1 -1
  91. package/src/modules/customers/backend/customers/companies/page.tsx +2 -1
  92. package/src/modules/customers/backend/customers/deals/page.tsx +1 -1
  93. package/src/modules/customers/backend/customers/people/page.tsx +2 -1
  94. package/src/modules/customers/components/CustomerTodosTable.tsx +1 -1
  95. package/src/modules/data_sync/backend/data-sync/page.tsx +1 -1
  96. package/src/modules/dictionaries/components/DictionaryTable.tsx +2 -1
  97. package/src/modules/directory/backend/directory/organizations/page.tsx +1 -1
  98. package/src/modules/directory/backend/directory/tenants/page.tsx +2 -1
  99. package/src/modules/entities/backend/entities/user/[entityId]/records/page.tsx +2 -1
  100. package/src/modules/entities/components/SystemEntitiesTable.tsx +2 -1
  101. package/src/modules/entities/components/UserEntitiesTable.tsx +2 -1
  102. package/src/modules/feature_toggles/components/FeatureTogglesTable.tsx +2 -1
  103. package/src/modules/feature_toggles/components/OverridesTable.tsx +2 -1
  104. package/src/modules/inbox_ops/backend/inbox-ops/log/page.tsx +1 -1
  105. package/src/modules/inbox_ops/backend/inbox-ops/page.tsx +1 -1
  106. package/src/modules/messages/components/MessagesInboxPageClient.tsx +1 -1
  107. package/src/modules/payment_gateways/backend/payment-gateways/page.tsx +1 -1
  108. package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +2 -1
  109. package/src/modules/query_index/components/QueryIndexesTable.tsx +2 -1
  110. package/src/modules/resources/backend/resources/resource-types/page.tsx +2 -1
  111. package/src/modules/resources/backend/resources/resources/page.tsx +1 -1
  112. package/src/modules/sales/backend/sales/channels/offers/page.tsx +2 -1
  113. package/src/modules/sales/backend/sales/channels/page.tsx +2 -1
  114. package/src/modules/sales/components/AdjustmentKindSettings.tsx +1 -1
  115. package/src/modules/sales/components/PaymentMethodsSettings.tsx +1 -1
  116. package/src/modules/sales/components/ShippingMethodsSettings.tsx +1 -1
  117. package/src/modules/sales/components/TaxRatesSettings.tsx +1 -1
  118. package/src/modules/sales/components/channels/SalesChannelOffersPanel.tsx +2 -1
  119. package/src/modules/sales/components/documents/AdjustmentsSection.tsx +1 -1
  120. package/src/modules/sales/components/documents/PaymentsSection.tsx +1 -1
  121. package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +2 -1
  122. package/src/modules/sales/components/documents/SalesOrderDraftLines.tsx +1 -1
  123. package/src/modules/staff/backend/staff/leave-requests/page.tsx +2 -1
  124. package/src/modules/staff/backend/staff/my-leave-requests/page.tsx +2 -1
  125. package/src/modules/staff/backend/staff/team-members/page.tsx +3 -2
  126. package/src/modules/staff/backend/staff/team-roles/page.tsx +1 -1
  127. package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +2 -1
  128. package/src/modules/staff/backend/staff/teams/page.tsx +2 -1
  129. package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +2 -1
  130. package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +2 -1
  131. package/src/modules/wms/components/backend/WmsInventoryConsolePage.tsx +4 -3
  132. package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +1 -1
  133. package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +1 -1
  134. package/src/modules/wms/components/backend/WmsLotsListPage.tsx +2 -1
  135. package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +1 -1
  136. package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +1 -1
  137. package/src/modules/workflows/backend/definitions/page.tsx +1 -1
  138. package/src/modules/workflows/backend/events/page.tsx +1 -1
  139. package/src/modules/workflows/backend/instances/page.tsx +1 -1
  140. package/src/modules/workflows/backend/tasks/page.tsx +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/business_rules/backend/logs/page.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useQuery } from '@tanstack/react-query'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\n\ntype RuleExecutionLog = {\n id: string\n ruleId: string\n rule?: {\n id: string\n ruleId: string\n ruleName: string\n ruleType: string\n } | null\n entityType: string\n entityId: string | null\n eventType: string | null\n executedAt: string\n executionTimeMs: number\n executionResult: 'SUCCESS' | 'FAILURE' | 'ERROR'\n resultValue: any | null\n errorMessage: string | null\n inputContext: any | null\n outputContext: any | null\n executedBy: string | null\n tenantId: string | null\n organizationId: string | null\n}\n\ntype LogsResponse = {\n items: RuleExecutionLog[]\n total: number\n totalPages: number\n}\n\nexport default function ExecutionLogsPage() {\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(50)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const t = useT()\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['business-rules', 'logs', filterValues, page],\n queryFn: async () => {\n const params = new URLSearchParams()\n params.set('page', page.toString())\n params.set('pageSize', pageSize.toString())\n params.set('sortField', 'executedAt')\n params.set('sortDir', 'desc')\n\n if (filterValues.ruleId) params.set('ruleId', filterValues.ruleId as string)\n if (filterValues.entityType) params.set('entityType', filterValues.entityType as string)\n if (filterValues.executionResult) params.set('executionResult', filterValues.executionResult as string)\n if (filterValues.executedBy) params.set('executedBy', filterValues.executedBy as string)\n if (filterValues.executedAtFrom) params.set('executedAtFrom', filterValues.executedAtFrom as string)\n if (filterValues.executedAtTo) params.set('executedAtTo', filterValues.executedAtTo as string)\n\n const result = await apiCall<LogsResponse>(\n `/api/business_rules/logs?${params.toString()}`\n )\n\n if (!result.ok) {\n throw new Error('Failed to fetch execution logs')\n }\n\n const response = result.result\n if (response) {\n setTotal(response.total || 0)\n setTotalPages(response.totalPages || 1)\n }\n\n return response?.items || []\n },\n })\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined) next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [])\n\n const filters: FilterDef[] = [\n {\n id: 'entityType',\n type: 'text',\n label: t('business_rules.logs.filters.entityType'),\n placeholder: t('business_rules.logs.filters.entityTypePlaceholder'),\n },\n {\n id: 'executionResult',\n type: 'select',\n label: t('business_rules.logs.filters.result'),\n options: [\n { value: '', label: t('common.all') },\n { value: 'SUCCESS', label: t('business_rules.logs.result.success') },\n { value: 'FAILURE', label: t('business_rules.logs.result.failure') },\n { value: 'ERROR', label: t('business_rules.logs.result.error') },\n ],\n },\n {\n id: 'executedBy',\n type: 'text',\n label: t('business_rules.logs.filters.executedBy'),\n placeholder: t('business_rules.logs.filters.executedByPlaceholder'),\n },\n {\n id: 'executedAtFrom',\n type: 'dateRange',\n label: t('business_rules.logs.filters.dateFrom'),\n },\n {\n id: 'executedAtTo',\n type: 'dateRange',\n label: t('business_rules.logs.filters.dateTo'),\n },\n ]\n\n const getResultBadgeClass = (result: string) => {\n switch (result) {\n case 'SUCCESS':\n return 'bg-green-100 text-green-800'\n case 'FAILURE':\n return 'bg-yellow-100 text-yellow-800'\n case 'ERROR':\n return 'bg-red-100 text-red-800'\n default:\n return 'bg-muted text-foreground'\n }\n }\n\n const columns: ColumnDef<RuleExecutionLog>[] = [\n {\n id: 'executedAt',\n header: t('business_rules.logs.fields.executedAt'),\n accessorKey: 'executedAt',\n cell: ({ row }) => (\n <div className=\"text-sm\">\n {new Date(row.original.executedAt).toLocaleString()}\n </div>\n ),\n },\n {\n id: 'rule',\n header: t('business_rules.logs.fields.rule'),\n cell: ({ row }) => (\n <div>\n {row.original.rule ? (\n <Link\n href={`/backend/rules/${row.original.rule.id}`}\n className=\"text-blue-600 hover:text-blue-800 hover:underline font-medium\"\n >\n {row.original.rule.ruleName}\n </Link>\n ) : (\n <span className=\"text-muted-foreground text-sm\">\n {t('business_rules.logs.ruleDeleted')}\n </span>\n )}\n {row.original.rule && (\n <div className=\"text-xs text-muted-foreground mt-0.5\">\n {row.original.rule.ruleType}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'entity',\n header: t('business_rules.logs.fields.entity'),\n cell: ({ row }) => (\n <div className=\"text-sm\">\n <div className=\"font-medium\">{row.original.entityType}</div>\n {row.original.entityId && (\n <div className=\"text-xs text-muted-foreground truncate max-w-[200px]\" title={row.original.entityId}>\n {row.original.entityId}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'result',\n header: t('business_rules.logs.fields.result'),\n accessorKey: 'executionResult',\n cell: ({ row }) => (\n <span\n className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium ${getResultBadgeClass(\n row.original.executionResult\n )}`}\n >\n {t(`business_rules.logs.result.${row.original.executionResult.toLowerCase()}`)}\n </span>\n ),\n },\n {\n id: 'executionTime',\n header: t('business_rules.logs.fields.executionTime'),\n accessorKey: 'executionTimeMs',\n cell: ({ row }) => (\n <div className=\"text-sm text-muted-foreground\">\n {row.original.executionTimeMs}ms\n </div>\n ),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => (\n <Link\n href={`/backend/logs/${row.original.id}`}\n className=\"text-sm text-blue-600 hover:text-blue-800 hover:underline\"\n >\n {t('common.details')}\n </Link>\n ),\n },\n ]\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('business_rules.logs.list.title')}\n columns={columns}\n data={data || []}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n isLoading={isLoading}\n error={error ? t('business_rules.logs.messages.loadFailed') : undefined}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n />\n </PageBody>\n </Page>\n )\n}\n"],
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useQuery } from '@tanstack/react-query'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\n\ntype RuleExecutionLog = {\n id: string\n ruleId: string\n rule?: {\n id: string\n ruleId: string\n ruleName: string\n ruleType: string\n } | null\n entityType: string\n entityId: string | null\n eventType: string | null\n executedAt: string\n executionTimeMs: number\n executionResult: 'SUCCESS' | 'FAILURE' | 'ERROR'\n resultValue: any | null\n errorMessage: string | null\n inputContext: any | null\n outputContext: any | null\n executedBy: string | null\n tenantId: string | null\n organizationId: string | null\n}\n\ntype LogsResponse = {\n items: RuleExecutionLog[]\n total: number\n totalPages: number\n}\n\nexport default function ExecutionLogsPage() {\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(50)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const t = useT()\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['business-rules', 'logs', filterValues, page],\n queryFn: async () => {\n const params = new URLSearchParams()\n params.set('page', page.toString())\n params.set('pageSize', pageSize.toString())\n params.set('sortField', 'executedAt')\n params.set('sortDir', 'desc')\n\n if (filterValues.ruleId) params.set('ruleId', filterValues.ruleId as string)\n if (filterValues.entityType) params.set('entityType', filterValues.entityType as string)\n if (filterValues.executionResult) params.set('executionResult', filterValues.executionResult as string)\n if (filterValues.executedBy) params.set('executedBy', filterValues.executedBy as string)\n if (filterValues.executedAtFrom) params.set('executedAtFrom', filterValues.executedAtFrom as string)\n if (filterValues.executedAtTo) params.set('executedAtTo', filterValues.executedAtTo as string)\n\n const result = await apiCall<LogsResponse>(\n `/api/business_rules/logs?${params.toString()}`\n )\n\n if (!result.ok) {\n throw new Error('Failed to fetch execution logs')\n }\n\n const response = result.result\n if (response) {\n setTotal(response.total || 0)\n setTotalPages(response.totalPages || 1)\n }\n\n return response?.items || []\n },\n })\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined) next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [])\n\n const filters: FilterDef[] = [\n {\n id: 'entityType',\n type: 'text',\n label: t('business_rules.logs.filters.entityType'),\n placeholder: t('business_rules.logs.filters.entityTypePlaceholder'),\n },\n {\n id: 'executionResult',\n type: 'select',\n label: t('business_rules.logs.filters.result'),\n options: [\n { value: '', label: t('common.all') },\n { value: 'SUCCESS', label: t('business_rules.logs.result.success') },\n { value: 'FAILURE', label: t('business_rules.logs.result.failure') },\n { value: 'ERROR', label: t('business_rules.logs.result.error') },\n ],\n },\n {\n id: 'executedBy',\n type: 'text',\n label: t('business_rules.logs.filters.executedBy'),\n placeholder: t('business_rules.logs.filters.executedByPlaceholder'),\n },\n {\n id: 'executedAtFrom',\n type: 'dateRange',\n label: t('business_rules.logs.filters.dateFrom'),\n },\n {\n id: 'executedAtTo',\n type: 'dateRange',\n label: t('business_rules.logs.filters.dateTo'),\n },\n ]\n\n const getResultBadgeClass = (result: string) => {\n switch (result) {\n case 'SUCCESS':\n return 'bg-green-100 text-green-800'\n case 'FAILURE':\n return 'bg-yellow-100 text-yellow-800'\n case 'ERROR':\n return 'bg-red-100 text-red-800'\n default:\n return 'bg-muted text-foreground'\n }\n }\n\n const columns: ColumnDef<RuleExecutionLog>[] = [\n {\n id: 'executedAt',\n header: t('business_rules.logs.fields.executedAt'),\n accessorKey: 'executedAt',\n cell: ({ row }) => (\n <div className=\"text-sm\">\n {new Date(row.original.executedAt).toLocaleString()}\n </div>\n ),\n },\n {\n id: 'rule',\n header: t('business_rules.logs.fields.rule'),\n cell: ({ row }) => (\n <div>\n {row.original.rule ? (\n <Link\n href={`/backend/rules/${row.original.rule.id}`}\n className=\"text-blue-600 hover:text-blue-800 hover:underline font-medium\"\n >\n {row.original.rule.ruleName}\n </Link>\n ) : (\n <span className=\"text-muted-foreground text-sm\">\n {t('business_rules.logs.ruleDeleted')}\n </span>\n )}\n {row.original.rule && (\n <div className=\"text-xs text-muted-foreground mt-0.5\">\n {row.original.rule.ruleType}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'entity',\n header: t('business_rules.logs.fields.entity'),\n cell: ({ row }) => (\n <div className=\"text-sm\">\n <div className=\"font-medium\">{row.original.entityType}</div>\n {row.original.entityId && (\n <div className=\"text-xs text-muted-foreground truncate max-w-[200px]\" title={row.original.entityId}>\n {row.original.entityId}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'result',\n header: t('business_rules.logs.fields.result'),\n accessorKey: 'executionResult',\n cell: ({ row }) => (\n <span\n className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium ${getResultBadgeClass(\n row.original.executionResult\n )}`}\n >\n {t(`business_rules.logs.result.${row.original.executionResult.toLowerCase()}`)}\n </span>\n ),\n },\n {\n id: 'executionTime',\n header: t('business_rules.logs.fields.executionTime'),\n accessorKey: 'executionTimeMs',\n cell: ({ row }) => (\n <div className=\"text-sm text-muted-foreground\">\n {row.original.executionTimeMs}ms\n </div>\n ),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => (\n <Link\n href={`/backend/logs/${row.original.id}`}\n className=\"text-sm text-blue-600 hover:text-blue-800 hover:underline\"\n >\n {t('common.details')}\n </Link>\n ),\n },\n ]\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('business_rules.logs.list.title')}\n columns={columns}\n data={data || []}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n isLoading={isLoading}\n error={error ? t('business_rules.logs.messages.loadFailed') : undefined}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n />\n </PageBody>\n </Page>\n )\n}\n"],
5
5
  "mappings": ";AAyJQ,cASA,YATA;AAvJR,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAE1B,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAiCN,SAAR,oBAAqC;AAC1C,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,CAAC;AACxC,QAAM,CAAC,QAAQ,IAAI,MAAM,SAAS,EAAE;AACpC,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;AAC1C,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,CAAC;AACpD,QAAM,IAAI,KAAK;AACf,QAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAuB,CAAC,CAAC;AAEvE,QAAM,EAAE,MAAM,WAAW,MAAM,IAAI,SAAS;AAAA,IAC1C,UAAU,CAAC,kBAAkB,QAAQ,cAAc,IAAI;AAAA,IACvD,SAAS,YAAY;AACnB,YAAM,SAAS,IAAI,gBAAgB;AACnC,aAAO,IAAI,QAAQ,KAAK,SAAS,CAAC;AAClC,aAAO,IAAI,YAAY,SAAS,SAAS,CAAC;AAC1C,aAAO,IAAI,aAAa,YAAY;AACpC,aAAO,IAAI,WAAW,MAAM;AAE5B,UAAI,aAAa,OAAQ,QAAO,IAAI,UAAU,a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ACE,oBAAC,QACC,8BAAC,YACC;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,gCAAgC;AAAA,MACzC;AAAA,MACA,MAAM,QAAQ,CAAC;AAAA,MACf;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,MAChB;AAAA,MACA,OAAO,QAAQ,EAAE,yCAAyC,IAAI;AAAA,MAC9D,YAAY,EAAE,MAAM,UAAU,OAAO,YAAY,cAAc,QAAQ;AAAA;AAAA,EACzE,GACF,GACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/business_rules/backend/rules/page.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/business_rules/extension-points'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\n\ntype Rule = {\n id: string\n ruleId: string\n ruleName: string\n description: string | null\n ruleType: 'GUARD' | 'VALIDATION' | 'CALCULATION' | 'ACTION' | 'ASSIGNMENT'\n ruleCategory: string | null\n entityType: string\n eventType: string | null\n enabled: boolean\n priority: number\n version: number\n effectiveFrom: string | null\n effectiveTo: string | null\n tenantId: string\n organizationId: string\n createdAt: string\n updatedAt: string\n}\n\ntype RulesResponse = {\n items: Rule[]\n total: number\n totalPages: number\n}\n\nexport default function RulesListPage() {\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(20)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const t = useT()\n const router = useRouter()\n const queryClient = useQueryClient()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['business-rules', 'list', filterValues, page],\n queryFn: async () => {\n const params = new URLSearchParams()\n params.set('page', page.toString())\n params.set('pageSize', pageSize.toString())\n params.set('sortField', 'priority')\n params.set('sortDir', 'desc')\n\n if (filterValues.enabled) params.set('enabled', filterValues.enabled as string)\n if (filterValues.ruleType) params.set('ruleType', filterValues.ruleType as string)\n if (filterValues.entityType) params.set('entityType', filterValues.entityType as string)\n if (filterValues.eventType) params.set('eventType', filterValues.eventType as string)\n if (filterValues.search) params.set('search', filterValues.search as string)\n\n const result = await apiCall<RulesResponse>(\n `/api/business_rules/rules?${params.toString()}`\n )\n\n if (!result.ok) {\n throw new Error('Failed to fetch rules')\n }\n\n const response = result.result\n if (response) {\n setTotal(response.total || 0)\n setTotalPages(response.totalPages || 1)\n }\n\n return response?.items || []\n },\n })\n\n const handleDelete = async (id: string, ruleName: string) => {\n const confirmed = await confirm({\n title: t('business_rules.confirm.delete', { name: ruleName }),\n variant: 'destructive',\n })\n if (!confirmed) return\n\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall(`/api/business_rules/rules?id=${id}`, {\n method: 'DELETE',\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.messages.deleted'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules'] })\n } else {\n flash(t('business_rules.messages.deleteFailed'), 'error')\n }\n }\n\n const handleToggleEnabled = async (id: string, currentEnabled: boolean) => {\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall('/api/business_rules/rules', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n id,\n enabled: !currentEnabled,\n }),\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.messages.updated'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules'] })\n } else {\n flash(t('business_rules.messages.updateFailed'), 'error')\n }\n }\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined) next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [setFilterValues, setPage])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [setFilterValues, setPage])\n\n const filters: FilterDef[] = [\n {\n id: 'search',\n type: 'text',\n label: t('business_rules.filters.search'),\n placeholder: t('business_rules.filters.searchPlaceholder'),\n },\n {\n id: 'enabled',\n type: 'select',\n label: t('business_rules.filters.status'),\n options: [\n { label: t('common.all'), value: '' },\n { label: t('common.enabled'), value: 'true' },\n { label: t('common.disabled'), value: 'false' },\n ],\n },\n {\n id: 'ruleType',\n type: 'select',\n label: t('business_rules.filters.type'),\n options: [\n { label: t('common.all'), value: '' },\n { label: t('business_rules.types.guard'), value: 'GUARD' },\n { label: t('business_rules.types.validation'), value: 'VALIDATION' },\n { label: t('business_rules.types.calculation'), value: 'CALCULATION' },\n { label: t('business_rules.types.action'), value: 'ACTION' },\n { label: t('business_rules.types.assignment'), value: 'ASSIGNMENT' },\n ],\n },\n {\n id: 'entityType',\n type: 'text',\n label: t('business_rules.filters.entityType'),\n placeholder: t('business_rules.filters.entityTypePlaceholder'),\n },\n {\n id: 'eventType',\n type: 'text',\n label: t('business_rules.filters.eventType'),\n placeholder: t('business_rules.filters.eventTypePlaceholder'),\n },\n ]\n\n const columns: ColumnDef<Rule>[] = [\n {\n id: 'ruleId',\n header: t('business_rules.fields.ruleId'),\n accessorKey: 'ruleId',\n cell: ({ row }) => (\n <span className=\"font-mono text-sm\">{row.original.ruleId}</span>\n ),\n },\n {\n id: 'ruleName',\n header: t('business_rules.fields.ruleName'),\n accessorKey: 'ruleName',\n cell: ({ row }) => (\n <div>\n <div className=\"font-medium\">{row.original.ruleName}</div>\n {row.original.description && (\n <div className=\"text-xs text-muted-foreground line-clamp-1\">\n {row.original.description}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'ruleType',\n header: t('business_rules.fields.ruleType'),\n accessorKey: 'ruleType',\n cell: ({ row }) => {\n const typeColors = {\n GUARD: 'bg-status-error-bg text-status-error-text',\n VALIDATION: 'bg-status-warning-bg text-status-warning-text',\n CALCULATION: 'bg-status-info-bg text-status-info-text',\n ACTION: 'bg-status-success-bg text-status-success-text',\n ASSIGNMENT: 'bg-brand-violet/10 text-brand-violet',\n }\n const color = typeColors[row.original.ruleType] || 'bg-muted text-foreground'\n return (\n <span className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium ${color}`}>\n {row.original.ruleType}\n </span>\n )\n },\n },\n {\n id: 'entityType',\n header: t('business_rules.fields.entityType'),\n accessorKey: 'entityType',\n },\n {\n id: 'eventType',\n header: t('business_rules.fields.eventType'),\n accessorKey: 'eventType',\n cell: ({ row }) => row.original.eventType || '-',\n },\n {\n id: 'enabled',\n header: t('business_rules.fields.enabled'),\n accessorKey: 'enabled',\n cell: ({ row }) => (\n <button\n onClick={() => handleToggleEnabled(row.original.id, row.original.enabled)}\n className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium cursor-pointer ${\n row.original.enabled\n ? 'bg-status-success-bg text-status-success-text hover:bg-status-success-bg/80'\n : 'bg-muted text-muted-foreground hover:bg-muted/50'\n }`}\n title={t('business_rules.actions.toggleEnabled')}\n >\n {row.original.enabled ? t('common.yes') : t('common.no')}\n </button>\n ),\n },\n {\n id: 'priority',\n header: t('business_rules.fields.priority'),\n accessorKey: 'priority',\n cell: ({ row }) => (\n <span className=\"font-mono text-sm\">{row.original.priority}</span>\n ),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('common.edit'),\n href: `/backend/rules/${row.original.id}`,\n },\n {\n id: row.original.enabled ? 'disable' : 'enable',\n label: row.original.enabled ? t('common.disable') : t('common.enable'),\n onSelect: () => handleToggleEnabled(row.original.id, row.original.enabled),\n },\n {\n id: 'duplicate',\n label: t('common.duplicate'),\n onSelect: () => {\n // TODO: Implement duplicate functionality in Step 5.2\n flash(t('business_rules.messages.duplicateNotYetImplemented'), 'info')\n },\n },\n {\n id: 'delete',\n label: t('common.delete'),\n onSelect: () => handleDelete(row.original.id, row.original.ruleName),\n destructive: true,\n },\n ]}\n />\n ),\n },\n ]\n\n if (error) {\n return (\n <Page>\n <PageBody>\n <div className=\"p-8 text-center\">\n <p className=\"text-status-error-text\">{t('business_rules.messages.loadFailed')}</p>\n <Button onClick={() => queryClient.invalidateQueries({ queryKey: ['business-rules'] })} className=\"mt-4\">\n {t('common.retry')}\n </Button>\n </div>\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n }\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('business_rules.list.title')}\n actions={(\n <Button asChild>\n <Link href=\"/backend/rules/create\">\n {t('business_rules.actions.create')}\n </Link>\n </Button>\n )}\n columns={columns}\n data={data || []}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n perspective={{\n tableId: extensionPoints.hosts.rulesTable.tableId,\n }}\n emptyState={(\n <ListEmptyState\n entityName={t('business_rules.list.title')}\n createHref=\"/backend/rules/create\"\n createLabel={t('business_rules.actions.create')}\n />\n )}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n"],
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/business_rules/extension-points'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\n\ntype Rule = {\n id: string\n ruleId: string\n ruleName: string\n description: string | null\n ruleType: 'GUARD' | 'VALIDATION' | 'CALCULATION' | 'ACTION' | 'ASSIGNMENT'\n ruleCategory: string | null\n entityType: string\n eventType: string | null\n enabled: boolean\n priority: number\n version: number\n effectiveFrom: string | null\n effectiveTo: string | null\n tenantId: string\n organizationId: string\n createdAt: string\n updatedAt: string\n}\n\ntype RulesResponse = {\n items: Rule[]\n total: number\n totalPages: number\n}\n\nexport default function RulesListPage() {\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(20)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const t = useT()\n const router = useRouter()\n const queryClient = useQueryClient()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['business-rules', 'list', filterValues, page],\n queryFn: async () => {\n const params = new URLSearchParams()\n params.set('page', page.toString())\n params.set('pageSize', pageSize.toString())\n params.set('sortField', 'priority')\n params.set('sortDir', 'desc')\n\n if (filterValues.enabled) params.set('enabled', filterValues.enabled as string)\n if (filterValues.ruleType) params.set('ruleType', filterValues.ruleType as string)\n if (filterValues.entityType) params.set('entityType', filterValues.entityType as string)\n if (filterValues.eventType) params.set('eventType', filterValues.eventType as string)\n if (filterValues.search) params.set('search', filterValues.search as string)\n\n const result = await apiCall<RulesResponse>(\n `/api/business_rules/rules?${params.toString()}`\n )\n\n if (!result.ok) {\n throw new Error('Failed to fetch rules')\n }\n\n const response = result.result\n if (response) {\n setTotal(response.total || 0)\n setTotalPages(response.totalPages || 1)\n }\n\n return response?.items || []\n },\n })\n\n const handleDelete = async (id: string, ruleName: string) => {\n const confirmed = await confirm({\n title: t('business_rules.confirm.delete', { name: ruleName }),\n variant: 'destructive',\n })\n if (!confirmed) return\n\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall(`/api/business_rules/rules?id=${id}`, {\n method: 'DELETE',\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.messages.deleted'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules'] })\n } else {\n flash(t('business_rules.messages.deleteFailed'), 'error')\n }\n }\n\n const handleToggleEnabled = async (id: string, currentEnabled: boolean) => {\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall('/api/business_rules/rules', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n id,\n enabled: !currentEnabled,\n }),\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.messages.updated'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules'] })\n } else {\n flash(t('business_rules.messages.updateFailed'), 'error')\n }\n }\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined) next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [setFilterValues, setPage])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [setFilterValues, setPage])\n\n const filters: FilterDef[] = [\n {\n id: 'search',\n type: 'text',\n label: t('business_rules.filters.search'),\n placeholder: t('business_rules.filters.searchPlaceholder'),\n },\n {\n id: 'enabled',\n type: 'select',\n label: t('business_rules.filters.status'),\n options: [\n { label: t('common.all'), value: '' },\n { label: t('common.enabled'), value: 'true' },\n { label: t('common.disabled'), value: 'false' },\n ],\n },\n {\n id: 'ruleType',\n type: 'select',\n label: t('business_rules.filters.type'),\n options: [\n { label: t('common.all'), value: '' },\n { label: t('business_rules.types.guard'), value: 'GUARD' },\n { label: t('business_rules.types.validation'), value: 'VALIDATION' },\n { label: t('business_rules.types.calculation'), value: 'CALCULATION' },\n { label: t('business_rules.types.action'), value: 'ACTION' },\n { label: t('business_rules.types.assignment'), value: 'ASSIGNMENT' },\n ],\n },\n {\n id: 'entityType',\n type: 'text',\n label: t('business_rules.filters.entityType'),\n placeholder: t('business_rules.filters.entityTypePlaceholder'),\n },\n {\n id: 'eventType',\n type: 'text',\n label: t('business_rules.filters.eventType'),\n placeholder: t('business_rules.filters.eventTypePlaceholder'),\n },\n ]\n\n const columns: ColumnDef<Rule>[] = [\n {\n id: 'ruleId',\n header: t('business_rules.fields.ruleId'),\n accessorKey: 'ruleId',\n cell: ({ row }) => (\n <span className=\"font-mono text-sm\">{row.original.ruleId}</span>\n ),\n },\n {\n id: 'ruleName',\n header: t('business_rules.fields.ruleName'),\n accessorKey: 'ruleName',\n cell: ({ row }) => (\n <div>\n <div className=\"font-medium\">{row.original.ruleName}</div>\n {row.original.description && (\n <div className=\"text-xs text-muted-foreground line-clamp-1\">\n {row.original.description}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'ruleType',\n header: t('business_rules.fields.ruleType'),\n accessorKey: 'ruleType',\n cell: ({ row }) => {\n const typeColors = {\n GUARD: 'bg-status-error-bg text-status-error-text',\n VALIDATION: 'bg-status-warning-bg text-status-warning-text',\n CALCULATION: 'bg-status-info-bg text-status-info-text',\n ACTION: 'bg-status-success-bg text-status-success-text',\n ASSIGNMENT: 'bg-brand-violet/10 text-brand-violet',\n }\n const color = typeColors[row.original.ruleType] || 'bg-muted text-foreground'\n return (\n <span className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium ${color}`}>\n {row.original.ruleType}\n </span>\n )\n },\n },\n {\n id: 'entityType',\n header: t('business_rules.fields.entityType'),\n accessorKey: 'entityType',\n },\n {\n id: 'eventType',\n header: t('business_rules.fields.eventType'),\n accessorKey: 'eventType',\n cell: ({ row }) => row.original.eventType || '-',\n },\n {\n id: 'enabled',\n header: t('business_rules.fields.enabled'),\n accessorKey: 'enabled',\n cell: ({ row }) => (\n <button\n onClick={() => handleToggleEnabled(row.original.id, row.original.enabled)}\n className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium cursor-pointer ${\n row.original.enabled\n ? 'bg-status-success-bg text-status-success-text hover:bg-status-success-bg/80'\n : 'bg-muted text-muted-foreground hover:bg-muted/50'\n }`}\n title={t('business_rules.actions.toggleEnabled')}\n >\n {row.original.enabled ? t('common.yes') : t('common.no')}\n </button>\n ),\n },\n {\n id: 'priority',\n header: t('business_rules.fields.priority'),\n accessorKey: 'priority',\n cell: ({ row }) => (\n <span className=\"font-mono text-sm\">{row.original.priority}</span>\n ),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('common.edit'),\n href: `/backend/rules/${row.original.id}`,\n },\n {\n id: row.original.enabled ? 'disable' : 'enable',\n label: row.original.enabled ? t('common.disable') : t('common.enable'),\n onSelect: () => handleToggleEnabled(row.original.id, row.original.enabled),\n },\n {\n id: 'duplicate',\n label: t('common.duplicate'),\n onSelect: () => {\n // TODO: Implement duplicate functionality in Step 5.2\n flash(t('business_rules.messages.duplicateNotYetImplemented'), 'info')\n },\n },\n {\n id: 'delete',\n label: t('common.delete'),\n onSelect: () => handleDelete(row.original.id, row.original.ruleName),\n destructive: true,\n },\n ]}\n />\n ),\n },\n ]\n\n if (error) {\n return (\n <Page>\n <PageBody>\n <div className=\"p-8 text-center\">\n <p className=\"text-status-error-text\">{t('business_rules.messages.loadFailed')}</p>\n <Button onClick={() => queryClient.invalidateQueries({ queryKey: ['business-rules'] })} className=\"mt-4\">\n {t('common.retry')}\n </Button>\n </div>\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n }\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('business_rules.list.title')}\n actions={(\n <Button asChild>\n <Link href=\"/backend/rules/create\">\n {t('business_rules.actions.create')}\n </Link>\n </Button>\n )}\n columns={columns}\n data={data || []}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n perspective={{\n tableId: extensionPoints.hosts.rulesTable.tableId,\n }}\n emptyState={(\n <ListEmptyState\n entityName={t('business_rules.list.title')}\n createHref=\"/backend/rules/create\"\n createLabel={t('business_rules.actions.create')}\n />\n )}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n"],
5
5
  "mappings": ";AAuMQ,cAQA,YARA;AArMR,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAE1B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,mCAAmC;AACrD,SAAS,iCAAiC;AAC1C,SAAS,aAAa;AACtB,SAAS,UAAU,sBAAsB;AACzC,SAAS,YAAY;AAErB,SAAS,wBAAwB;AACjC,SAAS,sBA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Y,cAAc,QAAQ;AAAA;AAAA,IACzE,GACF;AAAA,IACC;AAAA,KACH;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/business_rules/backend/sets/page.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\n\ntype RuleSet = {\n id: string\n setId: string\n setName: string\n description: string | null\n enabled: boolean\n tenantId: string\n organizationId: string\n createdBy: string | null\n updatedBy: string | null\n createdAt: string\n updatedAt: string\n}\n\ntype RuleSetsResponse = {\n items: RuleSet[]\n total: number\n totalPages: number\n}\n\nexport default function RuleSetsListPage() {\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(20)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const t = useT()\n const router = useRouter()\n const queryClient = useQueryClient()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['business-rules', 'sets', filterValues, page],\n queryFn: async () => {\n const params = new URLSearchParams()\n params.set('page', page.toString())\n params.set('pageSize', pageSize.toString())\n params.set('sortField', 'setName')\n params.set('sortDir', 'asc')\n\n if (filterValues.enabled) params.set('enabled', filterValues.enabled as string)\n if (filterValues.search) params.set('search', filterValues.search as string)\n\n const result = await apiCall<RuleSetsResponse>(\n `/api/business_rules/sets?${params.toString()}`\n )\n\n if (!result.ok) {\n throw new Error('Failed to fetch rule sets')\n }\n\n const response = result.result\n if (response) {\n setTotal(response.total || 0)\n setTotalPages(response.totalPages || 1)\n }\n\n return response?.items || []\n },\n })\n\n const handleDelete = async (id: string, setName: string) => {\n const confirmed = await confirm({\n title: t('business_rules.sets.confirm.delete', { name: setName }),\n variant: 'destructive',\n })\n if (!confirmed) return\n\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall(`/api/business_rules/sets?id=${id}`, {\n method: 'DELETE',\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.sets.messages.deleted'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules', 'sets'] })\n } else {\n flash(t('business_rules.sets.messages.deleteFailed'), 'error')\n }\n }\n\n const handleToggleEnabled = async (id: string, currentEnabled: boolean) => {\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall('/api/business_rules/sets', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n id,\n enabled: !currentEnabled,\n }),\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.sets.messages.updated'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules', 'sets'] })\n } else {\n flash(t('business_rules.sets.messages.updateFailed'), 'error')\n }\n }\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined) next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [setFilterValues, setPage])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [setFilterValues, setPage])\n\n const filters: FilterDef[] = [\n {\n id: 'search',\n type: 'text',\n label: t('business_rules.filters.search'),\n placeholder: t('business_rules.sets.filters.searchPlaceholder'),\n },\n {\n id: 'enabled',\n type: 'select',\n label: t('business_rules.filters.status'),\n options: [\n { value: '', label: t('common.all') },\n { value: 'true', label: t('common.enabled') },\n { value: 'false', label: t('common.disabled') },\n ],\n },\n ]\n\n const columns: ColumnDef<RuleSet>[] = [\n {\n id: 'setId',\n header: t('business_rules.sets.fields.setId'),\n accessorKey: 'setId',\n cell: ({ row }) => (\n <Link\n href={`/backend/sets/${row.original.id}`}\n className=\"font-mono text-sm text-primary hover:underline\"\n >\n {row.original.setId}\n </Link>\n ),\n },\n {\n id: 'setName',\n header: t('business_rules.sets.fields.setName'),\n accessorKey: 'setName',\n cell: ({ row }) => (\n <div>\n <div className=\"font-medium\">{row.original.setName}</div>\n {row.original.description && (\n <div className=\"text-xs text-muted-foreground mt-0.5 line-clamp-1\">\n {row.original.description}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'enabled',\n header: t('business_rules.sets.fields.enabled'),\n accessorKey: 'enabled',\n cell: ({ row }) => (\n <button\n onClick={() => handleToggleEnabled(row.original.id, row.original.enabled)}\n className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium cursor-pointer ${\n row.original.enabled\n ? 'bg-status-success-bg text-status-success-text hover:bg-status-success-bg/80'\n : 'bg-muted text-muted-foreground hover:bg-muted/50'\n }`}\n title={t('business_rules.sets.actions.toggleEnabled')}\n >\n {row.original.enabled ? t('common.yes') : t('common.no')}\n </button>\n ),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('common.edit'),\n href: `/backend/sets/${row.original.id}`,\n },\n {\n id: row.original.enabled ? 'disable' : 'enable',\n label: row.original.enabled ? t('common.disable') : t('common.enable'),\n onSelect: () => handleToggleEnabled(row.original.id, row.original.enabled),\n },\n {\n id: 'delete',\n label: t('common.delete'),\n onSelect: () => handleDelete(row.original.id, row.original.setName),\n destructive: true,\n },\n ]}\n />\n ),\n },\n ]\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('business_rules.sets.list.title')}\n actions={(\n <Button asChild>\n <Link href=\"/backend/sets/create\">\n {t('business_rules.sets.actions.create')}\n </Link>\n </Button>\n )}\n columns={columns}\n data={data || []}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n isLoading={isLoading}\n error={error ? t('business_rules.sets.messages.loadFailed') : undefined}\n emptyState={(\n <ListEmptyState\n entityName={t('business_rules.sets.list.title')}\n createHref=\"/backend/sets/create\"\n createLabel={t('business_rules.sets.actions.create')}\n />\n )}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n"],
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\n\ntype RuleSet = {\n id: string\n setId: string\n setName: string\n description: string | null\n enabled: boolean\n tenantId: string\n organizationId: string\n createdBy: string | null\n updatedBy: string | null\n createdAt: string\n updatedAt: string\n}\n\ntype RuleSetsResponse = {\n items: RuleSet[]\n total: number\n totalPages: number\n}\n\nexport default function RuleSetsListPage() {\n const [page, setPage] = React.useState(1)\n const [pageSize] = React.useState(20)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const t = useT()\n const router = useRouter()\n const queryClient = useQueryClient()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n\n const { data, isLoading, error } = useQuery({\n queryKey: ['business-rules', 'sets', filterValues, page],\n queryFn: async () => {\n const params = new URLSearchParams()\n params.set('page', page.toString())\n params.set('pageSize', pageSize.toString())\n params.set('sortField', 'setName')\n params.set('sortDir', 'asc')\n\n if (filterValues.enabled) params.set('enabled', filterValues.enabled as string)\n if (filterValues.search) params.set('search', filterValues.search as string)\n\n const result = await apiCall<RuleSetsResponse>(\n `/api/business_rules/sets?${params.toString()}`\n )\n\n if (!result.ok) {\n throw new Error('Failed to fetch rule sets')\n }\n\n const response = result.result\n if (response) {\n setTotal(response.total || 0)\n setTotalPages(response.totalPages || 1)\n }\n\n return response?.items || []\n },\n })\n\n const handleDelete = async (id: string, setName: string) => {\n const confirmed = await confirm({\n title: t('business_rules.sets.confirm.delete', { name: setName }),\n variant: 'destructive',\n })\n if (!confirmed) return\n\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall(`/api/business_rules/sets?id=${id}`, {\n method: 'DELETE',\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.sets.messages.deleted'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules', 'sets'] })\n } else {\n flash(t('business_rules.sets.messages.deleteFailed'), 'error')\n }\n }\n\n const handleToggleEnabled = async (id: string, currentEnabled: boolean) => {\n const record = (data || []).find((item) => item.id === id)\n const result = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(record?.updatedAt),\n () => apiCall('/api/business_rules/sets', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n id,\n enabled: !currentEnabled,\n }),\n }),\n )\n\n if (result.ok) {\n flash(t('business_rules.sets.messages.updated'), 'success')\n queryClient.invalidateQueries({ queryKey: ['business-rules', 'sets'] })\n } else {\n flash(t('business_rules.sets.messages.updateFailed'), 'error')\n }\n }\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined) next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [setFilterValues, setPage])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [setFilterValues, setPage])\n\n const filters: FilterDef[] = [\n {\n id: 'search',\n type: 'text',\n label: t('business_rules.filters.search'),\n placeholder: t('business_rules.sets.filters.searchPlaceholder'),\n },\n {\n id: 'enabled',\n type: 'select',\n label: t('business_rules.filters.status'),\n options: [\n { value: '', label: t('common.all') },\n { value: 'true', label: t('common.enabled') },\n { value: 'false', label: t('common.disabled') },\n ],\n },\n ]\n\n const columns: ColumnDef<RuleSet>[] = [\n {\n id: 'setId',\n header: t('business_rules.sets.fields.setId'),\n accessorKey: 'setId',\n cell: ({ row }) => (\n <Link\n href={`/backend/sets/${row.original.id}`}\n className=\"font-mono text-sm text-primary hover:underline\"\n >\n {row.original.setId}\n </Link>\n ),\n },\n {\n id: 'setName',\n header: t('business_rules.sets.fields.setName'),\n accessorKey: 'setName',\n cell: ({ row }) => (\n <div>\n <div className=\"font-medium\">{row.original.setName}</div>\n {row.original.description && (\n <div className=\"text-xs text-muted-foreground mt-0.5 line-clamp-1\">\n {row.original.description}\n </div>\n )}\n </div>\n ),\n },\n {\n id: 'enabled',\n header: t('business_rules.sets.fields.enabled'),\n accessorKey: 'enabled',\n cell: ({ row }) => (\n <button\n onClick={() => handleToggleEnabled(row.original.id, row.original.enabled)}\n className={`inline-flex items-center px-2 py-1 rounded text-xs font-medium cursor-pointer ${\n row.original.enabled\n ? 'bg-status-success-bg text-status-success-text hover:bg-status-success-bg/80'\n : 'bg-muted text-muted-foreground hover:bg-muted/50'\n }`}\n title={t('business_rules.sets.actions.toggleEnabled')}\n >\n {row.original.enabled ? t('common.yes') : t('common.no')}\n </button>\n ),\n },\n {\n id: 'actions',\n header: '',\n cell: ({ row }) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('common.edit'),\n href: `/backend/sets/${row.original.id}`,\n },\n {\n id: row.original.enabled ? 'disable' : 'enable',\n label: row.original.enabled ? t('common.disable') : t('common.enable'),\n onSelect: () => handleToggleEnabled(row.original.id, row.original.enabled),\n },\n {\n id: 'delete',\n label: t('common.delete'),\n onSelect: () => handleDelete(row.original.id, row.original.setName),\n destructive: true,\n },\n ]}\n />\n ),\n },\n ]\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('business_rules.sets.list.title')}\n actions={(\n <Button asChild>\n <Link href=\"/backend/sets/create\">\n {t('business_rules.sets.actions.create')}\n </Link>\n </Button>\n )}\n columns={columns}\n data={data || []}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n isLoading={isLoading}\n error={error ? t('business_rules.sets.messages.loadFailed') : undefined}\n emptyState={(\n <ListEmptyState\n entityName={t('business_rules.sets.list.title')}\n createHref=\"/backend/sets/create\"\n createLabel={t('business_rules.sets.actions.create')}\n />\n )}\n pagination={{ page, pageSize, total, totalPages, onPageChange: setPage }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n"],
5
5
  "mappings": ";AAoKQ,cAaA,YAbA;AAlKR,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS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,SAAS,IAAI,IAAI,SAAS,OAAO;AAAA,cAClE,aAAa;AAAA,YACf;AAAA,UACF;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AAEA,SACE,qBAAC,QACC;AAAA,wBAAC,YACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,gCAAgC;AAAA,QACzC,SACE,oBAAC,UAAO,SAAO,MACb,8BAAC,QAAK,MAAK,wBACR,YAAE,oCAAoC,GACzC,GACF;AAAA,QAEF;AAAA,QACA,MAAM,QAAQ,CAAC;AAAA,QACf;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB,gBAAgB;AAAA,QAChB;AAAA,QACA,OAAO,QAAQ,EAAE,yCAAyC,IAAI;AAAA,QAC9D,YACE;AAAA,UAAC;AAAA;AAAA,YACC,YAAY,EAAE,gCAAgC;AAAA,YAC9C,YAAW;AAAA,YACX,aAAa,EAAE,oCAAoC;AAAA;AAAA,QACrD;AAAA,QAEF,YAAY,EAAE,MAAM,UAAU,OAAO,YAAY,cAAc,QAAQ;AAAA;AAAA,IACzE,GACF;AAAA,IACC;AAAA,KACH;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/catalog/components/PriceKindSettings.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { RadioGroup, Radio } from '@open-mercato/ui/primitives/radio'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { DictionaryEntrySelect } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport { useCurrencyDictionary } from '@open-mercato/core/modules/customers/components/detail/hooks/useCurrencyDictionary'\nimport type { DictionaryOption } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport type { CatalogPriceDisplayMode } from '../data/types'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('catalog')\n\ntype PriceKind = {\n id: string\n code: string\n title: string\n displayMode: CatalogPriceDisplayMode\n currencyCode: string | null\n isPromotion: boolean\n isActive: boolean\n createdAt: string\n updatedAt: string\n}\n\ntype DialogState =\n | { mode: 'create' }\n | { mode: 'edit'; entry: PriceKind }\n\ntype PriceKindApiPayload = Partial<PriceKind> & {\n display_mode?: PriceKind['displayMode']\n currency_code?: string | null\n is_promotion?: boolean\n is_active?: boolean\n created_at?: string\n updated_at?: string\n}\n\nconst DISPLAY_MODES: Array<{ value: 'including-tax' | 'excluding-tax'; label: string }> = [\n { value: 'excluding-tax', label: 'Excluding tax' },\n { value: 'including-tax', label: 'Including tax' },\n]\n\nconst PAGE_SIZE = 100\n\ntype PriceKindFormState = {\n code: string\n title: string\n displayMode: CatalogPriceDisplayMode\n currencyCode: string\n isPromotion: boolean\n isActive: boolean\n}\n\nconst DEFAULT_FORM: PriceKindFormState = {\n code: '',\n title: '',\n displayMode: 'excluding-tax' as const,\n currencyCode: '',\n isPromotion: false,\n isActive: true,\n}\n\nconst normalizePriceKind = (input: PriceKindApiPayload | null | undefined): PriceKind => {\n const raw = input ?? {}\n const toStringValue = (value: unknown): string | null => {\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'bigint') return String(value)\n return null\n }\n const toBooleanValue = (value: unknown): boolean | null => (typeof value === 'boolean' ? value : null)\n const resolveDisplayMode = (value: string | null): PriceKind['displayMode'] =>\n value === 'including-tax' ? 'including-tax' : 'excluding-tax'\n\n const displayMode = resolveDisplayMode(\n toStringValue(raw.displayMode) ?? toStringValue(raw.display_mode),\n )\n const currencyCode = toStringValue(raw.currencyCode) ?? toStringValue(raw.currency_code)\n const isPromotion = toBooleanValue(raw.isPromotion) ?? toBooleanValue(raw.is_promotion)\n const isActive = toBooleanValue(raw.isActive) ?? toBooleanValue(raw.is_active)\n\n return {\n id: toStringValue(raw.id) ?? '',\n code: toStringValue(raw.code) ?? '',\n title: toStringValue(raw.title) ?? '',\n displayMode,\n currencyCode: currencyCode ?? null,\n isPromotion: isPromotion ?? false,\n isActive: isActive ?? true,\n createdAt: toStringValue(raw.createdAt) ?? toStringValue(raw.created_at) ?? '',\n updatedAt: toStringValue(raw.updatedAt) ?? toStringValue(raw.updated_at) ?? '',\n }\n}\n\nexport function PriceKindSettings() {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const scopeVersion = useOrganizationScopeVersion()\n const [items, setItems] = React.useState<PriceKind[]>([])\n const [loading, setLoading] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [dialog, setDialog] = React.useState<DialogState | null>(null)\n const [form, setForm] = React.useState<PriceKindFormState>(DEFAULT_FORM)\n const [submitting, setSubmitting] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n const { data: currencyDictionary, refetch: refetchCurrencyDictionary } = useCurrencyDictionary()\n\n const currencyOptionsLoader = React.useCallback(async (): Promise<DictionaryOption[]> => {\n if (currencyDictionary && Array.isArray(currencyDictionary.entries)) {\n return currencyDictionary.entries.map((entry) => ({\n value: entry.value,\n label: entry.label,\n color: entry.color ?? null,\n icon: entry.icon ?? null,\n }))\n }\n const payload = await refetchCurrencyDictionary()\n return payload.entries.map((entry) => ({\n value: entry.value,\n label: entry.label,\n color: entry.color ?? null,\n icon: entry.icon ?? null,\n }))\n }, [currencyDictionary, refetchCurrencyDictionary])\n\n const loadItems = React.useCallback(async () => {\n setLoading(true)\n const loadErrorMessage = t('catalog.priceKinds.errors.load', 'Failed to load price kinds.')\n try {\n const payload = await readApiResultOrThrow<{ items?: PriceKindApiPayload[] }>(\n `/api/catalog/price-kinds?pageSize=${PAGE_SIZE}`,\n undefined,\n { errorMessage: loadErrorMessage },\n )\n const normalized = Array.isArray(payload.items) ? payload.items.map((item) => normalizePriceKind(item)) : []\n setItems(normalized)\n } catch (err) {\n logger.error('catalog.price-kinds.list failed', { err })\n flash(loadErrorMessage, 'error')\n } finally {\n setLoading(false)\n }\n }, [t])\n\n React.useEffect(() => {\n loadItems().catch(() => {})\n }, [loadItems, scopeVersion])\n\n const openDialog = React.useCallback((state: DialogState) => {\n if (state.mode === 'edit') {\n setForm({\n code: state.entry.code,\n title: state.entry.title,\n displayMode: state.entry.displayMode,\n currencyCode: state.entry.currencyCode ?? '',\n isPromotion: state.entry.isPromotion,\n isActive: state.entry.isActive,\n })\n } else {\n setForm(DEFAULT_FORM)\n }\n setError(null)\n setDialog(state)\n }, [])\n\n const closeDialog = React.useCallback(() => {\n setDialog(null)\n setError(null)\n setSubmitting(false)\n setForm(DEFAULT_FORM)\n }, [])\n\n const handleSubmit = React.useCallback(async () => {\n if (!dialog) return\n const trimmedCode = form.code.trim().toLowerCase()\n const trimmedTitle = form.title.trim()\n if (!trimmedCode || !trimmedTitle) {\n setError(t('catalog.priceKinds.errors.required', 'Code and title are required.'))\n return\n }\n setSubmitting(true)\n setError(null)\n try {\n const payload = {\n code: trimmedCode,\n title: trimmedTitle,\n displayMode: form.displayMode,\n currencyCode: form.currencyCode.trim() || undefined,\n isPromotion: form.isPromotion,\n isActive: form.isActive,\n }\n const path = '/api/catalog/price-kinds'\n const method = dialog.mode === 'create' ? 'POST' : 'PUT'\n const body =\n dialog.mode === 'edit'\n ? JSON.stringify({ id: dialog.entry.id, ...payload })\n : JSON.stringify(payload)\n const savePriceKind = () => apiCall(path, {\n method,\n headers: { 'content-type': 'application/json' },\n body,\n })\n const optimisticLockHeader = buildOptimisticLockHeader(\n dialog.mode === 'edit' ? dialog.entry.updatedAt : null,\n )\n const call = Object.keys(optimisticLockHeader).length > 0\n ? await withScopedApiRequestHeaders(optimisticLockHeader, savePriceKind)\n : await savePriceKind()\n if (!call.ok) {\n await raiseCrudError(call.response, t('catalog.priceKinds.errors.save', 'Failed to save price kind.'))\n }\n flash(\n dialog.mode === 'create'\n ? t('catalog.priceKinds.messages.created', 'Price kind created.')\n : t('catalog.priceKinds.messages.updated', 'Price kind updated.'),\n 'success',\n )\n closeDialog()\n await loadItems()\n } catch (err) {\n logger.error('catalog.price-kinds.save failed', { err })\n // Route a concurrent-edit 409 through the single conflict surface (unified\n // conflict bar, or the enterprise merge dialog when its handler is mounted)\n // and close the editor so that surface owns the resolution. Other errors\n // stay inline in the dialog so the user can correct and resubmit.\n if (surfaceRecordConflict(err, t, { onRefresh: () => { void loadItems() } })) {\n closeDialog()\n return\n }\n const message = err instanceof Error ? err.message : t('catalog.priceKinds.errors.save', 'Failed to save price kind.')\n setError(message)\n } finally {\n setSubmitting(false)\n }\n }, [dialog, form, t, closeDialog, loadItems])\n\n const handleDelete = React.useCallback(\n async (entry: PriceKind) => {\n const confirmMessage = t('catalog.priceKinds.confirm.delete', 'Delete price kind \"{{code}}\"?').replace('{{code}}', entry.code)\n const confirmed = await confirm({\n title: confirmMessage,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n const deletePriceKind = () => apiCall('/api/catalog/price-kinds', {\n method: 'DELETE',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: entry.id }),\n })\n const optimisticLockHeader = buildOptimisticLockHeader(entry.updatedAt)\n const call = Object.keys(optimisticLockHeader).length > 0\n ? await withScopedApiRequestHeaders(optimisticLockHeader, deletePriceKind)\n : await deletePriceKind()\n if (!call.ok) {\n await raiseCrudError(call.response, t('catalog.priceKinds.errors.delete', 'Failed to delete price kind.'))\n }\n flash(t('catalog.priceKinds.messages.deleted', 'Price kind deleted.'), 'success')\n await loadItems()\n } catch (err) {\n logger.error('catalog.price-kinds.delete failed', { err })\n // Route a concurrent-edit 409 through the single conflict surface; fall\n // back to a flash for any other delete failure.\n if (surfaceRecordConflict(err, t, { onRefresh: () => { void loadItems() } })) return\n const message = err instanceof Error ? err.message : t('catalog.priceKinds.errors.delete', 'Failed to delete price kind.')\n flash(message, 'error')\n }\n },\n [confirm, loadItems, t],\n )\n\n const formKeyHandler = React.useCallback(\n (event: React.KeyboardEvent<HTMLFormElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n }\n },\n [handleSubmit],\n )\n\n const displayModeLabels = React.useMemo(() => ({\n 'including-tax': t('catalog.priceKinds.form.displayMode.include', 'Including tax'),\n 'excluding-tax': t('catalog.priceKinds.form.displayMode.exclude', 'Excluding tax'),\n }), [t])\n\n const displayModeOptions = React.useMemo(\n () =>\n DISPLAY_MODES.map((mode) => ({\n ...mode,\n label: displayModeLabels[mode.value],\n })),\n [displayModeLabels],\n )\n\n const currencyLabels = React.useMemo(() => ({\n placeholder: t('catalog.priceKinds.form.currency.placeholder', 'Select currency\u2026'),\n addLabel: t('catalog.priceKinds.form.currency.add', 'Add currency'),\n addPrompt: t('catalog.priceKinds.form.currency.addPrompt', 'Provide a currency code.'),\n dialogTitle: t('catalog.priceKinds.form.currency.dialogTitle', 'Add currency'),\n valueLabel: t('catalog.priceKinds.form.currency.valueLabel', 'Currency code'),\n valuePlaceholder: t('catalog.priceKinds.form.currency.valuePlaceholder', 'e.g. USD'),\n labelLabel: t('catalog.priceKinds.form.currency.labelLabel', 'Display label (optional)'),\n labelPlaceholder: t('catalog.priceKinds.form.currency.labelPlaceholder', 'e.g. US Dollar'),\n emptyError: t('catalog.priceKinds.form.currency.required', 'Currency code is required.'),\n cancelLabel: t('catalog.priceKinds.form.currency.cancel', 'Cancel'),\n saveLabel: t('catalog.priceKinds.form.currency.save', 'Save'),\n saveShortcutHint: t('catalog.priceKinds.form.currency.saveShortcut', 'Press Enter to save'),\n successCreateLabel: t('catalog.priceKinds.form.currency.success', 'Currency added.'),\n errorLoad: t('catalog.priceKinds.form.currency.loadError', 'Unable to load currencies.'),\n errorSave: t('catalog.priceKinds.form.currency.createError', 'Unable to add currency.'),\n loadingLabel: t('catalog.priceKinds.form.currency.loading', 'Loading currencies\u2026'),\n manageTitle: t('catalog.priceKinds.form.currency.manage', 'Manage currencies'),\n }), [t])\n\n const tableLabels = React.useMemo(() => ({\n code: t('catalog.priceKinds.table.code', 'Code'),\n title: t('catalog.priceKinds.table.title', 'Title'),\n displayMode: t('catalog.priceKinds.table.displayMode', 'Display mode'),\n currency: t('catalog.priceKinds.table.currency', 'Currency'),\n promotion: t('catalog.priceKinds.table.promotion', 'Promotion'),\n promotionYes: t('catalog.priceKinds.table.promotionYes', 'Yes'),\n promotionNo: t('catalog.priceKinds.table.promotionNo', 'No'),\n active: t('catalog.priceKinds.table.active', 'Active'),\n activeYes: t('catalog.priceKinds.table.activeYes', 'Active'),\n activeNo: t('catalog.priceKinds.table.activeNo', 'Inactive'),\n search: t('catalog.priceKinds.search.placeholder', 'Search by code or title\u2026'),\n empty: t('catalog.priceKinds.table.empty', 'No price kinds yet.'),\n }), [t])\n\n const columns = React.useMemo<ColumnDef<PriceKind>[]>(() => [\n {\n accessorKey: 'code',\n header: tableLabels.code,\n cell: ({ row }) => <span className=\"font-mono uppercase\">{row.original.code}</span>,\n },\n {\n accessorKey: 'title',\n header: tableLabels.title,\n cell: ({ row }) => <span className=\"font-medium\">{row.original.title}</span>,\n },\n {\n accessorKey: 'displayMode',\n header: tableLabels.displayMode,\n cell: ({ row }) => displayModeLabels[row.original.displayMode] ?? row.original.displayMode,\n },\n {\n accessorKey: 'currencyCode',\n header: tableLabels.currency,\n cell: ({ row }) => (row.original.currencyCode ? row.original.currencyCode.toUpperCase() : '\u2014'),\n },\n {\n id: 'promotion',\n header: tableLabels.promotion,\n cell: ({ row }) =>\n row.original.isPromotion ? (\n <span className=\"inline-flex items-center rounded-full border border-status-warning-border bg-status-warning-bg px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {tableLabels.promotionYes}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium\">\n {tableLabels.promotionNo}\n </span>\n ),\n },\n {\n id: 'active',\n header: tableLabels.active,\n cell: ({ row }) =>\n row.original.isActive ? (\n <span className=\"inline-flex items-center rounded-full border border-status-success-border bg-status-success-bg px-2 py-0.5 text-xs font-medium text-status-success-text\">\n {tableLabels.activeYes}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium\">\n {tableLabels.activeNo}\n </span>\n ),\n },\n ], [displayModeLabels, tableLabels])\n\n const filteredItems = React.useMemo(() => {\n const term = search.trim().toLowerCase()\n if (!term) return items\n return items.filter((item) => {\n const currency = (item.currencyCode ?? '').toLowerCase()\n const modeLabel = (displayModeLabels[item.displayMode] ?? item.displayMode).toLowerCase()\n return (\n item.code.toLowerCase().includes(term) ||\n item.title.toLowerCase().includes(term) ||\n currency.includes(term) ||\n modeLabel.includes(term)\n )\n })\n }, [displayModeLabels, items, search])\n\n const handleRowClick = React.useCallback((entry: PriceKind) => {\n openDialog({ mode: 'edit', entry })\n }, [openDialog])\n\n return (\n <>\n <section className=\"border bg-card text-card-foreground shadow-sm\">\n <div className=\"border-b px-6 py-4 space-y-1\">\n <h2 className=\"text-lg font-semibold\">{t('catalog.priceKinds.title', 'Price kinds')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('catalog.priceKinds.description', 'Configure reusable price kinds that control pricing columns and tax display.')}\n </p>\n </div>\n <div className=\"px-2 py-4 sm:px-4\">\n <DataTable<PriceKind>\n data={filteredItems}\n columns={columns}\n embedded\n isLoading={loading}\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={tableLabels.search}\n emptyState={<p className=\"py-8 text-center text-sm text-muted-foreground\">{tableLabels.empty}</p>}\n actions={(\n <Button size=\"sm\" onClick={() => openDialog({ mode: 'create' })}>\n {t('catalog.priceKinds.actions.add', 'Add price kind')}\n </Button>\n )}\n refreshButton={{\n label: t('catalog.priceKinds.actions.refresh', 'Refresh'),\n onRefresh: () => { void loadItems() },\n isRefreshing: loading,\n }}\n rowActions={(entry) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('catalog.priceKinds.actions.edit', 'Edit'),\n onSelect: () => openDialog({ mode: 'edit', entry }),\n },\n {\n id: 'delete',\n label: t('catalog.priceKinds.actions.delete', 'Delete'),\n destructive: true,\n onSelect: () => { void handleDelete(entry) },\n },\n ]}\n />\n )}\n onRowClick={handleRowClick}\n />\n </div>\n <Dialog open={dialog !== null} onOpenChange={(open) => { if (!open) closeDialog(); }}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {dialog?.mode === 'edit'\n ? t('catalog.priceKinds.dialog.editTitle', 'Edit price kind')\n : t('catalog.priceKinds.dialog.createTitle', 'Create price kind')}\n </DialogTitle>\n <DialogDescription>\n {dialog?.mode === 'edit'\n ? t('catalog.priceKinds.dialog.editDescription', 'Update labels or tax behavior for this price kind.')\n : t('catalog.priceKinds.dialog.createDescription', 'Define a reusable price kind for product pricing.')}\n </DialogDescription>\n </DialogHeader>\n <form className=\"space-y-4\" onKeyDown={formKeyHandler} onSubmit={(event) => { event.preventDefault(); void handleSubmit() }}>\n <div className=\"space-y-2\">\n <Label htmlFor=\"price-kind-code\">{t('catalog.priceKinds.form.codeLabel', 'Code')}</Label>\n <Input\n id=\"price-kind-code\"\n value={form.code}\n onChange={(event) => setForm((prev) => ({ ...prev, code: event.target.value }))}\n placeholder={t('catalog.priceKinds.form.codePlaceholder', 'e.g. regular')}\n className=\"font-mono uppercase\"\n disabled={dialog?.mode === 'edit'}\n />\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"price-kind-title\">{t('catalog.priceKinds.form.titleLabel', 'Title')}</Label>\n <Input\n id=\"price-kind-title\"\n value={form.title}\n onChange={(event) => setForm((prev) => ({ ...prev, title: event.target.value }))}\n placeholder={t('catalog.priceKinds.form.titlePlaceholder', 'e.g. Regular price')}\n />\n </div>\n <div className=\"space-y-2\">\n <Label>{t('catalog.priceKinds.form.displayModeLabel', 'Display mode')}</Label>\n <RadioGroup\n className=\"grid gap-2 md:grid-cols-2\"\n name=\"displayMode\"\n value={form.displayMode}\n onValueChange={(next) => setForm((prev) => ({ ...prev, displayMode: next as CatalogPriceDisplayMode }))}\n >\n {displayModeOptions.map((mode) => (\n <label\n key={mode.value}\n className={`flex cursor-pointer items-center gap-2 rounded-md border p-3 text-sm ${\n form.displayMode === mode.value ? 'border-primary bg-primary/5' : 'border-border'\n }`}\n >\n <Radio value={mode.value} />\n <span>{mode.label}</span>\n </label>\n ))}\n </RadioGroup>\n </div>\n <div className=\"space-y-2\">\n <Label>{t('catalog.priceKinds.form.currencyLabel', 'Currency (optional)')}</Label>\n <DictionaryEntrySelect\n value={form.currencyCode || undefined}\n onChange={(value) => setForm((prev) => ({ ...prev, currencyCode: value ?? '' }))}\n fetchOptions={currencyOptionsLoader}\n labels={currencyLabels}\n allowInlineCreate={false}\n sortOptions=\"none\"\n />\n </div>\n <div className=\"flex flex-col gap-2\">\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 rounded border\"\n checked={form.isPromotion}\n onChange={(event) => setForm((prev) => ({ ...prev, isPromotion: event.target.checked }))}\n />\n {t('catalog.priceKinds.form.promotionLabel', 'Mark as promotion')}\n </label>\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 rounded border\"\n checked={form.isActive}\n onChange={(event) => setForm((prev) => ({ ...prev, isActive: event.target.checked }))}\n />\n {t('catalog.priceKinds.form.activeLabel', 'Active')}\n </label>\n </div>\n {error ? <p className=\"text-sm text-status-error-text\">{error}</p> : null}\n </form>\n <DialogFooter>\n <Button variant=\"ghost\" onClick={closeDialog}>\n {t('catalog.priceKinds.actions.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={submitting}>\n {dialog?.mode === 'edit'\n ? t('catalog.priceKinds.actions.saveChanges', 'Save changes')\n : t('catalog.priceKinds.actions.create', 'Create')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </section>\n {ConfirmDialogElement}\n </>\n )\n}\n"],
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { RadioGroup, Radio } from '@open-mercato/ui/primitives/radio'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { DictionaryEntrySelect } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport { useCurrencyDictionary } from '@open-mercato/core/modules/customers/components/detail/hooks/useCurrencyDictionary'\nimport type { DictionaryOption } from '@open-mercato/core/modules/dictionaries/components/DictionaryEntrySelect'\nimport type { CatalogPriceDisplayMode } from '../data/types'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('catalog')\n\ntype PriceKind = {\n id: string\n code: string\n title: string\n displayMode: CatalogPriceDisplayMode\n currencyCode: string | null\n isPromotion: boolean\n isActive: boolean\n createdAt: string\n updatedAt: string\n}\n\ntype DialogState =\n | { mode: 'create' }\n | { mode: 'edit'; entry: PriceKind }\n\ntype PriceKindApiPayload = Partial<PriceKind> & {\n display_mode?: PriceKind['displayMode']\n currency_code?: string | null\n is_promotion?: boolean\n is_active?: boolean\n created_at?: string\n updated_at?: string\n}\n\nconst DISPLAY_MODES: Array<{ value: 'including-tax' | 'excluding-tax'; label: string }> = [\n { value: 'excluding-tax', label: 'Excluding tax' },\n { value: 'including-tax', label: 'Including tax' },\n]\n\nconst PAGE_SIZE = 100\n\ntype PriceKindFormState = {\n code: string\n title: string\n displayMode: CatalogPriceDisplayMode\n currencyCode: string\n isPromotion: boolean\n isActive: boolean\n}\n\nconst DEFAULT_FORM: PriceKindFormState = {\n code: '',\n title: '',\n displayMode: 'excluding-tax' as const,\n currencyCode: '',\n isPromotion: false,\n isActive: true,\n}\n\nconst normalizePriceKind = (input: PriceKindApiPayload | null | undefined): PriceKind => {\n const raw = input ?? {}\n const toStringValue = (value: unknown): string | null => {\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'bigint') return String(value)\n return null\n }\n const toBooleanValue = (value: unknown): boolean | null => (typeof value === 'boolean' ? value : null)\n const resolveDisplayMode = (value: string | null): PriceKind['displayMode'] =>\n value === 'including-tax' ? 'including-tax' : 'excluding-tax'\n\n const displayMode = resolveDisplayMode(\n toStringValue(raw.displayMode) ?? toStringValue(raw.display_mode),\n )\n const currencyCode = toStringValue(raw.currencyCode) ?? toStringValue(raw.currency_code)\n const isPromotion = toBooleanValue(raw.isPromotion) ?? toBooleanValue(raw.is_promotion)\n const isActive = toBooleanValue(raw.isActive) ?? toBooleanValue(raw.is_active)\n\n return {\n id: toStringValue(raw.id) ?? '',\n code: toStringValue(raw.code) ?? '',\n title: toStringValue(raw.title) ?? '',\n displayMode,\n currencyCode: currencyCode ?? null,\n isPromotion: isPromotion ?? false,\n isActive: isActive ?? true,\n createdAt: toStringValue(raw.createdAt) ?? toStringValue(raw.created_at) ?? '',\n updatedAt: toStringValue(raw.updatedAt) ?? toStringValue(raw.updated_at) ?? '',\n }\n}\n\nexport function PriceKindSettings() {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const scopeVersion = useOrganizationScopeVersion()\n const [items, setItems] = React.useState<PriceKind[]>([])\n const [loading, setLoading] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [dialog, setDialog] = React.useState<DialogState | null>(null)\n const [form, setForm] = React.useState<PriceKindFormState>(DEFAULT_FORM)\n const [submitting, setSubmitting] = React.useState(false)\n const [error, setError] = React.useState<string | null>(null)\n const { data: currencyDictionary, refetch: refetchCurrencyDictionary } = useCurrencyDictionary()\n\n const currencyOptionsLoader = React.useCallback(async (): Promise<DictionaryOption[]> => {\n if (currencyDictionary && Array.isArray(currencyDictionary.entries)) {\n return currencyDictionary.entries.map((entry) => ({\n value: entry.value,\n label: entry.label,\n color: entry.color ?? null,\n icon: entry.icon ?? null,\n }))\n }\n const payload = await refetchCurrencyDictionary()\n return payload.entries.map((entry) => ({\n value: entry.value,\n label: entry.label,\n color: entry.color ?? null,\n icon: entry.icon ?? null,\n }))\n }, [currencyDictionary, refetchCurrencyDictionary])\n\n const loadItems = React.useCallback(async () => {\n setLoading(true)\n const loadErrorMessage = t('catalog.priceKinds.errors.load', 'Failed to load price kinds.')\n try {\n const payload = await readApiResultOrThrow<{ items?: PriceKindApiPayload[] }>(\n `/api/catalog/price-kinds?pageSize=${PAGE_SIZE}`,\n undefined,\n { errorMessage: loadErrorMessage },\n )\n const normalized = Array.isArray(payload.items) ? payload.items.map((item) => normalizePriceKind(item)) : []\n setItems(normalized)\n } catch (err) {\n logger.error('catalog.price-kinds.list failed', { err })\n flash(loadErrorMessage, 'error')\n } finally {\n setLoading(false)\n }\n }, [t])\n\n React.useEffect(() => {\n loadItems().catch(() => {})\n }, [loadItems, scopeVersion])\n\n const openDialog = React.useCallback((state: DialogState) => {\n if (state.mode === 'edit') {\n setForm({\n code: state.entry.code,\n title: state.entry.title,\n displayMode: state.entry.displayMode,\n currencyCode: state.entry.currencyCode ?? '',\n isPromotion: state.entry.isPromotion,\n isActive: state.entry.isActive,\n })\n } else {\n setForm(DEFAULT_FORM)\n }\n setError(null)\n setDialog(state)\n }, [])\n\n const closeDialog = React.useCallback(() => {\n setDialog(null)\n setError(null)\n setSubmitting(false)\n setForm(DEFAULT_FORM)\n }, [])\n\n const handleSubmit = React.useCallback(async () => {\n if (!dialog) return\n const trimmedCode = form.code.trim().toLowerCase()\n const trimmedTitle = form.title.trim()\n if (!trimmedCode || !trimmedTitle) {\n setError(t('catalog.priceKinds.errors.required', 'Code and title are required.'))\n return\n }\n setSubmitting(true)\n setError(null)\n try {\n const payload = {\n code: trimmedCode,\n title: trimmedTitle,\n displayMode: form.displayMode,\n currencyCode: form.currencyCode.trim() || undefined,\n isPromotion: form.isPromotion,\n isActive: form.isActive,\n }\n const path = '/api/catalog/price-kinds'\n const method = dialog.mode === 'create' ? 'POST' : 'PUT'\n const body =\n dialog.mode === 'edit'\n ? JSON.stringify({ id: dialog.entry.id, ...payload })\n : JSON.stringify(payload)\n const savePriceKind = () => apiCall(path, {\n method,\n headers: { 'content-type': 'application/json' },\n body,\n })\n const optimisticLockHeader = buildOptimisticLockHeader(\n dialog.mode === 'edit' ? dialog.entry.updatedAt : null,\n )\n const call = Object.keys(optimisticLockHeader).length > 0\n ? await withScopedApiRequestHeaders(optimisticLockHeader, savePriceKind)\n : await savePriceKind()\n if (!call.ok) {\n await raiseCrudError(call.response, t('catalog.priceKinds.errors.save', 'Failed to save price kind.'))\n }\n flash(\n dialog.mode === 'create'\n ? t('catalog.priceKinds.messages.created', 'Price kind created.')\n : t('catalog.priceKinds.messages.updated', 'Price kind updated.'),\n 'success',\n )\n closeDialog()\n await loadItems()\n } catch (err) {\n logger.error('catalog.price-kinds.save failed', { err })\n // Route a concurrent-edit 409 through the single conflict surface (unified\n // conflict bar, or the enterprise merge dialog when its handler is mounted)\n // and close the editor so that surface owns the resolution. Other errors\n // stay inline in the dialog so the user can correct and resubmit.\n if (surfaceRecordConflict(err, t, { onRefresh: () => { void loadItems() } })) {\n closeDialog()\n return\n }\n const message = err instanceof Error ? err.message : t('catalog.priceKinds.errors.save', 'Failed to save price kind.')\n setError(message)\n } finally {\n setSubmitting(false)\n }\n }, [dialog, form, t, closeDialog, loadItems])\n\n const handleDelete = React.useCallback(\n async (entry: PriceKind) => {\n const confirmMessage = t('catalog.priceKinds.confirm.delete', 'Delete price kind \"{{code}}\"?').replace('{{code}}', entry.code)\n const confirmed = await confirm({\n title: confirmMessage,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n const deletePriceKind = () => apiCall('/api/catalog/price-kinds', {\n method: 'DELETE',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ id: entry.id }),\n })\n const optimisticLockHeader = buildOptimisticLockHeader(entry.updatedAt)\n const call = Object.keys(optimisticLockHeader).length > 0\n ? await withScopedApiRequestHeaders(optimisticLockHeader, deletePriceKind)\n : await deletePriceKind()\n if (!call.ok) {\n await raiseCrudError(call.response, t('catalog.priceKinds.errors.delete', 'Failed to delete price kind.'))\n }\n flash(t('catalog.priceKinds.messages.deleted', 'Price kind deleted.'), 'success')\n await loadItems()\n } catch (err) {\n logger.error('catalog.price-kinds.delete failed', { err })\n // Route a concurrent-edit 409 through the single conflict surface; fall\n // back to a flash for any other delete failure.\n if (surfaceRecordConflict(err, t, { onRefresh: () => { void loadItems() } })) return\n const message = err instanceof Error ? err.message : t('catalog.priceKinds.errors.delete', 'Failed to delete price kind.')\n flash(message, 'error')\n }\n },\n [confirm, loadItems, t],\n )\n\n const formKeyHandler = React.useCallback(\n (event: React.KeyboardEvent<HTMLFormElement>) => {\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n void handleSubmit()\n }\n },\n [handleSubmit],\n )\n\n const displayModeLabels = React.useMemo(() => ({\n 'including-tax': t('catalog.priceKinds.form.displayMode.include', 'Including tax'),\n 'excluding-tax': t('catalog.priceKinds.form.displayMode.exclude', 'Excluding tax'),\n }), [t])\n\n const displayModeOptions = React.useMemo(\n () =>\n DISPLAY_MODES.map((mode) => ({\n ...mode,\n label: displayModeLabels[mode.value],\n })),\n [displayModeLabels],\n )\n\n const currencyLabels = React.useMemo(() => ({\n placeholder: t('catalog.priceKinds.form.currency.placeholder', 'Select currency\u2026'),\n addLabel: t('catalog.priceKinds.form.currency.add', 'Add currency'),\n addPrompt: t('catalog.priceKinds.form.currency.addPrompt', 'Provide a currency code.'),\n dialogTitle: t('catalog.priceKinds.form.currency.dialogTitle', 'Add currency'),\n valueLabel: t('catalog.priceKinds.form.currency.valueLabel', 'Currency code'),\n valuePlaceholder: t('catalog.priceKinds.form.currency.valuePlaceholder', 'e.g. USD'),\n labelLabel: t('catalog.priceKinds.form.currency.labelLabel', 'Display label (optional)'),\n labelPlaceholder: t('catalog.priceKinds.form.currency.labelPlaceholder', 'e.g. US Dollar'),\n emptyError: t('catalog.priceKinds.form.currency.required', 'Currency code is required.'),\n cancelLabel: t('catalog.priceKinds.form.currency.cancel', 'Cancel'),\n saveLabel: t('catalog.priceKinds.form.currency.save', 'Save'),\n saveShortcutHint: t('catalog.priceKinds.form.currency.saveShortcut', 'Press Enter to save'),\n successCreateLabel: t('catalog.priceKinds.form.currency.success', 'Currency added.'),\n errorLoad: t('catalog.priceKinds.form.currency.loadError', 'Unable to load currencies.'),\n errorSave: t('catalog.priceKinds.form.currency.createError', 'Unable to add currency.'),\n loadingLabel: t('catalog.priceKinds.form.currency.loading', 'Loading currencies\u2026'),\n manageTitle: t('catalog.priceKinds.form.currency.manage', 'Manage currencies'),\n }), [t])\n\n const tableLabels = React.useMemo(() => ({\n code: t('catalog.priceKinds.table.code', 'Code'),\n title: t('catalog.priceKinds.table.title', 'Title'),\n displayMode: t('catalog.priceKinds.table.displayMode', 'Display mode'),\n currency: t('catalog.priceKinds.table.currency', 'Currency'),\n promotion: t('catalog.priceKinds.table.promotion', 'Promotion'),\n promotionYes: t('catalog.priceKinds.table.promotionYes', 'Yes'),\n promotionNo: t('catalog.priceKinds.table.promotionNo', 'No'),\n active: t('catalog.priceKinds.table.active', 'Active'),\n activeYes: t('catalog.priceKinds.table.activeYes', 'Active'),\n activeNo: t('catalog.priceKinds.table.activeNo', 'Inactive'),\n search: t('catalog.priceKinds.search.placeholder', 'Search by code or title\u2026'),\n empty: t('catalog.priceKinds.table.empty', 'No price kinds yet.'),\n }), [t])\n\n const columns = React.useMemo<ColumnDef<PriceKind>[]>(() => [\n {\n accessorKey: 'code',\n header: tableLabels.code,\n cell: ({ row }) => <span className=\"font-mono uppercase\">{row.original.code}</span>,\n },\n {\n accessorKey: 'title',\n header: tableLabels.title,\n cell: ({ row }) => <span className=\"font-medium\">{row.original.title}</span>,\n },\n {\n accessorKey: 'displayMode',\n header: tableLabels.displayMode,\n cell: ({ row }) => displayModeLabels[row.original.displayMode] ?? row.original.displayMode,\n },\n {\n accessorKey: 'currencyCode',\n header: tableLabels.currency,\n cell: ({ row }) => (row.original.currencyCode ? row.original.currencyCode.toUpperCase() : '\u2014'),\n },\n {\n id: 'promotion',\n header: tableLabels.promotion,\n cell: ({ row }) =>\n row.original.isPromotion ? (\n <span className=\"inline-flex items-center rounded-full border border-status-warning-border bg-status-warning-bg px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {tableLabels.promotionYes}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium\">\n {tableLabels.promotionNo}\n </span>\n ),\n },\n {\n id: 'active',\n header: tableLabels.active,\n cell: ({ row }) =>\n row.original.isActive ? (\n <span className=\"inline-flex items-center rounded-full border border-status-success-border bg-status-success-bg px-2 py-0.5 text-xs font-medium text-status-success-text\">\n {tableLabels.activeYes}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium\">\n {tableLabels.activeNo}\n </span>\n ),\n },\n ], [displayModeLabels, tableLabels])\n\n const filteredItems = React.useMemo(() => {\n const term = search.trim().toLowerCase()\n if (!term) return items\n return items.filter((item) => {\n const currency = (item.currencyCode ?? '').toLowerCase()\n const modeLabel = (displayModeLabels[item.displayMode] ?? item.displayMode).toLowerCase()\n return (\n item.code.toLowerCase().includes(term) ||\n item.title.toLowerCase().includes(term) ||\n currency.includes(term) ||\n modeLabel.includes(term)\n )\n })\n }, [displayModeLabels, items, search])\n\n const handleRowClick = React.useCallback((entry: PriceKind) => {\n openDialog({ mode: 'edit', entry })\n }, [openDialog])\n\n return (\n <>\n <section className=\"border bg-card text-card-foreground shadow-sm\">\n <div className=\"border-b px-6 py-4 space-y-1\">\n <h2 className=\"text-lg font-semibold\">{t('catalog.priceKinds.title', 'Price kinds')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('catalog.priceKinds.description', 'Configure reusable price kinds that control pricing columns and tax display.')}\n </p>\n </div>\n <div className=\"px-2 py-4 sm:px-4\">\n <DataTable<PriceKind>\n data={filteredItems}\n columns={columns}\n embedded\n isLoading={loading}\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={tableLabels.search}\n emptyState={<p className=\"py-8 text-center text-sm text-muted-foreground\">{tableLabels.empty}</p>}\n actions={(\n <Button size=\"sm\" onClick={() => openDialog({ mode: 'create' })}>\n {t('catalog.priceKinds.actions.add', 'Add price kind')}\n </Button>\n )}\n refreshButton={{\n label: t('catalog.priceKinds.actions.refresh', 'Refresh'),\n onRefresh: () => { void loadItems() },\n isRefreshing: loading,\n }}\n rowActions={(entry) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('catalog.priceKinds.actions.edit', 'Edit'),\n onSelect: () => openDialog({ mode: 'edit', entry }),\n },\n {\n id: 'delete',\n label: t('catalog.priceKinds.actions.delete', 'Delete'),\n destructive: true,\n onSelect: () => { void handleDelete(entry) },\n },\n ]}\n />\n )}\n onRowClick={handleRowClick}\n />\n </div>\n <Dialog open={dialog !== null} onOpenChange={(open) => { if (!open) closeDialog(); }}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n {dialog?.mode === 'edit'\n ? t('catalog.priceKinds.dialog.editTitle', 'Edit price kind')\n : t('catalog.priceKinds.dialog.createTitle', 'Create price kind')}\n </DialogTitle>\n <DialogDescription>\n {dialog?.mode === 'edit'\n ? t('catalog.priceKinds.dialog.editDescription', 'Update labels or tax behavior for this price kind.')\n : t('catalog.priceKinds.dialog.createDescription', 'Define a reusable price kind for product pricing.')}\n </DialogDescription>\n </DialogHeader>\n <form className=\"space-y-4\" onKeyDown={formKeyHandler} onSubmit={(event) => { event.preventDefault(); void handleSubmit() }}>\n <div className=\"space-y-2\">\n <Label htmlFor=\"price-kind-code\">{t('catalog.priceKinds.form.codeLabel', 'Code')}</Label>\n <Input\n id=\"price-kind-code\"\n value={form.code}\n onChange={(event) => setForm((prev) => ({ ...prev, code: event.target.value }))}\n placeholder={t('catalog.priceKinds.form.codePlaceholder', 'e.g. regular')}\n className=\"font-mono uppercase\"\n disabled={dialog?.mode === 'edit'}\n />\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"price-kind-title\">{t('catalog.priceKinds.form.titleLabel', 'Title')}</Label>\n <Input\n id=\"price-kind-title\"\n value={form.title}\n onChange={(event) => setForm((prev) => ({ ...prev, title: event.target.value }))}\n placeholder={t('catalog.priceKinds.form.titlePlaceholder', 'e.g. Regular price')}\n />\n </div>\n <div className=\"space-y-2\">\n <Label>{t('catalog.priceKinds.form.displayModeLabel', 'Display mode')}</Label>\n <RadioGroup\n className=\"grid gap-2 md:grid-cols-2\"\n name=\"displayMode\"\n value={form.displayMode}\n onValueChange={(next) => setForm((prev) => ({ ...prev, displayMode: next as CatalogPriceDisplayMode }))}\n >\n {displayModeOptions.map((mode) => (\n <label\n key={mode.value}\n className={`flex cursor-pointer items-center gap-2 rounded-md border p-3 text-sm ${\n form.displayMode === mode.value ? 'border-primary bg-primary/5' : 'border-border'\n }`}\n >\n <Radio value={mode.value} />\n <span>{mode.label}</span>\n </label>\n ))}\n </RadioGroup>\n </div>\n <div className=\"space-y-2\">\n <Label>{t('catalog.priceKinds.form.currencyLabel', 'Currency (optional)')}</Label>\n <DictionaryEntrySelect\n value={form.currencyCode || undefined}\n onChange={(value) => setForm((prev) => ({ ...prev, currencyCode: value ?? '' }))}\n fetchOptions={currencyOptionsLoader}\n labels={currencyLabels}\n allowInlineCreate={false}\n sortOptions=\"none\"\n />\n </div>\n <div className=\"flex flex-col gap-2\">\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 rounded border\"\n checked={form.isPromotion}\n onChange={(event) => setForm((prev) => ({ ...prev, isPromotion: event.target.checked }))}\n />\n {t('catalog.priceKinds.form.promotionLabel', 'Mark as promotion')}\n </label>\n <label className=\"flex items-center gap-2 text-sm font-medium\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4 rounded border\"\n checked={form.isActive}\n onChange={(event) => setForm((prev) => ({ ...prev, isActive: event.target.checked }))}\n />\n {t('catalog.priceKinds.form.activeLabel', 'Active')}\n </label>\n </div>\n {error ? <p className=\"text-sm text-status-error-text\">{error}</p> : null}\n </form>\n <DialogFooter>\n <Button variant=\"ghost\" onClick={closeDialog}>\n {t('catalog.priceKinds.actions.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={submitting}>\n {dialog?.mode === 'edit'\n ? t('catalog.priceKinds.actions.saveChanges', 'Save changes')\n : t('catalog.priceKinds.actions.create', 'Create')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </section>\n {ConfirmDialogElement}\n </>\n )\n}\n"],
5
5
  "mappings": ";AAmWyB,SAmErB,UAnEqB,KAqEjB,YArEiB;AAjWzB,YAAY,WAAW;AAEvB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,YAAY,aAAa;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,SAAS,sBAAsB,mCAAmC;AAC3E,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AAGtC,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,SAAS;AA2BrC,MAAM,gBAAoF;AAAA,EACxF,EAAE,OAAO,iBAAiB,OAAO,gBAAgB;AAAA,EACjD,EAAE,OAAO,iBAAiB,OAAO,gBAAgB;AACnD;AAEA,MAAM,YAAY;AAWlB,MAAM,eAAmC;AAAA,EACvC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAAA,EACd,aAAa;AAAA,EACb,UAAU;AACZ;AAEA,MAAM,qBAAqB,CAAC,UAA6D;AACvF,QAAM,MAAM,SAAS,CAAC;AACtB,QAAM,gBAAgB,CAAC,UAAkC;AACvD,QAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAI,OAAO,UAAU,YAAY,OAAO,UAAU,SAAU,QAAO,OAAO,KAAK;AAC/E,WAAO;AAAA,EACT;AACA,QAAM,iBAAiB,CAAC,UAAoC,OAAO,UAAU,YAAY,QAAQ;AACjG,QAAM,qBAAq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AAS,GAAG,EAAE;AAAA,gBAC/E,cAAc;AAAA,gBACd,QAAQ;AAAA,gBACR,mBAAmB;AAAA,gBACnB,aAAY;AAAA;AAAA,YACd;AAAA,aACF;AAAA,UACA,qBAAC,SAAI,WAAU,uBACb;AAAA,iCAAC,WAAM,WAAU,+CACf;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,SAAS,KAAK;AAAA,kBACd,UAAU,CAAC,UAAU,QAAQ,CAAC,UAAU,EAAE,GAAG,MAAM,aAAa,MAAM,OAAO,QAAQ,EAAE;AAAA;AAAA,cACzF;AAAA,cACC,EAAE,0CAA0C,mBAAmB;AAAA,eAClE;AAAA,YACA,qBAAC,WAAM,WAAU,+CACf;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAK;AAAA,kBACL,WAAU;AAAA,kBACV,SAAS,KAAK;AAAA,kBACd,UAAU,CAAC,UAAU,QAAQ,CAAC,UAAU,EAAE,GAAG,MAAM,UAAU,MAAM,OAAO,QAAQ,EAAE;AAAA;AAAA,cACtF;AAAA,cACC,EAAE,uCAAuC,QAAQ;AAAA,eACpD;AAAA,aACF;AAAA,UACC,QAAQ,oBAAC,OAAE,WAAU,kCAAkC,iBAAM,IAAO;AAAA,WACvE;AAAA,QACA,qBAAC,gBACC;AAAA,8BAAC,UAAO,SAAQ,SAAQ,SAAS,aAC9B,YAAE,qCAAqC,QAAQ,GAClD;AAAA,UACA,oBAAC,UAAO,SAAS,MAAM,KAAK,aAAa,GAAG,UAAU,YACnD,kBAAQ,SAAS,SACd,EAAE,0CAA0C,cAAc,IAC1D,EAAE,qCAAqC,QAAQ,GACrD;AAAA,WACF;AAAA,SACF,GACF;AAAA,OACF;AAAA,IACC;AAAA,KACH;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/catalog/components/categories/CategoriesDataTable.tsx"],
4
- "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/catalog/extension-points'\nimport Link from 'next/link'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\nimport type { FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { apiCall, apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { formatCategoryTreeLabel } from '../../lib/categoryTree'\n\ntype CategoryRow = {\n id: string\n name: string\n slug: string | null\n description: string | null\n parentId: string | null\n parentName: string | null\n depth: number\n treePath: string\n pathLabel: string\n childCount: number\n descendantCount: number\n isActive: boolean\n}\n\ntype CategoriesResponse = {\n items: CategoryRow[]\n total: number\n page: number\n pageSize: number\n totalPages: number\n}\n\nconst PAGE_SIZE = 50\nconst TREE_BASE_INDENT = 18\nconst TREE_STEP_INDENT = 14\n\nfunction computeIndent(depth: number): number {\n if (depth <= 0) return 0\n return TREE_BASE_INDENT + (depth - 1) * TREE_STEP_INDENT\n}\n\nexport default function CategoriesDataTable() {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const queryClient = useQueryClient()\n const scopeVersion = useOrganizationScopeVersion()\n const [page, setPage] = React.useState(1)\n const [status, setStatus] = React.useState<'all' | 'active' | 'inactive'>('all')\n const [search, setSearch] = React.useState('')\n const [canManage, setCanManage] = React.useState(false)\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n try {\n const call = await apiCall<{ granted?: string[]; ok?: boolean }>('/api/auth/feature-check', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ features: ['catalog.categories.manage'] }),\n })\n if (!cancelled) {\n const granted = Array.isArray(call.result?.granted) ? call.result.granted : []\n setCanManage(call.result?.ok === true || granted.includes('catalog.categories.manage'))\n }\n } catch {\n if (!cancelled) setCanManage(false)\n }\n }\n load()\n return () => {\n cancelled = true\n }\n }, [])\n\n const queryParams = React.useMemo(() => {\n const params = new URLSearchParams()\n params.set('view', 'manage')\n params.set('page', String(page))\n params.set('pageSize', String(PAGE_SIZE))\n params.set('status', status)\n if (search) params.set('search', search)\n return params.toString()\n }, [page, status, search])\n\n const { data, isLoading } = useQuery<CategoriesResponse>({\n queryKey: ['catalog-categories', queryParams, scopeVersion],\n queryFn: async () => {\n const payload = await readApiResultOrThrow<CategoriesResponse>(\n `/api/catalog/categories?${queryParams}`,\n undefined,\n { errorMessage: t('catalog.categories.list.error.load', 'Failed to load categories') },\n )\n return {\n items: Array.isArray(payload.items) ? payload.items : [],\n total: typeof payload.total === 'number' ? payload.total : 0,\n page: typeof payload.page === 'number' ? payload.page : 1,\n pageSize: typeof payload.pageSize === 'number' ? payload.pageSize : PAGE_SIZE,\n totalPages: typeof payload.totalPages === 'number' ? payload.totalPages : 1,\n }\n },\n })\n\n const rows = data?.items ?? []\n const total = data?.total ?? 0\n const totalPages = data?.totalPages ?? 0\n\n const columns = React.useMemo<ColumnDef<CategoryRow>[]>(() => [\n {\n accessorKey: 'name',\n header: t('catalog.categories.list.columns.category', 'Category'),\n meta: { priority: 1 },\n cell: ({ row }) => {\n const depth = row.original.depth ?? 0\n return (\n <div className=\"flex items-center text-sm font-medium leading-none text-foreground\">\n <span style={{ marginLeft: computeIndent(depth), whiteSpace: 'pre' }}>\n {formatCategoryTreeLabel(row.original.name, depth)}\n </span>\n </div>\n )\n },\n },\n {\n accessorKey: 'pathLabel',\n header: t('catalog.categories.list.columns.path', 'Path'),\n meta: { priority: 3 },\n cell: ({ getValue }) => {\n const value = getValue<string>()\n return <span className=\"text-xs text-muted-foreground\">{value || '\u2014'}</span>\n },\n },\n {\n accessorKey: 'parentName',\n header: t('catalog.categories.list.columns.parent', 'Parent'),\n meta: { priority: 4 },\n cell: ({ getValue }) => getValue<string>() || t('catalog.categories.list.none', '\u2014'),\n },\n {\n accessorKey: 'childCount',\n header: t('catalog.categories.list.columns.children', 'Children'),\n meta: { priority: 5 },\n },\n {\n accessorKey: 'isActive',\n header: t('catalog.categories.list.columns.active', 'Active'),\n enableSorting: false,\n meta: { priority: 2 },\n cell: ({ getValue }) => <BooleanIcon value={Boolean(getValue())} />,\n },\n ], [t])\n\n const handleDelete = React.useCallback(async (category: CategoryRow) => {\n const confirmLabel = t(\n 'catalog.categories.list.confirmDelete',\n 'Archive category \"{{name}}\"?',\n { name: category.name },\n )\n const confirmed = await confirm({\n title: confirmLabel,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n // optimistic-lock-exempt: delete-only mutation \u2014 no field-level lost-update\n await apiCallOrThrow(\n `/api/catalog/categories?id=${encodeURIComponent(category.id)}`,\n { method: 'DELETE' },\n { errorMessage: t('catalog.categories.list.error.delete', 'Failed to delete category') },\n )\n await queryClient.invalidateQueries({ queryKey: ['catalog-categories'] })\n flash(t('catalog.categories.flash.deleted', 'Category archived'), 'success')\n } catch (err: unknown) {\n const fallback = t('catalog.categories.list.error.delete', 'Failed to delete category')\n const message = err instanceof Error ? err.message : fallback\n flash(message, 'error')\n }\n }, [confirm, queryClient, t])\n\n return (\n <>\n <DataTable\n title={t('catalog.categories.list.title', 'Categories')}\n actions={canManage ? (\n <Button asChild>\n <Link href=\"/backend/catalog/categories/create\">\n {t('catalog.categories.list.actions.create', 'Create')}\n </Link>\n </Button>\n ) : undefined}\n columns={columns}\n data={rows}\n emptyState={(\n <ListEmptyState\n entityName={t('catalog.categories.list.title', 'Categories')}\n createHref={canManage ? '/backend/catalog/categories/create' : undefined}\n createLabel={canManage ? t('catalog.categories.list.actions.create', 'Create') : undefined}\n />\n )}\n searchValue={search}\n searchPlaceholder={t('catalog.categories.list.searchPlaceholder', 'Search categories')}\n onSearchChange={(value) => { setSearch(value); setPage(1) }}\n filters={[\n {\n id: 'status',\n label: t('catalog.categories.list.filters.status', 'Status'),\n type: 'select',\n options: [\n { value: 'all', label: t('catalog.categories.list.filters.all', 'All') },\n { value: 'active', label: t('catalog.categories.list.filters.active', 'Active') },\n { value: 'inactive', label: t('catalog.categories.list.filters.inactive', 'Inactive') },\n ],\n },\n ]}\n filterValues={status === 'all' ? {} : { status }}\n onFiltersApply={(values: FilterValues) => {\n const nextStatus = (values.status as 'all' | 'active' | 'inactive' | undefined) ?? 'all'\n setStatus(nextStatus)\n setPage(1)\n }}\n onFiltersClear={() => {\n setStatus('all')\n setPage(1)\n }}\n sortable={false}\n perspective={{ tableId: extensionPoints.hosts.categoriesTable.tableId }}\n rowActions={(row) => (\n canManage ? (\n <RowActions\n items={[\n { id: 'edit', label: t('catalog.categories.list.actions.edit', 'Edit'), href: `/backend/catalog/categories/${row.id}/edit` },\n { id: 'delete', label: t('catalog.categories.list.actions.delete', 'Delete'), destructive: true, onSelect: () => handleDelete(row) },\n ]}\n />\n ) : null\n )}\n pagination={{\n page,\n pageSize: PAGE_SIZE,\n total,\n totalPages,\n onPageChange: setPage,\n }}\n isLoading={isLoading}\n />\n {ConfirmDialogElement}\n </>\n )\n}\n"],
4
+ "sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/catalog/extension-points'\nimport Link from 'next/link'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\nimport type { FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { apiCall, apiCallOrThrow, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { formatCategoryTreeLabel } from '../../lib/categoryTree'\n\ntype CategoryRow = {\n id: string\n name: string\n slug: string | null\n description: string | null\n parentId: string | null\n parentName: string | null\n depth: number\n treePath: string\n pathLabel: string\n childCount: number\n descendantCount: number\n isActive: boolean\n}\n\ntype CategoriesResponse = {\n items: CategoryRow[]\n total: number\n page: number\n pageSize: number\n totalPages: number\n}\n\nconst PAGE_SIZE = 50\nconst TREE_BASE_INDENT = 18\nconst TREE_STEP_INDENT = 14\n\nfunction computeIndent(depth: number): number {\n if (depth <= 0) return 0\n return TREE_BASE_INDENT + (depth - 1) * TREE_STEP_INDENT\n}\n\nexport default function CategoriesDataTable() {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const queryClient = useQueryClient()\n const scopeVersion = useOrganizationScopeVersion()\n const [page, setPage] = React.useState(1)\n const [status, setStatus] = React.useState<'all' | 'active' | 'inactive'>('all')\n const [search, setSearch] = React.useState('')\n const [canManage, setCanManage] = React.useState(false)\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n try {\n const call = await apiCall<{ granted?: string[]; ok?: boolean }>('/api/auth/feature-check', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ features: ['catalog.categories.manage'] }),\n })\n if (!cancelled) {\n const granted = Array.isArray(call.result?.granted) ? call.result.granted : []\n setCanManage(call.result?.ok === true || granted.includes('catalog.categories.manage'))\n }\n } catch {\n if (!cancelled) setCanManage(false)\n }\n }\n load()\n return () => {\n cancelled = true\n }\n }, [])\n\n const queryParams = React.useMemo(() => {\n const params = new URLSearchParams()\n params.set('view', 'manage')\n params.set('page', String(page))\n params.set('pageSize', String(PAGE_SIZE))\n params.set('status', status)\n if (search) params.set('search', search)\n return params.toString()\n }, [page, status, search])\n\n const { data, isLoading } = useQuery<CategoriesResponse>({\n queryKey: ['catalog-categories', queryParams, scopeVersion],\n queryFn: async () => {\n const payload = await readApiResultOrThrow<CategoriesResponse>(\n `/api/catalog/categories?${queryParams}`,\n undefined,\n { errorMessage: t('catalog.categories.list.error.load', 'Failed to load categories') },\n )\n return {\n items: Array.isArray(payload.items) ? payload.items : [],\n total: typeof payload.total === 'number' ? payload.total : 0,\n page: typeof payload.page === 'number' ? payload.page : 1,\n pageSize: typeof payload.pageSize === 'number' ? payload.pageSize : PAGE_SIZE,\n totalPages: typeof payload.totalPages === 'number' ? payload.totalPages : 1,\n }\n },\n })\n\n const rows = data?.items ?? []\n const total = data?.total ?? 0\n const totalPages = data?.totalPages ?? 0\n\n const columns = React.useMemo<ColumnDef<CategoryRow>[]>(() => [\n {\n accessorKey: 'name',\n header: t('catalog.categories.list.columns.category', 'Category'),\n meta: { priority: 1 },\n cell: ({ row }) => {\n const depth = row.original.depth ?? 0\n return (\n <div className=\"flex items-center text-sm font-medium leading-none text-foreground\">\n <span style={{ marginLeft: computeIndent(depth), whiteSpace: 'pre' }}>\n {formatCategoryTreeLabel(row.original.name, depth)}\n </span>\n </div>\n )\n },\n },\n {\n accessorKey: 'pathLabel',\n header: t('catalog.categories.list.columns.path', 'Path'),\n meta: { priority: 3 },\n cell: ({ getValue }) => {\n const value = getValue<string>()\n return <span className=\"text-xs text-muted-foreground\">{value || '\u2014'}</span>\n },\n },\n {\n accessorKey: 'parentName',\n header: t('catalog.categories.list.columns.parent', 'Parent'),\n meta: { priority: 4 },\n cell: ({ getValue }) => getValue<string>() || t('catalog.categories.list.none', '\u2014'),\n },\n {\n accessorKey: 'childCount',\n header: t('catalog.categories.list.columns.children', 'Children'),\n meta: { priority: 5 },\n },\n {\n accessorKey: 'isActive',\n header: t('catalog.categories.list.columns.active', 'Active'),\n enableSorting: false,\n meta: { priority: 2 },\n cell: ({ getValue }) => <BooleanIcon value={Boolean(getValue())} />,\n },\n ], [t])\n\n const handleDelete = React.useCallback(async (category: CategoryRow) => {\n const confirmLabel = t(\n 'catalog.categories.list.confirmDelete',\n 'Archive category \"{{name}}\"?',\n { name: category.name },\n )\n const confirmed = await confirm({\n title: confirmLabel,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n // optimistic-lock-exempt: delete-only mutation \u2014 no field-level lost-update\n await apiCallOrThrow(\n `/api/catalog/categories?id=${encodeURIComponent(category.id)}`,\n { method: 'DELETE' },\n { errorMessage: t('catalog.categories.list.error.delete', 'Failed to delete category') },\n )\n await queryClient.invalidateQueries({ queryKey: ['catalog-categories'] })\n flash(t('catalog.categories.flash.deleted', 'Category archived'), 'success')\n } catch (err: unknown) {\n const fallback = t('catalog.categories.list.error.delete', 'Failed to delete category')\n const message = err instanceof Error ? err.message : fallback\n flash(message, 'error')\n }\n }, [confirm, queryClient, t])\n\n return (\n <>\n <DataTable\n title={t('catalog.categories.list.title', 'Categories')}\n actions={canManage ? (\n <Button asChild>\n <Link href=\"/backend/catalog/categories/create\">\n {t('catalog.categories.list.actions.create', 'Create')}\n </Link>\n </Button>\n ) : undefined}\n columns={columns}\n data={rows}\n emptyState={(\n <ListEmptyState\n entityName={t('catalog.categories.list.title', 'Categories')}\n createHref={canManage ? '/backend/catalog/categories/create' : undefined}\n createLabel={canManage ? t('catalog.categories.list.actions.create', 'Create') : undefined}\n />\n )}\n searchValue={search}\n searchPlaceholder={t('catalog.categories.list.searchPlaceholder', 'Search categories')}\n onSearchChange={(value) => { setSearch(value); setPage(1) }}\n filters={[\n {\n id: 'status',\n label: t('catalog.categories.list.filters.status', 'Status'),\n type: 'select',\n options: [\n { value: 'all', label: t('catalog.categories.list.filters.all', 'All') },\n { value: 'active', label: t('catalog.categories.list.filters.active', 'Active') },\n { value: 'inactive', label: t('catalog.categories.list.filters.inactive', 'Inactive') },\n ],\n },\n ]}\n filterValues={status === 'all' ? {} : { status }}\n onFiltersApply={(values: FilterValues) => {\n const nextStatus = (values.status as 'all' | 'active' | 'inactive' | undefined) ?? 'all'\n setStatus(nextStatus)\n setPage(1)\n }}\n onFiltersClear={() => {\n setStatus('all')\n setPage(1)\n }}\n sortable={false}\n perspective={{ tableId: extensionPoints.hosts.categoriesTable.tableId }}\n rowActions={(row) => (\n canManage ? (\n <RowActions\n items={[\n { id: 'edit', label: t('catalog.categories.list.actions.edit', 'Edit'), href: `/backend/catalog/categories/${row.id}/edit` },\n { id: 'delete', label: t('catalog.categories.list.actions.delete', 'Delete'), destructive: true, onSelect: () => handleDelete(row) },\n ]}\n />\n ) : null\n )}\n pagination={{\n page,\n pageSize: PAGE_SIZE,\n total,\n totalPages,\n onPageChange: setPage,\n }}\n isLoading={isLoading}\n />\n {ConfirmDialogElement}\n </>\n )\n}\n"],
5
5
  "mappings": ";AA8HY,SAgER,UAhEQ,KAgER,YAhEQ;AA5HZ,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,OAAO,UAAU;AACjB,SAAS,UAAU,sBAAsB;AAEzC,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,SAAS,gBAAgB,4BAA4B;AAC9D,SAAS,aAAa;AACtB,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AAyBxC,MAAM,YAAY;AAClB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAEzB,SAAS,cAAc,OAAuB;AAC5C,MAAI,SAAS,EAAG,QAAO;AACvB,SAAO,oBAAoB,QAAQ,KAAK;AAC1C;AAEe,SA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