@open-mercato/core 0.4.5-develop-610fbb24ec → 0.4.5-develop-811deeb983
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/categories/[id]/edit/page.js +17 -2
- package/dist/modules/catalog/backend/catalog/categories/[id]/edit/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +15 -0
- 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 +30 -0
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
- package/dist/modules/catalog/data/validators.js +4 -3
- package/dist/modules/catalog/data/validators.js.map +2 -2
- package/dist/modules/catalog/lib/messageObjectPreviews.js +146 -0
- package/dist/modules/catalog/lib/messageObjectPreviews.js.map +7 -0
- package/dist/modules/catalog/message-objects.js +95 -0
- package/dist/modules/catalog/message-objects.js.map +7 -0
- package/dist/modules/currencies/backend/currencies/[id]/page.js +21 -0
- package/dist/modules/currencies/backend/currencies/[id]/page.js.map +2 -2
- package/dist/modules/currencies/lib/messageObjectPreviews.js +51 -0
- package/dist/modules/currencies/lib/messageObjectPreviews.js.map +7 -0
- package/dist/modules/currencies/message-objects.js +41 -0
- package/dist/modules/currencies/message-objects.js.map +7 -0
- package/dist/modules/customers/backend/customers/companies/[id]/page.js +20 -0
- package/dist/modules/customers/backend/customers/companies/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/[id]/page.js +12 -1
- package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people/[id]/page.js +20 -0
- package/dist/modules/customers/backend/customers/people/[id]/page.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyHighlights.js +18 -14
- package/dist/modules/customers/components/detail/CompanyHighlights.js.map +2 -2
- package/dist/modules/customers/components/detail/PersonHighlights.js +18 -14
- package/dist/modules/customers/components/detail/PersonHighlights.js.map +2 -2
- package/dist/modules/customers/lib/messageObjectPreviews.js +41 -5
- package/dist/modules/customers/lib/messageObjectPreviews.js.map +2 -2
- package/dist/modules/customers/message-objects.js +31 -11
- package/dist/modules/customers/message-objects.js.map +2 -2
- package/dist/modules/messages/commands/messages.js +3 -0
- package/dist/modules/messages/commands/messages.js.map +2 -2
- package/dist/modules/messages/components/message-detail/panels/objects-panel.js +6 -1
- package/dist/modules/messages/components/message-detail/panels/objects-panel.js.map +2 -2
- package/dist/modules/messages/components/message-detail/panels/thread-panel.js +4 -1
- package/dist/modules/messages/components/message-detail/panels/thread-panel.js.map +2 -2
- package/dist/modules/messages/frontend/messages/view/[token]/page.js +1 -0
- package/dist/modules/messages/frontend/messages/view/[token]/page.js.map +2 -2
- package/dist/modules/resources/backend/resources/resources/[id]/page.js +24 -7
- package/dist/modules/resources/backend/resources/resources/[id]/page.js.map +2 -2
- package/dist/modules/resources/lib/messageObjectPreviews.js +43 -0
- package/dist/modules/resources/lib/messageObjectPreviews.js.map +7 -0
- package/dist/modules/resources/message-objects.js +37 -0
- package/dist/modules/resources/message-objects.js.map +7 -0
- package/dist/modules/sales/backend/sales/channels/[channelId]/edit/page.js +19 -0
- package/dist/modules/sales/backend/sales/channels/[channelId]/edit/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +23 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/quotes/[id]/page.js +1 -1
- package/dist/modules/sales/backend/sales/quotes/[id]/page.js.map +2 -2
- package/dist/modules/sales/lib/messageObjectPreviews.js +49 -4
- package/dist/modules/sales/lib/messageObjectPreviews.js.map +2 -2
- package/dist/modules/sales/message-objects.js +44 -2
- package/dist/modules/sales/message-objects.js.map +2 -2
- package/dist/modules/sales/widgets/messages/SalesDocumentMessageDetail.js +59 -30
- package/dist/modules/sales/widgets/messages/SalesDocumentMessageDetail.js.map +2 -2
- package/dist/modules/sales/widgets/messages/SalesDocumentMessagePreview.js +1 -1
- package/dist/modules/sales/widgets/messages/SalesDocumentMessagePreview.js.map +1 -1
- package/dist/modules/staff/backend/staff/leave-requests/[id]/page.js +8 -30
- package/dist/modules/staff/backend/staff/leave-requests/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/my-availability/page.js +13 -0
- package/dist/modules/staff/backend/staff/my-availability/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/my-leave-requests/[id]/page.js +8 -31
- package/dist/modules/staff/backend/staff/my-leave-requests/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js +32 -10
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-roles/[id]/edit/page.js +14 -1
- package/dist/modules/staff/backend/staff/team-roles/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +14 -1
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/components/TeamForm.js +4 -2
- package/dist/modules/staff/components/TeamForm.js.map +2 -2
- package/dist/modules/staff/components/TeamRoleForm.js +4 -2
- package/dist/modules/staff/components/TeamRoleForm.js.map +2 -2
- package/dist/modules/staff/lib/messageObjectPreviews.js +111 -2
- package/dist/modules/staff/lib/messageObjectPreviews.js.map +2 -2
- package/dist/modules/staff/message-objects.js +79 -8
- package/dist/modules/staff/message-objects.js.map +2 -2
- package/package.json +3 -3
- package/src/modules/catalog/backend/catalog/categories/[id]/edit/page.tsx +19 -5
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +14 -0
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +40 -0
- package/src/modules/catalog/data/validators.ts +47 -45
- package/src/modules/catalog/lib/messageObjectPreviews.ts +176 -0
- package/src/modules/catalog/message-objects.ts +102 -0
- package/src/modules/currencies/backend/currencies/[id]/page.tsx +20 -0
- package/src/modules/currencies/lib/messageObjectPreviews.ts +65 -0
- package/src/modules/currencies/message-objects.ts +40 -0
- package/src/modules/customers/backend/customers/companies/[id]/page.tsx +19 -0
- package/src/modules/customers/backend/customers/deals/[id]/page.tsx +13 -0
- package/src/modules/customers/backend/customers/people/[id]/page.tsx +19 -0
- package/src/modules/customers/components/detail/CompanyHighlights.tsx +14 -9
- package/src/modules/customers/components/detail/PersonHighlights.tsx +14 -9
- package/src/modules/customers/lib/messageObjectPreviews.ts +43 -3
- package/src/modules/customers/message-objects.ts +31 -11
- package/src/modules/customers/migrations/.snapshot-open-mercato.json +236 -0
- package/src/modules/customers/migrations/.snapshot-openmercato.json +236 -0
- package/src/modules/messages/commands/messages.ts +4 -0
- package/src/modules/messages/components/message-detail/panels/objects-panel.tsx +8 -1
- package/src/modules/messages/components/message-detail/panels/thread-panel.tsx +3 -0
- package/src/modules/messages/frontend/messages/view/[token]/page.tsx +1 -0
- package/src/modules/resources/backend/resources/resources/[id]/page.tsx +20 -4
- package/src/modules/resources/lib/messageObjectPreviews.ts +55 -0
- package/src/modules/resources/message-objects.ts +36 -0
- package/src/modules/sales/backend/sales/channels/[channelId]/edit/page.tsx +18 -0
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +23 -0
- package/src/modules/sales/backend/sales/quotes/[id]/page.tsx +1 -1
- package/src/modules/sales/lib/messageObjectPreviews.ts +54 -4
- package/src/modules/sales/message-objects.ts +44 -2
- package/src/modules/sales/widgets/messages/SalesDocumentMessageDetail.tsx +72 -34
- package/src/modules/sales/widgets/messages/SalesDocumentMessagePreview.tsx +1 -1
- package/src/modules/staff/backend/staff/leave-requests/[id]/page.tsx +7 -29
- package/src/modules/staff/backend/staff/my-availability/page.tsx +14 -0
- package/src/modules/staff/backend/staff/my-leave-requests/[id]/page.tsx +8 -30
- package/src/modules/staff/backend/staff/team-members/[id]/page.tsx +28 -7
- package/src/modules/staff/backend/staff/team-roles/[id]/edit/page.tsx +12 -0
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +12 -0
- package/src/modules/staff/components/TeamForm.tsx +3 -0
- package/src/modules/staff/components/TeamRoleForm.tsx +3 -0
- package/src/modules/staff/lib/messageObjectPreviews.ts +133 -2
- package/src/modules/staff/message-objects.ts +79 -8
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectDetail.js +0 -51
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectDetail.js.map +0 -7
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectPreview.js +0 -35
- package/dist/modules/customers/widgets/messages/CustomerMessageObjectPreview.js.map +0 -7
- package/dist/modules/customers/widgets/messages/index.js +0 -7
- package/dist/modules/customers/widgets/messages/index.js.map +0 -7
- package/dist/modules/staff/widgets/messages/StaffMessageObjectDetail.js +0 -51
- package/dist/modules/staff/widgets/messages/StaffMessageObjectDetail.js.map +0 -7
- package/dist/modules/staff/widgets/messages/StaffMessageObjectPreview.js +0 -34
- package/dist/modules/staff/widgets/messages/StaffMessageObjectPreview.js.map +0 -7
- package/dist/modules/staff/widgets/messages/index.js +0 -7
- package/dist/modules/staff/widgets/messages/index.js.map +0 -7
- package/src/modules/customers/widgets/messages/CustomerMessageObjectDetail.tsx +0 -57
- package/src/modules/customers/widgets/messages/CustomerMessageObjectPreview.tsx +0 -49
- package/src/modules/customers/widgets/messages/index.ts +0 -2
- package/src/modules/staff/widgets/messages/StaffMessageObjectDetail.tsx +0 -57
- package/src/modules/staff/widgets/messages/StaffMessageObjectPreview.tsx +0 -44
- package/src/modules/staff/widgets/messages/index.ts +0 -2
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { MessageObjectDetail, MessageObjectPreview } from "@open-mercato/ui/backend/messages";
|
|
2
|
+
const objectMessageTypes = ["default", "messages.defaultWithObjects"];
|
|
3
|
+
const messageObjectTypes = [
|
|
4
|
+
{
|
|
5
|
+
module: "catalog",
|
|
6
|
+
entityType: "product",
|
|
7
|
+
messageTypes: objectMessageTypes,
|
|
8
|
+
entityId: "catalog:catalog_product",
|
|
9
|
+
optionLabelField: "title",
|
|
10
|
+
optionSubtitleField: "subtitle",
|
|
11
|
+
labelKey: "catalog.messageObjects.product.title",
|
|
12
|
+
icon: "package",
|
|
13
|
+
PreviewComponent: MessageObjectPreview,
|
|
14
|
+
DetailComponent: MessageObjectDetail,
|
|
15
|
+
actions: [
|
|
16
|
+
{
|
|
17
|
+
id: "view",
|
|
18
|
+
labelKey: "common.view",
|
|
19
|
+
variant: "outline",
|
|
20
|
+
href: "/backend/catalog/products/{entityId}"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
loadPreview: async (entityId, ctx) => {
|
|
24
|
+
if (typeof window !== "undefined") {
|
|
25
|
+
return { title: "Product", subtitle: entityId };
|
|
26
|
+
}
|
|
27
|
+
const previews = await import("./lib/messageObjectPreviews.js");
|
|
28
|
+
const productLoader = previews.loadCatalogProductPreview;
|
|
29
|
+
if (productLoader) return productLoader(entityId, ctx);
|
|
30
|
+
return previews.loadCatalogCategoryPreview(entityId, ctx);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
module: "catalog",
|
|
35
|
+
entityType: "variant",
|
|
36
|
+
messageTypes: objectMessageTypes,
|
|
37
|
+
entityId: "catalog:catalog_product_variant",
|
|
38
|
+
optionLabelField: "name",
|
|
39
|
+
optionSubtitleField: "sku",
|
|
40
|
+
labelKey: "catalog.variants.form.editTitle",
|
|
41
|
+
icon: "package-plus",
|
|
42
|
+
PreviewComponent: MessageObjectPreview,
|
|
43
|
+
DetailComponent: MessageObjectDetail,
|
|
44
|
+
actions: [
|
|
45
|
+
{
|
|
46
|
+
id: "view",
|
|
47
|
+
labelKey: "common.view",
|
|
48
|
+
variant: "outline",
|
|
49
|
+
href: "/backend/catalog/products"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
loadPreview: async (entityId, ctx) => {
|
|
53
|
+
if (typeof window !== "undefined") {
|
|
54
|
+
return { title: "Variant", subtitle: entityId };
|
|
55
|
+
}
|
|
56
|
+
const previews = await import("./lib/messageObjectPreviews.js");
|
|
57
|
+
const variantLoader = previews.loadCatalogVariantPreview;
|
|
58
|
+
if (variantLoader) return variantLoader(entityId, ctx);
|
|
59
|
+
return previews.loadCatalogProductPreview(entityId, ctx);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
module: "catalog",
|
|
64
|
+
entityType: "category",
|
|
65
|
+
messageTypes: objectMessageTypes,
|
|
66
|
+
entityId: "catalog:catalog_product_category",
|
|
67
|
+
optionLabelField: "name",
|
|
68
|
+
optionSubtitleField: "description",
|
|
69
|
+
labelKey: "catalog.messageObjects.category.title",
|
|
70
|
+
icon: "tag",
|
|
71
|
+
PreviewComponent: MessageObjectPreview,
|
|
72
|
+
DetailComponent: MessageObjectDetail,
|
|
73
|
+
actions: [
|
|
74
|
+
{
|
|
75
|
+
id: "view",
|
|
76
|
+
labelKey: "common.view",
|
|
77
|
+
variant: "outline",
|
|
78
|
+
href: "/backend/catalog/categories/{entityId}/edit"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
loadPreview: async (entityId, ctx) => {
|
|
82
|
+
if (typeof window !== "undefined") {
|
|
83
|
+
return { title: "Category", subtitle: entityId };
|
|
84
|
+
}
|
|
85
|
+
const { loadCatalogCategoryPreview } = await import("./lib/messageObjectPreviews.js");
|
|
86
|
+
return loadCatalogCategoryPreview(entityId, ctx);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
var message_objects_default = messageObjectTypes;
|
|
91
|
+
export {
|
|
92
|
+
message_objects_default as default,
|
|
93
|
+
messageObjectTypes
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=message-objects.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/catalog/message-objects.ts"],
|
|
4
|
+
"sourcesContent": ["import type { MessageObjectTypeDefinition } from '@open-mercato/shared/modules/messages/types'\nimport { MessageObjectDetail, MessageObjectPreview } from '@open-mercato/ui/backend/messages'\n\nconst objectMessageTypes = ['default', 'messages.defaultWithObjects']\n\nexport const messageObjectTypes: MessageObjectTypeDefinition[] = [\n {\n module: 'catalog',\n entityType: 'product',\n messageTypes: objectMessageTypes,\n entityId: 'catalog:catalog_product',\n optionLabelField: 'title',\n optionSubtitleField: 'subtitle',\n labelKey: 'catalog.messageObjects.product.title',\n icon: 'package',\n PreviewComponent: MessageObjectPreview,\n DetailComponent: MessageObjectDetail,\n actions: [\n {\n id: 'view',\n labelKey: 'common.view',\n variant: 'outline',\n href: '/backend/catalog/products/{entityId}',\n },\n ],\n loadPreview: async (entityId, ctx) => {\n if (typeof window !== 'undefined') {\n return { title: 'Product', subtitle: entityId }\n }\n const previews = await import('./lib/messageObjectPreviews')\n const productLoader = (\n previews as typeof previews & {\n loadCatalogProductPreview?: (id: string, previewCtx: typeof ctx) => Promise<{ title: string; subtitle?: string }>\n }\n ).loadCatalogProductPreview\n if (productLoader) return productLoader(entityId, ctx)\n return previews.loadCatalogCategoryPreview(entityId, ctx)\n },\n },\n {\n module: 'catalog',\n entityType: 'variant',\n messageTypes: objectMessageTypes,\n entityId: 'catalog:catalog_product_variant',\n optionLabelField: 'name',\n optionSubtitleField: 'sku',\n labelKey: 'catalog.variants.form.editTitle',\n icon: 'package-plus',\n PreviewComponent: MessageObjectPreview,\n DetailComponent: MessageObjectDetail,\n actions: [\n {\n id: 'view',\n labelKey: 'common.view',\n variant: 'outline',\n href: '/backend/catalog/products',\n },\n ],\n loadPreview: async (entityId, ctx) => {\n if (typeof window !== 'undefined') {\n return { title: 'Variant', subtitle: entityId }\n }\n const previews = await import('./lib/messageObjectPreviews')\n const variantLoader = (\n previews as typeof previews & {\n loadCatalogVariantPreview?: (id: string, previewCtx: typeof ctx) => Promise<{ title: string; subtitle?: string }>\n }\n ).loadCatalogVariantPreview\n if (variantLoader) return variantLoader(entityId, ctx)\n return previews.loadCatalogProductPreview(entityId, ctx)\n },\n },\n {\n module: 'catalog',\n entityType: 'category',\n messageTypes: objectMessageTypes,\n entityId: 'catalog:catalog_product_category',\n optionLabelField: 'name',\n optionSubtitleField: 'description',\n labelKey: 'catalog.messageObjects.category.title',\n icon: 'tag',\n PreviewComponent: MessageObjectPreview,\n DetailComponent: MessageObjectDetail,\n actions: [\n {\n id: 'view',\n labelKey: 'common.view',\n variant: 'outline',\n href: '/backend/catalog/categories/{entityId}/edit',\n },\n ],\n loadPreview: async (entityId, ctx) => {\n if (typeof window !== 'undefined') {\n return { title: 'Category', subtitle: entityId }\n }\n const { loadCatalogCategoryPreview } = await import('./lib/messageObjectPreviews')\n return loadCatalogCategoryPreview(entityId, ctx)\n },\n },\n]\n\nexport default messageObjectTypes\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,qBAAqB,4BAA4B;AAE1D,MAAM,qBAAqB,CAAC,WAAW,6BAA6B;AAE7D,MAAM,qBAAoD;AAAA,EAC/D;AAAA,IACE,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,qBAAqB;AAAA,IACrB,UAAU;AAAA,IACV,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,IACjB,SAAS;AAAA,MACP;AAAA,QACE,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,aAAa,OAAO,UAAU,QAAQ;AACpC,UAAI,OAAO,WAAW,aAAa;AACjC,eAAO,EAAE,OAAO,WAAW,UAAU,SAAS;AAAA,MAChD;AACA,YAAM,WAAW,MAAM,OAAO,6BAA6B;AAC3D,YAAM,gBACJ,SAGA;AACF,UAAI,cAAe,QAAO,cAAc,UAAU,GAAG;AACrD,aAAO,SAAS,2BAA2B,UAAU,GAAG;AAAA,IAC1D;AAAA,EACF;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,IACR,YAAY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9
|
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
10
10
|
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
11
11
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
12
|
+
import { SendObjectMessageDialog } from "@open-mercato/ui/backend/messages";
|
|
12
13
|
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
13
14
|
function EditCurrencyPage({ params }) {
|
|
14
15
|
const t = useT();
|
|
@@ -144,6 +145,26 @@ function EditCurrencyPage({ params }) {
|
|
|
144
145
|
title: t("currencies.edit.title"),
|
|
145
146
|
backHref: "/backend/currencies",
|
|
146
147
|
versionHistory: { resourceKind: "currencies.currency", resourceId: currency.id },
|
|
148
|
+
extraActions: /* @__PURE__ */ jsx(
|
|
149
|
+
SendObjectMessageDialog,
|
|
150
|
+
{
|
|
151
|
+
object: {
|
|
152
|
+
entityModule: "currencies",
|
|
153
|
+
entityType: "currency",
|
|
154
|
+
entityId: currency.id,
|
|
155
|
+
previewData: {
|
|
156
|
+
title: currency.name,
|
|
157
|
+
subtitle: currency.code,
|
|
158
|
+
metadata: {
|
|
159
|
+
[t("currencies.form.field.code")]: currency.code,
|
|
160
|
+
[t("currencies.form.field.name")]: currency.name,
|
|
161
|
+
[t("currencies.form.field.symbol")]: currency.symbol || "-"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
viewHref: `/backend/currencies/${currency.id}`
|
|
166
|
+
}
|
|
167
|
+
),
|
|
147
168
|
fields: [],
|
|
148
169
|
groups,
|
|
149
170
|
initialValues: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/currencies/backend/currencies/%5Bid%5D/page.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { useRouter, useParams } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm, type CrudFormGroup } from '@open-mercato/ui/backend/CrudForm'\nimport { updateCrud, deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { DataLoader } from '@open-mercato/ui/primitives/DataLoader'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\n\ntype CurrencyData = {\n id: string\n code: string\n name: string\n symbol: string | null\n decimalPlaces: number\n thousandsSeparator: string | null\n decimalSeparator: string | null\n isBase: boolean\n isActive: boolean\n organizationId: string\n tenantId: string\n}\n\nexport default function EditCurrencyPage({ params }: { params?: { id?: string } }) {\n const t = useT()\n const router = useRouter()\n const { confirm: confirmDialog, ConfirmDialogElement } = useConfirmDialog()\n\n const [currency, setCurrency] = React.useState<CurrencyData | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n\n React.useEffect(() => {\n async function loadCurrency() {\n try {\n const response = await apiCall<{ items: CurrencyData[] }>(`/api/currencies/currencies?id=${params?.id}`)\n if (response.ok && response.result && response.result.items.length > 0) {\n setCurrency(response.result.items[0])\n } else {\n setError(t('currencies.form.errors.notFound'))\n }\n } catch (err) {\n setError(t('currencies.form.errors.load'))\n } finally {\n setLoading(false)\n }\n }\n loadCurrency()\n }, [params, t])\n\n const groups = React.useMemo<CrudFormGroup[]>(\n () => [\n {\n id: 'basic',\n column: 1,\n title: t('currencies.form.group.details'),\n fields: [\n {\n id: 'code',\n type: 'text',\n label: t('currencies.form.field.code'),\n placeholder: t('currencies.form.field.codePlaceholder'),\n required: true,\n maxLength: 3,\n helpText: t('currencies.form.field.codeHelp'),\n },\n {\n id: 'name',\n type: 'text',\n label: t('currencies.form.field.name'),\n placeholder: t('currencies.form.field.namePlaceholder'),\n required: true,\n },\n {\n id: 'symbol',\n type: 'text',\n label: t('currencies.form.field.symbol'),\n placeholder: t('currencies.form.field.symbolPlaceholder'),\n },\n ],\n },\n {\n id: 'formatting',\n column: 2,\n title: t('currencies.form.group.formatting'),\n fields: [\n {\n id: 'decimalPlaces',\n type: 'number',\n label: t('currencies.form.field.decimalPlaces'),\n min: 0,\n max: 8,\n },\n {\n id: 'thousandsSeparator',\n type: 'text',\n label: t('currencies.form.field.thousandsSeparator'),\n placeholder: ',',\n maxLength: 5,\n },\n {\n id: 'decimalSeparator',\n type: 'text',\n label: t('currencies.form.field.decimalSeparator'),\n placeholder: '.',\n maxLength: 5,\n },\n {\n id: 'isBase',\n type: 'checkbox',\n label: t('currencies.form.field.isBase'),\n },\n {\n id: 'isActive',\n type: 'checkbox',\n label: t('currencies.form.field.isActive'),\n },\n ],\n },\n ],\n [t]\n )\n\n const handleDelete = React.useCallback(async () => {\n if (!currency) return\n\n const confirmed = await confirmDialog({\n title: t('currencies.list.confirmDelete', { code: currency.code }),\n variant: 'destructive',\n })\n if (!confirmed) return\n\n try {\n await apiCall('/api/currencies/currencies', {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ id: currency.id, organizationId: currency.organizationId, tenantId: currency.tenantId }),\n })\n\n flash(t('currencies.flash.deleted'), 'success')\n router.push('/backend/currencies')\n } catch (error) {\n flash(t('currencies.flash.deleteError'), 'error')\n }\n }, [currency, t, router, confirmDialog])\n\n if (loading) {\n return (\n <Page>\n <PageBody>\n <div className=\"flex items-center justify-center p-8\">\n <div className=\"text-muted-foreground\">{t('currencies.form.loading')}</div>\n </div>\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n }\n\n if (error || !currency) {\n return (\n <Page>\n <PageBody>\n <div className=\"text-destructive\">{error || t('currencies.form.errors.notFound')}</div>\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n }\n\n return (\n <Page>\n <PageBody>\n <CrudForm\n title={t('currencies.edit.title')}\n backHref=\"/backend/currencies\"\n versionHistory={{ resourceKind: 'currencies.currency', resourceId: currency.id }}\n fields={[]}\n groups={groups}\n initialValues={{\n code: currency.code,\n name: currency.name,\n symbol: currency.symbol || '',\n decimalPlaces: currency.decimalPlaces,\n thousandsSeparator: currency.thousandsSeparator || '',\n decimalSeparator: currency.decimalSeparator || '',\n isBase: currency.isBase,\n isActive: currency.isActive,\n }}\n submitLabel={t('currencies.form.action.save')}\n cancelHref=\"/backend/currencies\"\n onSubmit={async (values) => {\n // Validate currency code\n const code = String(values.code || '').trim().toUpperCase()\n if (!/^[A-Z]{3}$/.test(code)) {\n throw createCrudFormError(t('currencies.form.errors.codeFormat'), {\n code: t('currencies.form.errors.codeFormat'),\n })\n }\n\n const payload = {\n id: currency.id,\n code,\n name: String(values.name || '').trim(),\n symbol: values.symbol ? String(values.symbol).trim() : null,\n decimalPlaces: values.decimalPlaces ? parseInt(String(values.decimalPlaces)) : 2,\n thousandsSeparator: values.thousandsSeparator ? String(values.thousandsSeparator) : null,\n decimalSeparator: values.decimalSeparator ? String(values.decimalSeparator) : null,\n isBase: !!values.isBase,\n isActive: values.isActive !== false,\n }\n\n await updateCrud('currencies/currencies', payload)\n\n flash(t('currencies.flash.updated'), 'success')\n router.push('/backend/currencies')\n }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { useRouter, useParams } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm, type CrudFormGroup } from '@open-mercato/ui/backend/CrudForm'\nimport { updateCrud, deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { createCrudFormError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { SendObjectMessageDialog } from '@open-mercato/ui/backend/messages'\nimport { DataLoader } from '@open-mercato/ui/primitives/DataLoader'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\n\ntype CurrencyData = {\n id: string\n code: string\n name: string\n symbol: string | null\n decimalPlaces: number\n thousandsSeparator: string | null\n decimalSeparator: string | null\n isBase: boolean\n isActive: boolean\n organizationId: string\n tenantId: string\n}\n\nexport default function EditCurrencyPage({ params }: { params?: { id?: string } }) {\n const t = useT()\n const router = useRouter()\n const { confirm: confirmDialog, ConfirmDialogElement } = useConfirmDialog()\n\n const [currency, setCurrency] = React.useState<CurrencyData | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n\n React.useEffect(() => {\n async function loadCurrency() {\n try {\n const response = await apiCall<{ items: CurrencyData[] }>(`/api/currencies/currencies?id=${params?.id}`)\n if (response.ok && response.result && response.result.items.length > 0) {\n setCurrency(response.result.items[0])\n } else {\n setError(t('currencies.form.errors.notFound'))\n }\n } catch (err) {\n setError(t('currencies.form.errors.load'))\n } finally {\n setLoading(false)\n }\n }\n loadCurrency()\n }, [params, t])\n\n const groups = React.useMemo<CrudFormGroup[]>(\n () => [\n {\n id: 'basic',\n column: 1,\n title: t('currencies.form.group.details'),\n fields: [\n {\n id: 'code',\n type: 'text',\n label: t('currencies.form.field.code'),\n placeholder: t('currencies.form.field.codePlaceholder'),\n required: true,\n maxLength: 3,\n helpText: t('currencies.form.field.codeHelp'),\n },\n {\n id: 'name',\n type: 'text',\n label: t('currencies.form.field.name'),\n placeholder: t('currencies.form.field.namePlaceholder'),\n required: true,\n },\n {\n id: 'symbol',\n type: 'text',\n label: t('currencies.form.field.symbol'),\n placeholder: t('currencies.form.field.symbolPlaceholder'),\n },\n ],\n },\n {\n id: 'formatting',\n column: 2,\n title: t('currencies.form.group.formatting'),\n fields: [\n {\n id: 'decimalPlaces',\n type: 'number',\n label: t('currencies.form.field.decimalPlaces'),\n min: 0,\n max: 8,\n },\n {\n id: 'thousandsSeparator',\n type: 'text',\n label: t('currencies.form.field.thousandsSeparator'),\n placeholder: ',',\n maxLength: 5,\n },\n {\n id: 'decimalSeparator',\n type: 'text',\n label: t('currencies.form.field.decimalSeparator'),\n placeholder: '.',\n maxLength: 5,\n },\n {\n id: 'isBase',\n type: 'checkbox',\n label: t('currencies.form.field.isBase'),\n },\n {\n id: 'isActive',\n type: 'checkbox',\n label: t('currencies.form.field.isActive'),\n },\n ],\n },\n ],\n [t]\n )\n\n const handleDelete = React.useCallback(async () => {\n if (!currency) return\n\n const confirmed = await confirmDialog({\n title: t('currencies.list.confirmDelete', { code: currency.code }),\n variant: 'destructive',\n })\n if (!confirmed) return\n\n try {\n await apiCall('/api/currencies/currencies', {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ id: currency.id, organizationId: currency.organizationId, tenantId: currency.tenantId }),\n })\n\n flash(t('currencies.flash.deleted'), 'success')\n router.push('/backend/currencies')\n } catch (error) {\n flash(t('currencies.flash.deleteError'), 'error')\n }\n }, [currency, t, router, confirmDialog])\n\n if (loading) {\n return (\n <Page>\n <PageBody>\n <div className=\"flex items-center justify-center p-8\">\n <div className=\"text-muted-foreground\">{t('currencies.form.loading')}</div>\n </div>\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n }\n\n if (error || !currency) {\n return (\n <Page>\n <PageBody>\n <div className=\"text-destructive\">{error || t('currencies.form.errors.notFound')}</div>\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n }\n\n return (\n <Page>\n <PageBody>\n <CrudForm\n title={t('currencies.edit.title')}\n backHref=\"/backend/currencies\"\n versionHistory={{ resourceKind: 'currencies.currency', resourceId: currency.id }}\n extraActions={(\n <SendObjectMessageDialog\n object={{\n entityModule: 'currencies',\n entityType: 'currency',\n entityId: currency.id,\n previewData: {\n title: currency.name,\n subtitle: currency.code,\n metadata: {\n [t('currencies.form.field.code')]: currency.code,\n [t('currencies.form.field.name')]: currency.name,\n [t('currencies.form.field.symbol')]: currency.symbol || '-',\n },\n },\n }}\n viewHref={`/backend/currencies/${currency.id}`}\n />\n )}\n fields={[]}\n groups={groups}\n initialValues={{\n code: currency.code,\n name: currency.name,\n symbol: currency.symbol || '',\n decimalPlaces: currency.decimalPlaces,\n thousandsSeparator: currency.thousandsSeparator || '',\n decimalSeparator: currency.decimalSeparator || '',\n isBase: currency.isBase,\n isActive: currency.isActive,\n }}\n submitLabel={t('currencies.form.action.save')}\n cancelHref=\"/backend/currencies\"\n onSubmit={async (values) => {\n // Validate currency code\n const code = String(values.code || '').trim().toUpperCase()\n if (!/^[A-Z]{3}$/.test(code)) {\n throw createCrudFormError(t('currencies.form.errors.codeFormat'), {\n code: t('currencies.form.errors.codeFormat'),\n })\n }\n\n const payload = {\n id: currency.id,\n code,\n name: String(values.name || '').trim(),\n symbol: values.symbol ? String(values.symbol).trim() : null,\n decimalPlaces: values.decimalPlaces ? parseInt(String(values.decimalPlaces)) : 2,\n thousandsSeparator: values.thousandsSeparator ? String(values.thousandsSeparator) : null,\n decimalSeparator: values.decimalSeparator ? String(values.decimalSeparator) : null,\n isBase: !!values.isBase,\n isActive: values.isActive !== false,\n }\n\n await updateCrud('currencies/currencies', payload)\n\n flash(t('currencies.flash.updated'), 'success')\n router.push('/backend/currencies')\n }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA0JM,SAGM,KAHN;AAxJN,YAAY,WAAW;AACvB,SAAS,iBAA4B;AACrC,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAoC;AAC7C,SAAS,kBAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,+BAA+B;AAExC,SAAS,wBAAwB;AAgBlB,SAAR,iBAAkC,EAAE,OAAO,GAAiC;AACjF,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,SAAS,eAAe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AAAA,UAC3B,eAAe,SAAS;AAAA,UACxB,oBAAoB,SAAS,sBAAsB;AAAA,UACnD,kBAAkB,SAAS,oBAAoB;AAAA,UAC/C,QAAQ,SAAS;AAAA,UACjB,UAAU,SAAS;AAAA,QACrB;AAAA,QACA,aAAa,EAAE,6BAA6B;AAAA,QAC5C,YAAW;AAAA,QACX,UAAU,OAAO,WAAW;AAE1B,gBAAM,OAAO,OAAO,OAAO,QAAQ,EAAE,EAAE,KAAK,EAAE,YAAY;AAC1D,cAAI,CAAC,aAAa,KAAK,IAAI,GAAG;AAC5B,kBAAM,oBAAoB,EAAE,mCAAmC,GAAG;AAAA,cAChE,MAAM,EAAE,mCAAmC;AAAA,YAC7C,CAAC;AAAA,UACH;AAEA,gBAAM,UAAU;AAAA,YACd,IAAI,SAAS;AAAA,YACb;AAAA,YACA,MAAM,OAAO,OAAO,QAAQ,EAAE,EAAE,KAAK;AAAA,YACrC,QAAQ,OAAO,SAAS,OAAO,OAAO,MAAM,EAAE,KAAK,IAAI;AAAA,YACvD,eAAe,OAAO,gBAAgB,SAAS,OAAO,OAAO,aAAa,CAAC,IAAI;AAAA,YAC/E,oBAAoB,OAAO,qBAAqB,OAAO,OAAO,kBAAkB,IAAI;AAAA,YACpF,kBAAkB,OAAO,mBAAmB,OAAO,OAAO,gBAAgB,IAAI;AAAA,YAC9E,QAAQ,CAAC,CAAC,OAAO;AAAA,YACjB,UAAU,OAAO,aAAa;AAAA,UAChC;AAEA,gBAAM,WAAW,yBAAyB,OAAO;AAEjD,gBAAM,EAAE,0BAA0B,GAAG,SAAS;AAC9C,iBAAO,KAAK,qBAAqB;AAAA,QACnC;AAAA;AAAA,IACF,GACF;AAAA,IACC;AAAA,KACH;AAEJ;",
|
|
6
6
|
"names": ["error"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
2
|
+
import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
3
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
4
|
+
import { Currency } from "../data/entities.js";
|
|
5
|
+
async function resolveEm() {
|
|
6
|
+
const { resolve } = await createRequestContainer();
|
|
7
|
+
return resolve("em");
|
|
8
|
+
}
|
|
9
|
+
async function loadCurrencyPreview(entityId, ctx) {
|
|
10
|
+
const { t } = await resolveTranslations();
|
|
11
|
+
const defaultTitle = t("currencies.messageObjects.currency.title");
|
|
12
|
+
if (!ctx.organizationId) {
|
|
13
|
+
return { title: defaultTitle, subtitle: entityId };
|
|
14
|
+
}
|
|
15
|
+
const em = await resolveEm();
|
|
16
|
+
const entity = await findOneWithDecryption(
|
|
17
|
+
em,
|
|
18
|
+
Currency,
|
|
19
|
+
{
|
|
20
|
+
id: entityId,
|
|
21
|
+
tenantId: ctx.tenantId,
|
|
22
|
+
organizationId: ctx.organizationId,
|
|
23
|
+
deletedAt: null
|
|
24
|
+
},
|
|
25
|
+
void 0,
|
|
26
|
+
{ tenantId: ctx.tenantId, organizationId: ctx.organizationId }
|
|
27
|
+
);
|
|
28
|
+
if (!entity) {
|
|
29
|
+
return {
|
|
30
|
+
title: defaultTitle,
|
|
31
|
+
subtitle: entityId,
|
|
32
|
+
status: t("customers.messageObjects.notFound"),
|
|
33
|
+
statusColor: "gray"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const subtitleParts = [entity.code, entity.symbol].filter((part) => Boolean(part && part.trim().length > 0));
|
|
37
|
+
const metadata = {};
|
|
38
|
+
const codeLabel = t("currencies.form.field.code");
|
|
39
|
+
const symbolLabel = t("currencies.form.field.symbol");
|
|
40
|
+
if (entity.code) metadata[codeLabel] = entity.code;
|
|
41
|
+
if (entity.symbol) metadata[symbolLabel] = entity.symbol;
|
|
42
|
+
return {
|
|
43
|
+
title: entity.name,
|
|
44
|
+
subtitle: subtitleParts.join(" \xB7 ") || entityId,
|
|
45
|
+
metadata: Object.keys(metadata).length > 0 ? metadata : void 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
loadCurrencyPreview
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=messageObjectPreviews.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/currencies/lib/messageObjectPreviews.ts"],
|
|
4
|
+
"sourcesContent": ["import { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport type { ObjectPreviewData } from '@open-mercato/shared/modules/messages/types'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { Currency } from '../data/entities'\n\ntype PreviewContext = {\n tenantId: string\n organizationId?: string | null\n}\n\nasync function resolveEm() {\n const { resolve } = await createRequestContainer()\n return resolve('em') as EntityManager\n}\n\nexport async function loadCurrencyPreview(\n entityId: string,\n ctx: PreviewContext,\n): Promise<ObjectPreviewData> {\n const { t } = await resolveTranslations()\n const defaultTitle = t('currencies.messageObjects.currency.title')\n\n if (!ctx.organizationId) {\n return { title: defaultTitle, subtitle: entityId }\n }\n\n const em = await resolveEm()\n const entity = await findOneWithDecryption(\n em,\n Currency,\n {\n id: entityId,\n tenantId: ctx.tenantId,\n organizationId: ctx.organizationId,\n deletedAt: null,\n },\n undefined,\n { tenantId: ctx.tenantId, organizationId: ctx.organizationId },\n )\n\n if (!entity) {\n return {\n title: defaultTitle,\n subtitle: entityId,\n status: t('customers.messageObjects.notFound'),\n statusColor: 'gray',\n }\n }\n\n const subtitleParts = [entity.code, entity.symbol]\n .filter((part): part is string => Boolean(part && part.trim().length > 0))\n const metadata: Record<string, string> = {}\n const codeLabel = t('currencies.form.field.code')\n const symbolLabel = t('currencies.form.field.symbol')\n if (entity.code) metadata[codeLabel] = entity.code\n if (entity.symbol) metadata[symbolLabel] = entity.symbol\n\n return {\n title: entity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ACL,OAAO,OAAO;AAAA,IACd,UAAU,cAAc,KAAK,QAAK,KAAK;AAAA,IACvC,UAAU,OAAO,KAAK,QAAQ,EAAE,SAAS,IAAI,WAAW;AAAA,EAC1D;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MessageObjectDetail, MessageObjectPreview } from "@open-mercato/ui/backend/messages";
|
|
2
|
+
const objectMessageTypes = ["default", "messages.defaultWithObjects"];
|
|
3
|
+
const messageObjectTypes = [
|
|
4
|
+
{
|
|
5
|
+
module: "currencies",
|
|
6
|
+
entityType: "currency",
|
|
7
|
+
messageTypes: objectMessageTypes,
|
|
8
|
+
entityId: "currencies:currency",
|
|
9
|
+
optionLabelField: "name",
|
|
10
|
+
optionSubtitleField: "code",
|
|
11
|
+
labelKey: "currencies.messageObjects.currency.title",
|
|
12
|
+
icon: "coins",
|
|
13
|
+
PreviewComponent: MessageObjectPreview,
|
|
14
|
+
DetailComponent: MessageObjectDetail,
|
|
15
|
+
actions: [
|
|
16
|
+
{
|
|
17
|
+
id: "view",
|
|
18
|
+
labelKey: "common.view",
|
|
19
|
+
variant: "outline",
|
|
20
|
+
href: "/backend/currencies/{entityId}"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
loadPreview: async (entityId, ctx) => {
|
|
24
|
+
if (typeof window !== "undefined") {
|
|
25
|
+
return {
|
|
26
|
+
title: "Currency",
|
|
27
|
+
subtitle: entityId,
|
|
28
|
+
metadata: { id: entityId }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const { loadCurrencyPreview } = await import("./lib/messageObjectPreviews.js");
|
|
32
|
+
return loadCurrencyPreview(entityId, ctx);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
var message_objects_default = messageObjectTypes;
|
|
37
|
+
export {
|
|
38
|
+
message_objects_default as default,
|
|
39
|
+
messageObjectTypes
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=message-objects.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/currencies/message-objects.ts"],
|
|
4
|
+
"sourcesContent": ["import type { MessageObjectTypeDefinition } from '@open-mercato/shared/modules/messages/types'\nimport { MessageObjectDetail, MessageObjectPreview } from '@open-mercato/ui/backend/messages'\n\nconst objectMessageTypes = ['default', 'messages.defaultWithObjects']\n\nexport const messageObjectTypes: MessageObjectTypeDefinition[] = [\n {\n module: 'currencies',\n entityType: 'currency',\n messageTypes: objectMessageTypes,\n entityId: 'currencies:currency',\n optionLabelField: 'name',\n optionSubtitleField: 'code',\n labelKey: 'currencies.messageObjects.currency.title',\n icon: 'coins',\n PreviewComponent: MessageObjectPreview,\n DetailComponent: MessageObjectDetail,\n actions: [\n {\n id: 'view',\n labelKey: 'common.view',\n variant: 'outline',\n href: '/backend/currencies/{entityId}',\n },\n ],\n loadPreview: async (entityId, ctx) => {\n if (typeof window !== 'undefined') {\n return {\n title: 'Currency',\n subtitle: entityId,\n metadata: { id: entityId },\n }\n }\n const { loadCurrencyPreview } = await import('./lib/messageObjectPreviews')\n return loadCurrencyPreview(entityId, ctx)\n },\n },\n]\n\nexport default messageObjectTypes\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,qBAAqB,4BAA4B;AAE1D,MAAM,qBAAqB,CAAC,WAAW,6BAA6B;AAE7D,MAAM,qBAAoD;AAAA,EAC/D;AAAA,IACE,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,qBAAqB;AAAA,IACrB,UAAU;AAAA,IACV,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,IACjB,SAAS;AAAA,MACP;AAAA,QACE,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,SAAS;AAAA,QACT,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,aAAa,OAAO,UAAU,QAAQ;AACpC,UAAI,OAAO,WAAW,aAAa;AACjC,eAAO;AAAA,UACL,OAAO;AAAA,UACP,UAAU;AAAA,UACV,UAAU,EAAE,IAAI,SAAS;AAAA,QAC3B;AAAA,MACF;AACA,YAAM,EAAE,oBAAoB,IAAI,MAAM,OAAO,6BAA6B;AAC1E,aAAO,oBAAoB,UAAU,GAAG;AAAA,IAC1C;AAAA,EACF;AACF;AAEA,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -44,6 +44,7 @@ import { readMarkdownPreferenceCookie, writeMarkdownPreferenceCookie } from "../
|
|
|
44
44
|
import { InjectionSpot, useInjectionWidgets } from "@open-mercato/ui/backend/injection/InjectionSpot";
|
|
45
45
|
import { DetailTabsLayout } from "../../../../components/detail/DetailTabsLayout.js";
|
|
46
46
|
import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
|
|
47
|
+
import { SendObjectMessageDialog } from "@open-mercato/ui/backend/messages";
|
|
47
48
|
function CustomerCompanyDetailPage({ params }) {
|
|
48
49
|
const id = params?.id;
|
|
49
50
|
const t = useT();
|
|
@@ -607,6 +608,25 @@ function CustomerCompanyDetailPage({ params }) {
|
|
|
607
608
|
profile: profile ?? null,
|
|
608
609
|
validators,
|
|
609
610
|
onDisplayNameSave: updateDisplayName,
|
|
611
|
+
utilityActions: /* @__PURE__ */ jsx(
|
|
612
|
+
SendObjectMessageDialog,
|
|
613
|
+
{
|
|
614
|
+
object: {
|
|
615
|
+
entityModule: "customers",
|
|
616
|
+
entityType: "company",
|
|
617
|
+
entityId: companyId,
|
|
618
|
+
previewData: {
|
|
619
|
+
title: company.displayName,
|
|
620
|
+
subtitle: company.primaryEmail ?? void 0,
|
|
621
|
+
metadata: {
|
|
622
|
+
[t("customers.companies.detail.highlights.primaryPhone")]: company.primaryPhone ?? "-",
|
|
623
|
+
[t("customers.companies.detail.fields.industry")]: profile?.industry ?? "-"
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
viewHref: `/backend/customers/companies/${companyId}`
|
|
628
|
+
}
|
|
629
|
+
),
|
|
610
630
|
onPrimaryEmailSave: (value) => updateCompanyField("primaryEmail", value),
|
|
611
631
|
onPrimaryPhoneSave: (value) => updateCompanyField("primaryPhone", value),
|
|
612
632
|
onStatusSave: (value) => updateCompanyField("status", value),
|