@inspirer-dev/crm-dashboard 1.0.9 → 1.0.11

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.
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const DEFAULT_CONFIG = {
7
+ type: "event_based",
8
+ eventName: "",
9
+ delayValue: 10,
10
+ delayUnit: "minutes",
11
+ scheduleType: "daily",
12
+ scheduleTime: "12:00",
13
+ scheduleDays: [1, 2, 3, 4, 5],
14
+ scheduleCron: "0 12 * * *"
15
+ };
16
+ const WEEKDAYS = [
17
+ { value: 0, label: "Sun" },
18
+ { value: 1, label: "Mon" },
19
+ { value: 2, label: "Tue" },
20
+ { value: 3, label: "Wed" },
21
+ { value: 4, label: "Thu" },
22
+ { value: 5, label: "Fri" },
23
+ { value: 6, label: "Sat" }
24
+ ];
25
+ const parseConfig = (value) => {
26
+ if (!value) return DEFAULT_CONFIG;
27
+ try {
28
+ const parsed = JSON.parse(value);
29
+ return {
30
+ type: parsed.type || "event_based",
31
+ eventName: parsed.eventName || "",
32
+ delayValue: parsed.delayValue ?? 10,
33
+ delayUnit: parsed.delayUnit || "minutes",
34
+ scheduleType: parsed.scheduleType || "daily",
35
+ scheduleTime: parsed.scheduleTime || "12:00",
36
+ scheduleDays: parsed.scheduleDays || [1, 2, 3, 4, 5],
37
+ scheduleCron: parsed.scheduleCron || "0 12 * * *"
38
+ };
39
+ } catch {
40
+ return DEFAULT_CONFIG;
41
+ }
42
+ };
43
+ const serializeConfig = (config) => {
44
+ return JSON.stringify(config);
45
+ };
46
+ const TriggerConfigField = React.forwardRef(
47
+ ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
48
+ const [config, setConfig] = React.useState(() => parseConfig(value));
49
+ React.useEffect(() => {
50
+ const parsed = parseConfig(value);
51
+ setConfig(parsed);
52
+ }, [value]);
53
+ const handleUpdate = (updates) => {
54
+ const newConfig = { ...config, ...updates };
55
+ setConfig(newConfig);
56
+ onChange({
57
+ target: {
58
+ name,
59
+ value: serializeConfig(newConfig)
60
+ }
61
+ });
62
+ };
63
+ const toggleDay = (day) => {
64
+ const days = config.scheduleDays || [];
65
+ const newDays = days.includes(day) ? days.filter((d) => d !== day) : [...days, day].sort((a, b) => a - b);
66
+ handleUpdate({ scheduleDays: newDays });
67
+ };
68
+ const isEventBased = config.type === "event_based";
69
+ const isDbBased = config.type === "db_based";
70
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { name, error, required, hint, ref, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
71
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: intlLabel?.defaultMessage || "Trigger Configuration" }),
72
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
73
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { marginBottom: "8px", display: "block" }, children: "Campaign Type" }),
74
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
75
+ /* @__PURE__ */ jsxRuntime.jsxs(
76
+ designSystem.Box,
77
+ {
78
+ padding: 3,
79
+ background: isEventBased ? "primary100" : "neutral100",
80
+ hasRadius: true,
81
+ style: {
82
+ cursor: disabled ? "not-allowed" : "pointer",
83
+ border: `2px solid ${isEventBased ? "#4945ff" : "#dcdce4"}`,
84
+ flex: 1,
85
+ textAlign: "center"
86
+ },
87
+ onClick: () => !disabled && handleUpdate({ type: "event_based" }),
88
+ children: [
89
+ /* @__PURE__ */ jsxRuntime.jsx(
90
+ designSystem.Typography,
91
+ {
92
+ variant: "omega",
93
+ fontWeight: isEventBased ? "bold" : "regular",
94
+ textColor: isEventBased ? "primary600" : "neutral600",
95
+ children: "Event-Based"
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Fires on user action" })
99
+ ]
100
+ }
101
+ ),
102
+ /* @__PURE__ */ jsxRuntime.jsxs(
103
+ designSystem.Box,
104
+ {
105
+ padding: 3,
106
+ background: isDbBased ? "primary100" : "neutral100",
107
+ hasRadius: true,
108
+ style: {
109
+ cursor: disabled ? "not-allowed" : "pointer",
110
+ border: `2px solid ${isDbBased ? "#4945ff" : "#dcdce4"}`,
111
+ flex: 1,
112
+ textAlign: "center"
113
+ },
114
+ onClick: () => !disabled && handleUpdate({ type: "db_based" }),
115
+ children: [
116
+ /* @__PURE__ */ jsxRuntime.jsx(
117
+ designSystem.Typography,
118
+ {
119
+ variant: "omega",
120
+ fontWeight: isDbBased ? "bold" : "regular",
121
+ textColor: isDbBased ? "primary600" : "neutral600",
122
+ children: "DB-Based (Scheduled)"
123
+ }
124
+ ),
125
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", children: "Runs on schedule" })
126
+ ]
127
+ }
128
+ )
129
+ ] })
130
+ ] }),
131
+ isEventBased && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { background: "neutral100", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 4, padding: 4, children: [
132
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", children: "Event Configuration" }),
133
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: `${name}-eventName`, children: [
134
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Event Name" }),
135
+ /* @__PURE__ */ jsxRuntime.jsx(
136
+ designSystem.TextInput,
137
+ {
138
+ placeholder: "e.g., gg-case-deposit",
139
+ value: config.eventName || "",
140
+ onChange: (e) => handleUpdate({ eventName: e.target.value }),
141
+ disabled
142
+ }
143
+ ),
144
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: "The event that triggers this campaign (e.g., gg-case-deposit, gg-deposit-suggestion-selected)" })
145
+ ] }),
146
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
147
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral800", style: { marginBottom: "8px", display: "block" }, children: "Delay Before Sending" }),
148
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "flex-start", children: [
149
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "120px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
150
+ designSystem.TextInput,
151
+ {
152
+ type: "number",
153
+ value: String(config.delayValue || 0),
154
+ onChange: (e) => handleUpdate({ delayValue: parseInt(e.target.value, 10) || 0 }),
155
+ disabled,
156
+ "aria-label": "Delay value"
157
+ }
158
+ ) }),
159
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "150px" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
160
+ designSystem.SingleSelect,
161
+ {
162
+ value: config.delayUnit || "minutes",
163
+ onChange: (val) => handleUpdate({ delayUnit: val }),
164
+ disabled,
165
+ children: [
166
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "seconds", children: "seconds" }),
167
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "minutes", children: "minutes" }),
168
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "hours", children: "hours" })
169
+ ]
170
+ }
171
+ ) })
172
+ ] }),
173
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", style: { marginTop: "4px" }, children: "Wait this long after the event before checking segment rules and sending" })
174
+ ] })
175
+ ] }) }) }),
176
+ isDbBased && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { background: "neutral100", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 4, padding: 4, children: [
177
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", children: "Schedule Configuration" }),
178
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: `${name}-scheduleType`, children: [
179
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Schedule Type" }),
180
+ /* @__PURE__ */ jsxRuntime.jsxs(
181
+ designSystem.SingleSelect,
182
+ {
183
+ value: config.scheduleType || "daily",
184
+ onChange: (val) => handleUpdate({ scheduleType: val }),
185
+ disabled,
186
+ children: [
187
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "daily", children: "Daily" }),
188
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "weekly", children: "Weekly" }),
189
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "cron", children: "Custom (Cron)" })
190
+ ]
191
+ }
192
+ )
193
+ ] }),
194
+ (config.scheduleType === "daily" || config.scheduleType === "weekly") && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: `${name}-scheduleTime`, children: [
195
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Time of Day (UTC)" }),
196
+ /* @__PURE__ */ jsxRuntime.jsx(
197
+ designSystem.TextInput,
198
+ {
199
+ type: "time",
200
+ value: config.scheduleTime || "12:00",
201
+ onChange: (e) => handleUpdate({ scheduleTime: e.target.value }),
202
+ disabled
203
+ }
204
+ )
205
+ ] }),
206
+ config.scheduleType === "weekly" && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
207
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral800", style: { marginBottom: "8px", display: "block" }, children: "Days of Week" }),
208
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, wrap: "wrap", children: WEEKDAYS.map((day) => /* @__PURE__ */ jsxRuntime.jsx(
209
+ designSystem.Box,
210
+ {
211
+ padding: 2,
212
+ background: (config.scheduleDays || []).includes(day.value) ? "primary100" : "neutral100",
213
+ hasRadius: true,
214
+ style: {
215
+ cursor: disabled ? "not-allowed" : "pointer",
216
+ border: `1px solid ${(config.scheduleDays || []).includes(day.value) ? "#4945ff" : "#dcdce4"}`,
217
+ minWidth: "50px",
218
+ textAlign: "center"
219
+ },
220
+ onClick: () => !disabled && toggleDay(day.value),
221
+ children: /* @__PURE__ */ jsxRuntime.jsx(
222
+ designSystem.Typography,
223
+ {
224
+ variant: "omega",
225
+ textColor: (config.scheduleDays || []).includes(day.value) ? "primary600" : "neutral600",
226
+ children: day.label
227
+ }
228
+ )
229
+ },
230
+ day.value
231
+ )) })
232
+ ] }),
233
+ config.scheduleType === "cron" && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: `${name}-scheduleCron`, children: [
234
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: "Cron Expression" }),
235
+ /* @__PURE__ */ jsxRuntime.jsx(
236
+ designSystem.TextInput,
237
+ {
238
+ placeholder: "0 12 * * *",
239
+ value: config.scheduleCron || "",
240
+ onChange: (e) => handleUpdate({ scheduleCron: e.target.value }),
241
+ disabled
242
+ }
243
+ ),
244
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: 'Standard cron format: minute hour day month weekday (e.g., "0 12 * * *" = daily at 12:00 UTC)' })
245
+ ] })
246
+ ] }) }) }),
247
+ error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, { children: error }),
248
+ hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, { children: hint })
249
+ ] }) });
250
+ }
251
+ );
252
+ TriggerConfigField.displayName = "TriggerConfigField";
253
+ exports.default = TriggerConfigField;
@@ -22,7 +22,6 @@ const index = {
22
22
  app.customFields.register({
23
23
  name: "rules",
24
24
  pluginId: PLUGIN_ID,
25
- plugin: PLUGIN_ID,
26
25
  type: "json",
27
26
  intlLabel: {
28
27
  id: `${PLUGIN_ID}.rules.label`,
@@ -44,6 +43,54 @@ const index = {
44
43
  advanced: []
45
44
  }
46
45
  });
46
+ app.customFields.register({
47
+ name: "trigger-config",
48
+ pluginId: PLUGIN_ID,
49
+ type: "json",
50
+ intlLabel: {
51
+ id: `${PLUGIN_ID}.trigger-config.label`,
52
+ defaultMessage: "Trigger Configuration"
53
+ },
54
+ intlDescription: {
55
+ id: `${PLUGIN_ID}.trigger-config.description`,
56
+ defaultMessage: "Configure segment type (scheduled or event-triggered) and trigger settings"
57
+ },
58
+ icon: icons.Clock,
59
+ components: {
60
+ Input: async () => Promise.resolve().then(() => require(
61
+ /* webpackChunkName: "crm-trigger-config" */
62
+ "../_chunks/index-DRJ5o0cz.js"
63
+ ))
64
+ },
65
+ options: {
66
+ base: [],
67
+ advanced: []
68
+ }
69
+ });
70
+ app.customFields.register({
71
+ name: "cancel-conditions",
72
+ pluginId: PLUGIN_ID,
73
+ type: "json",
74
+ intlLabel: {
75
+ id: `${PLUGIN_ID}.cancel-conditions.label`,
76
+ defaultMessage: "Cancel Conditions"
77
+ },
78
+ intlDescription: {
79
+ id: `${PLUGIN_ID}.cancel-conditions.description`,
80
+ defaultMessage: "Conditions that will cancel sending (checked right before send)"
81
+ },
82
+ icon: icons.Cross,
83
+ components: {
84
+ Input: async () => Promise.resolve().then(() => require(
85
+ /* webpackChunkName: "crm-cancel-conditions" */
86
+ "../_chunks/index-Cf8DZYT6.js"
87
+ ))
88
+ },
89
+ options: {
90
+ base: [],
91
+ advanced: []
92
+ }
93
+ });
47
94
  app.addMenuLink({
48
95
  to: `/plugins/${PLUGIN_ID}`,
49
96
  icon: icons.Message,
@@ -54,7 +101,7 @@ const index = {
54
101
  Component: async () => {
55
102
  const component = await Promise.resolve().then(() => require(
56
103
  /* webpackChunkName: "crm-dashboard-page" */
57
- "../_chunks/index-CYXNVioH.js"
104
+ "../_chunks/index-C1dJdMYf.js"
58
105
  ));
59
106
  return component;
60
107
  },
@@ -1,4 +1,4 @@
1
- import { Message } from "@strapi/icons";
1
+ import { Message, Clock, Cross } from "@strapi/icons";
2
2
  const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
3
3
  const v = glob[path];
4
4
  if (v) {
@@ -21,7 +21,6 @@ const index = {
21
21
  app.customFields.register({
22
22
  name: "rules",
23
23
  pluginId: PLUGIN_ID,
24
- plugin: PLUGIN_ID,
25
24
  type: "json",
26
25
  intlLabel: {
27
26
  id: `${PLUGIN_ID}.rules.label`,
@@ -43,6 +42,54 @@ const index = {
43
42
  advanced: []
44
43
  }
45
44
  });
45
+ app.customFields.register({
46
+ name: "trigger-config",
47
+ pluginId: PLUGIN_ID,
48
+ type: "json",
49
+ intlLabel: {
50
+ id: `${PLUGIN_ID}.trigger-config.label`,
51
+ defaultMessage: "Trigger Configuration"
52
+ },
53
+ intlDescription: {
54
+ id: `${PLUGIN_ID}.trigger-config.description`,
55
+ defaultMessage: "Configure segment type (scheduled or event-triggered) and trigger settings"
56
+ },
57
+ icon: Clock,
58
+ components: {
59
+ Input: async () => import(
60
+ /* webpackChunkName: "crm-trigger-config" */
61
+ "../_chunks/index-DFqEb9sm.mjs"
62
+ )
63
+ },
64
+ options: {
65
+ base: [],
66
+ advanced: []
67
+ }
68
+ });
69
+ app.customFields.register({
70
+ name: "cancel-conditions",
71
+ pluginId: PLUGIN_ID,
72
+ type: "json",
73
+ intlLabel: {
74
+ id: `${PLUGIN_ID}.cancel-conditions.label`,
75
+ defaultMessage: "Cancel Conditions"
76
+ },
77
+ intlDescription: {
78
+ id: `${PLUGIN_ID}.cancel-conditions.description`,
79
+ defaultMessage: "Conditions that will cancel sending (checked right before send)"
80
+ },
81
+ icon: Cross,
82
+ components: {
83
+ Input: async () => import(
84
+ /* webpackChunkName: "crm-cancel-conditions" */
85
+ "../_chunks/index-Bnjm_sYk.mjs"
86
+ )
87
+ },
88
+ options: {
89
+ base: [],
90
+ advanced: []
91
+ }
92
+ });
46
93
  app.addMenuLink({
47
94
  to: `/plugins/${PLUGIN_ID}`,
48
95
  icon: Message,
@@ -53,7 +100,7 @@ const index = {
53
100
  Component: async () => {
54
101
  const component = await import(
55
102
  /* webpackChunkName: "crm-dashboard-page" */
56
- "../_chunks/index-BWojad6n.mjs"
103
+ "../_chunks/index-DEONgZRM.mjs"
57
104
  );
58
105
  return component;
59
106
  },
@@ -5,6 +5,16 @@ const register = ({ strapi: strapi2 }) => {
5
5
  plugin: "crm-dashboard",
6
6
  type: "json"
7
7
  });
8
+ strapi2.customFields.register({
9
+ name: "trigger-config",
10
+ plugin: "crm-dashboard",
11
+ type: "json"
12
+ });
13
+ strapi2.customFields.register({
14
+ name: "cancel-conditions",
15
+ plugin: "crm-dashboard",
16
+ type: "json"
17
+ });
8
18
  };
9
19
  const bootstrap = ({ strapi: strapi2 }) => {
10
20
  };
@@ -4,6 +4,16 @@ const register = ({ strapi: strapi2 }) => {
4
4
  plugin: "crm-dashboard",
5
5
  type: "json"
6
6
  });
7
+ strapi2.customFields.register({
8
+ name: "trigger-config",
9
+ plugin: "crm-dashboard",
10
+ type: "json"
11
+ });
12
+ strapi2.customFields.register({
13
+ name: "cancel-conditions",
14
+ plugin: "crm-dashboard",
15
+ type: "json"
16
+ });
7
17
  };
8
18
  const bootstrap = ({ strapi: strapi2 }) => {
9
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inspirer-dev/crm-dashboard",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "CRM Dashboard and Tools",
5
5
  "strapi": {
6
6
  "name": "crm-dashboard",
@@ -6,6 +6,18 @@ const register = ({ strapi }: { strapi: Core.Strapi }) => {
6
6
  plugin: 'crm-dashboard',
7
7
  type: 'json',
8
8
  });
9
+
10
+ strapi.customFields.register({
11
+ name: 'trigger-config',
12
+ plugin: 'crm-dashboard',
13
+ type: 'json',
14
+ });
15
+
16
+ strapi.customFields.register({
17
+ name: 'cancel-conditions',
18
+ plugin: 'crm-dashboard',
19
+ type: 'json',
20
+ });
9
21
  };
10
22
 
11
23
  export default register;