@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../src/modules/sales/backend/sales/channels/%5BchannelId%5D/edit/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter, useSearchParams } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm } from '@open-mercato/ui/backend/CrudForm'\nimport { collectCustomFieldValues } from '@open-mercato/ui/backend/utils/customFieldValues'\nimport { updateCrud, deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useChannelFields, buildChannelPayload, type ChannelFormValues } from '@open-mercato/core/modules/sales/components/channels/channelFormFields'\nimport { E } from '#generated/entities.ids.generated'\nimport { SalesChannelOffersPanel } from '@open-mercato/core/modules/sales/components/channels/SalesChannelOffersPanel'\n\ntype ChannelApiResponse = {\n items?: Array<Record<string, unknown>>\n}\n\nexport default function EditChannelPage({ params }: { params?: { channelId?: string } }) {\n const channelId = params?.channelId ?? ''\n const router = useRouter()\n const searchParams = useSearchParams()\n const t = useT()\n const { fields, groups } = useChannelFields()\n const [initialValues, setInitialValues] = React.useState<ChannelFormValues | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [activeTab, setActiveTab] = React.useState<'settings' | 'offers'>('settings')\n\n React.useEffect(() => {\n const tabParam = (searchParams?.get('tab') ?? '').toLowerCase()\n if (tabParam === 'offers') {\n setActiveTab('offers')\n } else if (tabParam === 'settings') {\n setActiveTab('settings')\n }\n }, [searchParams])\n\n React.useEffect(() => {\n if (!channelId) return\n let cancelled = false\n async function loadChannel() {\n setLoading(true)\n setError(null)\n try {\n const payload = await readApiResultOrThrow<ChannelApiResponse>(\n `/api/sales/channels?id=${encodeURIComponent(channelId)}&pageSize=1`,\n undefined,\n { errorMessage: t('sales.channels.form.errors.load', 'Failed to load channel.') },\n )\n const item = Array.isArray(payload.items) ? payload.items[0] : null\n if (!item) {\n throw new Error('not_found')\n }\n if (!cancelled) {\n setInitialValues(mapChannelToFormValues(item))\n }\n } catch (err) {\n console.error('sales.channels.load', err)\n if (!cancelled) setError(t('sales.channels.form.errors.load', 'Failed to load channel.'))\n } finally {\n if (!cancelled) setLoading(false)\n }\n }\n void loadChannel()\n return () => { cancelled = true }\n }, [channelId, t])\n\n const handleSubmit = React.useCallback(async (values: ChannelFormValues) => {\n if (!channelId) return\n const payload: Record<string, unknown> = { id: channelId, ...buildChannelPayload(values) }\n const customFields = collectCustomFieldValues(values)\n if (Object.keys(customFields).length) payload.customFields = customFields\n await updateCrud('sales/channels', payload, {\n errorMessage: t('sales.channels.form.errors.update', 'Failed to save channel.'),\n })\n flash(t('sales.channels.form.messages.updated', 'Channel updated.'), 'success')\n router.push('/backend/sales/channels')\n }, [channelId, router, t])\n\n const handleDelete = React.useCallback(async () => {\n if (!channelId) return\n await deleteCrud('sales/channels', channelId, {\n errorMessage: t('sales.channels.form.errors.delete', 'Failed to delete channel.'),\n })\n flash(t('sales.channels.form.messages.deleted', 'Channel deleted.'), 'success')\n router.push('/backend/sales/channels')\n }, [channelId, router, t])\n\n const handleTabSelect = React.useCallback((value: 'settings' | 'offers') => {\n setActiveTab(value)\n if (!channelId) return\n const basePath = `/backend/sales/channels/${channelId}/edit`\n const nextUrl = value === 'offers' ? `${basePath}?tab=offers` : basePath\n router.replace(nextUrl)\n }, [channelId, router])\n\n const tabButton = React.useCallback((value: 'settings' | 'offers', label: string) => (\n <button\n key={value}\n type=\"button\"\n className={`px-4 py-2 text-sm font-medium border-b-2 ${activeTab === value ? 'border-primary text-primary' : 'border-transparent text-muted-foreground'}`}\n onClick={() => handleTabSelect(value)}\n >\n {label}\n </button>\n ), [activeTab, handleTabSelect])\n\n const renderTabs = React.useCallback(() => (\n <div className=\"flex items-center gap-2 border-b mb-6\">\n {tabButton('settings', t('sales.channels.form.tabs.settings', 'Settings'))}\n {tabButton('offers', t('sales.channels.form.tabs.offers', 'Offers'))}\n </div>\n ), [tabButton, t])\n\n return (\n <Page>\n <PageBody>\n {error ? (\n <div className=\"mb-4 rounded border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive\">\n {error}\n </div>\n ) : null}\n {activeTab === 'settings' ? (\n <CrudForm<ChannelFormValues>\n title={t('sales.channels.form.editTitle', 'Edit channel')}\n versionHistory={{ resourceKind: 'sales.channel', resourceId: channelId ? String(channelId) : '' }}\n entityId={E.sales.sales_channel}\n fields={fields}\n groups={[\n ...groups,\n { id: 'custom', title: t('entities.customFields.title', 'Custom Attributes'), column: 2, kind: 'customFields' },\n ]}\n initialValues={initialValues ?? undefined}\n isLoading={loading}\n loadingMessage={t('sales.channels.form.loading', 'Loading channel\u2026')}\n submitLabel={t('sales.channels.form.updateSubmit', 'Save changes')}\n cancelHref=\"/backend/sales/channels\"\n backHref=\"/backend/sales/channels\"\n contentHeader={renderTabs()}\n onSubmit={handleSubmit}\n onDelete={handleDelete}\n deleteVisible\n deleteRedirect=\"/backend/sales/channels\"\n />\n ) : (\n <>\n {renderTabs()}\n <SalesChannelOffersPanel channelId={channelId} channelName={initialValues?.name ?? ''} />\n </>\n )}\n </PageBody>\n </Page>\n )\n}\n\nfunction mapChannelToFormValues(item: Record<string, unknown>): ChannelFormValues {\n const values: ChannelFormValues = {\n name: typeof item.name === 'string' ? item.name : '',\n code: typeof item.code === 'string' ? item.code : null,\n description: typeof item.description === 'string' ? item.description : null,\n websiteUrl: typeof item.websiteUrl === 'string' ? item.websiteUrl : typeof item.website_url === 'string' ? item.website_url : null,\n contactEmail: typeof item.contactEmail === 'string' ? item.contactEmail : typeof item.contact_email === 'string' ? item.contact_email : null,\n contactPhone: typeof item.contactPhone === 'string' ? item.contactPhone : typeof item.contact_phone === 'string' ? item.contact_phone : null,\n addressLine1: typeof item.addressLine1 === 'string' ? item.addressLine1 : typeof item.address_line1 === 'string' ? item.address_line1 : null,\n addressLine2: typeof item.addressLine2 === 'string' ? item.addressLine2 : typeof item.address_line2 === 'string' ? item.address_line2 : null,\n city: typeof item.city === 'string' ? item.city : null,\n region: typeof item.region === 'string' ? item.region : null,\n postalCode: typeof item.postalCode === 'string' ? item.postalCode : typeof item.postal_code === 'string' ? item.postal_code : null,\n country: typeof item.country === 'string' ? item.country : null,\n latitude: typeof item.latitude === 'number' ? item.latitude : typeof item.latitude === 'string' ? item.latitude : null,\n longitude: typeof item.longitude === 'number' ? item.longitude : typeof item.longitude === 'string' ? item.longitude : null,\n statusEntryId: typeof item.statusEntryId === 'string'\n ? item.statusEntryId\n : typeof item.status_entry_id === 'string'\n ? item.status_entry_id\n : null,\n isActive: item.isActive === true || item.is_active === true,\n }\n const mergeCustomObject = (source: unknown) => {\n if (!source || typeof source !== 'object' || Array.isArray(source)) return\n for (const [key, value] of Object.entries(source as Record<string, unknown>)) {\n if (!key) continue\n values[`cf_${key}`] = value\n }\n }\n const mergeCustomArray = (source: unknown) => {\n if (!Array.isArray(source)) return\n source.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const key = typeof (entry as Record<string, unknown>).key === 'string'\n ? (entry as Record<string, unknown>).key\n : null\n if (!key) return\n values[`cf_${key}`] = (entry as Record<string, unknown>).value\n })\n }\n mergeCustomObject(item.customValues)\n mergeCustomObject((item as Record<string, unknown>).custom_values)\n mergeCustomObject(item.customFields)\n mergeCustomObject((item as Record<string, unknown>).custom_fields)\n mergeCustomArray(item.customFields)\n mergeCustomArray((item as Record<string, unknown>).custom_fields)\n mergeCustomArray((item as Record<string, unknown>).customFieldEntries)\n mergeCustomArray((item as Record<string, unknown>).custom_field_entries)\n return values\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter, useSearchParams } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { CrudForm } from '@open-mercato/ui/backend/CrudForm'\nimport { collectCustomFieldValues } from '@open-mercato/ui/backend/utils/customFieldValues'\nimport { updateCrud, deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useChannelFields, buildChannelPayload, type ChannelFormValues } from '@open-mercato/core/modules/sales/components/channels/channelFormFields'\nimport { E } from '#generated/entities.ids.generated'\nimport { SalesChannelOffersPanel } from '@open-mercato/core/modules/sales/components/channels/SalesChannelOffersPanel'\nimport { SendObjectMessageDialog } from '@open-mercato/ui/backend/messages'\n\ntype ChannelApiResponse = {\n items?: Array<Record<string, unknown>>\n}\n\nexport default function EditChannelPage({ params }: { params?: { channelId?: string } }) {\n const channelId = params?.channelId ?? ''\n const router = useRouter()\n const searchParams = useSearchParams()\n const t = useT()\n const { fields, groups } = useChannelFields()\n const [initialValues, setInitialValues] = React.useState<ChannelFormValues | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [activeTab, setActiveTab] = React.useState<'settings' | 'offers'>('settings')\n\n React.useEffect(() => {\n const tabParam = (searchParams?.get('tab') ?? '').toLowerCase()\n if (tabParam === 'offers') {\n setActiveTab('offers')\n } else if (tabParam === 'settings') {\n setActiveTab('settings')\n }\n }, [searchParams])\n\n React.useEffect(() => {\n if (!channelId) return\n let cancelled = false\n async function loadChannel() {\n setLoading(true)\n setError(null)\n try {\n const payload = await readApiResultOrThrow<ChannelApiResponse>(\n `/api/sales/channels?id=${encodeURIComponent(channelId)}&pageSize=1`,\n undefined,\n { errorMessage: t('sales.channels.form.errors.load', 'Failed to load channel.') },\n )\n const item = Array.isArray(payload.items) ? payload.items[0] : null\n if (!item) {\n throw new Error('not_found')\n }\n if (!cancelled) {\n setInitialValues(mapChannelToFormValues(item))\n }\n } catch (err) {\n console.error('sales.channels.load', err)\n if (!cancelled) setError(t('sales.channels.form.errors.load', 'Failed to load channel.'))\n } finally {\n if (!cancelled) setLoading(false)\n }\n }\n void loadChannel()\n return () => { cancelled = true }\n }, [channelId, t])\n\n const handleSubmit = React.useCallback(async (values: ChannelFormValues) => {\n if (!channelId) return\n const payload: Record<string, unknown> = { id: channelId, ...buildChannelPayload(values) }\n const customFields = collectCustomFieldValues(values)\n if (Object.keys(customFields).length) payload.customFields = customFields\n await updateCrud('sales/channels', payload, {\n errorMessage: t('sales.channels.form.errors.update', 'Failed to save channel.'),\n })\n flash(t('sales.channels.form.messages.updated', 'Channel updated.'), 'success')\n router.push('/backend/sales/channels')\n }, [channelId, router, t])\n\n const handleDelete = React.useCallback(async () => {\n if (!channelId) return\n await deleteCrud('sales/channels', channelId, {\n errorMessage: t('sales.channels.form.errors.delete', 'Failed to delete channel.'),\n })\n flash(t('sales.channels.form.messages.deleted', 'Channel deleted.'), 'success')\n router.push('/backend/sales/channels')\n }, [channelId, router, t])\n\n const handleTabSelect = React.useCallback((value: 'settings' | 'offers') => {\n setActiveTab(value)\n if (!channelId) return\n const basePath = `/backend/sales/channels/${channelId}/edit`\n const nextUrl = value === 'offers' ? `${basePath}?tab=offers` : basePath\n router.replace(nextUrl)\n }, [channelId, router])\n\n const tabButton = React.useCallback((value: 'settings' | 'offers', label: string) => (\n <button\n key={value}\n type=\"button\"\n className={`px-4 py-2 text-sm font-medium border-b-2 ${activeTab === value ? 'border-primary text-primary' : 'border-transparent text-muted-foreground'}`}\n onClick={() => handleTabSelect(value)}\n >\n {label}\n </button>\n ), [activeTab, handleTabSelect])\n\n const renderTabs = React.useCallback(() => (\n <div className=\"flex items-center gap-2 border-b mb-6\">\n {tabButton('settings', t('sales.channels.form.tabs.settings', 'Settings'))}\n {tabButton('offers', t('sales.channels.form.tabs.offers', 'Offers'))}\n </div>\n ), [tabButton, t])\n\n return (\n <Page>\n <PageBody>\n {error ? (\n <div className=\"mb-4 rounded border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm text-destructive\">\n {error}\n </div>\n ) : null}\n {activeTab === 'settings' ? (\n <CrudForm<ChannelFormValues>\n title={t('sales.channels.form.editTitle', 'Edit channel')}\n versionHistory={{ resourceKind: 'sales.channel', resourceId: channelId ? String(channelId) : '' }}\n extraActions={channelId ? (\n <SendObjectMessageDialog\n object={{\n entityModule: 'sales',\n entityType: 'channel',\n entityId: channelId,\n previewData: {\n title: initialValues?.name ?? '',\n metadata: {\n [t('sales.channels.form.contactEmail')]: initialValues?.contactEmail ?? '-',\n [t('sales.channels.form.websiteUrl')]: initialValues?.websiteUrl ?? '-',\n },\n },\n }}\n viewHref={`/backend/sales/channels/${channelId}/edit`}\n />\n ) : undefined}\n entityId={E.sales.sales_channel}\n fields={fields}\n groups={[\n ...groups,\n { id: 'custom', title: t('entities.customFields.title', 'Custom Attributes'), column: 2, kind: 'customFields' },\n ]}\n initialValues={initialValues ?? undefined}\n isLoading={loading}\n loadingMessage={t('sales.channels.form.loading', 'Loading channel\u2026')}\n submitLabel={t('sales.channels.form.updateSubmit', 'Save changes')}\n cancelHref=\"/backend/sales/channels\"\n backHref=\"/backend/sales/channels\"\n contentHeader={renderTabs()}\n onSubmit={handleSubmit}\n onDelete={handleDelete}\n deleteVisible\n deleteRedirect=\"/backend/sales/channels\"\n />\n ) : (\n <>\n {renderTabs()}\n <SalesChannelOffersPanel channelId={channelId} channelName={initialValues?.name ?? ''} />\n </>\n )}\n </PageBody>\n </Page>\n )\n}\n\nfunction mapChannelToFormValues(item: Record<string, unknown>): ChannelFormValues {\n const values: ChannelFormValues = {\n name: typeof item.name === 'string' ? item.name : '',\n code: typeof item.code === 'string' ? item.code : null,\n description: typeof item.description === 'string' ? item.description : null,\n websiteUrl: typeof item.websiteUrl === 'string' ? item.websiteUrl : typeof item.website_url === 'string' ? item.website_url : null,\n contactEmail: typeof item.contactEmail === 'string' ? item.contactEmail : typeof item.contact_email === 'string' ? item.contact_email : null,\n contactPhone: typeof item.contactPhone === 'string' ? item.contactPhone : typeof item.contact_phone === 'string' ? item.contact_phone : null,\n addressLine1: typeof item.addressLine1 === 'string' ? item.addressLine1 : typeof item.address_line1 === 'string' ? item.address_line1 : null,\n addressLine2: typeof item.addressLine2 === 'string' ? item.addressLine2 : typeof item.address_line2 === 'string' ? item.address_line2 : null,\n city: typeof item.city === 'string' ? item.city : null,\n region: typeof item.region === 'string' ? item.region : null,\n postalCode: typeof item.postalCode === 'string' ? item.postalCode : typeof item.postal_code === 'string' ? item.postal_code : null,\n country: typeof item.country === 'string' ? item.country : null,\n latitude: typeof item.latitude === 'number' ? item.latitude : typeof item.latitude === 'string' ? item.latitude : null,\n longitude: typeof item.longitude === 'number' ? item.longitude : typeof item.longitude === 'string' ? item.longitude : null,\n statusEntryId: typeof item.statusEntryId === 'string'\n ? item.statusEntryId\n : typeof item.status_entry_id === 'string'\n ? item.status_entry_id\n : null,\n isActive: item.isActive === true || item.is_active === true,\n }\n const mergeCustomObject = (source: unknown) => {\n if (!source || typeof source !== 'object' || Array.isArray(source)) return\n for (const [key, value] of Object.entries(source as Record<string, unknown>)) {\n if (!key) continue\n values[`cf_${key}`] = value\n }\n }\n const mergeCustomArray = (source: unknown) => {\n if (!Array.isArray(source)) return\n source.forEach((entry) => {\n if (!entry || typeof entry !== 'object') return\n const key = typeof (entry as Record<string, unknown>).key === 'string'\n ? (entry as Record<string, unknown>).key\n : null\n if (!key) return\n values[`cf_${key}`] = (entry as Record<string, unknown>).value\n })\n }\n mergeCustomObject(item.customValues)\n mergeCustomObject((item as Record<string, unknown>).custom_values)\n mergeCustomObject(item.customFields)\n mergeCustomObject((item as Record<string, unknown>).custom_fields)\n mergeCustomArray(item.customFields)\n mergeCustomArray((item as Record<string, unknown>).custom_fields)\n mergeCustomArray((item as Record<string, unknown>).customFieldEntries)\n mergeCustomArray((item as Record<string, unknown>).custom_field_entries)\n return values\n}\n"],
|
|
5
|
+
"mappings": ";AAoGI,SAiEM,UAjEN,KAWA,YAXA;AAlGJ,YAAY,WAAW;AACvB,SAAS,WAAW,uBAAuB;AAC3C,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,gCAAgC;AACzC,SAAS,YAAY,kBAAkB;AACvC,SAAS,4BAA4B;AACrC,SAAS,aAAa;AACtB,SAAS,YAAY;AACrB,SAAS,kBAAkB,2BAAmD;AAC9E,SAAS,SAAS;AACl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
|
"names": []
|
|
7
7
|
}
|
|
@@ -55,6 +55,15 @@ import { ICON_SUGGESTIONS } from "@open-mercato/core/modules/customers/lib/dicti
|
|
|
55
55
|
import { readMarkdownPreferenceCookie, writeMarkdownPreferenceCookie } from "@open-mercato/core/modules/customers/lib/markdownPreference";
|
|
56
56
|
import { InjectionSpot, useInjectionWidgets } from "@open-mercato/ui/backend/injection/InjectionSpot";
|
|
57
57
|
import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
|
|
58
|
+
function formatMessageAmount(amount, currency) {
|
|
59
|
+
if (typeof amount !== "number" || !Number.isFinite(amount)) return null;
|
|
60
|
+
if (!currency) return amount.toLocaleString();
|
|
61
|
+
try {
|
|
62
|
+
return new Intl.NumberFormat(void 0, { style: "currency", currency }).format(amount);
|
|
63
|
+
} catch {
|
|
64
|
+
return `${amount.toLocaleString()} ${currency}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
58
67
|
function CurrencyInlineEditor({
|
|
59
68
|
label,
|
|
60
69
|
value,
|
|
@@ -1460,7 +1469,8 @@ function StatusInlineEditor({
|
|
|
1460
1469
|
}
|
|
1461
1470
|
function SalesDocumentDetailPage({
|
|
1462
1471
|
params,
|
|
1463
|
-
initialKind
|
|
1472
|
+
initialKind,
|
|
1473
|
+
includeAmountInMessageMetadata
|
|
1464
1474
|
}) {
|
|
1465
1475
|
const t = useT();
|
|
1466
1476
|
const router = useRouter();
|
|
@@ -2203,6 +2213,11 @@ function SalesDocumentDetailPage({
|
|
|
2203
2213
|
const metadataEmail = record?.metadata && typeof record.metadata.customerEmail === "string" ? record.metadata.customerEmail : null;
|
|
2204
2214
|
const contactEmail = resolveCustomerEmail(customerSnapshot) ?? metadataEmail ?? record?.contactEmail ?? null;
|
|
2205
2215
|
const statusDisplay = record?.status ? statusDictionaryMap[record.status] ?? null : null;
|
|
2216
|
+
const previewAmount = formatMessageAmount(record?.grandTotalGrossAmount ?? null, record?.currencyCode ?? null);
|
|
2217
|
+
const messagePreviewMetadata = {};
|
|
2218
|
+
if (includeAmountInMessageMetadata && previewAmount) {
|
|
2219
|
+
messagePreviewMetadata[t("sales.documents.detail.totals.grandTotalGross")] = previewAmount;
|
|
2220
|
+
}
|
|
2206
2221
|
const contactRecordId = customerSnapshot?.contact?.id ?? customerSnapshot?.customer?.id ?? record?.customerEntityId ?? null;
|
|
2207
2222
|
const resolveAdjustmentLabel = React.useCallback(
|
|
2208
2223
|
(row) => {
|
|
@@ -3674,8 +3689,14 @@ function SalesDocumentDetailPage({
|
|
|
3674
3689
|
entityType: kind,
|
|
3675
3690
|
entityId: record.id,
|
|
3676
3691
|
sourceEntityType: kind === "order" ? "sales.order" : "sales.quote",
|
|
3677
|
-
sourceEntityId: record.id
|
|
3692
|
+
sourceEntityId: record.id,
|
|
3693
|
+
previewData: {
|
|
3694
|
+
title: number,
|
|
3695
|
+
status: statusDisplay?.label ?? record?.status ?? void 0,
|
|
3696
|
+
metadata: Object.keys(messagePreviewMetadata).length > 0 ? messagePreviewMetadata : void 0
|
|
3697
|
+
}
|
|
3678
3698
|
},
|
|
3699
|
+
viewHref: `/backend/sales/${kind === "order" ? "orders" : "quotes"}/${record.id}`,
|
|
3679
3700
|
defaultValues: {
|
|
3680
3701
|
sourceEntityType: kind === "order" ? "sales.order" : "sales.quote",
|
|
3681
3702
|
sourceEntityId: record.id
|