@open-mercato/core 0.6.6-develop.6201.1.8ceb502c4b → 0.6.6-develop.6205.1.109e4b6a84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +52 -45
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js +9 -13
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivitiesSection.js +17 -12
- package/dist/modules/customers/components/detail/ActivitiesSection.js.map +2 -2
- package/dist/modules/customers/components/detail/ActivityHistorySection.js +11 -7
- package/dist/modules/customers/components/detail/ActivityHistorySection.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionariesManager.js +82 -37
- package/dist/modules/dictionaries/components/DictionariesManager.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js +95 -43
- package/dist/modules/dictionaries/components/DictionaryEntriesEditor.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionarySelectControl.js +40 -19
- package/dist/modules/dictionaries/components/DictionarySelectControl.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +58 -48
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +14 -13
- package/src/modules/customers/components/detail/ActivitiesSection.tsx +22 -13
- package/src/modules/customers/components/detail/ActivityHistorySection.tsx +13 -7
- package/src/modules/dictionaries/components/DictionariesManager.tsx +89 -38
- package/src/modules/dictionaries/components/DictionaryEntriesEditor.tsx +99 -42
- package/src/modules/dictionaries/components/DictionarySelectControl.tsx +43 -18
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
5
|
+
import { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'
|
|
5
6
|
import { useQueryClient } from '@tanstack/react-query'
|
|
6
7
|
import { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'
|
|
7
8
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
@@ -35,6 +36,18 @@ export function DictionarySelectControl({
|
|
|
35
36
|
const t = useT()
|
|
36
37
|
const queryClient = useQueryClient()
|
|
37
38
|
const scopeVersion = useOrganizationScopeVersion()
|
|
39
|
+
const mutationContextId = React.useMemo(
|
|
40
|
+
() => `dictionaries:dictionary_entry:inline:${dictionaryId}`,
|
|
41
|
+
[dictionaryId],
|
|
42
|
+
)
|
|
43
|
+
const { runMutation, retryLastMutation } = useGuardedMutation<{
|
|
44
|
+
formId: string
|
|
45
|
+
resourceKind: string
|
|
46
|
+
retryLastMutation: () => Promise<boolean>
|
|
47
|
+
}>({
|
|
48
|
+
contextId: mutationContextId,
|
|
49
|
+
blockedMessage: t('ui.forms.flash.saveBlocked', 'Save blocked by validation'),
|
|
50
|
+
})
|
|
38
51
|
const [inlineCreateEnabled, setInlineCreateEnabled] = React.useState<boolean>(allowInlineCreate)
|
|
39
52
|
|
|
40
53
|
React.useEffect(() => {
|
|
@@ -110,24 +123,36 @@ export function DictionarySelectControl({
|
|
|
110
123
|
|
|
111
124
|
const createOption = React.useCallback(
|
|
112
125
|
async (input: { value: string; label?: string; color?: string | null; icon?: string | null }) => {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
body: JSON.stringify({
|
|
119
|
-
value: input.value,
|
|
120
|
-
label: input.label ?? input.value,
|
|
121
|
-
color: input.color,
|
|
122
|
-
icon: input.icon,
|
|
123
|
-
}),
|
|
124
|
-
},
|
|
125
|
-
)
|
|
126
|
-
if (!call.ok) {
|
|
127
|
-
throw new Error(
|
|
128
|
-
typeof call.result?.error === 'string' ? call.result.error : 'Failed to create dictionary entry',
|
|
129
|
-
)
|
|
126
|
+
const payload = {
|
|
127
|
+
value: input.value,
|
|
128
|
+
label: input.label ?? input.value,
|
|
129
|
+
color: input.color,
|
|
130
|
+
icon: input.icon,
|
|
130
131
|
}
|
|
132
|
+
const call = await runMutation({
|
|
133
|
+
operation: async () => {
|
|
134
|
+
const result = await apiCall<Record<string, unknown>>(
|
|
135
|
+
`/api/dictionaries/${dictionaryId}/entries`,
|
|
136
|
+
{
|
|
137
|
+
method: 'POST',
|
|
138
|
+
headers: { 'content-type': 'application/json' },
|
|
139
|
+
body: JSON.stringify(payload),
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
if (!result.ok) {
|
|
143
|
+
throw new Error(
|
|
144
|
+
typeof result.result?.error === 'string' ? result.result.error : 'Failed to create dictionary entry',
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
return result
|
|
148
|
+
},
|
|
149
|
+
context: {
|
|
150
|
+
formId: mutationContextId,
|
|
151
|
+
resourceKind: 'dictionaries.dictionary_entry',
|
|
152
|
+
retryLastMutation,
|
|
153
|
+
},
|
|
154
|
+
mutationPayload: payload,
|
|
155
|
+
})
|
|
131
156
|
await invalidateDictionaryEntries(queryClient, dictionaryId)
|
|
132
157
|
return {
|
|
133
158
|
value: String(call.result?.value ?? input.value),
|
|
@@ -139,7 +164,7 @@ export function DictionarySelectControl({
|
|
|
139
164
|
icon: typeof call.result?.icon === 'string' ? call.result.icon : null,
|
|
140
165
|
}
|
|
141
166
|
},
|
|
142
|
-
[dictionaryId, queryClient],
|
|
167
|
+
[dictionaryId, mutationContextId, queryClient, runMutation, retryLastMutation],
|
|
143
168
|
)
|
|
144
169
|
|
|
145
170
|
const labels = React.useMemo(
|