@vicacha-devs/medusa-plugin-notifications 0.0.0-stage → 0.0.1
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/.medusa/server/src/admin/index.cjs +4215 -0
- package/.medusa/server/src/admin/index.js +4193 -0
- package/.medusa/server/src/api/admin/mpn/broadcasts/route.js +99 -0
- package/.medusa/server/src/api/admin/mpn/channels/route.js +109 -0
- package/.medusa/server/src/api/admin/mpn/logs/route.js +33 -0
- package/.medusa/server/src/api/admin/mpn/mappings/[id]/route.js +33 -0
- package/.medusa/server/src/api/admin/mpn/mappings/route.js +51 -0
- package/.medusa/server/src/api/admin/mpn/render-template/route.js +37 -0
- package/.medusa/server/src/api/admin/mpn/sandbox/route.js +36 -0
- package/.medusa/server/src/api/admin/mpn/send/route.js +135 -0
- package/.medusa/server/src/api/admin/mpn/templates/[id]/route.js +77 -0
- package/.medusa/server/src/api/admin/mpn/templates/route.js +71 -0
- package/.medusa/server/src/api/admin/plugin/route.js +4 -0
- package/.medusa/server/src/api/middlewares.js +28 -0
- package/.medusa/server/src/api/store/mpn/consent/route.js +37 -0
- package/.medusa/server/src/api/store/mpn/webhooks/[provider]/route.js +97 -0
- package/.medusa/server/src/api/store/plugin/route.js +4 -0
- package/.medusa/server/src/api/validators.js +118 -0
- package/.medusa/server/src/hooks/index.js +7 -0
- package/.medusa/server/src/hooks/use-mpn-channels.js +13 -0
- package/.medusa/server/src/hooks/use-mpn-dispatch.js +45 -0
- package/.medusa/server/src/hooks/use-mpn-mappings.js +21 -0
- package/.medusa/server/src/hooks/use-mpn-templates.js +34 -0
- package/.medusa/server/src/hooks/use-order-notifications-widget-state.js +79 -0
- package/.medusa/server/src/hooks/use-sdk-primitives.js +113 -0
- package/.medusa/server/src/index.js +14 -0
- package/.medusa/server/src/integrations/automations-action-handler.js +112 -0
- package/.medusa/server/src/jobs/abandoned-cart-recovery.js +123 -0
- package/.medusa/server/src/jobs/log-retention-and-broadcasts.js +15 -0
- package/.medusa/server/src/modules/notifications/i18n/index.js +65 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/ar.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/de.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/en.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/es.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/fr.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/it.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/nl.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/pl.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/pt.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/locales/tr.js +76 -0
- package/.medusa/server/src/modules/notifications/i18n/types.js +2 -0
- package/.medusa/server/src/modules/notifications/index.js +9 -0
- package/.medusa/server/src/modules/notifications/integrations/documents-and-b2b-resolver.js +129 -0
- package/.medusa/server/src/modules/notifications/migrations/Migration20261010000000.js +184 -0
- package/.medusa/server/src/modules/notifications/models/index.js +118 -0
- package/.medusa/server/src/modules/notifications/renderer/block-helpers.js +36 -0
- package/.medusa/server/src/modules/notifications/renderer/email.js +161 -0
- package/.medusa/server/src/modules/notifications/renderer/index.js +240 -0
- package/.medusa/server/src/modules/notifications/renderer/slack.js +114 -0
- package/.medusa/server/src/modules/notifications/renderer/telegram.js +99 -0
- package/.medusa/server/src/modules/notifications/renderer/whatsapp.js +91 -0
- package/.medusa/server/src/modules/notifications/service-helpers/channel-config.js +45 -0
- package/.medusa/server/src/modules/notifications/service-helpers/consent.js +65 -0
- package/.medusa/server/src/modules/notifications/service-helpers/delivery-log.js +29 -0
- package/.medusa/server/src/modules/notifications/service-helpers/event-conditions.js +46 -0
- package/.medusa/server/src/modules/notifications/service-helpers/external-templates.js +80 -0
- package/.medusa/server/src/modules/notifications/service-helpers/recipient-resolution.js +85 -0
- package/.medusa/server/src/modules/notifications/service-helpers/sender-profiles.js +29 -0
- package/.medusa/server/src/modules/notifications/service-helpers/template-blocks.js +81 -0
- package/.medusa/server/src/modules/notifications/service-helpers/template-catalog.js +129 -0
- package/.medusa/server/src/modules/notifications/service-helpers/template-render.js +65 -0
- package/.medusa/server/src/modules/notifications/service.js +340 -0
- package/.medusa/server/src/modules/notifications/types.js +2 -0
- package/.medusa/server/src/modules/notifications/utils/auth-presets.js +140 -0
- package/.medusa/server/src/modules/notifications/utils/interpolation.js +178 -0
- package/.medusa/server/src/modules/notifications/utils/security.js +312 -0
- package/.medusa/server/src/modules/notifications/utils/system-presets.js +651 -0
- package/.medusa/server/src/modules/notifications/utils/transformers.js +358 -0
- package/.medusa/server/src/providers/dummy-sandbox/index.js +96 -0
- package/.medusa/server/src/providers/email-smtp/index.js +187 -0
- package/.medusa/server/src/providers/index.js +7 -0
- package/.medusa/server/src/providers/slack/index.js +54 -0
- package/.medusa/server/src/providers/sms/index.js +254 -0
- package/.medusa/server/src/providers/telegram/index.js +119 -0
- package/.medusa/server/src/providers/whatsapp/index.js +371 -0
- package/.medusa/server/src/rbac.js +109 -0
- package/.medusa/server/src/sdk/client.js +186 -0
- package/.medusa/server/src/sdk/index.js +3 -0
- package/.medusa/server/src/sdk/query-keys.js +61 -0
- package/.medusa/server/src/subscribers/customer-and-document-events.js +33 -0
- package/.medusa/server/src/subscribers/fulfillment-and-inventory-events.js +30 -0
- package/.medusa/server/src/subscribers/order-events.js +28 -0
- package/.medusa/server/src/types/constants.js +129 -0
- package/.medusa/server/src/types/core.js +2 -0
- package/.medusa/server/src/types/domain.js +2 -0
- package/.medusa/server/src/types/enums.js +53 -0
- package/.medusa/server/src/types/errors.js +28 -0
- package/.medusa/server/src/types/hooks.js +2 -0
- package/.medusa/server/src/types/index.js +12 -0
- package/.medusa/server/src/types/providers.js +2 -0
- package/.medusa/server/src/types/records.js +2 -0
- package/.medusa/server/src/types/render.js +2 -0
- package/.medusa/server/src/types/sdk-api.js +2 -0
- package/.medusa/server/src/types/translations.js +2 -0
- package/.medusa/server/src/workflows/index.js +461 -0
- package/LICENSE +21 -0
- package/README.md +389 -2
- package/package.json +133 -3
- package/src/admin/README.md +123 -0
- package/src/admin/components/mpn/broadcast-consent-section.tsx +62 -0
- package/src/admin/components/mpn/broadcasts-tab.tsx +208 -0
- package/src/admin/components/mpn/channels-main-section.tsx +205 -0
- package/src/admin/components/mpn/channels-side-section.tsx +88 -0
- package/src/admin/components/mpn/channels-tab.tsx +130 -0
- package/src/admin/components/mpn/constants.ts +8 -0
- package/src/admin/components/mpn/delivery-logs-tab.tsx +70 -0
- package/src/admin/components/mpn/event-mapping-form.tsx +191 -0
- package/src/admin/components/mpn/event-mappings-tab.tsx +165 -0
- package/src/admin/components/mpn/header-bar.tsx +35 -0
- package/src/admin/components/mpn/index.ts +17 -0
- package/src/admin/components/mpn/overview-cards.tsx +103 -0
- package/src/admin/components/mpn/sandbox-tab.tsx +93 -0
- package/src/admin/components/mpn/template-editor-section.tsx +203 -0
- package/src/admin/components/mpn/template-preview-section.tsx +122 -0
- package/src/admin/components/mpn/templates-list-section.tsx +115 -0
- package/src/admin/components/mpn/templates-tab.tsx +188 -0
- package/src/admin/components/mpn/use-notification-studio.ts +84 -0
- package/src/admin/components/rbac-guard.tsx +153 -0
- package/src/admin/i18n/README.md +134 -0
- package/src/admin/i18n/index.ts +23 -0
- package/src/admin/i18n/json/ar.json +157 -0
- package/src/admin/i18n/json/de.json +157 -0
- package/src/admin/i18n/json/en.json +157 -0
- package/src/admin/i18n/json/es.json +157 -0
- package/src/admin/i18n/json/fr.json +157 -0
- package/src/admin/i18n/json/it.json +157 -0
- package/src/admin/i18n/json/nl.json +157 -0
- package/src/admin/i18n/json/pl.json +157 -0
- package/src/admin/i18n/json/pt.json +157 -0
- package/src/admin/i18n/json/tr.json +157 -0
- package/src/admin/routes/mpn/broadcasts/page.tsx +75 -0
- package/src/admin/routes/mpn/channels/page.tsx +66 -0
- package/src/admin/routes/mpn/logs/page.tsx +50 -0
- package/src/admin/routes/mpn/mappings/page.tsx +62 -0
- package/src/admin/routes/mpn/page.tsx +200 -0
- package/src/admin/routes/mpn/sandbox/page.tsx +53 -0
- package/src/admin/routes/mpn/templates/page.tsx +55 -0
- package/src/admin/tsconfig.json +23 -0
- package/src/admin/vite-env.d.ts +1 -0
- package/src/admin/widgets/order-notifications-widget.tsx +178 -0
- package/src/api/README.md +98 -0
- package/src/api/admin/mpn/broadcasts/route.ts +130 -0
- package/src/api/admin/mpn/channels/route.ts +143 -0
- package/src/api/admin/mpn/logs/route.ts +41 -0
- package/src/api/admin/mpn/mappings/[id]/route.ts +45 -0
- package/src/api/admin/mpn/mappings/route.ts +68 -0
- package/src/api/admin/mpn/render-template/route.ts +46 -0
- package/src/api/admin/mpn/sandbox/route.ts +51 -0
- package/src/api/admin/mpn/send/route.ts +163 -0
- package/src/api/admin/mpn/templates/[id]/route.ts +101 -0
- package/src/api/admin/mpn/templates/route.ts +99 -0
- package/src/api/admin/plugin/route.ts +5 -0
- package/src/api/middlewares.ts +42 -0
- package/src/api/store/mpn/consent/route.ts +45 -0
- package/src/api/store/mpn/webhooks/[provider]/route.ts +119 -0
- package/src/api/store/plugin/route.ts +5 -0
- package/src/api/validators.ts +149 -0
- package/src/hooks/index.ts +14 -0
- package/src/hooks/use-mpn-channels.ts +43 -0
- package/src/hooks/use-mpn-dispatch.ts +149 -0
- package/src/hooks/use-mpn-mappings.ts +75 -0
- package/src/hooks/use-mpn-templates.ts +120 -0
- package/src/hooks/use-order-notifications-widget-state.ts +103 -0
- package/src/hooks/use-sdk-primitives.ts +157 -0
- package/src/index.ts +16 -0
- package/src/integrations/automations-action-handler.ts +156 -0
- package/src/jobs/README.md +41 -0
- package/src/jobs/abandoned-cart-recovery.ts +152 -0
- package/src/jobs/log-retention-and-broadcasts.ts +23 -0
- package/src/links/README.md +52 -0
- package/src/modules/README.md +99 -0
- package/src/modules/notifications/i18n/index.ts +83 -0
- package/src/modules/notifications/i18n/locales/ar.ts +84 -0
- package/src/modules/notifications/i18n/locales/de.ts +83 -0
- package/src/modules/notifications/i18n/locales/en.ts +84 -0
- package/src/modules/notifications/i18n/locales/es.ts +84 -0
- package/src/modules/notifications/i18n/locales/fr.ts +82 -0
- package/src/modules/notifications/i18n/locales/it.ts +82 -0
- package/src/modules/notifications/i18n/locales/nl.ts +83 -0
- package/src/modules/notifications/i18n/locales/pl.ts +84 -0
- package/src/modules/notifications/i18n/locales/pt.ts +82 -0
- package/src/modules/notifications/i18n/locales/tr.ts +86 -0
- package/src/modules/notifications/i18n/types.ts +1 -0
- package/src/modules/notifications/index.ts +10 -0
- package/src/modules/notifications/integrations/documents-and-b2b-resolver.ts +168 -0
- package/src/modules/notifications/migrations/Migration20261010000000.ts +185 -0
- package/src/modules/notifications/models/index.ts +125 -0
- package/src/modules/notifications/renderer/block-helpers.ts +51 -0
- package/src/modules/notifications/renderer/email.ts +281 -0
- package/src/modules/notifications/renderer/index.ts +301 -0
- package/src/modules/notifications/renderer/slack.ts +168 -0
- package/src/modules/notifications/renderer/telegram.ts +161 -0
- package/src/modules/notifications/renderer/whatsapp.ts +156 -0
- package/src/modules/notifications/service-helpers/channel-config.ts +65 -0
- package/src/modules/notifications/service-helpers/consent.ts +88 -0
- package/src/modules/notifications/service-helpers/delivery-log.ts +56 -0
- package/src/modules/notifications/service-helpers/event-conditions.ts +66 -0
- package/src/modules/notifications/service-helpers/external-templates.ts +127 -0
- package/src/modules/notifications/service-helpers/recipient-resolution.ts +124 -0
- package/src/modules/notifications/service-helpers/sender-profiles.ts +34 -0
- package/src/modules/notifications/service-helpers/template-blocks.ts +116 -0
- package/src/modules/notifications/service-helpers/template-catalog.ts +170 -0
- package/src/modules/notifications/service-helpers/template-render.ts +113 -0
- package/src/modules/notifications/service.ts +589 -0
- package/src/modules/notifications/types.ts +1 -0
- package/src/modules/notifications/utils/auth-presets.ts +145 -0
- package/src/modules/notifications/utils/interpolation.ts +231 -0
- package/src/modules/notifications/utils/security.ts +378 -0
- package/src/modules/notifications/utils/system-presets.ts +695 -0
- package/src/modules/notifications/utils/transformers.ts +456 -0
- package/src/providers/README.md +92 -0
- package/src/providers/dummy-sandbox/index.ts +143 -0
- package/src/providers/email-smtp/index.ts +257 -0
- package/src/providers/index.ts +38 -0
- package/src/providers/slack/index.ts +82 -0
- package/src/providers/sms/index.ts +342 -0
- package/src/providers/telegram/index.ts +181 -0
- package/src/providers/whatsapp/index.ts +505 -0
- package/src/rbac.ts +123 -0
- package/src/sdk/client.ts +319 -0
- package/src/sdk/index.ts +48 -0
- package/src/sdk/query-keys.ts +89 -0
- package/src/subscribers/README.md +50 -0
- package/src/subscribers/customer-and-document-events.ts +36 -0
- package/src/subscribers/fulfillment-and-inventory-events.ts +35 -0
- package/src/subscribers/order-events.ts +31 -0
- package/src/types/constants.ts +143 -0
- package/src/types/core.ts +96 -0
- package/src/types/domain.ts +84 -0
- package/src/types/enums.ts +73 -0
- package/src/types/errors.ts +32 -0
- package/src/types/hooks.ts +48 -0
- package/src/types/index.ts +11 -0
- package/src/types/providers.ts +96 -0
- package/src/types/records.ts +100 -0
- package/src/types/render.ts +74 -0
- package/src/types/sdk-api.ts +228 -0
- package/src/types/translations.ts +75 -0
- package/src/workflows/README.md +67 -0
- package/src/workflows/index.ts +619 -0
- package/tsconfig.json +40 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Button,
|
|
5
|
+
Container,
|
|
6
|
+
Heading,
|
|
7
|
+
Label,
|
|
8
|
+
Select,
|
|
9
|
+
Text,
|
|
10
|
+
} from "@medusajs/ui"
|
|
11
|
+
import React from "react"
|
|
12
|
+
import { useTranslation } from "react-i18next"
|
|
13
|
+
|
|
14
|
+
export interface ChannelsSideSectionProps {
|
|
15
|
+
smsDriverInput: string
|
|
16
|
+
isPending: boolean
|
|
17
|
+
onSmsDriverChange: (driver: string) => void
|
|
18
|
+
onSaveSms: () => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ChannelsSideSection: React.FC<ChannelsSideSectionProps> = ({
|
|
22
|
+
smsDriverInput,
|
|
23
|
+
isPending,
|
|
24
|
+
onSmsDriverChange,
|
|
25
|
+
onSaveSms,
|
|
26
|
+
}) => {
|
|
27
|
+
const { t } = useTranslation()
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Container className="divide-y p-0">
|
|
31
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
32
|
+
<div>
|
|
33
|
+
<Heading level="h2">{t("channels.smsTitle")}</Heading>
|
|
34
|
+
<Text className="text-ui-fg-subtle text-xs mt-1">
|
|
35
|
+
{t("channels.smsSubtitle")}
|
|
36
|
+
</Text>
|
|
37
|
+
</div>
|
|
38
|
+
<Badge size="2xsmall" color="blue">
|
|
39
|
+
{smsDriverInput}
|
|
40
|
+
</Badge>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<SectionRow title={t("channels.smsDriverLabel")} value={smsDriverInput} />
|
|
44
|
+
|
|
45
|
+
<div className="flex flex-col gap-y-3 px-6 py-4">
|
|
46
|
+
<div className="flex flex-col gap-y-2">
|
|
47
|
+
<Label size="small">{t("channels.smsDriverLabel")}</Label>
|
|
48
|
+
<Select
|
|
49
|
+
size="small"
|
|
50
|
+
value={smsDriverInput}
|
|
51
|
+
onValueChange={onSmsDriverChange}
|
|
52
|
+
>
|
|
53
|
+
<Select.Trigger>
|
|
54
|
+
<Select.Value />
|
|
55
|
+
</Select.Trigger>
|
|
56
|
+
<Select.Content>
|
|
57
|
+
<Select.Item value="twilio">
|
|
58
|
+
{t("channels.driverTwilio")}
|
|
59
|
+
</Select.Item>
|
|
60
|
+
<Select.Item value="signalhouse">
|
|
61
|
+
{t("channels.driverSignalHouse")}
|
|
62
|
+
</Select.Item>
|
|
63
|
+
<Select.Item value="msg91">
|
|
64
|
+
{t("channels.driverMsg91")}
|
|
65
|
+
</Select.Item>
|
|
66
|
+
<Select.Item value="smsapi">
|
|
67
|
+
{t("channels.driverSmsApi")}
|
|
68
|
+
</Select.Item>
|
|
69
|
+
<Select.Item value="dummy">
|
|
70
|
+
{t("channels.driverDummy")}
|
|
71
|
+
</Select.Item>
|
|
72
|
+
</Select.Content>
|
|
73
|
+
</Select>
|
|
74
|
+
</div>
|
|
75
|
+
<div className="flex justify-end">
|
|
76
|
+
<Button
|
|
77
|
+
size="small"
|
|
78
|
+
variant="primary"
|
|
79
|
+
isLoading={isPending}
|
|
80
|
+
onClick={onSaveSms}
|
|
81
|
+
>
|
|
82
|
+
{t("channels.saveSmsButton")}
|
|
83
|
+
</Button>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</Container>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Toaster, toast } from "@medusajs/ui"
|
|
2
|
+
import React, { useEffect, useState } from "react"
|
|
3
|
+
import { useTranslation } from "react-i18next"
|
|
4
|
+
import { useSaveOrVerifyMpnChannel } from "../../../hooks"
|
|
5
|
+
import { ChannelsMainSection } from "./channels-main-section"
|
|
6
|
+
import { ChannelsSideSection } from "./channels-side-section"
|
|
7
|
+
import type { StatusBannerState } from "./constants"
|
|
8
|
+
|
|
9
|
+
export interface ChannelsConfigTabProps {
|
|
10
|
+
channelsConfig: Array<Record<string, any>>
|
|
11
|
+
onRefresh: () => Promise<void>
|
|
12
|
+
onStatus?: (status: StatusBannerState) => void
|
|
13
|
+
section?: "main" | "side" | "all"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ChannelsConfigTab: React.FC<ChannelsConfigTabProps> = ({
|
|
17
|
+
channelsConfig,
|
|
18
|
+
onRefresh,
|
|
19
|
+
onStatus,
|
|
20
|
+
section = "all",
|
|
21
|
+
}) => {
|
|
22
|
+
const { t } = useTranslation()
|
|
23
|
+
const [telegramChannelInput, setTelegramChannelInput] = useState<string>("")
|
|
24
|
+
const [openWaUrlInput, setOpenWaUrlInput] = useState<string>("")
|
|
25
|
+
const [whatsappDriverInput, setWhatsappDriverInput] =
|
|
26
|
+
useState<string>("meta-cloud")
|
|
27
|
+
const [smsDriverInput, setSmsDriverInput] = useState<string>("twilio")
|
|
28
|
+
const [verifyCooldown, setVerifyCooldown] = useState<boolean>(false)
|
|
29
|
+
|
|
30
|
+
const saveOrVerifyMutation = useSaveOrVerifyMpnChannel()
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const tg = channelsConfig.find((c) => c.channel === "telegram")
|
|
34
|
+
if (tg?.config_json?.merchant_channel_id) {
|
|
35
|
+
setTelegramChannelInput(String(tg.config_json.merchant_channel_id))
|
|
36
|
+
}
|
|
37
|
+
const wa = channelsConfig.find((c) => c.channel === "whatsapp")
|
|
38
|
+
if (wa?.driver) setWhatsappDriverInput(String(wa.driver))
|
|
39
|
+
if (wa?.config_json?.gateway_url) {
|
|
40
|
+
setOpenWaUrlInput(String(wa.config_json.gateway_url))
|
|
41
|
+
}
|
|
42
|
+
const sms = channelsConfig.find((c) => c.channel === "sms")
|
|
43
|
+
if (sms?.driver) setSmsDriverInput(String(sms.driver))
|
|
44
|
+
}, [channelsConfig])
|
|
45
|
+
|
|
46
|
+
const handleSaveOrVerifyChannel = async (
|
|
47
|
+
channel: string,
|
|
48
|
+
driver: string,
|
|
49
|
+
configJson: Record<string, any>,
|
|
50
|
+
action: "save" | "verify"
|
|
51
|
+
) => {
|
|
52
|
+
if (action === "verify") {
|
|
53
|
+
setVerifyCooldown(true)
|
|
54
|
+
setTimeout(() => setVerifyCooldown(false), 3000)
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
await saveOrVerifyMutation.mutateAsync({
|
|
58
|
+
channel,
|
|
59
|
+
driver,
|
|
60
|
+
config_json: configJson,
|
|
61
|
+
action,
|
|
62
|
+
})
|
|
63
|
+
const msg =
|
|
64
|
+
action === "verify"
|
|
65
|
+
? t("messages.verifiedChannelSuccess", { channel })
|
|
66
|
+
: t("messages.savedChannelSuccess", { channel })
|
|
67
|
+
toast.success(msg)
|
|
68
|
+
onStatus?.({ type: "success", text: msg })
|
|
69
|
+
await onRefresh()
|
|
70
|
+
} catch (err: any) {
|
|
71
|
+
const msg =
|
|
72
|
+
err?.message || t("messages.channelActionError", { action, channel })
|
|
73
|
+
toast.error(msg)
|
|
74
|
+
onStatus?.({ type: "error", text: msg })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const tgVerified = Boolean(
|
|
79
|
+
channelsConfig.find((c) => c.channel === "telegram")?.is_verified
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const mainCards = (
|
|
83
|
+
<ChannelsMainSection
|
|
84
|
+
whatsappDriverInput={whatsappDriverInput}
|
|
85
|
+
openWaUrlInput={openWaUrlInput}
|
|
86
|
+
telegramChannelInput={telegramChannelInput}
|
|
87
|
+
tgVerified={tgVerified}
|
|
88
|
+
verifyCooldown={verifyCooldown}
|
|
89
|
+
isPending={saveOrVerifyMutation.isPending}
|
|
90
|
+
onWhatsappDriverChange={setWhatsappDriverInput}
|
|
91
|
+
onOpenWaUrlChange={setOpenWaUrlInput}
|
|
92
|
+
onTelegramChannelChange={setTelegramChannelInput}
|
|
93
|
+
onSaveOrVerify={(ch, drv, cfg, act) =>
|
|
94
|
+
void handleSaveOrVerifyChannel(ch, drv, cfg, act)
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const sideCard = (
|
|
100
|
+
<ChannelsSideSection
|
|
101
|
+
smsDriverInput={smsDriverInput}
|
|
102
|
+
isPending={saveOrVerifyMutation.isPending}
|
|
103
|
+
onSmsDriverChange={setSmsDriverInput}
|
|
104
|
+
onSaveSms={() =>
|
|
105
|
+
void handleSaveOrVerifyChannel("sms", smsDriverInput, {}, "save")
|
|
106
|
+
}
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
if (section === "main") {
|
|
111
|
+
return (
|
|
112
|
+
<>
|
|
113
|
+
<Toaster />
|
|
114
|
+
{mainCards}
|
|
115
|
+
</>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (section === "side") {
|
|
120
|
+
return sideCard
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
|
|
125
|
+
<Toaster />
|
|
126
|
+
<div className="lg:col-span-2">{mainCards}</div>
|
|
127
|
+
<div>{sideCard}</div>
|
|
128
|
+
</div>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Container,
|
|
5
|
+
Heading,
|
|
6
|
+
StatusBadge,
|
|
7
|
+
Table,
|
|
8
|
+
Toaster,
|
|
9
|
+
} from "@medusajs/ui"
|
|
10
|
+
import React from "react"
|
|
11
|
+
import { useTranslation } from "react-i18next"
|
|
12
|
+
|
|
13
|
+
interface DeliveryLogsTabProps {
|
|
14
|
+
logs: Array<Record<string, any>>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const DeliveryLogsTab: React.FC<DeliveryLogsTabProps> = ({ logs }) => {
|
|
18
|
+
const { t } = useTranslation()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Container className="divide-y p-0">
|
|
22
|
+
<Toaster />
|
|
23
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
24
|
+
<Heading level="h2">{t("logs.title")}</Heading>
|
|
25
|
+
<StatusBadge color="green">{logs.length}</StatusBadge>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<SectionRow title={t("logs.colStatus")} value={logs.length} />
|
|
29
|
+
|
|
30
|
+
<Table>
|
|
31
|
+
<Table.Header>
|
|
32
|
+
<Table.Row>
|
|
33
|
+
<Table.HeaderCell>{t("logs.colEvent")}</Table.HeaderCell>
|
|
34
|
+
<Table.HeaderCell>{t("logs.colChannel")}</Table.HeaderCell>
|
|
35
|
+
<Table.HeaderCell>{t("logs.colRecipient")}</Table.HeaderCell>
|
|
36
|
+
<Table.HeaderCell>{t("logs.colStatus")}</Table.HeaderCell>
|
|
37
|
+
<Table.HeaderCell>{t("logs.colExternalId")}</Table.HeaderCell>
|
|
38
|
+
</Table.Row>
|
|
39
|
+
</Table.Header>
|
|
40
|
+
<Table.Body>
|
|
41
|
+
{logs.map((row) => (
|
|
42
|
+
<Table.Row key={row.id}>
|
|
43
|
+
<Table.Cell>{row.event_name}</Table.Cell>
|
|
44
|
+
<Table.Cell>
|
|
45
|
+
<Badge size="2xsmall" color="blue">
|
|
46
|
+
{row.channel}
|
|
47
|
+
</Badge>
|
|
48
|
+
</Table.Cell>
|
|
49
|
+
<Table.Cell>{row.recipient_masked}</Table.Cell>
|
|
50
|
+
<Table.Cell>
|
|
51
|
+
<StatusBadge
|
|
52
|
+
color={
|
|
53
|
+
row.status === "sent" || row.status === "delivered"
|
|
54
|
+
? "green"
|
|
55
|
+
: row.status === "failed"
|
|
56
|
+
? "red"
|
|
57
|
+
: "orange"
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
{row.status}
|
|
61
|
+
</StatusBadge>
|
|
62
|
+
</Table.Cell>
|
|
63
|
+
<Table.Cell>{row.external_message_id || "—"}</Table.Cell>
|
|
64
|
+
</Table.Row>
|
|
65
|
+
))}
|
|
66
|
+
</Table.Body>
|
|
67
|
+
</Table>
|
|
68
|
+
</Container>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Form, KeyboundForm } from "@medusajs/dashboard/components"
|
|
2
|
+
import { Button, Input, Label, Select, Switch } from "@medusajs/ui"
|
|
3
|
+
import React from "react"
|
|
4
|
+
import { useForm } from "react-hook-form"
|
|
5
|
+
import { useTranslation } from "react-i18next"
|
|
6
|
+
import { CHANNELS } from "./constants"
|
|
7
|
+
|
|
8
|
+
export interface EventMappingFormProps {
|
|
9
|
+
supportedEvents: string[]
|
|
10
|
+
templates: Array<Record<string, any>>
|
|
11
|
+
newMappingEvent: string
|
|
12
|
+
newMappingChannel: string
|
|
13
|
+
newMappingTemplateId: string
|
|
14
|
+
newMappingRecipientRule: string
|
|
15
|
+
newMappingAttachInvoice: boolean
|
|
16
|
+
newMappingThreadId: string
|
|
17
|
+
isSubmitting?: boolean
|
|
18
|
+
onEventChange: (event: string) => void
|
|
19
|
+
onChannelChange: (channel: string) => void
|
|
20
|
+
onTemplateChange: (templateId: string) => void
|
|
21
|
+
onRecipientRuleChange: (rule: string) => void
|
|
22
|
+
onAttachInvoiceChange: (attach: boolean) => void
|
|
23
|
+
onThreadIdChange: (threadId: string) => void
|
|
24
|
+
onSubmit: () => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const EventMappingForm: React.FC<EventMappingFormProps> = ({
|
|
28
|
+
supportedEvents,
|
|
29
|
+
templates,
|
|
30
|
+
newMappingEvent,
|
|
31
|
+
newMappingChannel,
|
|
32
|
+
newMappingTemplateId,
|
|
33
|
+
newMappingRecipientRule,
|
|
34
|
+
newMappingAttachInvoice,
|
|
35
|
+
newMappingThreadId,
|
|
36
|
+
isSubmitting = false,
|
|
37
|
+
onEventChange,
|
|
38
|
+
onChannelChange,
|
|
39
|
+
onTemplateChange,
|
|
40
|
+
onRecipientRuleChange,
|
|
41
|
+
onAttachInvoiceChange,
|
|
42
|
+
onThreadIdChange,
|
|
43
|
+
onSubmit,
|
|
44
|
+
}) => {
|
|
45
|
+
const { t } = useTranslation()
|
|
46
|
+
const form = useForm({
|
|
47
|
+
defaultValues: {
|
|
48
|
+
event_name: newMappingEvent,
|
|
49
|
+
channel: newMappingChannel,
|
|
50
|
+
template_id: newMappingTemplateId,
|
|
51
|
+
recipient_rule: newMappingRecipientRule,
|
|
52
|
+
telegram_thread_id: newMappingThreadId,
|
|
53
|
+
attach_invoice: newMappingAttachInvoice,
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Form {...form}>
|
|
59
|
+
<KeyboundForm
|
|
60
|
+
onSubmit={(e) => {
|
|
61
|
+
e.preventDefault()
|
|
62
|
+
onSubmit()
|
|
63
|
+
}}
|
|
64
|
+
className="px-6 py-4"
|
|
65
|
+
>
|
|
66
|
+
<div className="grid grid-cols-1 gap-4 md:grid-cols-5">
|
|
67
|
+
<div className="flex flex-col gap-y-2">
|
|
68
|
+
<Label size="small">{t("mappings.eventLabel")}</Label>
|
|
69
|
+
<Select
|
|
70
|
+
size="small"
|
|
71
|
+
value={newMappingEvent}
|
|
72
|
+
onValueChange={onEventChange}
|
|
73
|
+
>
|
|
74
|
+
<Select.Trigger>
|
|
75
|
+
<Select.Value />
|
|
76
|
+
</Select.Trigger>
|
|
77
|
+
<Select.Content>
|
|
78
|
+
{supportedEvents.map((ev) => (
|
|
79
|
+
<Select.Item key={ev} value={ev}>
|
|
80
|
+
{ev}
|
|
81
|
+
</Select.Item>
|
|
82
|
+
))}
|
|
83
|
+
</Select.Content>
|
|
84
|
+
</Select>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div className="flex flex-col gap-y-2">
|
|
88
|
+
<Label size="small">{t("mappings.channelLabel")}</Label>
|
|
89
|
+
<Select
|
|
90
|
+
size="small"
|
|
91
|
+
value={newMappingChannel}
|
|
92
|
+
onValueChange={onChannelChange}
|
|
93
|
+
>
|
|
94
|
+
<Select.Trigger>
|
|
95
|
+
<Select.Value />
|
|
96
|
+
</Select.Trigger>
|
|
97
|
+
<Select.Content>
|
|
98
|
+
{CHANNELS.map((ch) => (
|
|
99
|
+
<Select.Item key={ch} value={ch}>
|
|
100
|
+
{ch.toUpperCase()}
|
|
101
|
+
</Select.Item>
|
|
102
|
+
))}
|
|
103
|
+
</Select.Content>
|
|
104
|
+
</Select>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div className="flex flex-col gap-y-2">
|
|
108
|
+
<Label size="small">{t("mappings.templateLabel")}</Label>
|
|
109
|
+
<Select
|
|
110
|
+
size="small"
|
|
111
|
+
value={newMappingTemplateId}
|
|
112
|
+
onValueChange={onTemplateChange}
|
|
113
|
+
>
|
|
114
|
+
<Select.Trigger>
|
|
115
|
+
<Select.Value />
|
|
116
|
+
</Select.Trigger>
|
|
117
|
+
<Select.Content>
|
|
118
|
+
{templates.map((tpl) => (
|
|
119
|
+
<Select.Item key={tpl.id} value={tpl.id}>
|
|
120
|
+
[{tpl.channel}] {tpl.label}
|
|
121
|
+
</Select.Item>
|
|
122
|
+
))}
|
|
123
|
+
</Select.Content>
|
|
124
|
+
</Select>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div className="flex flex-col gap-y-2">
|
|
128
|
+
<Label size="small">{t("mappings.recipientRuleLabel")}</Label>
|
|
129
|
+
<Select
|
|
130
|
+
size="small"
|
|
131
|
+
value={newMappingRecipientRule}
|
|
132
|
+
onValueChange={onRecipientRuleChange}
|
|
133
|
+
>
|
|
134
|
+
<Select.Trigger>
|
|
135
|
+
<Select.Value />
|
|
136
|
+
</Select.Trigger>
|
|
137
|
+
<Select.Content>
|
|
138
|
+
<Select.Item value="customer_auto">
|
|
139
|
+
{t("mappings.ruleCustomerAuto")}
|
|
140
|
+
</Select.Item>
|
|
141
|
+
<Select.Item value="order_email">
|
|
142
|
+
{t("mappings.ruleOrderEmail")}
|
|
143
|
+
</Select.Item>
|
|
144
|
+
<Select.Item value="order_phone">
|
|
145
|
+
{t("mappings.ruleOrderPhone")}
|
|
146
|
+
</Select.Item>
|
|
147
|
+
<Select.Item value="customer_telegram">
|
|
148
|
+
{t("mappings.ruleCustomerTelegram")}
|
|
149
|
+
</Select.Item>
|
|
150
|
+
<Select.Item value="merchant_channel">
|
|
151
|
+
{t("mappings.ruleMerchantChannel")}
|
|
152
|
+
</Select.Item>
|
|
153
|
+
<Select.Item value="b2b_accounting_contact">
|
|
154
|
+
{t("mappings.ruleB2bAccounting")}
|
|
155
|
+
</Select.Item>
|
|
156
|
+
</Select.Content>
|
|
157
|
+
</Select>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div className="flex flex-col gap-y-2">
|
|
161
|
+
<Label size="small">{t("mappings.threadIdLabel")}</Label>
|
|
162
|
+
<Input
|
|
163
|
+
size="small"
|
|
164
|
+
placeholder={t("mappings.threadIdPlaceholder")}
|
|
165
|
+
value={newMappingThreadId}
|
|
166
|
+
onChange={(e) => onThreadIdChange(e.target.value)}
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div className="mt-4 flex items-center justify-between">
|
|
172
|
+
<div className="flex items-center gap-x-2">
|
|
173
|
+
<Switch
|
|
174
|
+
checked={newMappingAttachInvoice}
|
|
175
|
+
onCheckedChange={onAttachInvoiceChange}
|
|
176
|
+
/>
|
|
177
|
+
<Label size="small">{t("mappings.attachInvoiceLabel")}</Label>
|
|
178
|
+
</div>
|
|
179
|
+
<Button
|
|
180
|
+
size="small"
|
|
181
|
+
variant="primary"
|
|
182
|
+
type="submit"
|
|
183
|
+
isLoading={isSubmitting}
|
|
184
|
+
>
|
|
185
|
+
{t("mappings.addMappingButton")}
|
|
186
|
+
</Button>
|
|
187
|
+
</div>
|
|
188
|
+
</KeyboundForm>
|
|
189
|
+
</Form>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { SectionRow } from "@medusajs/dashboard/components"
|
|
2
|
+
import {
|
|
3
|
+
Badge,
|
|
4
|
+
Button,
|
|
5
|
+
Container,
|
|
6
|
+
Heading,
|
|
7
|
+
StatusBadge,
|
|
8
|
+
Table,
|
|
9
|
+
Toaster,
|
|
10
|
+
toast,
|
|
11
|
+
} from "@medusajs/ui"
|
|
12
|
+
import React, { useState } from "react"
|
|
13
|
+
import { useTranslation } from "react-i18next"
|
|
14
|
+
import { useCreateMpnMapping, useDeleteMpnMapping } from "../../../hooks"
|
|
15
|
+
import type { StatusBannerState } from "./constants"
|
|
16
|
+
import { EventMappingForm } from "./event-mapping-form"
|
|
17
|
+
|
|
18
|
+
export interface EventMappingsTabProps {
|
|
19
|
+
mappings: Array<Record<string, any>>
|
|
20
|
+
supportedEvents: string[]
|
|
21
|
+
templates: Array<Record<string, any>>
|
|
22
|
+
onRefresh: () => Promise<void>
|
|
23
|
+
onStatus?: (status: StatusBannerState) => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const EventMappingsTab: React.FC<EventMappingsTabProps> = ({
|
|
27
|
+
mappings,
|
|
28
|
+
supportedEvents,
|
|
29
|
+
templates,
|
|
30
|
+
onRefresh,
|
|
31
|
+
onStatus,
|
|
32
|
+
}) => {
|
|
33
|
+
const { t } = useTranslation()
|
|
34
|
+
const [newMappingEvent, setNewMappingEvent] = useState<string>("order.placed")
|
|
35
|
+
const [newMappingChannel, setNewMappingChannel] = useState<string>("email")
|
|
36
|
+
const [newMappingTemplateId, setNewMappingTemplateId] = useState<string>(
|
|
37
|
+
"system_email_order_placed"
|
|
38
|
+
)
|
|
39
|
+
const [newMappingRecipientRule, setNewMappingRecipientRule] =
|
|
40
|
+
useState<string>("customer_auto")
|
|
41
|
+
const [newMappingAttachInvoice, setNewMappingAttachInvoice] =
|
|
42
|
+
useState<boolean>(false)
|
|
43
|
+
const [newMappingThreadId, setNewMappingThreadId] = useState<string>("")
|
|
44
|
+
|
|
45
|
+
const createMappingMutation = useCreateMpnMapping()
|
|
46
|
+
const deleteMappingMutation = useDeleteMpnMapping()
|
|
47
|
+
|
|
48
|
+
const handleCreateMapping = async () => {
|
|
49
|
+
try {
|
|
50
|
+
await createMappingMutation.mutateAsync({
|
|
51
|
+
event_name: newMappingEvent,
|
|
52
|
+
channel: newMappingChannel,
|
|
53
|
+
template_id: newMappingTemplateId,
|
|
54
|
+
recipient_rule: newMappingRecipientRule,
|
|
55
|
+
telegram_thread_id: newMappingThreadId
|
|
56
|
+
? Number(newMappingThreadId)
|
|
57
|
+
: null,
|
|
58
|
+
attach_document_types: newMappingAttachInvoice ? ["invoice"] : null,
|
|
59
|
+
is_active: true,
|
|
60
|
+
})
|
|
61
|
+
const msg = t("messages.createdMappingSuccess", {
|
|
62
|
+
event: newMappingEvent,
|
|
63
|
+
channel: newMappingChannel,
|
|
64
|
+
})
|
|
65
|
+
toast.success(msg)
|
|
66
|
+
onStatus?.({ type: "success", text: msg })
|
|
67
|
+
await onRefresh()
|
|
68
|
+
} catch {
|
|
69
|
+
const msg = t("messages.createMappingError")
|
|
70
|
+
toast.error(msg)
|
|
71
|
+
onStatus?.({ type: "error", text: msg })
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleDeleteMapping = async (mappingId: string) => {
|
|
76
|
+
try {
|
|
77
|
+
await deleteMappingMutation.mutateAsync({ id: mappingId })
|
|
78
|
+
await onRefresh()
|
|
79
|
+
} catch {
|
|
80
|
+
// Ignore delete error
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Container className="divide-y p-0">
|
|
86
|
+
<Toaster />
|
|
87
|
+
<div className="flex items-center justify-between px-6 py-4">
|
|
88
|
+
<Heading level="h2">{t("mappings.title")}</Heading>
|
|
89
|
+
<StatusBadge color="green">{mappings.length}</StatusBadge>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<SectionRow
|
|
93
|
+
title={t("mappings.eventLabel")}
|
|
94
|
+
value={
|
|
95
|
+
<Badge size="2xsmall" color="grey">
|
|
96
|
+
{supportedEvents.length}
|
|
97
|
+
</Badge>
|
|
98
|
+
}
|
|
99
|
+
/>
|
|
100
|
+
|
|
101
|
+
<EventMappingForm
|
|
102
|
+
supportedEvents={supportedEvents}
|
|
103
|
+
templates={templates}
|
|
104
|
+
newMappingEvent={newMappingEvent}
|
|
105
|
+
newMappingChannel={newMappingChannel}
|
|
106
|
+
newMappingTemplateId={newMappingTemplateId}
|
|
107
|
+
newMappingRecipientRule={newMappingRecipientRule}
|
|
108
|
+
newMappingAttachInvoice={newMappingAttachInvoice}
|
|
109
|
+
newMappingThreadId={newMappingThreadId}
|
|
110
|
+
isSubmitting={createMappingMutation.isPending}
|
|
111
|
+
onEventChange={setNewMappingEvent}
|
|
112
|
+
onChannelChange={setNewMappingChannel}
|
|
113
|
+
onTemplateChange={setNewMappingTemplateId}
|
|
114
|
+
onRecipientRuleChange={setNewMappingRecipientRule}
|
|
115
|
+
onAttachInvoiceChange={setNewMappingAttachInvoice}
|
|
116
|
+
onThreadIdChange={setNewMappingThreadId}
|
|
117
|
+
onSubmit={() => void handleCreateMapping()}
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
<Table>
|
|
121
|
+
<Table.Header>
|
|
122
|
+
<Table.Row>
|
|
123
|
+
<Table.HeaderCell>{t("mappings.colEvent")}</Table.HeaderCell>
|
|
124
|
+
<Table.HeaderCell>{t("mappings.colChannel")}</Table.HeaderCell>
|
|
125
|
+
<Table.HeaderCell>{t("mappings.colTemplate")}</Table.HeaderCell>
|
|
126
|
+
<Table.HeaderCell>
|
|
127
|
+
{t("mappings.colRecipientRule")}
|
|
128
|
+
</Table.HeaderCell>
|
|
129
|
+
<Table.HeaderCell>{t("mappings.colAttachments")}</Table.HeaderCell>
|
|
130
|
+
<Table.HeaderCell>{t("mappings.colAction")}</Table.HeaderCell>
|
|
131
|
+
</Table.Row>
|
|
132
|
+
</Table.Header>
|
|
133
|
+
<Table.Body>
|
|
134
|
+
{mappings.map((m) => (
|
|
135
|
+
<Table.Row key={m.id}>
|
|
136
|
+
<Table.Cell>{m.event_name}</Table.Cell>
|
|
137
|
+
<Table.Cell>
|
|
138
|
+
<Badge size="2xsmall" color="blue">
|
|
139
|
+
{m.channel}
|
|
140
|
+
</Badge>
|
|
141
|
+
</Table.Cell>
|
|
142
|
+
<Table.Cell>{m.template_id}</Table.Cell>
|
|
143
|
+
<Table.Cell>{m.recipient_rule}</Table.Cell>
|
|
144
|
+
<Table.Cell>
|
|
145
|
+
{Array.isArray(m.attach_document_types)
|
|
146
|
+
? m.attach_document_types.join(", ")
|
|
147
|
+
: "—"}
|
|
148
|
+
</Table.Cell>
|
|
149
|
+
<Table.Cell>
|
|
150
|
+
<Button
|
|
151
|
+
size="small"
|
|
152
|
+
variant="secondary"
|
|
153
|
+
isLoading={deleteMappingMutation.isPending}
|
|
154
|
+
onClick={() => void handleDeleteMapping(m.id)}
|
|
155
|
+
>
|
|
156
|
+
{t("mappings.deleteButton")}
|
|
157
|
+
</Button>
|
|
158
|
+
</Table.Cell>
|
|
159
|
+
</Table.Row>
|
|
160
|
+
))}
|
|
161
|
+
</Table.Body>
|
|
162
|
+
</Table>
|
|
163
|
+
</Container>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Button, Container, Heading, Text, Toaster } from "@medusajs/ui"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { useTranslation } from "react-i18next"
|
|
4
|
+
import type { StatusBannerState } from "./constants"
|
|
5
|
+
|
|
6
|
+
export interface NotificationHeaderBarProps {
|
|
7
|
+
statusBanner?: StatusBannerState | null
|
|
8
|
+
onRefresh: () => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const NotificationHeaderBar: React.FC<NotificationHeaderBarProps> = ({
|
|
12
|
+
onRefresh,
|
|
13
|
+
}) => {
|
|
14
|
+
const { t } = useTranslation()
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Container className="divide-y p-0">
|
|
18
|
+
<Toaster />
|
|
19
|
+
<div className="flex flex-wrap items-center justify-between gap-4 px-6 py-4">
|
|
20
|
+
<div>
|
|
21
|
+
<Heading level="h1">{t("header.title")}</Heading>
|
|
22
|
+
<Text size="small" className="text-ui-fg-subtle mt-1">
|
|
23
|
+
{t("header.subtitle")}
|
|
24
|
+
</Text>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div className="flex items-center gap-x-2">
|
|
28
|
+
<Button size="small" variant="secondary" onClick={onRefresh}>
|
|
29
|
+
{t("header.refresh")}
|
|
30
|
+
</Button>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</Container>
|
|
34
|
+
)
|
|
35
|
+
}
|