@contentgrowth/content-emailing 0.7.9 → 0.8.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.
@@ -152,9 +152,10 @@ var TemplateTester = ({
152
152
  template,
153
153
  onSendTest,
154
154
  onCancel,
155
- sending = false
155
+ sending = false,
156
+ defaultValues = {}
156
157
  }) => {
157
- const [toEmail, setToEmail] = useState2("");
158
+ const [toEmail, setToEmail] = useState2(defaultValues.to || "");
158
159
  const [variables, setVariables] = useState2({});
159
160
  const [detectedVariables, setDetectedVariables] = useState2([]);
160
161
  const [error, setError] = useState2(null);
@@ -166,11 +167,18 @@ var TemplateTester = ({
166
167
  const uniqueVars = Array.from(/* @__PURE__ */ new Set([...subjectVars, ...bodyVars]));
167
168
  setDetectedVariables(uniqueVars);
168
169
  const initialValues = {};
170
+ const defaults = defaultValues.variables || {};
169
171
  uniqueVars.forEach((v) => {
170
- initialValues[v] = "";
172
+ if (defaults[v]) {
173
+ initialValues[v] = defaults[v];
174
+ } else if (v === "email" && toEmail) {
175
+ initialValues[v] = toEmail;
176
+ } else {
177
+ initialValues[v] = "";
178
+ }
171
179
  });
172
180
  setVariables(initialValues);
173
- }, [template]);
181
+ }, [template, defaultValues]);
174
182
  const handleSubmit = async (e) => {
175
183
  e.preventDefault();
176
184
  setError(null);
@@ -192,7 +200,13 @@ var TemplateTester = ({
192
200
  type: "email",
193
201
  required: true,
194
202
  value: toEmail,
195
- onChange: (e) => setToEmail(e.target.value),
203
+ onChange: (e) => {
204
+ const val = e.target.value;
205
+ setToEmail(val);
206
+ if (variables["email"] !== void 0) {
207
+ setVariables((prev) => ({ ...prev, email: val }));
208
+ }
209
+ },
196
210
  className: "w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500",
197
211
  placeholder: "recipient@example.com"
198
212
  }
@@ -245,8 +259,10 @@ var TemplateManager = ({
245
259
  onSendTestEmail,
246
260
  title = "Email Templates",
247
261
  description = "Manage system email templates",
248
- templateTypes
262
+ templateTypes,
263
+ defaultTestValues
249
264
  }) => {
265
+ const props = { defaultTestValues };
250
266
  const [templates, setTemplates] = useState3([]);
251
267
  const [loading, setLoading] = useState3(true);
252
268
  const [error, setError] = useState3(null);
@@ -453,7 +469,8 @@ var TemplateManager = ({
453
469
  template: testingTemplate,
454
470
  onSendTest: handleTest,
455
471
  onCancel: () => setShowTester(false),
456
- sending: saving
472
+ sending: saving,
473
+ defaultValues: props.defaultTestValues
457
474
  }
458
475
  ), deleteConfirm && /* @__PURE__ */ React3.createElement("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4" }, /* @__PURE__ */ React3.createElement("div", { className: "bg-white rounded-lg shadow-xl max-w-sm w-full p-6" }, /* @__PURE__ */ React3.createElement("h3", { className: "text-lg font-semibold mb-2" }, "Delete Template?"), /* @__PURE__ */ React3.createElement("p", { className: "text-gray-600 mb-4" }, "This action cannot be undone."), /* @__PURE__ */ React3.createElement("div", { className: "flex justify-end gap-3" }, /* @__PURE__ */ React3.createElement(
459
476
  "button",
@@ -538,13 +555,22 @@ var EmailSettings = ({
538
555
  if (loading) {
539
556
  return /* @__PURE__ */ React4.createElement("div", { className: "flex items-center justify-center p-12" }, /* @__PURE__ */ React4.createElement("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" }));
540
557
  }
541
- return /* @__PURE__ */ React4.createElement("div", { className: "max-w-4xl p-6 space-y-8" }, /* @__PURE__ */ React4.createElement("div", null, /* @__PURE__ */ React4.createElement("h2", { className: "text-2xl font-bold text-gray-900" }, title), /* @__PURE__ */ React4.createElement("p", { className: "text-gray-500 mt-1" }, description)), /* @__PURE__ */ React4.createElement("div", { className: "bg-white rounded-lg border border-gray-200 shadow-sm overflow-hidden" }, /* @__PURE__ */ React4.createElement("div", { className: "px-6 py-4 border-b border-gray-100 bg-gray-50" }, /* @__PURE__ */ React4.createElement("h3", { className: "text-lg font-medium text-gray-900" }, "Global Configuration"), /* @__PURE__ */ React4.createElement("p", { className: "text-sm text-gray-500" }, "Default sender identity and delivery provider.")), /* @__PURE__ */ React4.createElement("div", { className: "p-6 space-y-6" }, /* @__PURE__ */ React4.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6" }, /* @__PURE__ */ React4.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React4.createElement("label", { className: "block text-sm font-medium text-gray-700" }, "From Name"), /* @__PURE__ */ React4.createElement(
558
+ return /* @__PURE__ */ React4.createElement("div", { className: "max-w-4xl p-6 space-y-8" }, /* @__PURE__ */ React4.createElement("div", null, /* @__PURE__ */ React4.createElement("h2", { className: "text-2xl font-bold text-gray-900" }, title), /* @__PURE__ */ React4.createElement("p", { className: "text-gray-500 mt-1" }, description)), /* @__PURE__ */ React4.createElement("div", { className: "bg-white rounded-lg border border-gray-200 shadow-sm overflow-hidden" }, /* @__PURE__ */ React4.createElement("div", { className: "px-6 py-4 border-b border-gray-100 bg-gray-50" }, /* @__PURE__ */ React4.createElement("h3", { className: "text-lg font-medium text-gray-900" }, "Global Configuration"), /* @__PURE__ */ React4.createElement("p", { className: "text-sm text-gray-500" }, "Default sender identity and delivery provider.")), /* @__PURE__ */ React4.createElement("div", { className: "p-6 space-y-6" }, /* @__PURE__ */ React4.createElement("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-6" }, /* @__PURE__ */ React4.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React4.createElement("label", { className: "block text-sm font-medium text-gray-700" }, "Brand Name"), /* @__PURE__ */ React4.createElement(
559
+ "input",
560
+ {
561
+ type: "text",
562
+ value: settings.brandName || "",
563
+ onChange: (e) => handleChange("brandName", e.target.value),
564
+ placeholder: "e.g. Content Growth",
565
+ className: "w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
566
+ }
567
+ ), /* @__PURE__ */ React4.createElement("p", { className: "text-xs text-gray-500" }, "Used in email templates as ", "{{brandName}}")), /* @__PURE__ */ React4.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React4.createElement("label", { className: "block text-sm font-medium text-gray-700" }, "From Name"), /* @__PURE__ */ React4.createElement(
542
568
  "input",
543
569
  {
544
570
  type: "text",
545
571
  value: settings.fromName,
546
572
  onChange: (e) => handleChange("fromName", e.target.value),
547
- placeholder: "e.g. Acme System",
573
+ placeholder: "e.g. Support Team",
548
574
  className: "w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
549
575
  }
550
576
  )), /* @__PURE__ */ React4.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React4.createElement("label", { className: "block text-sm font-medium text-gray-700" }, "From Address"), /* @__PURE__ */ React4.createElement(
@@ -553,7 +579,7 @@ var EmailSettings = ({
553
579
  type: "email",
554
580
  value: settings.fromAddress,
555
581
  onChange: (e) => handleChange("fromAddress", e.target.value),
556
- placeholder: "e.g. noreply@acme.com",
582
+ placeholder: "e.g. noreply@example.com",
557
583
  className: "w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
558
584
  }
559
585
  ))), /* @__PURE__ */ React4.createElement("div", { className: "space-y-2" }, /* @__PURE__ */ React4.createElement("label", { className: "block text-sm font-medium text-gray-700" }, "Email Provider"), /* @__PURE__ */ React4.createElement("div", { className: "relative" }, /* @__PURE__ */ React4.createElement(