strapi-plugin-magic-link-v5 5.5.8 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +740 -0
  2. package/README.md +662 -928
  3. package/dist/admin/LicenseGuard-BgLA9go3.mjs +495 -0
  4. package/dist/admin/LicenseGuard-ewCjpc17.js +513 -0
  5. package/dist/admin/de-B1FNErPH.mjs +673 -0
  6. package/dist/admin/de-e75OECdq.js +673 -0
  7. package/dist/admin/en-CABKGbxH.js +673 -0
  8. package/dist/admin/en-HqDOFBCc.mjs +673 -0
  9. package/dist/admin/es-DpWl0Fax.js +673 -0
  10. package/dist/admin/es-jb94jqPR.mjs +673 -0
  11. package/dist/admin/fr-BQhLPvYw.js +673 -0
  12. package/dist/admin/fr-BseH1wrr.mjs +673 -0
  13. package/dist/admin/index-6ot9j1cN.js +5268 -0
  14. package/dist/admin/index-B390rccl.js +622 -0
  15. package/dist/admin/index-BPGKtruf.mjs +5266 -0
  16. package/dist/admin/index-BaTIQtnA.js +3869 -0
  17. package/dist/admin/index-CmG-93yx.js +141 -0
  18. package/dist/admin/index-DXe_ge4v.mjs +620 -0
  19. package/dist/admin/index-Dv5PVT1E.mjs +3867 -0
  20. package/dist/admin/index-k240ls6p.mjs +142 -0
  21. package/dist/admin/index.js +3 -3
  22. package/dist/admin/index.mjs +1 -2
  23. package/dist/admin/pt-CPkaveti.js +673 -0
  24. package/dist/admin/pt-DhlSCJn2.mjs +673 -0
  25. package/dist/admin/useUnsavedChangesGuard-BVZ4Mg4E.js +225 -0
  26. package/dist/admin/useUnsavedChangesGuard-QnkiZTLP.mjs +224 -0
  27. package/dist/server/i18n/de.json +32 -1
  28. package/dist/server/i18n/en.json +32 -1
  29. package/dist/server/i18n/es.json +32 -1
  30. package/dist/server/i18n/fr.json +32 -1
  31. package/dist/server/i18n/pt.json +32 -1
  32. package/dist/server/index.js +7092 -5979
  33. package/dist/server/index.mjs +7114 -5979
  34. package/package.json +42 -41
  35. package/strapi-admin.js +3 -1
  36. package/strapi-server.js +3 -2
  37. package/dist/_chunks/LicenseGuard-CiyjFnrw.js +0 -54
  38. package/dist/_chunks/LicenseGuard-DJ5fq2UZ.mjs +0 -55
  39. package/dist/_chunks/de-BSOk5suQ.js +0 -454
  40. package/dist/_chunks/de-CwhYs3O3.mjs +0 -454
  41. package/dist/_chunks/en-DnvSpXvu.js +0 -454
  42. package/dist/_chunks/en-gXXgGDV1.mjs +0 -454
  43. package/dist/_chunks/es-B-tnwByt.js +0 -407
  44. package/dist/_chunks/es-DG5gW3RZ.mjs +0 -407
  45. package/dist/_chunks/fr-BKo8t7Fx.js +0 -407
  46. package/dist/_chunks/fr-BQn1OHOR.mjs +0 -407
  47. package/dist/_chunks/index-01GHNxSr.js +0 -307
  48. package/dist/_chunks/index-B9Ch8Jpe.mjs +0 -5066
  49. package/dist/_chunks/index-Bj-erY7g.mjs +0 -143
  50. package/dist/_chunks/index-CGxbhJfg.js +0 -142
  51. package/dist/_chunks/index-DF3Edydl.mjs +0 -330
  52. package/dist/_chunks/index-Dufv-daf.mjs +0 -305
  53. package/dist/_chunks/index-I72rBTkL.js +0 -332
  54. package/dist/_chunks/index-SCxv154G.mjs +0 -2904
  55. package/dist/_chunks/index-XYWLmmEs.js +0 -5068
  56. package/dist/_chunks/index-zzoovbM0.js +0 -2906
  57. package/dist/_chunks/pt-CjEkXBAz.js +0 -407
  58. package/dist/_chunks/pt-trziAOzT.mjs +0 -407
@@ -1,143 +0,0 @@
1
- import { useRef, useEffect } from "react";
2
- import { jsx } from "react/jsx-runtime";
3
- import { Key } from "@strapi/icons";
4
- const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
5
- const v = glob[path];
6
- if (v) {
7
- return typeof v === "function" ? v() : Promise.resolve(v);
8
- }
9
- return new Promise((_, reject) => {
10
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
11
- reject.bind(
12
- null,
13
- new Error(
14
- "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
15
- )
16
- )
17
- );
18
- });
19
- };
20
- const strapi = {
21
- name: "magic-link"
22
- };
23
- const pluginPkg = {
24
- strapi
25
- };
26
- const PLUGIN_ID = "magic-link";
27
- const Initializer = ({ setPlugin }) => {
28
- const ref = useRef(setPlugin);
29
- useEffect(() => {
30
- ref.current(PLUGIN_ID);
31
- }, []);
32
- return null;
33
- };
34
- const PluginIcon = () => /* @__PURE__ */ jsx(Key, {});
35
- const pluginPermissions = {
36
- access: [{ action: "plugin::magic-link.access", subject: null }],
37
- readSettings: [{ action: "plugin::magic-link.settings.read", subject: null }]
38
- };
39
- const getTrad = (id) => {
40
- if (id.startsWith(`${PLUGIN_ID}.`)) {
41
- return id;
42
- }
43
- return `${PLUGIN_ID}.${id}`;
44
- };
45
- const name = pluginPkg.strapi.name;
46
- const index = {
47
- register(app) {
48
- app.registerPlugin({
49
- id: PLUGIN_ID,
50
- initializer: Initializer,
51
- isReady: false,
52
- name
53
- });
54
- app.addMenuLink({
55
- to: `plugins/${PLUGIN_ID}/tokens`,
56
- icon: PluginIcon,
57
- intlLabel: {
58
- id: getTrad("tokens.title"),
59
- defaultMessage: "Magic Link Tokens"
60
- },
61
- Component: () => import(
62
- /* webpackChunkName: "magic-link-tokens" */
63
- "./index-B9Ch8Jpe.mjs"
64
- ),
65
- permissions: pluginPermissions.access
66
- });
67
- app.createSettingSection(
68
- {
69
- id: PLUGIN_ID,
70
- intlLabel: {
71
- id: getTrad("Header.Settings"),
72
- defaultMessage: "Magic Link"
73
- }
74
- },
75
- [
76
- {
77
- intlLabel: {
78
- id: getTrad("Form.title.Settings"),
79
- defaultMessage: "Settings"
80
- },
81
- id: "magic-link-settings",
82
- to: `${PLUGIN_ID}/config`,
83
- Component: () => import(
84
- /* webpackChunkName: "magic-link-settings" */
85
- "./index-SCxv154G.mjs"
86
- ),
87
- permissions: pluginPermissions.readSettings
88
- },
89
- {
90
- intlLabel: {
91
- id: getTrad("Form.title.License"),
92
- defaultMessage: "License"
93
- },
94
- id: "magic-link-license",
95
- to: `${PLUGIN_ID}/license`,
96
- Component: () => import(
97
- /* webpackChunkName: "magic-link-license" */
98
- "./index-Dufv-daf.mjs"
99
- ),
100
- permissions: pluginPermissions.access
101
- },
102
- {
103
- intlLabel: {
104
- id: getTrad("Form.title.WhatsApp"),
105
- defaultMessage: "WhatsApp"
106
- },
107
- id: "magic-link-whatsapp",
108
- to: `${PLUGIN_ID}/whatsapp`,
109
- Component: () => import(
110
- /* webpackChunkName: "magic-link-whatsapp" */
111
- "./index-DF3Edydl.mjs"
112
- ),
113
- permissions: pluginPermissions.access
114
- }
115
- ]
116
- );
117
- },
118
- bootstrap() {
119
- },
120
- async registerTrads({ locales }) {
121
- const importedTrads = await Promise.all(
122
- locales.map((locale) => {
123
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("./de-CwhYs3O3.mjs"), "./translations/en.json": () => import("./en-gXXgGDV1.mjs"), "./translations/es.json": () => import("./es-DG5gW3RZ.mjs"), "./translations/fr.json": () => import("./fr-BQn1OHOR.mjs"), "./translations/pt.json": () => import("./pt-trziAOzT.mjs") }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
124
- return {
125
- data,
126
- locale
127
- };
128
- }).catch(() => {
129
- return {
130
- data: {},
131
- locale
132
- };
133
- });
134
- })
135
- );
136
- return Promise.resolve(importedTrads);
137
- }
138
- };
139
- export {
140
- PLUGIN_ID as P,
141
- getTrad as g,
142
- index as i
143
- };
@@ -1,142 +0,0 @@
1
- "use strict";
2
- const react = require("react");
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const icons = require("@strapi/icons");
5
- const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
6
- const v = glob[path];
7
- if (v) {
8
- return typeof v === "function" ? v() : Promise.resolve(v);
9
- }
10
- return new Promise((_, reject) => {
11
- (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
12
- reject.bind(
13
- null,
14
- new Error(
15
- "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
16
- )
17
- )
18
- );
19
- });
20
- };
21
- const strapi = {
22
- name: "magic-link"
23
- };
24
- const pluginPkg = {
25
- strapi
26
- };
27
- const PLUGIN_ID = "magic-link";
28
- const Initializer = ({ setPlugin }) => {
29
- const ref = react.useRef(setPlugin);
30
- react.useEffect(() => {
31
- ref.current(PLUGIN_ID);
32
- }, []);
33
- return null;
34
- };
35
- const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Key, {});
36
- const pluginPermissions = {
37
- access: [{ action: "plugin::magic-link.access", subject: null }],
38
- readSettings: [{ action: "plugin::magic-link.settings.read", subject: null }]
39
- };
40
- const getTrad = (id) => {
41
- if (id.startsWith(`${PLUGIN_ID}.`)) {
42
- return id;
43
- }
44
- return `${PLUGIN_ID}.${id}`;
45
- };
46
- const name = pluginPkg.strapi.name;
47
- const index = {
48
- register(app) {
49
- app.registerPlugin({
50
- id: PLUGIN_ID,
51
- initializer: Initializer,
52
- isReady: false,
53
- name
54
- });
55
- app.addMenuLink({
56
- to: `plugins/${PLUGIN_ID}/tokens`,
57
- icon: PluginIcon,
58
- intlLabel: {
59
- id: getTrad("tokens.title"),
60
- defaultMessage: "Magic Link Tokens"
61
- },
62
- Component: () => Promise.resolve().then(() => require(
63
- /* webpackChunkName: "magic-link-tokens" */
64
- "./index-XYWLmmEs.js"
65
- )),
66
- permissions: pluginPermissions.access
67
- });
68
- app.createSettingSection(
69
- {
70
- id: PLUGIN_ID,
71
- intlLabel: {
72
- id: getTrad("Header.Settings"),
73
- defaultMessage: "Magic Link"
74
- }
75
- },
76
- [
77
- {
78
- intlLabel: {
79
- id: getTrad("Form.title.Settings"),
80
- defaultMessage: "Settings"
81
- },
82
- id: "magic-link-settings",
83
- to: `${PLUGIN_ID}/config`,
84
- Component: () => Promise.resolve().then(() => require(
85
- /* webpackChunkName: "magic-link-settings" */
86
- "./index-zzoovbM0.js"
87
- )),
88
- permissions: pluginPermissions.readSettings
89
- },
90
- {
91
- intlLabel: {
92
- id: getTrad("Form.title.License"),
93
- defaultMessage: "License"
94
- },
95
- id: "magic-link-license",
96
- to: `${PLUGIN_ID}/license`,
97
- Component: () => Promise.resolve().then(() => require(
98
- /* webpackChunkName: "magic-link-license" */
99
- "./index-01GHNxSr.js"
100
- )),
101
- permissions: pluginPermissions.access
102
- },
103
- {
104
- intlLabel: {
105
- id: getTrad("Form.title.WhatsApp"),
106
- defaultMessage: "WhatsApp"
107
- },
108
- id: "magic-link-whatsapp",
109
- to: `${PLUGIN_ID}/whatsapp`,
110
- Component: () => Promise.resolve().then(() => require(
111
- /* webpackChunkName: "magic-link-whatsapp" */
112
- "./index-I72rBTkL.js"
113
- )),
114
- permissions: pluginPermissions.access
115
- }
116
- ]
117
- );
118
- },
119
- bootstrap() {
120
- },
121
- async registerTrads({ locales }) {
122
- const importedTrads = await Promise.all(
123
- locales.map((locale) => {
124
- return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-BSOk5suQ.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-DnvSpXvu.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-B-tnwByt.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-BKo8t7Fx.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CjEkXBAz.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
125
- return {
126
- data,
127
- locale
128
- };
129
- }).catch(() => {
130
- return {
131
- data: {},
132
- locale
133
- };
134
- });
135
- })
136
- );
137
- return Promise.resolve(importedTrads);
138
- }
139
- };
140
- exports.PLUGIN_ID = PLUGIN_ID;
141
- exports.getTrad = getTrad;
142
- exports.index = index;
@@ -1,330 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useCallback, useEffect } from "react";
3
- import styled from "styled-components";
4
- import { useIntl } from "react-intl";
5
- import { Flex, Loader, Box, Typography, Button, TextInput, Badge } from "@strapi/design-system";
6
- import { Phone, Check, Message, ArrowClockwise } from "@strapi/icons";
7
- import { useNotification, useFetchClient } from "@strapi/strapi/admin";
8
- import { g as getTrad } from "./index-Bj-erY7g.mjs";
9
- const theme = {
10
- colors: {
11
- primary: { 700: "#075985", 100: "#E0F2FE", 50: "#F0F9FF" },
12
- success: { 600: "#16A34A", 700: "#15803D", 100: "#DCFCE7" },
13
- danger: { 700: "#B91C1C", 100: "#FEE2E2" },
14
- warning: { 700: "#A16207", 100: "#FEF3C7", 50: "#FFFBEB" },
15
- whatsapp: { 600: "#25D366" },
16
- neutral: { 50: "#F9FAFB", 100: "#F3F4F6", 200: "#E5E7EB", 800: "#1F2937" }
17
- },
18
- shadows: { md: "0 4px 6px rgba(0,0,0,0.1)" },
19
- borderRadius: { md: "8px", lg: "12px" }
20
- };
21
- const Container = styled(Box)`
22
- max-width: 900px;
23
- margin: 0 auto;
24
- padding: 32px;
25
- `;
26
- const Card = styled(Box)`
27
- background: white;
28
- border-radius: ${theme.borderRadius.lg};
29
- box-shadow: ${theme.shadows.md};
30
- padding: 24px;
31
- margin-bottom: 24px;
32
- `;
33
- const QRCodeContainer = styled(Box)`
34
- display: flex;
35
- justify-content: center;
36
- align-items: center;
37
- padding: 24px;
38
- background: ${theme.colors.neutral[50]};
39
- border-radius: ${theme.borderRadius.lg};
40
- border: 2px dashed ${theme.colors.neutral[200]};
41
- min-height: 280px;
42
-
43
- img {
44
- max-width: 256px;
45
- border-radius: ${theme.borderRadius.md};
46
- }
47
- `;
48
- const StatusBadge = styled(Badge)`
49
- background: ${(props) => {
50
- switch (props.$status) {
51
- case "connected":
52
- return theme.colors.success[100];
53
- case "connecting":
54
- return theme.colors.warning[100];
55
- case "qr_pending":
56
- return theme.colors.primary[100];
57
- default:
58
- return theme.colors.danger[100];
59
- }
60
- }};
61
- color: ${(props) => {
62
- switch (props.$status) {
63
- case "connected":
64
- return theme.colors.success[700];
65
- case "connecting":
66
- return theme.colors.warning[700];
67
- case "qr_pending":
68
- return theme.colors.primary[700];
69
- default:
70
- return theme.colors.danger[700];
71
- }
72
- }};
73
- font-weight: 600;
74
- padding: 8px 16px;
75
- font-size: 14px;
76
- `;
77
- const WhatsAppIcon = styled.div`
78
- width: 48px;
79
- height: 48px;
80
- border-radius: 50%;
81
- background: ${theme.colors.whatsapp[600]};
82
- display: flex;
83
- align-items: center;
84
- justify-content: center;
85
- color: white;
86
- font-size: 24px;
87
- `;
88
- const WhatsAppPage = () => {
89
- const { formatMessage } = useIntl();
90
- const { toggleNotification } = useNotification();
91
- const { get, post } = useFetchClient();
92
- const [loading, setLoading] = useState(true);
93
- const [status, setStatus] = useState({
94
- available: false,
95
- status: "disconnected",
96
- qrCode: null,
97
- session: null,
98
- delegatedTo: null
99
- });
100
- const [settings, setSettings] = useState({
101
- whatsapp_enabled: false,
102
- whatsapp_app_name: "Magic Link"
103
- });
104
- const [testPhone, setTestPhone] = useState("");
105
- const [testMessage, setTestMessage] = useState("");
106
- const [sending, setSending] = useState(false);
107
- const [connecting, setConnecting] = useState(false);
108
- const fetchStatus = useCallback(async () => {
109
- try {
110
- const response = await get("/magic-link/whatsapp/status");
111
- setStatus(response.data);
112
- } catch (error) {
113
- console.error("Error fetching WhatsApp status:", error);
114
- }
115
- }, [get]);
116
- const fetchSettings = useCallback(async () => {
117
- try {
118
- const response = await get("/magic-link/settings");
119
- setSettings(response.data || {});
120
- } catch (error) {
121
- console.error("Error fetching settings:", error);
122
- }
123
- }, [get]);
124
- useEffect(() => {
125
- const init = async () => {
126
- setLoading(true);
127
- await Promise.all([fetchStatus(), fetchSettings()]);
128
- setLoading(false);
129
- };
130
- init();
131
- }, [fetchStatus, fetchSettings]);
132
- useEffect(() => {
133
- if (status.status === "connecting" || status.status === "qr_pending") {
134
- const interval = setInterval(fetchStatus, 3e3);
135
- return () => clearInterval(interval);
136
- }
137
- }, [status.status, fetchStatus]);
138
- const handleConnect = async () => {
139
- setConnecting(true);
140
- try {
141
- await post("/magic-link/whatsapp/connect");
142
- await fetchStatus();
143
- toggleNotification({
144
- type: "success",
145
- message: formatMessage({ id: getTrad("whatsapp.notifications.connecting") })
146
- });
147
- } catch (error) {
148
- toggleNotification({
149
- type: "warning",
150
- message: error.response?.data?.error?.message || "Connection failed"
151
- });
152
- }
153
- setConnecting(false);
154
- };
155
- const handleDisconnect = async () => {
156
- try {
157
- await post("/magic-link/whatsapp/disconnect");
158
- await fetchStatus();
159
- toggleNotification({
160
- type: "success",
161
- message: formatMessage({ id: getTrad("whatsapp.notifications.disconnected") })
162
- });
163
- } catch (error) {
164
- toggleNotification({
165
- type: "warning",
166
- message: "Disconnect failed"
167
- });
168
- }
169
- };
170
- const handleTestMessage = async () => {
171
- if (!testPhone) {
172
- toggleNotification({
173
- type: "warning",
174
- message: formatMessage({ id: getTrad("whatsapp.notifications.phoneRequired") })
175
- });
176
- return;
177
- }
178
- setSending(true);
179
- try {
180
- const response = await post("/magic-link/whatsapp/test-message", {
181
- phoneNumber: testPhone,
182
- message: testMessage || void 0
183
- });
184
- if (response.data.success) {
185
- toggleNotification({
186
- type: "success",
187
- message: formatMessage({ id: getTrad("whatsapp.notifications.messageSent") })
188
- });
189
- setTestMessage("");
190
- } else {
191
- toggleNotification({
192
- type: "warning",
193
- message: response.data.error || "Failed to send"
194
- });
195
- }
196
- } catch (error) {
197
- toggleNotification({
198
- type: "warning",
199
- message: error.response?.data?.error?.message || "Failed to send message"
200
- });
201
- }
202
- setSending(false);
203
- };
204
- const getStatusLabel = () => {
205
- switch (status.status) {
206
- case "connected":
207
- return "Connected";
208
- case "connecting":
209
- return "Connecting...";
210
- case "qr_pending":
211
- return "Scan QR Code";
212
- case "not_installed":
213
- return "Baileys not installed";
214
- default:
215
- return "Disconnected";
216
- }
217
- };
218
- if (loading) {
219
- return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsx(Loader, {}) }) });
220
- }
221
- return /* @__PURE__ */ jsxs(Container, { children: [
222
- /* @__PURE__ */ jsxs(Box, { marginBottom: 6, children: [
223
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-start", marginBottom: 2, children: [
224
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 4, children: [
225
- /* @__PURE__ */ jsx(WhatsAppIcon, { children: /* @__PURE__ */ jsx(Phone, {}) }),
226
- /* @__PURE__ */ jsx(Typography, { variant: "alpha", fontWeight: "bold", children: formatMessage({ id: getTrad("whatsapp.title") }) })
227
- ] }),
228
- /* @__PURE__ */ jsx(StatusBadge, { $status: status.status, children: getStatusLabel() })
229
- ] }),
230
- /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", style: { marginLeft: "64px" }, children: formatMessage({ id: getTrad("whatsapp.subtitle") }) })
231
- ] }),
232
- status.delegatedTo === "magic-mail" && /* @__PURE__ */ jsxs(Card, { style: { background: theme.colors.primary[50], border: `2px solid ${theme.colors.primary[100]}` }, children: [
233
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "12px" }, children: "WhatsApp managed by Magic-Mail" }),
234
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { display: "block", lineHeight: "1.6", marginBottom: "16px" }, children: "Magic-Mail plugin is installed and handles the WhatsApp connection. You only need to scan the QR code once in Magic-Mail, and both plugins will share the same WhatsApp session." }),
235
- /* @__PURE__ */ jsxs(Box, { style: { padding: "12px", background: theme.colors.neutral[100], borderRadius: theme.borderRadius.md }, children: [
236
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { display: "block", marginBottom: "8px" }, children: "Go to: Plugins → Magic-Mail → WhatsApp" }),
237
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "All WhatsApp settings and connection management is done there." })
238
- ] })
239
- ] }),
240
- !status.available && !status.delegatedTo && /* @__PURE__ */ jsxs(Card, { style: { background: theme.colors.warning[50], border: `2px solid ${theme.colors.warning[100]}` }, children: [
241
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "12px" }, children: formatMessage({ id: getTrad("whatsapp.notInstalled.title") }) }),
242
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { display: "block", lineHeight: "1.6", marginBottom: "16px" }, children: formatMessage({ id: getTrad("whatsapp.notInstalled.description") }) }),
243
- /* @__PURE__ */ jsx(Box, { style: { padding: "12px", background: theme.colors.neutral[100], borderRadius: theme.borderRadius.md }, children: /* @__PURE__ */ jsx("code", { style: { fontSize: "14px" }, children: "npm install @whiskeysockets/baileys pino" }) })
244
- ] }),
245
- status.available && !status.delegatedTo && /* @__PURE__ */ jsxs(Card, { children: [
246
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", marginBottom: 4, children: formatMessage({ id: getTrad("whatsapp.connection.title") }) }),
247
- (status.status === "qr_pending" || status.status === "disconnected" || status.status === "connecting") && /* @__PURE__ */ jsx(QRCodeContainer, { children: status.qrCode ? /* @__PURE__ */ jsxs(Box, { textAlign: "center", children: [
248
- /* @__PURE__ */ jsx("img", { src: status.qrCode, alt: "WhatsApp QR Code" }),
249
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { marginTop: "16px", display: "block" }, children: formatMessage({ id: getTrad("whatsapp.qr.instruction") }) })
250
- ] }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 4, children: [
251
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: status.status === "connecting" ? formatMessage({ id: getTrad("whatsapp.connection.generating") }) : formatMessage({ id: getTrad("whatsapp.connection.clickToConnect") }) }),
252
- status.status !== "connecting" && /* @__PURE__ */ jsx(
253
- Button,
254
- {
255
- onClick: handleConnect,
256
- loading: connecting,
257
- startIcon: /* @__PURE__ */ jsx(Phone, {}),
258
- style: { background: theme.colors.whatsapp[600] },
259
- children: formatMessage({ id: getTrad("whatsapp.actions.connect") })
260
- }
261
- )
262
- ] }) }),
263
- status.status === "connected" && /* @__PURE__ */ jsxs(Box, { children: [
264
- /* @__PURE__ */ jsxs(
265
- Flex,
266
- {
267
- alignItems: "flex-start",
268
- justifyContent: "space-between",
269
- padding: 4,
270
- background: "success100",
271
- style: { borderRadius: theme.borderRadius.md, marginBottom: "16px" },
272
- children: [
273
- /* @__PURE__ */ jsxs(Flex, { alignItems: "flex-start", gap: 3, children: [
274
- /* @__PURE__ */ jsx(Check, { style: { color: theme.colors.success[600], marginTop: "4px" } }),
275
- /* @__PURE__ */ jsxs(Box, { children: [
276
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "8px" }, children: formatMessage({ id: getTrad("whatsapp.connected.title") }) }),
277
- status.session && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { display: "block" }, children: [
278
- status.session.phoneNumber,
279
- " • ",
280
- status.session.name || "WhatsApp User"
281
- ] })
282
- ] })
283
- ] }),
284
- /* @__PURE__ */ jsx(Button, { variant: "danger", onClick: handleDisconnect, size: "S", children: formatMessage({ id: getTrad("whatsapp.actions.disconnect") }) })
285
- ]
286
- }
287
- ),
288
- /* @__PURE__ */ jsxs(Box, { style: { marginTop: "24px" }, children: [
289
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "16px" }, children: formatMessage({ id: getTrad("whatsapp.test.title") }) }),
290
- /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-start", children: [
291
- /* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
292
- TextInput,
293
- {
294
- placeholder: "491234567890",
295
- value: testPhone,
296
- onChange: (e) => setTestPhone(e.target.value)
297
- }
298
- ) }),
299
- /* @__PURE__ */ jsx(
300
- Button,
301
- {
302
- onClick: handleTestMessage,
303
- loading: sending,
304
- startIcon: /* @__PURE__ */ jsx(Message, {}),
305
- children: formatMessage({ id: getTrad("whatsapp.actions.sendTest") })
306
- }
307
- )
308
- ] })
309
- ] })
310
- ] }),
311
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", marginTop: 4, children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: fetchStatus, startIcon: /* @__PURE__ */ jsx(ArrowClockwise, {}), children: formatMessage({ id: getTrad("whatsapp.actions.refresh") }) }) })
312
- ] }),
313
- !status.delegatedTo && /* @__PURE__ */ jsxs(Card, { style: { background: theme.colors.primary[50], border: `2px solid ${theme.colors.primary[100]}` }, children: [
314
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "12px" }, children: formatMessage({ id: getTrad("whatsapp.info.title") }) }),
315
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral700", style: { display: "block", lineHeight: "1.6", marginBottom: "16px" }, children: formatMessage({ id: getTrad("whatsapp.info.description") }) }),
316
- /* @__PURE__ */ jsxs(Box, { style: { marginTop: "16px" }, children: [
317
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { display: "block", marginBottom: "8px" }, children: formatMessage({ id: getTrad("whatsapp.info.apiExample") }) }),
318
- /* @__PURE__ */ jsx(Box, { style: { padding: "12px", background: theme.colors.neutral[800], borderRadius: theme.borderRadius.md, color: "#fff", fontFamily: "monospace", fontSize: "13px" }, children: /* @__PURE__ */ jsx("pre", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: `POST /api/magic-link/send-link
319
- {
320
- "email": "user@example.com",
321
- "phoneNumber": "491234567890",
322
- "delivery": "whatsapp"
323
- }` }) })
324
- ] })
325
- ] })
326
- ] });
327
- };
328
- export {
329
- WhatsAppPage as default
330
- };