ublo-lib 1.38.34 → 1.38.36

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 (82) hide show
  1. package/es/common/components/editable-map/editable-map.module.css +1 -1
  2. package/es/common/components/editable-map/index.d.ts.map +1 -1
  3. package/es/common/components/editable-map/index.js +5 -10
  4. package/es/esf/components/espace-prive/admin/client-links.d.ts +2 -0
  5. package/es/esf/components/espace-prive/admin/client-links.d.ts.map +1 -0
  6. package/es/esf/components/espace-prive/admin/client-links.js +34 -0
  7. package/es/esf/components/espace-prive/admin/client-links.module.css +42 -0
  8. package/es/esf/components/espace-prive/admin/config-field.d.ts +4 -0
  9. package/es/esf/components/espace-prive/admin/config-field.d.ts.map +1 -0
  10. package/es/esf/components/espace-prive/admin/config-field.js +41 -0
  11. package/es/esf/components/espace-prive/admin/config-field.module.css +30 -0
  12. package/es/esf/components/espace-prive/admin/config.d.ts +2 -0
  13. package/es/esf/components/espace-prive/admin/config.d.ts.map +1 -0
  14. package/es/esf/components/espace-prive/admin/config.js +17 -0
  15. package/es/esf/components/espace-prive/admin/config.module.css +40 -0
  16. package/es/esf/components/espace-prive/admin/link-form.d.ts +5 -0
  17. package/es/esf/components/espace-prive/admin/link-form.d.ts.map +1 -0
  18. package/es/esf/components/espace-prive/admin/link-form.js +97 -0
  19. package/es/esf/components/espace-prive/admin/link-form.module.css +60 -0
  20. package/es/esf/components/espace-prive/admin/link-row.d.ts +7 -0
  21. package/es/esf/components/espace-prive/admin/link-row.d.ts.map +1 -0
  22. package/es/esf/components/espace-prive/admin/link-row.js +29 -0
  23. package/es/esf/components/espace-prive/admin/link-row.module.css +59 -0
  24. package/es/esf/components/espace-prive/admin/mail-template.d.ts +2 -0
  25. package/es/esf/components/espace-prive/admin/mail-template.d.ts.map +1 -0
  26. package/es/esf/components/espace-prive/admin/mail-template.js +34 -0
  27. package/es/esf/components/espace-prive/admin/mail-template.module.css +33 -0
  28. package/es/esf/components/espace-prive/cart-link.d.ts +2 -0
  29. package/es/esf/components/espace-prive/cart-link.d.ts.map +1 -0
  30. package/es/esf/components/espace-prive/cart-link.js +14 -0
  31. package/es/esf/components/espace-prive/cart-link.module.css +2 -0
  32. package/es/esf/components/espace-prive/connexion.d.ts +4 -0
  33. package/es/esf/components/espace-prive/connexion.d.ts.map +1 -0
  34. package/es/esf/components/espace-prive/connexion.js +43 -0
  35. package/es/esf/components/espace-prive/connexion.module.css +79 -0
  36. package/es/esf/components/espace-prive/context.d.ts +6 -0
  37. package/es/esf/components/espace-prive/context.d.ts.map +1 -0
  38. package/es/esf/components/espace-prive/context.js +96 -0
  39. package/es/esf/components/espace-prive/custom-offers.d.ts +5 -0
  40. package/es/esf/components/espace-prive/custom-offers.d.ts.map +1 -0
  41. package/es/esf/components/espace-prive/custom-offers.js +8 -0
  42. package/es/esf/components/espace-prive/custom-offers.module.css +60 -0
  43. package/es/esf/components/espace-prive/discount-icon.svg +1 -0
  44. package/es/esf/components/espace-prive/index.d.ts +5 -0
  45. package/es/esf/components/espace-prive/index.d.ts.map +1 -0
  46. package/es/esf/components/espace-prive/index.js +6 -0
  47. package/es/esf/components/espace-prive/message.d.ts +6 -0
  48. package/es/esf/components/espace-prive/message.d.ts.map +1 -0
  49. package/es/esf/components/espace-prive/message.js +82 -0
  50. package/es/esf/components/espace-prive/panier.d.ts +2 -0
  51. package/es/esf/components/espace-prive/panier.d.ts.map +1 -0
  52. package/es/esf/components/espace-prive/panier.js +43 -0
  53. package/es/esf/components/espace-prive/partenaire.d.ts +6 -0
  54. package/es/esf/components/espace-prive/partenaire.d.ts.map +1 -0
  55. package/es/esf/components/espace-prive/partenaire.js +23 -0
  56. package/es/esf/components/espace-prive/partenaire.module.css +80 -0
  57. package/es/esf/components/espace-prive/services/config.d.ts +8 -0
  58. package/es/esf/components/espace-prive/services/config.d.ts.map +1 -0
  59. package/es/esf/components/espace-prive/services/config.js +76 -0
  60. package/es/esf/components/espace-prive/services/links.d.ts +5 -0
  61. package/es/esf/components/espace-prive/services/links.d.ts.map +1 -0
  62. package/es/esf/components/espace-prive/services/links.js +48 -0
  63. package/es/esf/components/espace-prive/services/mail.d.ts +2 -0
  64. package/es/esf/components/espace-prive/services/mail.d.ts.map +1 -0
  65. package/es/esf/components/espace-prive/services/mail.js +17 -0
  66. package/es/esf/components/espace-prive/tools.d.ts +4 -0
  67. package/es/esf/components/espace-prive/tools.d.ts.map +1 -0
  68. package/es/esf/components/espace-prive/tools.js +54 -0
  69. package/es/esf/components/espace-prive/tools.module.css +111 -0
  70. package/es/esf/components/espace-prive/tunnel.d.ts +2 -0
  71. package/es/esf/components/espace-prive/tunnel.d.ts.map +1 -0
  72. package/es/esf/components/espace-prive/tunnel.js +23 -0
  73. package/es/esf/components/espace-prive/utils/construct-link.d.ts +2 -0
  74. package/es/esf/components/espace-prive/utils/construct-link.d.ts.map +1 -0
  75. package/es/esf/components/espace-prive/utils/construct-link.js +3 -0
  76. package/es/esf/components/espace-prive/utils/path-includes-key.d.ts +2 -0
  77. package/es/esf/components/espace-prive/utils/path-includes-key.d.ts.map +1 -0
  78. package/es/esf/components/espace-prive/utils/path-includes-key.js +4 -0
  79. package/es/esf/components/espace-prive/utils/snackbar-message.d.ts +2 -0
  80. package/es/esf/components/espace-prive/utils/snackbar-message.d.ts.map +1 -0
  81. package/es/esf/components/espace-prive/utils/snackbar-message.js +14 -0
  82. package/package.json +1 -1
@@ -140,7 +140,7 @@ button.resetCenter:hover {
140
140
 
141
141
  .map :global(.leaflet-tooltip) {
142
142
  padding: 10px 16px;
143
- font-size: 16px;
143
+ font-size: 15px;
144
144
  font-weight: 700;
145
145
  font-family: inherit;
146
146
  text-shadow: -1px 0px 1px white, 0px -1px 1px white, 1px 0px 1px white,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/index.js"],"names":[],"mappings":"AAQA;;;gEAkFC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/index.js"],"names":[],"mappings":"AAQA;;;gEAgFC"}
@@ -40,13 +40,11 @@ export default function EditableMap({ iconSet = "esf", hideSlopes }) {
40
40
  }, 200);
41
41
  }, [lang, path, refreshKey]);
42
42
  React.useEffect(() => {
43
- if (formats.some((format) => format.isInZone)) {
44
- window.addEventListener("ublo-content-saved", reloadWindow);
45
- return () => {
46
- window.addEventListener("ublo-content-saved", reloadWindow);
47
- };
48
- }
49
- }, [formats]);
43
+ window.addEventListener("ublo-content-saved", refreshEditableMap);
44
+ return () => {
45
+ window.addEventListener("ublo-content-saved", refreshEditableMap);
46
+ };
47
+ }, []);
50
48
  React.useEffect(() => {
51
49
  const zones = Array.from(document.querySelectorAll(".cms"));
52
50
  zones.forEach((zone) => {
@@ -67,6 +65,3 @@ export default function EditableMap({ iconSet = "esf", hideSlopes }) {
67
65
  });
68
66
  return formats.map((format) => ReactDOM.createPortal(_jsx(Map, { format: format, iconSet: iconSet, hideSlopes: hideSlopes }), format.element));
69
67
  }
70
- function reloadWindow() {
71
- window.location.reload();
72
- }
@@ -0,0 +1,2 @@
1
+ export default function ClientLinks(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=client-links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-links.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/admin/client-links.js"],"names":[],"mappings":"AAUA,+EA2DC"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useUbloContext } from "ublo/with-ublo";
4
+ import * as Services from "../services/links";
5
+ import LinkRow from "./link-row";
6
+ import LinkForm from "./link-form";
7
+ import Config from "./config";
8
+ import Message from "../message";
9
+ import { useContext } from "../context";
10
+ import styles from "./client-links.module.css";
11
+ export default function ClientLinks() {
12
+ const { path, config } = useUbloContext();
13
+ const { domains } = config;
14
+ const { apiURL, partnerID, cmsToken } = useContext();
15
+ const relativeURL = `https://${domains.fr}${path}`;
16
+ const [links, setLinks] = React.useState([]);
17
+ const getExistingLinks = React.useCallback(async () => {
18
+ const existingLinks = await Services.getLinks(apiURL, partnerID, cmsToken);
19
+ setLinks(existingLinks);
20
+ }, [apiURL, partnerID, cmsToken]);
21
+ React.useEffect(() => {
22
+ getExistingLinks();
23
+ }, [getExistingLinks]);
24
+ const onDeleteLink = async (id) => {
25
+ try {
26
+ await Services.deleteLink(apiURL, id, cmsToken);
27
+ setLinks((prevState) => prevState.filter((link) => link.id !== id));
28
+ }
29
+ catch (e) {
30
+ console.error(e);
31
+ }
32
+ };
33
+ return (_jsxs("div", { className: styles.container, children: [links.length > 0 && (_jsxs("table", { className: styles.table, children: [_jsx("thead", { className: styles.head, children: _jsxs("tr", { children: [_jsx("th", { className: styles.cell, scope: "col", children: _jsx(Message, { id: "table-head-emails" }) }), _jsx("th", { className: styles.cell, scope: "col", children: _jsx(Message, { id: "table-head-links" }) }), _jsx("th", { className: styles.cell, scope: "col", children: _jsx(Message, { id: "table-head-actions" }) })] }) }), _jsx("tbody", { children: links.map((link, i) => (_jsx(LinkRow, { path: relativeURL, onDelete: () => onDeleteLink(link.id), ...link }, i))) })] })), _jsx(LinkForm, { path: relativeURL, getExistingLinks: getExistingLinks }), _jsx(Config, {})] }));
34
+ }
@@ -0,0 +1,42 @@
1
+ .container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 30px;
5
+ width: 100%;
6
+ min-width: 320px;
7
+ max-width: 1080px;
8
+ margin: 0 auto 20px auto;
9
+ }
10
+
11
+ .wrapper {
12
+ display: flex;
13
+ align-items: center;
14
+ gap: 15px;
15
+ }
16
+
17
+ .table {
18
+ display: block;
19
+ table-layout: fixed;
20
+ width: 100%;
21
+ margin-top: 20px;
22
+ border-collapse: collapse;
23
+ letter-spacing: 1px;
24
+ max-height: 400px;
25
+ overflow-y: auto;
26
+ }
27
+
28
+ .head {
29
+ position: sticky;
30
+ top: -1px;
31
+ background-color: var(--ds-grey-200, #ededed);
32
+ z-index: 2;
33
+ }
34
+
35
+ .cell {
36
+ padding: 8px 10px;
37
+ width: 100%;
38
+ }
39
+
40
+ .cell:last-of-type {
41
+ text-align: center;
42
+ }
@@ -0,0 +1,4 @@
1
+ export default function ConfigField({ isReplyTo }: {
2
+ isReplyTo: any;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=config-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-field.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/admin/config-field.js"],"names":[],"mappings":"AAYA;;4CAwEC"}
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useUbloContext } from "ublo/with-ublo";
4
+ import Input from "dt-design-system/es/input";
5
+ import Button from "dt-design-system/es/button";
6
+ import Loader from "dt-design-system/es/loader";
7
+ import { useSnackbar } from "dt-design-system/es/snackbar";
8
+ import Message, { message } from "../message";
9
+ import { snackbarMessage } from "../utils/snackbar-message";
10
+ import * as Services from "../services/config";
11
+ import { useContext } from "../context";
12
+ import styles from "./config-field.module.css";
13
+ export default function ConfigField({ isReplyTo }) {
14
+ const [isLoading, setIsLoading] = React.useState(false);
15
+ const { lang } = useUbloContext();
16
+ const { apiURL, site, partnerID, intermediary, setIntermediary, replyTo, setReplyTo, cmsToken, } = useContext();
17
+ const snackbar = useSnackbar();
18
+ const updateIntermediary = async (e) => {
19
+ e.preventDefault();
20
+ setIsLoading(true);
21
+ try {
22
+ const inputValue = e.target.elements[0].value;
23
+ if (!isReplyTo) {
24
+ await Services.setIntermediary(apiURL, site, partnerID, inputValue, cmsToken);
25
+ setIntermediary(inputValue);
26
+ }
27
+ else {
28
+ await Services.setReplyTo(apiURL, site, partnerID, inputValue, cmsToken);
29
+ setReplyTo(inputValue);
30
+ }
31
+ snackbarMessage(snackbar, lang, "snackbar-content-saved", "success");
32
+ }
33
+ catch (e) {
34
+ console.error(e);
35
+ snackbarMessage(snackbar, lang, "snackbar-error", "error");
36
+ }
37
+ setIsLoading(false);
38
+ };
39
+ const label = isReplyTo ? "label-reply-to-input" : "label-intermediary-input";
40
+ return (_jsxs("form", { className: styles.wrapper, onSubmit: updateIntermediary, children: [_jsx(Input, { type: "text", className: styles.input, label: message(lang, label), defaultValue: isReplyTo ? replyTo : intermediary, autoFocus: !isReplyTo, required: true }, isReplyTo ? replyTo : intermediary), _jsxs(Button, { type: "submit", className: styles.button, "data-loading": isLoading, disabled: isLoading, children: [_jsx(Message, { id: "button-modify" }), isLoading && _jsx(Loader, { className: styles.loader })] })] }));
41
+ }
@@ -0,0 +1,30 @@
1
+ .wrapper {
2
+ display: flex;
3
+ align-items: flex-end;
4
+ gap: 20px;
5
+ width: 100%;
6
+ }
7
+
8
+ .input {
9
+ min-width: 200px;
10
+ }
11
+
12
+ @media (min-width: 530px) {
13
+ .input {
14
+ min-width: 300px;
15
+ }
16
+ }
17
+
18
+ .input input {
19
+ background-color: var(--ds-grey-000, #fff);
20
+ }
21
+
22
+ .button[data-loading="true"] {
23
+ color: transparent;
24
+ }
25
+
26
+ .loader {
27
+ --ds-loader-spinner-size: 14px;
28
+ --ds-loader-thickness: 3px;
29
+ position: absolute;
30
+ }
@@ -0,0 +1,2 @@
1
+ export default function Config(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/admin/config.js"],"names":[],"mappings":"AASA,0EAkCC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import Button from "dt-design-system/es/button";
4
+ import Tooltip from "dt-design-system/es/tooltip";
5
+ import * as Icons from "dt-design-system/es/icons";
6
+ import ConfigField from "./config-field";
7
+ import MailTemplate from "./mail-template";
8
+ import Message from "../message";
9
+ import styles from "./config.module.css";
10
+ export default function Config() {
11
+ const [isOpened, setIsOpened] = React.useState(false);
12
+ const toggleOpened = () => {
13
+ setIsOpened((prev) => !prev);
14
+ };
15
+ const message = isOpened ? "hide-config" : "show-config";
16
+ return (_jsxs("div", { className: styles.config, "data-opened": isOpened, children: [_jsx("div", { className: styles.head, children: _jsx(Tooltip, { content: _jsx(Message, { id: message }), children: _jsxs(Button, { className: styles.button, variant: "transparent", onClick: toggleOpened, children: [_jsx("h1", { className: styles.title, children: "Configuration" }), _jsx(Icons.ChevronDown, {})] }) }) }), isOpened && (_jsxs(_Fragment, { children: [_jsx(ConfigField, {}), _jsx("div", { className: styles.divider }), _jsx(ConfigField, { isReplyTo: true }), _jsx("div", { className: styles.divider }), _jsx(MailTemplate, {})] }))] }));
17
+ }
@@ -0,0 +1,40 @@
1
+ .config {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 20px;
5
+ }
6
+
7
+ .head {
8
+ display: flex;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+ background-color: var(--ds-grey-000, #fff);
12
+ padding: 10px;
13
+ border-radius: var(--ds-radius-200, 4px);
14
+ }
15
+
16
+ .title {
17
+ font-size: 24px;
18
+ font-weight: 600;
19
+ }
20
+ .button {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: space-between;
24
+ width: 100%;
25
+ }
26
+
27
+ .button svg {
28
+ width: 20px;
29
+ height: 20px;
30
+ transition: transform 240ms;
31
+ }
32
+
33
+ .config[data-opened="true"] .button svg {
34
+ transform: rotate(-180deg);
35
+ }
36
+
37
+ .divider {
38
+ height: 1px;
39
+ background-color: var(--ds-grey-200, #e0e0e0);
40
+ }
@@ -0,0 +1,5 @@
1
+ export default function LinkForm({ path, getExistingLinks }: {
2
+ path: any;
3
+ getExistingLinks: any;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=link-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-form.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/admin/link-form.js"],"names":[],"mappings":"AAoBA;;;4CAqKC"}
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import getConfig from "next/config";
4
+ import { useUbloContext } from "ublo/with-ublo";
5
+ import Button from "dt-design-system/es/button";
6
+ import Checkbox from "dt-design-system/es/checkbox";
7
+ import TextArea from "dt-design-system/es/textarea";
8
+ import Dialog from "dt-design-system/es/dialog";
9
+ import Loader from "dt-design-system/es/loader";
10
+ import { useSnackbar } from "dt-design-system/es/snackbar";
11
+ import { snackbarMessage } from "../utils/snackbar-message";
12
+ import Message, { message } from "../message";
13
+ import { constructLink } from "../utils/construct-link";
14
+ import { useContext } from "../context";
15
+ import * as Services from "../services/links";
16
+ import * as Mails from "../services/mail";
17
+ import styles from "./link-form.module.css";
18
+ const { publicRuntimeConfig } = getConfig();
19
+ const { siteName } = publicRuntimeConfig;
20
+ export default function LinkForm({ path, getExistingLinks }) {
21
+ const formRef = React.useRef(null);
22
+ const mailRef = React.useRef(null);
23
+ const templateRef = React.useRef(null);
24
+ const checkRef = React.useRef(null);
25
+ const snackbar = useSnackbar();
26
+ const { lang, site } = useUbloContext();
27
+ const { apiURL, partnerID, cmsToken, replyTo, mailTemplate } = useContext();
28
+ const [isDialogOpen, setIsDialogOpen] = React.useState(false);
29
+ const [isLoading, setIsLoading] = React.useState(false);
30
+ const onSubmit = (e) => {
31
+ const checked = checkRef.current?.firstChild?.checked;
32
+ const mailInput = mailRef.current?.querySelector("textarea");
33
+ const template = templateRef.current?.querySelector("textarea")?.value;
34
+ e.preventDefault();
35
+ const mails = mailInput?.value
36
+ .split("\n")
37
+ .map((mail) => mail.trim())
38
+ .filter(Boolean);
39
+ if (!checkMailsPattern(mails)) {
40
+ snackbarMessage(snackbar, lang, "mail-pattern-error", "error");
41
+ setIsLoading(false);
42
+ return;
43
+ }
44
+ if (checked && !isDialogOpen) {
45
+ setIsDialogOpen(true);
46
+ }
47
+ else {
48
+ submitForm(mails, checked, template, mailInput);
49
+ }
50
+ };
51
+ const closeDialog = () => setIsDialogOpen(false);
52
+ const submitForm = async (mails, checked, template, mailInput) => {
53
+ setIsLoading(true);
54
+ const chunckSize = 30;
55
+ const chunks = [];
56
+ for (let i = 0; i < mails.length; i += chunckSize) {
57
+ chunks.push(mails.slice(i, i + chunckSize));
58
+ }
59
+ const errors = [];
60
+ for (const chunk of chunks) {
61
+ await Promise.all(chunk.map(async (mail) => {
62
+ try {
63
+ const hash = await Services.createLink(apiURL, mail, partnerID, site, cmsToken);
64
+ if (hash && checked) {
65
+ const link = constructLink(path, hash);
66
+ const mailSent = await Mails.sendMail(apiURL, siteName, mail, replyTo, template, link, cmsToken);
67
+ snackbarMessage(snackbar, lang, "snackbar-links-sent", "success");
68
+ return mailSent;
69
+ }
70
+ else {
71
+ snackbarMessage(snackbar, lang, "snackbar-links-created", "success");
72
+ return hash;
73
+ }
74
+ }
75
+ catch (e) {
76
+ console.error(`Failed to create link for ${mail}:`, e);
77
+ errors.push({ mail, error: e });
78
+ return null;
79
+ }
80
+ }));
81
+ }
82
+ if (errors.length > 0) {
83
+ console.error("Some problems were encountered:", errors);
84
+ snackbarMessage(snackbar, lang, "snackbar-links-error", "error");
85
+ }
86
+ mailInput.value = "";
87
+ setIsLoading(false);
88
+ getExistingLinks();
89
+ if (checked)
90
+ closeDialog();
91
+ };
92
+ return (_jsxs("form", { ref: formRef, className: styles.wrapper, onSubmit: onSubmit, children: [_jsx(TextArea, { ref: mailRef, type: "email", autoFocus: true, className: styles.input, label: message(lang, "link-textarea-label"), placeholder: message(lang, "link-input-placeholder"), required: true }), _jsxs("div", { className: styles.buttons, children: [_jsx(Checkbox, { ref: checkRef, className: styles.checkbox, label: message(lang, "send-email"), defaultChecked: true }), _jsxs(Button, { className: styles.button, type: "submit", disabled: isLoading, "data-loading": isLoading, children: [_jsx(Message, { id: "links-form-submit" }), isLoading && _jsx(Loader, { className: styles.loader })] })] }), _jsxs(Dialog, { className: styles.dialog, isOpened: isDialogOpen, close: closeDialog, showAsModal: false, children: [_jsx(Message, { id: "mail-text" }), _jsx(TextArea, { ref: templateRef, type: "text", autoFocus: true, className: styles.text, defaultValue: mailTemplate, required: true }), _jsxs("div", { className: styles.buttons, children: [_jsx(Button, { variant: "secondary", onClick: closeDialog, children: _jsx(Message, { id: "cancel-button" }) }), _jsxs(Button, { className: styles.button, variant: "success", onClick: onSubmit, disabled: isLoading, "data-loading": isLoading, children: [_jsx(Message, { id: "send-mail-button" }), isLoading && _jsx(Loader, { className: styles.loader })] })] })] })] }));
93
+ }
94
+ function checkMailsPattern(mails) {
95
+ const pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
96
+ return mails.every((mail) => pattern.test(mail.trim()));
97
+ }
@@ -0,0 +1,60 @@
1
+ .wrapper {
2
+ width: 100%;
3
+ display: flex;
4
+ align-items: flex-end;
5
+ justify-content: space-between;
6
+ gap: 10px;
7
+ }
8
+
9
+ .input {
10
+ --ds-input-background: var(--ds-grey-000, #fff);
11
+ flex: 1 1 400px;
12
+ }
13
+
14
+ .input textarea {
15
+ max-width: 500px;
16
+ }
17
+
18
+ .buttons {
19
+ display: flex;
20
+ align-items: center;
21
+ gap: 20px;
22
+ }
23
+
24
+ /* .checkbox {
25
+ min-width: 120px;
26
+ } */
27
+
28
+ .button[data-loading="true"] {
29
+ color: transparent;
30
+ }
31
+
32
+ .loader {
33
+ --ds-loader-spinner-size: 14px;
34
+ --ds-loader-thickness: 3px;
35
+ position: absolute;
36
+ }
37
+
38
+ .dialog {
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: 20px;
42
+ width: 1000px;
43
+ height: 500px;
44
+ padding: 20px;
45
+ }
46
+
47
+ .text {
48
+ /* --ds-input-background: var(--ds-grey-000, #fff); */
49
+ }
50
+
51
+ .text textarea {
52
+ min-height: 330px;
53
+ }
54
+
55
+ .buttons {
56
+ margin-left: auto;
57
+ display: flex;
58
+ align-items: center;
59
+ gap: 10px;
60
+ }
@@ -0,0 +1,7 @@
1
+ export default function LinkRow({ path, email, hash, onDelete }: {
2
+ path: any;
3
+ email: any;
4
+ hash: any;
5
+ onDelete: any;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=link-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-row.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/admin/link-row.js"],"names":[],"mappings":"AAUA;;;;;4CAqEC"}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useUbloContext } from "ublo/with-ublo";
4
+ import Tooltip from "dt-design-system/es/tooltip";
5
+ import Button from "dt-design-system/es/button";
6
+ import Dialog from "dt-design-system/es/dialog";
7
+ import * as Icons from "dt-design-system/es/icons";
8
+ import Message, { message } from "../message";
9
+ import { constructLink } from "../utils/construct-link";
10
+ import styles from "./link-row.module.css";
11
+ export default function LinkRow({ path, email, hash, onDelete }) {
12
+ const { lang } = useUbloContext();
13
+ const [isDialogOpen, setIsDialogOpen] = React.useState(false);
14
+ const [copySuccess, setCopySuccess] = React.useState(false);
15
+ const link = constructLink(path, hash);
16
+ const copyLink = () => {
17
+ navigator.clipboard.writeText(link);
18
+ setCopySuccess(true);
19
+ setTimeout(() => {
20
+ setCopySuccess(false);
21
+ }, 1000);
22
+ };
23
+ const toggleDialog = () => setIsDialogOpen((prevState) => !prevState);
24
+ const confirmDelete = async () => {
25
+ await onDelete();
26
+ toggleDialog();
27
+ };
28
+ return (_jsxs("tr", { className: styles.row, children: [_jsx("th", { className: styles.cell, scope: "row", children: email }), _jsx("td", { className: styles.cell, children: _jsxs("div", { className: styles.linkWrapper, children: [_jsx("span", { className: styles.linkText, children: link }), _jsx(Tooltip, { content: message(lang, "hover-copy-button"), children: _jsx(Button, { variant: copySuccess ? "success" : "transparent", onClick: copyLink, children: copySuccess ? _jsx(Icons.Check, {}) : _jsx(Icons.Copy, {}) }) })] }) }), _jsx("td", { className: styles.cell, children: _jsx(Tooltip, { content: message(lang, "delete-button"), children: _jsx(Button, { className: styles.button, variant: "danger", onClick: toggleDialog, children: _jsx(Icons.Trash, {}) }) }) }), _jsxs(Dialog, { className: styles.dialog, isOpened: isDialogOpen, close: toggleDialog, showCloseButton: false, showAsModal: false, children: [_jsx(Message, { id: "confirm-delete-link" }), _jsxs("div", { className: styles.buttons, children: [_jsx(Button, { variant: "secondary", onClick: toggleDialog, children: _jsx(Message, { id: "cancel-button" }) }), _jsx(Button, { variant: "danger", onClick: confirmDelete, children: _jsx(Message, { id: "delete-button" }) })] })] })] }));
29
+ }
@@ -0,0 +1,59 @@
1
+ .linkWrapper {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 10px;
5
+ width: 100%;
6
+ max-width: 100%;
7
+ max-width: 650px;
8
+ white-space: nowrap;
9
+ overflow: hidden;
10
+ margin: 0 auto;
11
+ }
12
+
13
+ .linkText {
14
+ display: inline-block;
15
+ width: 100%;
16
+ overflow: hidden;
17
+ text-overflow: ellipsis;
18
+ }
19
+
20
+ .cell {
21
+ padding: 8px 10px;
22
+ width: 100%;
23
+ }
24
+
25
+ .cell:last-of-type {
26
+ text-align: center;
27
+ }
28
+
29
+ .row:nth-of-type(odd) {
30
+ background-color: var(--ds-grey-000, #fff);
31
+ }
32
+
33
+ .row > svg {
34
+ width: 20px;
35
+ height: 20px;
36
+ cursor: pointer;
37
+ }
38
+
39
+ .button {
40
+ margin: 0 auto;
41
+ }
42
+
43
+ .dialog {
44
+ display: flex;
45
+ flex-direction: column;
46
+ align-items: center;
47
+ justify-content: center;
48
+ gap: 20px;
49
+ width: 400px;
50
+ height: 200px;
51
+ padding: 20px;
52
+ }
53
+
54
+ .buttons {
55
+ display: flex;
56
+ align-items: center;
57
+ gap: 20px;
58
+ margin-left: auto;
59
+ }
@@ -0,0 +1,2 @@
1
+ export default function MailTemplate(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=mail-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mail-template.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/espace-prive/admin/mail-template.js"],"names":[],"mappings":"AAYA,gFA+CC"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { useUbloContext } from "ublo/with-ublo";
4
+ import TextArea from "dt-design-system/es/textarea";
5
+ import { useSnackbar } from "dt-design-system/es/snackbar";
6
+ import Loader from "dt-design-system/es/loader";
7
+ import Button from "dt-design-system/es/button";
8
+ import Message, { message } from "../message";
9
+ import * as Config from "../services/config";
10
+ import { useContext } from "../context";
11
+ import { snackbarMessage } from "../utils/snackbar-message";
12
+ import styles from "./mail-template.module.css";
13
+ export default function MailTemplate() {
14
+ const snackbar = useSnackbar();
15
+ const [isLoading, setIsLoading] = React.useState(false);
16
+ const { lang } = useUbloContext();
17
+ const { apiURL, cmsToken, site, partnerID, mailTemplate, setMailTemplate } = useContext();
18
+ const modifyTemplate = async (e) => {
19
+ e.preventDefault();
20
+ const text = e.target[0].value;
21
+ setIsLoading(true);
22
+ try {
23
+ await Config.setMailTemplate(apiURL, site, partnerID, text, cmsToken);
24
+ snackbarMessage(snackbar, lang, "snackbar-content-saved", "success");
25
+ setMailTemplate(text);
26
+ }
27
+ catch (error) {
28
+ console.error(error);
29
+ snackbarMessage(snackbar, lang, "snackbar-error", "error");
30
+ }
31
+ setIsLoading(false);
32
+ };
33
+ return (_jsxs("form", { className: styles.form, onSubmit: modifyTemplate, children: [_jsx(TextArea, { type: "text", className: styles.text, label: _jsx(Message, { id: "mail-template-label" }), placeholder: mailTemplate, defaultValue: mailTemplate || message(lang, "mail-template-placeholder"), required: true }, mailTemplate), _jsxs(Button, { className: styles.button, variant: "primary", "data-loading": isLoading, type: "submit", children: [_jsx(Message, { id: "button-modify" }), isLoading && _jsx(Loader, { className: styles.loader })] })] }));
34
+ }
@@ -0,0 +1,33 @@
1
+ .form {
2
+ display: flex;
3
+ align-items: flex-end;
4
+ justify-content: space-between;
5
+ }
6
+
7
+ .text textarea {
8
+ min-width: 200px;
9
+ min-height: 200px;
10
+ background-color: var(--ds-grey-000, #fff);
11
+ }
12
+
13
+ @media (min-width: 530px) {
14
+ .text textarea {
15
+ min-width: 400px;
16
+ }
17
+ }
18
+
19
+ @media (min-width: 992px) {
20
+ .text textarea {
21
+ min-width: 800px;
22
+ }
23
+ }
24
+
25
+ .button[data-loading="true"] {
26
+ color: transparent;
27
+ }
28
+
29
+ .loader {
30
+ --ds-loader-spinner-size: 14px;
31
+ --ds-loader-thickness: 3px;
32
+ position: absolute;
33
+ }
@@ -0,0 +1,2 @@
1
+ export default function CartLink(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=cart-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart-link.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/espace-prive/cart-link.js"],"names":[],"mappings":"AAQA,4EAaC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import Link from "ublo/link";
3
+ import * as Icons from "dt-design-system/es/icons";
4
+ import Tooltip from "dt-design-system/es/tooltip";
5
+ import { useUbloContext } from "ublo/with-ublo";
6
+ import { message } from "./message";
7
+ import { useContext } from "./context";
8
+ import styles from "./cart-link.module.css";
9
+ export default function CartLink() {
10
+ const { lang } = useUbloContext();
11
+ const { partnerID } = useContext();
12
+ const href = `/espace-prive/${partnerID}/panier`;
13
+ return (_jsx(Tooltip, { content: message(lang, "go-to-cart"), children: _jsx(Link, { href: href, className: styles.link, children: _jsx(Icons.ShoppingCart, {}) }) }));
14
+ }