@kb0912/notification-brevo 2.0.3 → 2.0.4

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.
@@ -145,69 +145,6 @@ const config$1 = adminSdk.defineRouteConfig({
145
145
  label: "Email Analytics",
146
146
  icon: icons.ChartBar
147
147
  });
148
- const MultiSelectModal = ({
149
- title,
150
- options,
151
- selected,
152
- onClose,
153
- onSave
154
- }) => {
155
- const [search, setSearch] = react.useState("");
156
- const [checked, setChecked] = react.useState(new Set(selected));
157
- const filtered = options.filter(
158
- (o) => o.label.toLowerCase().includes(search.toLowerCase()) || o.value.toLowerCase().includes(search.toLowerCase())
159
- );
160
- const toggle = (val) => {
161
- setChecked((prev) => {
162
- const next = new Set(prev);
163
- next.has(val) ? next.delete(val) : next.add(val);
164
- return next;
165
- });
166
- };
167
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-2xl w-[420px] max-h-[520px] flex flex-col", onClick: (e) => e.stopPropagation(), children: [
168
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4 border-b", children: [
169
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "font-semibold text-base", children: title }),
170
- /* @__PURE__ */ jsxRuntime.jsx(
171
- ui.Input,
172
- {
173
- className: "mt-2",
174
- placeholder: "Search...",
175
- value: search,
176
- onChange: (e) => setSearch(e.target.value)
177
- }
178
- )
179
- ] }),
180
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 overflow-y-auto px-5 py-3", children: [
181
- filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle text-sm", children: "No results" }),
182
- filtered.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-3 py-1.5 cursor-pointer hover:bg-ui-bg-base-hover rounded px-2 -mx-2", children: [
183
- /* @__PURE__ */ jsxRuntime.jsx(
184
- "input",
185
- {
186
- type: "checkbox",
187
- className: "accent-ui-fg-interactive w-4 h-4",
188
- checked: checked.has(opt.value),
189
- onChange: () => toggle(opt.value)
190
- }
191
- ),
192
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: opt.label }),
193
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-ui-fg-subtle font-mono ml-auto", children: opt.value.toUpperCase() })
194
- ] }, opt.value))
195
- ] }),
196
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-3 border-t flex items-center justify-between", children: [
197
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "text-xs text-ui-fg-subtle", children: [
198
- checked.size,
199
- " selected"
200
- ] }),
201
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
202
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", onClick: onClose, children: "Cancel" }),
203
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", onClick: () => {
204
- onSave(Array.from(checked));
205
- onClose();
206
- }, children: "Apply" })
207
- ] })
208
- ] })
209
- ] }) });
210
- };
211
148
  const BrevoSettingsPage = () => {
212
149
  const [settings, setSettings] = react.useState(null);
213
150
  const [loading, setLoading] = react.useState(true);
@@ -216,6 +153,7 @@ const BrevoSettingsPage = () => {
216
153
  const [currencies, setCurrencies] = react.useState([]);
217
154
  const [countries, setCountries] = react.useState([]);
218
155
  const [modal, setModal] = react.useState(null);
156
+ const [drawerSearch, setDrawerSearch] = react.useState("");
219
157
  react.useEffect(() => {
220
158
  Promise.all([
221
159
  fetch("/admin/brevo-plugin-settings", { credentials: "include" }).then((r) => r.json()),
@@ -1040,16 +978,66 @@ const BrevoSettingsPage = () => {
1040
978
  ] })
1041
979
  ] })
1042
980
  ] }) }),
1043
- modal && settings && /* @__PURE__ */ jsxRuntime.jsx(
1044
- MultiSelectModal,
1045
- {
1046
- title: modal.title,
1047
- options: modal.options,
1048
- selected: settings[modal.key] || [],
1049
- onClose: () => setModal(null),
1050
- onSave: (values) => update(modal.key, values)
981
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer, { open: !!modal, onOpenChange: (open) => {
982
+ if (!open) {
983
+ setModal(null);
984
+ setDrawerSearch("");
1051
985
  }
1052
- )
986
+ }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Drawer.Content, { children: [
987
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Title, { children: (modal == null ? void 0 : modal.title) || "" }) }),
988
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Body, { className: "overflow-y-auto", children: modal && (() => {
989
+ const [search, setSearch] = [drawerSearch, setDrawerSearch];
990
+ const currentSelected = new Set((settings == null ? void 0 : settings[modal.key]) || []);
991
+ const filtered = modal.options.filter(
992
+ (o) => o.label.toLowerCase().includes(search.toLowerCase()) || o.value.toLowerCase().includes(search.toLowerCase())
993
+ );
994
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
995
+ /* @__PURE__ */ jsxRuntime.jsx(
996
+ ui.Input,
997
+ {
998
+ placeholder: "Search...",
999
+ value: search,
1000
+ onChange: (e) => setSearch(e.target.value)
1001
+ }
1002
+ ),
1003
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-0.5", children: [
1004
+ filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle text-sm py-4 text-center", children: "No results" }),
1005
+ filtered.map((opt) => {
1006
+ const isChecked = currentSelected.has(opt.value);
1007
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1008
+ "label",
1009
+ {
1010
+ className: "flex items-center gap-3 py-2 px-3 cursor-pointer hover:bg-ui-bg-base-hover rounded-lg",
1011
+ children: [
1012
+ /* @__PURE__ */ jsxRuntime.jsx(
1013
+ ui.Checkbox,
1014
+ {
1015
+ checked: isChecked,
1016
+ onCheckedChange: () => {
1017
+ const arr = (settings == null ? void 0 : settings[modal.key]) || [];
1018
+ const next = isChecked ? arr.filter((c) => c !== opt.value) : [...arr, opt.value];
1019
+ update(modal.key, next);
1020
+ }
1021
+ }
1022
+ ),
1023
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm flex-1", children: opt.label }),
1024
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-ui-fg-subtle font-mono", children: opt.value.toUpperCase() })
1025
+ ]
1026
+ },
1027
+ opt.value
1028
+ );
1029
+ })
1030
+ ] })
1031
+ ] });
1032
+ })() }),
1033
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Drawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full", children: [
1034
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "text-xs text-ui-fg-subtle", children: [
1035
+ ((settings == null ? void 0 : settings[(modal == null ? void 0 : modal.key) || ""]) || []).length,
1036
+ " selected"
1037
+ ] }),
1038
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", onClick: () => setModal(null), children: "Done" })
1039
+ ] }) })
1040
+ ] }) })
1053
1041
  ] });
1054
1042
  };
1055
1043
  const config = adminSdk.defineRouteConfig({
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { defineRouteConfig } from "@medusajs/admin-sdk";
3
- import { Container, Text, Heading, Badge, Table, toast, Toaster, Button, Label, Input, Switch, Select } from "@medusajs/ui";
3
+ import { Container, Text, Heading, Badge, Table, toast, Toaster, Button, Label, Input, Switch, Select, Drawer, Checkbox } from "@medusajs/ui";
4
4
  import { ChartBar, EnvelopeSolid } from "@medusajs/icons";
5
5
  import { useState, useEffect } from "react";
6
6
  const EVENT_LABELS = {
@@ -144,69 +144,6 @@ const config$1 = defineRouteConfig({
144
144
  label: "Email Analytics",
145
145
  icon: ChartBar
146
146
  });
147
- const MultiSelectModal = ({
148
- title,
149
- options,
150
- selected,
151
- onClose,
152
- onSave
153
- }) => {
154
- const [search, setSearch] = useState("");
155
- const [checked, setChecked] = useState(new Set(selected));
156
- const filtered = options.filter(
157
- (o) => o.label.toLowerCase().includes(search.toLowerCase()) || o.value.toLowerCase().includes(search.toLowerCase())
158
- );
159
- const toggle = (val) => {
160
- setChecked((prev) => {
161
- const next = new Set(prev);
162
- next.has(val) ? next.delete(val) : next.add(val);
163
- return next;
164
- });
165
- };
166
- return /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40", onClick: onClose, children: /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-2xl w-[420px] max-h-[520px] flex flex-col", onClick: (e) => e.stopPropagation(), children: [
167
- /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 border-b", children: [
168
- /* @__PURE__ */ jsx(Text, { className: "font-semibold text-base", children: title }),
169
- /* @__PURE__ */ jsx(
170
- Input,
171
- {
172
- className: "mt-2",
173
- placeholder: "Search...",
174
- value: search,
175
- onChange: (e) => setSearch(e.target.value)
176
- }
177
- )
178
- ] }),
179
- /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto px-5 py-3", children: [
180
- filtered.length === 0 && /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: "No results" }),
181
- filtered.map((opt) => /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-3 py-1.5 cursor-pointer hover:bg-ui-bg-base-hover rounded px-2 -mx-2", children: [
182
- /* @__PURE__ */ jsx(
183
- "input",
184
- {
185
- type: "checkbox",
186
- className: "accent-ui-fg-interactive w-4 h-4",
187
- checked: checked.has(opt.value),
188
- onChange: () => toggle(opt.value)
189
- }
190
- ),
191
- /* @__PURE__ */ jsx("span", { className: "text-sm", children: opt.label }),
192
- /* @__PURE__ */ jsx("span", { className: "text-xs text-ui-fg-subtle font-mono ml-auto", children: opt.value.toUpperCase() })
193
- ] }, opt.value))
194
- ] }),
195
- /* @__PURE__ */ jsxs("div", { className: "px-5 py-3 border-t flex items-center justify-between", children: [
196
- /* @__PURE__ */ jsxs(Text, { className: "text-xs text-ui-fg-subtle", children: [
197
- checked.size,
198
- " selected"
199
- ] }),
200
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
201
- /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: onClose, children: "Cancel" }),
202
- /* @__PURE__ */ jsx(Button, { size: "small", onClick: () => {
203
- onSave(Array.from(checked));
204
- onClose();
205
- }, children: "Apply" })
206
- ] })
207
- ] })
208
- ] }) });
209
- };
210
147
  const BrevoSettingsPage = () => {
211
148
  const [settings, setSettings] = useState(null);
212
149
  const [loading, setLoading] = useState(true);
@@ -215,6 +152,7 @@ const BrevoSettingsPage = () => {
215
152
  const [currencies, setCurrencies] = useState([]);
216
153
  const [countries, setCountries] = useState([]);
217
154
  const [modal, setModal] = useState(null);
155
+ const [drawerSearch, setDrawerSearch] = useState("");
218
156
  useEffect(() => {
219
157
  Promise.all([
220
158
  fetch("/admin/brevo-plugin-settings", { credentials: "include" }).then((r) => r.json()),
@@ -1039,16 +977,66 @@ const BrevoSettingsPage = () => {
1039
977
  ] })
1040
978
  ] })
1041
979
  ] }) }),
1042
- modal && settings && /* @__PURE__ */ jsx(
1043
- MultiSelectModal,
1044
- {
1045
- title: modal.title,
1046
- options: modal.options,
1047
- selected: settings[modal.key] || [],
1048
- onClose: () => setModal(null),
1049
- onSave: (values) => update(modal.key, values)
980
+ /* @__PURE__ */ jsx(Drawer, { open: !!modal, onOpenChange: (open) => {
981
+ if (!open) {
982
+ setModal(null);
983
+ setDrawerSearch("");
1050
984
  }
1051
- )
985
+ }, children: /* @__PURE__ */ jsxs(Drawer.Content, { children: [
986
+ /* @__PURE__ */ jsx(Drawer.Header, { children: /* @__PURE__ */ jsx(Drawer.Title, { children: (modal == null ? void 0 : modal.title) || "" }) }),
987
+ /* @__PURE__ */ jsx(Drawer.Body, { className: "overflow-y-auto", children: modal && (() => {
988
+ const [search, setSearch] = [drawerSearch, setDrawerSearch];
989
+ const currentSelected = new Set((settings == null ? void 0 : settings[modal.key]) || []);
990
+ const filtered = modal.options.filter(
991
+ (o) => o.label.toLowerCase().includes(search.toLowerCase()) || o.value.toLowerCase().includes(search.toLowerCase())
992
+ );
993
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
994
+ /* @__PURE__ */ jsx(
995
+ Input,
996
+ {
997
+ placeholder: "Search...",
998
+ value: search,
999
+ onChange: (e) => setSearch(e.target.value)
1000
+ }
1001
+ ),
1002
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 space-y-0.5", children: [
1003
+ filtered.length === 0 && /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm py-4 text-center", children: "No results" }),
1004
+ filtered.map((opt) => {
1005
+ const isChecked = currentSelected.has(opt.value);
1006
+ return /* @__PURE__ */ jsxs(
1007
+ "label",
1008
+ {
1009
+ className: "flex items-center gap-3 py-2 px-3 cursor-pointer hover:bg-ui-bg-base-hover rounded-lg",
1010
+ children: [
1011
+ /* @__PURE__ */ jsx(
1012
+ Checkbox,
1013
+ {
1014
+ checked: isChecked,
1015
+ onCheckedChange: () => {
1016
+ const arr = (settings == null ? void 0 : settings[modal.key]) || [];
1017
+ const next = isChecked ? arr.filter((c) => c !== opt.value) : [...arr, opt.value];
1018
+ update(modal.key, next);
1019
+ }
1020
+ }
1021
+ ),
1022
+ /* @__PURE__ */ jsx("span", { className: "text-sm flex-1", children: opt.label }),
1023
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-ui-fg-subtle font-mono", children: opt.value.toUpperCase() })
1024
+ ]
1025
+ },
1026
+ opt.value
1027
+ );
1028
+ })
1029
+ ] })
1030
+ ] });
1031
+ })() }),
1032
+ /* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full", children: [
1033
+ /* @__PURE__ */ jsxs(Text, { className: "text-xs text-ui-fg-subtle", children: [
1034
+ ((settings == null ? void 0 : settings[(modal == null ? void 0 : modal.key) || ""]) || []).length,
1035
+ " selected"
1036
+ ] }),
1037
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", onClick: () => setModal(null), children: "Done" })
1038
+ ] }) })
1039
+ ] }) })
1052
1040
  ] });
1053
1041
  };
1054
1042
  const config = defineRouteConfig({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kb0912/notification-brevo",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Sending email notification using Brevo.",
5
5
  "author": "KB (https://medusajs.com)",
6
6
  "license": "MIT",