@burdenoff/microfe-headshotmarketing 2026.704.5 → 2026.704.6
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.
- package/dist/generated/wspace-operations.js +197 -100
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/headshotmarketing/pages/ads/AdReachEstimatePanel.js +147 -0
- package/dist/headshotmarketing/pages/ads/AdReachEstimatePanel.js.map +1 -0
- package/dist/headshotmarketing/pages/ads/CreateAdCampaignPage.js +246 -235
- package/dist/headshotmarketing/pages/ads/CreateAdCampaignPage.js.map +1 -1
- package/dist/headshotmarketing/pages/campaigns/CampaignTemplatesPage.js +123 -233
- package/dist/headshotmarketing/pages/campaigns/CampaignTemplatesPage.js.map +1 -1
- package/dist/headshotmarketing/pages/campaigns/TemplateCard.js +81 -0
- package/dist/headshotmarketing/pages/campaigns/TemplateCard.js.map +1 -0
- package/dist/headshotmarketing/pages/crm/ConvertLeadButton.js +107 -0
- package/dist/headshotmarketing/pages/crm/ConvertLeadButton.js.map +1 -0
- package/dist/headshotmarketing/pages/crm/LeadCreateModal.js +232 -0
- package/dist/headshotmarketing/pages/crm/LeadCreateModal.js.map +1 -0
- package/dist/headshotmarketing/pages/crm/LeadsPage.js +267 -233
- package/dist/headshotmarketing/pages/crm/LeadsPage.js.map +1 -1
- package/dist/headshotmarketing/utils/adsMapper.js +2 -2
- package/dist/headshotmarketing/utils/adsMapper.js.map +1 -1
- package/dist/headshotmarketing/utils/campaignMapper.js +1 -22
- package/dist/headshotmarketing/utils/campaignMapper.js.map +1 -1
- package/dist/headshotmarketing/utils/crmMapper.js +2 -2
- package/dist/headshotmarketing/utils/crmMapper.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,78 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Pagination as l } from "../../components/Pagination.js";
|
|
1
|
+
import { useCreateHeadshotmarketingCampaignFromTemplateMutation as e } from "../../../generated/wspace-operations.js";
|
|
2
|
+
import { useHeadshotMarketing as t } from "../../context/HeadshotMarketingContext.js";
|
|
3
|
+
import { PageLayout as n } from "../../components/PageLayout.js";
|
|
4
|
+
import { StatCard as r } from "../../components/StatCard.js";
|
|
5
|
+
import { EmptyState as i } from "../../components/EmptyState.js";
|
|
6
|
+
import { FilterBar as a } from "../../components/FilterBar.js";
|
|
7
|
+
import { QueryStateBoundary as o } from "../../components/QueryStateBoundary.js";
|
|
8
|
+
import { Pagination as s } from "../../components/Pagination.js";
|
|
10
9
|
import "../../components/index.js";
|
|
11
|
-
import { useHeadshotmarketingBootstrap as
|
|
12
|
-
import { usePagination as
|
|
10
|
+
import { useHeadshotmarketingBootstrap as c } from "../../hooks/useHeadshotmarketingBootstrap.js";
|
|
11
|
+
import { usePagination as l } from "../../hooks/usePagination.js";
|
|
13
12
|
import "../../hooks/index.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { TemplateCard as u } from "./TemplateCard.js";
|
|
14
|
+
import { useCallback as d, useEffect as f, useMemo as p, useState as m } from "react";
|
|
15
|
+
import { ArrowLeft as h, Award as g, LayoutTemplate as _, Tag as v, Users as y } from "lucide-react";
|
|
16
|
+
import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
17
|
+
import { EmphasisPanel as C, PagePurpose as w } from "@burdenoff/fe-libs/ui";
|
|
18
18
|
//#region src/headshotmarketing/pages/campaigns/CampaignTemplatesPage.tsx
|
|
19
|
-
var
|
|
20
|
-
{
|
|
21
|
-
value: "all",
|
|
22
|
-
label: "All Categories"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
value: "Launch",
|
|
26
|
-
label: "Launch"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
value: "Sales",
|
|
30
|
-
label: "Sales"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
value: "Branding",
|
|
34
|
-
label: "Branding"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
value: "Lead Gen",
|
|
38
|
-
label: "Lead Gen"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
value: "Influencer",
|
|
42
|
-
label: "Influencer"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
value: "Email",
|
|
46
|
-
label: "Email"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
value: "Video",
|
|
50
|
-
label: "Video"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
value: "Content",
|
|
54
|
-
label: "Content"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
value: "Conversion",
|
|
58
|
-
label: "Conversion"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
value: "B2B",
|
|
62
|
-
label: "B2B"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
value: "Events",
|
|
66
|
-
label: "Events"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
value: "Social",
|
|
70
|
-
label: "Social"
|
|
71
|
-
}
|
|
72
|
-
], k = [
|
|
19
|
+
var T = [
|
|
73
20
|
{
|
|
74
21
|
value: "popular",
|
|
75
|
-
label: "Most
|
|
22
|
+
label: "Most Used"
|
|
76
23
|
},
|
|
77
24
|
{
|
|
78
25
|
value: "name",
|
|
@@ -90,224 +37,167 @@ var O = [
|
|
|
90
37
|
value: "budget-high",
|
|
91
38
|
label: "Budget: High to Low"
|
|
92
39
|
}
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
let t = !L || e.name.toLowerCase().includes(L.toLowerCase()) || e.description.toLowerCase().includes(L.toLowerCase()), n = z === "all" || e.category === z;
|
|
109
|
-
return t && n;
|
|
40
|
+
], E = () => {
|
|
41
|
+
let { navigate: E, basePath: D } = t(), { data: O, loading: k, error: A, refetch: j } = c(), [M, N] = m(""), [P, F] = m("all"), [I, L] = m("popular"), R = l({ initialPageSize: 9 }), { setTotal: z, setPage: B } = R, [V] = e(), [H, U] = m(null), [W, G] = m(null), K = p(() => O?.headshotmarketingCampaignTemplates.items ?? [], [O?.headshotmarketingCampaignTemplates.items]), q = p(() => K.reduce((e, t) => e + t.usageCount, 0), [K]), J = p(() => K.length > 0 ? K.reduce((e, t) => t.usageCount > e.usageCount ? t : e, K[0]) : null, [K]), Y = p(() => {
|
|
42
|
+
let e = /* @__PURE__ */ new Set();
|
|
43
|
+
for (let t of K) t.category && e.add(t.category);
|
|
44
|
+
return [{
|
|
45
|
+
value: "all",
|
|
46
|
+
label: "All Categories"
|
|
47
|
+
}, ...Array.from(e).sort((e, t) => e.localeCompare(t)).map((e) => ({
|
|
48
|
+
value: e,
|
|
49
|
+
label: e
|
|
50
|
+
}))];
|
|
51
|
+
}, [K]), X = p(() => {
|
|
52
|
+
let e = M.trim().toLowerCase(), t = K.filter((t) => {
|
|
53
|
+
let n = !e || t.name.toLowerCase().includes(e) || (t.description ?? "").toLowerCase().includes(e), r = P === "all" || t.category === P;
|
|
54
|
+
return n && r;
|
|
110
55
|
});
|
|
111
|
-
switch (
|
|
56
|
+
switch (I) {
|
|
112
57
|
case "popular":
|
|
113
|
-
|
|
58
|
+
t = [...t].sort((e, t) => t.usageCount - e.usageCount);
|
|
114
59
|
break;
|
|
115
60
|
case "name":
|
|
116
|
-
|
|
61
|
+
t = [...t].sort((e, t) => e.name.localeCompare(t.name));
|
|
117
62
|
break;
|
|
118
63
|
case "newest":
|
|
119
|
-
|
|
64
|
+
t = [...t].sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime());
|
|
120
65
|
break;
|
|
121
66
|
case "budget-low":
|
|
122
|
-
|
|
67
|
+
t = [...t].sort((e, t) => (e.defaultBudget ?? 0) - (t.defaultBudget ?? 0));
|
|
123
68
|
break;
|
|
124
69
|
case "budget-high":
|
|
125
|
-
|
|
70
|
+
t = [...t].sort((e, t) => (t.defaultBudget ?? 0) - (e.defaultBudget ?? 0));
|
|
126
71
|
break;
|
|
127
72
|
}
|
|
128
|
-
return
|
|
73
|
+
return t;
|
|
129
74
|
}, [
|
|
130
75
|
K,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
76
|
+
M,
|
|
77
|
+
P,
|
|
78
|
+
I
|
|
134
79
|
]);
|
|
135
80
|
f(() => {
|
|
136
|
-
|
|
81
|
+
B(1);
|
|
137
82
|
}, [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
83
|
+
M,
|
|
84
|
+
P,
|
|
85
|
+
I,
|
|
86
|
+
B
|
|
142
87
|
]), f(() => {
|
|
143
|
-
|
|
144
|
-
}, [X.length,
|
|
145
|
-
let Z = p(() => X.slice(
|
|
88
|
+
z(X.length);
|
|
89
|
+
}, [X.length, z]);
|
|
90
|
+
let Z = p(() => X.slice(R.offset, R.offset + R.pageSize), [
|
|
146
91
|
X,
|
|
147
|
-
|
|
148
|
-
|
|
92
|
+
R.offset,
|
|
93
|
+
R.pageSize
|
|
94
|
+
]), Q = d(async (e) => {
|
|
95
|
+
if (!H) {
|
|
96
|
+
U(e.id), G(null);
|
|
97
|
+
try {
|
|
98
|
+
let t = (await V({ variables: { templateId: e.id } })).data?.createHeadshotmarketingCampaignFromTemplate;
|
|
99
|
+
await j(), E(t?.id ? `${D}/campaigns/${t.id}` : `${D}/campaigns`);
|
|
100
|
+
} catch (t) {
|
|
101
|
+
G({
|
|
102
|
+
id: e.id,
|
|
103
|
+
message: t instanceof Error ? t.message : "Failed to create a campaign from this template. Please try again."
|
|
104
|
+
});
|
|
105
|
+
} finally {
|
|
106
|
+
U(null);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}, [
|
|
110
|
+
H,
|
|
111
|
+
V,
|
|
112
|
+
j,
|
|
113
|
+
E,
|
|
114
|
+
D
|
|
149
115
|
]);
|
|
150
|
-
return /* @__PURE__ */
|
|
116
|
+
return /* @__PURE__ */ S(n, {
|
|
151
117
|
title: "Campaign Templates",
|
|
152
118
|
description: "Ready-to-use templates to launch your campaigns faster",
|
|
153
|
-
actions: /* @__PURE__ */
|
|
154
|
-
onClick: () =>
|
|
119
|
+
actions: /* @__PURE__ */ S("button", {
|
|
120
|
+
onClick: () => E(D + "/campaigns"),
|
|
155
121
|
className: "inline-flex items-center gap-2 rounded-md border border-border-seam bg-gloss-card shadow-pop px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
156
|
-
children: [/* @__PURE__ */
|
|
122
|
+
children: [/* @__PURE__ */ x(h, { className: "h-4 w-4" }), "Back to Campaigns"]
|
|
157
123
|
}),
|
|
158
124
|
children: [
|
|
159
|
-
/* @__PURE__ */ w
|
|
160
|
-
/* @__PURE__ */
|
|
125
|
+
/* @__PURE__ */ x(w, { children: "Start from a proven playbook instead of a blank page. Each template bundles a recommended channel mix, budget and timeline for a specific goal so you can spin up a campaign in minutes — pick one and we'll create the campaign for you." }),
|
|
126
|
+
/* @__PURE__ */ x(C, { children: /* @__PURE__ */ S("div", {
|
|
161
127
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
|
|
162
128
|
children: [
|
|
163
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ x(r, {
|
|
164
130
|
title: "Templates",
|
|
165
131
|
value: String(K.length),
|
|
166
|
-
icon: /* @__PURE__ */
|
|
132
|
+
icon: /* @__PURE__ */ x(_, { className: "h-5 w-5" })
|
|
167
133
|
}),
|
|
168
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ x(r, {
|
|
169
135
|
title: "Total Uses",
|
|
170
136
|
value: String(q),
|
|
171
|
-
icon: /* @__PURE__ */
|
|
137
|
+
icon: /* @__PURE__ */ x(y, { className: "h-5 w-5" })
|
|
172
138
|
}),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
title: "
|
|
175
|
-
value:
|
|
176
|
-
icon: /* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ x(r, {
|
|
140
|
+
title: "Categories",
|
|
141
|
+
value: String(Math.max(Y.length - 1, 0)),
|
|
142
|
+
icon: /* @__PURE__ */ x(v, { className: "h-5 w-5" })
|
|
177
143
|
}),
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
title: "
|
|
180
|
-
value:
|
|
181
|
-
icon: /* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ x(r, {
|
|
145
|
+
title: "Most Used",
|
|
146
|
+
value: J?.name ?? "-",
|
|
147
|
+
icon: /* @__PURE__ */ x(g, { className: "h-5 w-5" })
|
|
182
148
|
})
|
|
183
149
|
]
|
|
184
150
|
}) }),
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
searchValue:
|
|
187
|
-
onSearchChange:
|
|
151
|
+
/* @__PURE__ */ x(a, {
|
|
152
|
+
searchValue: M,
|
|
153
|
+
onSearchChange: N,
|
|
188
154
|
searchPlaceholder: "Search templates...",
|
|
189
|
-
filters: /* @__PURE__ */
|
|
190
|
-
value:
|
|
191
|
-
onChange: (e) =>
|
|
155
|
+
filters: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("select", {
|
|
156
|
+
value: P,
|
|
157
|
+
onChange: (e) => F(e.target.value),
|
|
192
158
|
className: "rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
|
|
193
|
-
children:
|
|
159
|
+
children: Y.map((e) => /* @__PURE__ */ x("option", {
|
|
194
160
|
value: e.value,
|
|
195
161
|
children: e.label
|
|
196
162
|
}, e.value))
|
|
197
|
-
}), /* @__PURE__ */
|
|
198
|
-
value:
|
|
199
|
-
onChange: (e) =>
|
|
163
|
+
}), /* @__PURE__ */ x("select", {
|
|
164
|
+
value: I,
|
|
165
|
+
onChange: (e) => L(e.target.value),
|
|
200
166
|
className: "rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]",
|
|
201
|
-
children:
|
|
167
|
+
children: T.map((e) => /* @__PURE__ */ x("option", {
|
|
202
168
|
value: e.value,
|
|
203
169
|
children: e.label
|
|
204
170
|
}, e.value))
|
|
205
171
|
})] })
|
|
206
172
|
}),
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
loading:
|
|
209
|
-
error:
|
|
210
|
-
onRetry: () => void
|
|
211
|
-
hasData: !!
|
|
173
|
+
/* @__PURE__ */ S(o, {
|
|
174
|
+
loading: k,
|
|
175
|
+
error: A,
|
|
176
|
+
onRetry: () => void j(),
|
|
177
|
+
hasData: !!O,
|
|
212
178
|
children: [
|
|
213
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ x("div", {
|
|
214
180
|
className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
215
|
-
children: Z.map((e) => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
children: /* @__PURE__ */ w("span", {
|
|
223
|
-
className: "inline-flex items-center rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary",
|
|
224
|
-
children: e.category
|
|
225
|
-
})
|
|
226
|
-
}),
|
|
227
|
-
/* @__PURE__ */ w("h3", {
|
|
228
|
-
className: "text-sm font-semibold text-text-primary mb-1",
|
|
229
|
-
children: e.name
|
|
230
|
-
}),
|
|
231
|
-
/* @__PURE__ */ w("p", {
|
|
232
|
-
className: "text-xs text-text-secondary mb-3 line-clamp-2",
|
|
233
|
-
children: e.description
|
|
234
|
-
}),
|
|
235
|
-
/* @__PURE__ */ T("div", {
|
|
236
|
-
className: "flex items-center gap-1 mb-3",
|
|
237
|
-
children: [A(e.popularity), /* @__PURE__ */ T("span", {
|
|
238
|
-
className: "text-xs text-text-secondary ml-1",
|
|
239
|
-
children: [
|
|
240
|
-
"(",
|
|
241
|
-
e.popularity,
|
|
242
|
-
" uses)"
|
|
243
|
-
]
|
|
244
|
-
})]
|
|
245
|
-
}),
|
|
246
|
-
/* @__PURE__ */ T("div", {
|
|
247
|
-
className: "grid grid-cols-2 gap-2 mb-3 text-xs",
|
|
248
|
-
children: [/* @__PURE__ */ T("div", {
|
|
249
|
-
className: "flex items-center gap-1.5 text-text-secondary",
|
|
250
|
-
children: [/* @__PURE__ */ w(S, { className: "h-3 w-3" }), /* @__PURE__ */ T("span", { children: [
|
|
251
|
-
n(e.estimatedBudget.min),
|
|
252
|
-
" -",
|
|
253
|
-
" ",
|
|
254
|
-
n(e.estimatedBudget.max)
|
|
255
|
-
] })]
|
|
256
|
-
}), /* @__PURE__ */ T("div", {
|
|
257
|
-
className: "flex items-center gap-1.5 text-text-secondary",
|
|
258
|
-
children: [/* @__PURE__ */ w(_, { className: "h-3 w-3" }), /* @__PURE__ */ w("span", { children: e.duration })]
|
|
259
|
-
})]
|
|
260
|
-
}),
|
|
261
|
-
/* @__PURE__ */ w("div", {
|
|
262
|
-
className: "flex flex-wrap gap-1.5 mb-3",
|
|
263
|
-
children: e.channels.map((e) => /* @__PURE__ */ w("span", {
|
|
264
|
-
className: "inline-flex items-center rounded-full border border-border-subtle px-2 py-0.5 text-[10px] font-medium text-text-secondary",
|
|
265
|
-
children: e
|
|
266
|
-
}, e))
|
|
267
|
-
}),
|
|
268
|
-
/* @__PURE__ */ T("div", {
|
|
269
|
-
className: "mb-4",
|
|
270
|
-
children: [/* @__PURE__ */ T("div", {
|
|
271
|
-
className: "flex items-center justify-between text-xs mb-1",
|
|
272
|
-
children: [/* @__PURE__ */ w("span", {
|
|
273
|
-
className: "text-text-secondary",
|
|
274
|
-
children: "Success Rate"
|
|
275
|
-
}), /* @__PURE__ */ T("span", {
|
|
276
|
-
className: "font-medium text-text-primary",
|
|
277
|
-
children: [r, "%"]
|
|
278
|
-
})]
|
|
279
|
-
}), /* @__PURE__ */ w("div", {
|
|
280
|
-
className: "h-1.5 w-full rounded-full bg-bg-sunken",
|
|
281
|
-
children: /* @__PURE__ */ w("div", {
|
|
282
|
-
className: t("h-1.5 rounded-full transition-all", r >= 80 ? "bg-status-success-text" : r >= 60 ? "bg-status-warning-text" : "bg-status-error-text"),
|
|
283
|
-
style: { width: `${r}%` }
|
|
284
|
-
})
|
|
285
|
-
})]
|
|
286
|
-
}),
|
|
287
|
-
/* @__PURE__ */ w("div", {
|
|
288
|
-
className: "mt-auto",
|
|
289
|
-
children: /* @__PURE__ */ w("button", {
|
|
290
|
-
onClick: () => y(M + "/campaigns/new"),
|
|
291
|
-
className: "w-full rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 transition-colors",
|
|
292
|
-
children: "Use Template"
|
|
293
|
-
})
|
|
294
|
-
})
|
|
295
|
-
]
|
|
296
|
-
}, e.id);
|
|
297
|
-
})
|
|
181
|
+
children: Z.map((e) => /* @__PURE__ */ x(u, {
|
|
182
|
+
template: e,
|
|
183
|
+
onUse: Q,
|
|
184
|
+
submitting: H === e.id,
|
|
185
|
+
disabled: H !== null,
|
|
186
|
+
errorMessage: W?.id === e.id ? W.message : void 0
|
|
187
|
+
}, e.id))
|
|
298
188
|
}),
|
|
299
|
-
X.length === 0 && /* @__PURE__ */
|
|
189
|
+
X.length === 0 && /* @__PURE__ */ x(i, {
|
|
300
190
|
illustration: K.length === 0 ? "empty-generic" : "empty-search",
|
|
301
191
|
title: K.length === 0 ? "No templates available" : "No templates found",
|
|
302
192
|
description: K.length === 0 ? "Templates will appear here once they're added to your workspace." : "Try adjusting your search or filter criteria."
|
|
303
193
|
}),
|
|
304
|
-
X.length > 0 && /* @__PURE__ */
|
|
194
|
+
X.length > 0 && /* @__PURE__ */ x(s, {
|
|
305
195
|
className: "mt-6",
|
|
306
|
-
page:
|
|
307
|
-
pageSize:
|
|
308
|
-
total:
|
|
309
|
-
onPageChange:
|
|
310
|
-
onPageSizeChange:
|
|
196
|
+
page: R.page,
|
|
197
|
+
pageSize: R.pageSize,
|
|
198
|
+
total: R.total,
|
|
199
|
+
onPageChange: R.setPage,
|
|
200
|
+
onPageSizeChange: R.setPageSize,
|
|
311
201
|
pageSizeOptions: [
|
|
312
202
|
9,
|
|
313
203
|
18,
|
|
@@ -321,6 +211,6 @@ var M = () => {
|
|
|
321
211
|
});
|
|
322
212
|
};
|
|
323
213
|
//#endregion
|
|
324
|
-
export {
|
|
214
|
+
export { E as CampaignTemplatesPage };
|
|
325
215
|
|
|
326
216
|
//# sourceMappingURL=CampaignTemplatesPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CampaignTemplatesPage.js","names":[],"sources":["../../../../src/headshotmarketing/pages/campaigns/CampaignTemplatesPage.tsx"],"sourcesContent":["/**\n * Campaign Templates Gallery Page\n * @module headshotmarketing\n */\n\nimport { useEffect, useMemo, useState, type FC } from \"react\";\nimport {\n ArrowLeft,\n Star,\n Clock,\n Users,\n TrendingUp,\n Award,\n Zap,\n LayoutTemplate,\n} from \"lucide-react\";\nimport { cn, formatCurrency } from \"../../utils/helpers\";\nimport { toCampaignTemplateModel } from \"../../utils/campaignMapper\";\nimport {\n PageLayout,\n StatCard,\n FilterBar,\n EmptyState,\n Pagination,\n QueryStateBoundary,\n} from \"../../components\";\nimport { EmphasisPanel, PagePurpose } from \"@burdenoff/fe-libs/ui\";\nimport { useHeadshotMarketing } from \"../../context/HeadshotMarketingContext\";\nimport { useHeadshotmarketingBootstrap, usePagination } from \"../../hooks\";\nimport type { CampaignTemplate } from \"../../types\";\n\nconst categoryOptions = [\n { value: \"all\", label: \"All Categories\" },\n { value: \"Launch\", label: \"Launch\" },\n { value: \"Sales\", label: \"Sales\" },\n { value: \"Branding\", label: \"Branding\" },\n { value: \"Lead Gen\", label: \"Lead Gen\" },\n { value: \"Influencer\", label: \"Influencer\" },\n { value: \"Email\", label: \"Email\" },\n { value: \"Video\", label: \"Video\" },\n { value: \"Content\", label: \"Content\" },\n { value: \"Conversion\", label: \"Conversion\" },\n { value: \"B2B\", label: \"B2B\" },\n { value: \"Events\", label: \"Events\" },\n { value: \"Social\", label: \"Social\" },\n];\n\nconst sortOptions = [\n { value: \"popular\", label: \"Most Popular\" },\n { value: \"name\", label: \"Name A-Z\" },\n { value: \"newest\", label: \"Newest First\" },\n { value: \"budget-low\", label: \"Budget: Low to High\" },\n { value: \"budget-high\", label: \"Budget: High to Low\" },\n];\n\nfunction renderStars(popularity: number) {\n const rating = Math.min(5, Math.max(1, Math.round(popularity / 60)));\n return Array.from({ length: 5 }, (_, i) => (\n <Star\n key={i}\n className={cn(\n \"h-3.5 w-3.5\",\n i < rating\n ? \"fill-[var(--color-status-warning)] text-status-warning-text\"\n : \"text-text-secondary/30\",\n )}\n />\n ));\n}\n\nfunction getSuccessRate(popularity: number): number {\n return Math.min(98, Math.round(60 + (popularity / 312) * 35));\n}\n\nexport const CampaignTemplatesPage: FC = () => {\n const { navigate, basePath } = useHeadshotMarketing();\n const { data, loading, error, refetch } = useHeadshotmarketingBootstrap();\n const [searchTerm, setSearchTerm] = useState(\"\");\n const [categoryFilter, setCategoryFilter] = useState(\"all\");\n const [sortBy, setSortBy] = useState(\"popular\");\n const pagination = usePagination({ initialPageSize: 9 });\n const { setTotal, setPage } = pagination;\n\n const templates: CampaignTemplate[] = useMemo(\n () =>\n (data?.headshotmarketingCampaignTemplates.items ?? []).map(\n (item: Parameters<typeof toCampaignTemplateModel>[0]) =>\n toCampaignTemplateModel(item),\n ),\n [data?.headshotmarketingCampaignTemplates.items],\n );\n const totalUses = useMemo(\n () => templates.reduce((sum, t) => sum + t.popularity, 0),\n [templates],\n );\n const avgSuccessRate = useMemo(() => {\n if (templates.length === 0) return 0;\n const rates = templates.map((t) => getSuccessRate(t.popularity));\n return Math.round(rates.reduce((s, r) => s + r, 0) / rates.length);\n }, [templates]);\n const topRated = useMemo(\n () =>\n templates.length > 0\n ? templates.reduce(\n (best, t) => (t.popularity > best.popularity ? t : best),\n templates[0],\n )\n : null,\n [templates],\n );\n\n const filteredTemplates = useMemo(() => {\n let result = templates.filter((tpl) => {\n const matchesSearch =\n !searchTerm ||\n tpl.name.toLowerCase().includes(searchTerm.toLowerCase()) ||\n tpl.description.toLowerCase().includes(searchTerm.toLowerCase());\n const matchesCategory =\n categoryFilter === \"all\" || tpl.category === categoryFilter;\n return matchesSearch && matchesCategory;\n });\n\n switch (sortBy) {\n case \"popular\":\n result = [...result].sort((a, b) => b.popularity - a.popularity);\n break;\n case \"name\":\n result = [...result].sort((a, b) => a.name.localeCompare(b.name));\n break;\n case \"newest\":\n result = [...result].sort(\n (a, b) =>\n new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),\n );\n break;\n case \"budget-low\":\n result = [...result].sort(\n (a, b) => a.estimatedBudget.min - b.estimatedBudget.min,\n );\n break;\n case \"budget-high\":\n result = [...result].sort(\n (a, b) => b.estimatedBudget.max - a.estimatedBudget.max,\n );\n break;\n }\n\n return result;\n }, [templates, searchTerm, categoryFilter, sortBy]);\n\n // Reset to page 1 whenever filters/sort change, and keep the pager's total in\n // sync with the filtered result set (client-side pagination over the snapshot).\n useEffect(() => {\n setPage(1);\n }, [searchTerm, categoryFilter, sortBy, setPage]);\n useEffect(() => {\n setTotal(filteredTemplates.length);\n }, [filteredTemplates.length, setTotal]);\n\n const pageTemplates = useMemo(\n () =>\n filteredTemplates.slice(\n pagination.offset,\n pagination.offset + pagination.pageSize,\n ),\n [filteredTemplates, pagination.offset, pagination.pageSize],\n );\n\n return (\n <PageLayout\n title=\"Campaign Templates\"\n description=\"Ready-to-use templates to launch your campaigns faster\"\n actions={\n <button\n onClick={() => navigate(basePath + \"/campaigns\")}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-seam bg-gloss-card shadow-pop px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"h-4 w-4\" />\n Back to Campaigns\n </button>\n }\n >\n <PagePurpose>\n Start from a proven playbook instead of a blank page. Each template\n bundles a recommended channel mix, budget range and timeline for a\n specific goal (launch, lead-gen, sales, branding) so you can spin up a\n campaign in minutes — pick one and we'll pre-fill the campaign builder.\n </PagePurpose>\n\n {/* Stats — primary emphasis zone */}\n <EmphasisPanel>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n title=\"Templates\"\n value={String(templates.length)}\n icon={<LayoutTemplate className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Total Uses\"\n value={String(totalUses)}\n icon={<Users className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Avg Success Rate\"\n value={`${avgSuccessRate}%`}\n icon={<TrendingUp className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Top Rated\"\n value={topRated?.name ?? \"-\"}\n icon={<Award className=\"h-5 w-5\" />}\n />\n </div>\n </EmphasisPanel>\n\n {/* Filters */}\n <FilterBar\n searchValue={searchTerm}\n onSearchChange={setSearchTerm}\n searchPlaceholder=\"Search templates...\"\n filters={\n <>\n <select\n value={categoryFilter}\n onChange={(e) => setCategoryFilter(e.target.value)}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n {categoryOptions.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n <select\n value={sortBy}\n onChange={(e) => setSortBy(e.target.value)}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n {sortOptions.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n </>\n }\n />\n\n <QueryStateBoundary\n loading={loading}\n error={error}\n onRetry={() => void refetch()}\n hasData={Boolean(data)}\n >\n {/* Template Grid */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {pageTemplates.map((template) => {\n const successRate = getSuccessRate(template.popularity);\n return (\n <div\n key={template.id}\n className=\"rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop hover:shadow-md transition-shadow flex flex-col\"\n >\n {/* Category Badge */}\n <div className=\"mb-3\">\n <span className=\"inline-flex items-center rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\">\n {template.category}\n </span>\n </div>\n\n {/* Name & Description */}\n <h3 className=\"text-sm font-semibold text-text-primary mb-1\">\n {template.name}\n </h3>\n <p className=\"text-xs text-text-secondary mb-3 line-clamp-2\">\n {template.description}\n </p>\n\n {/* Rating */}\n <div className=\"flex items-center gap-1 mb-3\">\n {renderStars(template.popularity)}\n <span className=\"text-xs text-text-secondary ml-1\">\n ({template.popularity} uses)\n </span>\n </div>\n\n {/* Meta */}\n <div className=\"grid grid-cols-2 gap-2 mb-3 text-xs\">\n <div className=\"flex items-center gap-1.5 text-text-secondary\">\n <Zap className=\"h-3 w-3\" />\n <span>\n {formatCurrency(template.estimatedBudget.min)} -{\" \"}\n {formatCurrency(template.estimatedBudget.max)}\n </span>\n </div>\n <div className=\"flex items-center gap-1.5 text-text-secondary\">\n <Clock className=\"h-3 w-3\" />\n <span>{template.duration}</span>\n </div>\n </div>\n\n {/* Channels */}\n <div className=\"flex flex-wrap gap-1.5 mb-3\">\n {template.channels.map((channel) => (\n <span\n key={channel}\n className=\"inline-flex items-center rounded-full border border-border-subtle px-2 py-0.5 text-[10px] font-medium text-text-secondary\"\n >\n {channel}\n </span>\n ))}\n </div>\n\n {/* Success Rate Bar */}\n <div className=\"mb-4\">\n <div className=\"flex items-center justify-between text-xs mb-1\">\n <span className=\"text-text-secondary\">Success Rate</span>\n <span className=\"font-medium text-text-primary\">\n {successRate}%\n </span>\n </div>\n <div className=\"h-1.5 w-full rounded-full bg-bg-sunken\">\n <div\n className={cn(\n \"h-1.5 rounded-full transition-all\",\n successRate >= 80\n ? \"bg-status-success-text\"\n : successRate >= 60\n ? \"bg-status-warning-text\"\n : \"bg-status-error-text\",\n )}\n style={{ width: `${successRate}%` }}\n />\n </div>\n </div>\n\n {/* Use Button */}\n <div className=\"mt-auto\">\n <button\n onClick={() => navigate(basePath + \"/campaigns/new\")}\n className=\"w-full rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 transition-colors\"\n >\n Use Template\n </button>\n </div>\n </div>\n );\n })}\n </div>\n\n {filteredTemplates.length === 0 && (\n <EmptyState\n illustration={\n templates.length === 0 ? \"empty-generic\" : \"empty-search\"\n }\n title={\n templates.length === 0\n ? \"No templates available\"\n : \"No templates found\"\n }\n description={\n templates.length === 0\n ? \"Templates will appear here once they're added to your workspace.\"\n : \"Try adjusting your search or filter criteria.\"\n }\n />\n )}\n\n {filteredTemplates.length > 0 && (\n <Pagination\n className=\"mt-6\"\n page={pagination.page}\n pageSize={pagination.pageSize}\n total={pagination.total}\n onPageChange={pagination.setPage}\n onPageSizeChange={pagination.setPageSize}\n pageSizeOptions={[9, 18, 36]}\n hideWhenSinglePage\n />\n )}\n </QueryStateBoundary>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,IAAM,IAAkB;CACtB;EAAE,OAAO;EAAO,OAAO;EAAkB;CACzC;EAAE,OAAO;EAAU,OAAO;EAAU;CACpC;EAAE,OAAO;EAAS,OAAO;EAAS;CAClC;EAAE,OAAO;EAAY,OAAO;EAAY;CACxC;EAAE,OAAO;EAAY,OAAO;EAAY;CACxC;EAAE,OAAO;EAAc,OAAO;EAAc;CAC5C;EAAE,OAAO;EAAS,OAAO;EAAS;CAClC;EAAE,OAAO;EAAS,OAAO;EAAS;CAClC;EAAE,OAAO;EA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EAC7B,kBAAC,QAAD,EAAA,UAAO,EAAS,UAAgB,CAAA,CAC5B;aACF;;SAGN,kBAAC,OAAD;UAAK,WAAU;oBACZ,EAAS,SAAS,KAAK,MACtB,kBAAC,QAAD;WAEE,WAAU;qBAET;WACI,EAJA,EAIA,CACP;UACE,CAAA;SAGN,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,QAAD;YAAM,WAAU;sBAAsB;YAAmB,CAAA,EACzD,kBAAC,QAAD;YAAM,WAAU;sBAAhB,CACG,GAAY,IACR;cACH;cACN,kBAAC,OAAD;WAAK,WAAU;qBACb,kBAAC,OAAD;YACE,WAAW,EACT,qCACA,KAAe,KACX,2BACA,KAAe,KACb,2BACA,uBACP;YACD,OAAO,EAAE,OAAO,GAAG,EAAY,IAAI;YACnC,CAAA;WACE,CAAA,CACF;;SAGN,kBAAC,OAAD;UAAK,WAAU;oBACb,kBAAC,UAAD;WACE,eAAe,EAAS,IAAW,iBAAiB;WACpD,WAAU;qBACX;WAEQ,CAAA;UACL,CAAA;SACF;UArFC,EAAS,GAqFV;QAER;MACE,CAAA;KAEL,EAAkB,WAAW,KAC5B,kBAAC,GAAD;MACE,cACE,EAAU,WAAW,IAAI,kBAAkB;MAE7C,OACE,EAAU,WAAW,IACjB,2BACA;MAEN,aACE,EAAU,WAAW,IACjB,qEACA;MAEN,CAAA;KAGH,EAAkB,SAAS,KAC1B,kBAAC,GAAD;MACE,WAAU;MACV,MAAM,EAAW;MACjB,UAAU,EAAW;MACrB,OAAO,EAAW;MAClB,cAAc,EAAW;MACzB,kBAAkB,EAAW;MAC7B,iBAAiB;OAAC;OAAG;OAAI;OAAG;MAC5B,oBAAA;MACA,CAAA;KAEe;;GACV"}
|
|
1
|
+
{"version":3,"file":"CampaignTemplatesPage.js","names":[],"sources":["../../../../src/headshotmarketing/pages/campaigns/CampaignTemplatesPage.tsx"],"sourcesContent":["/**\n * Campaign Templates Gallery Page\n * @module headshotmarketing\n */\n\nimport { useCallback, useEffect, useMemo, useState, type FC } from \"react\";\nimport { ArrowLeft, Award, LayoutTemplate, Tag, Users } from \"lucide-react\";\nimport {\n PageLayout,\n StatCard,\n FilterBar,\n EmptyState,\n Pagination,\n QueryStateBoundary,\n} from \"../../components\";\nimport { EmphasisPanel, PagePurpose } from \"@burdenoff/fe-libs/ui\";\nimport { useHeadshotMarketing } from \"../../context/HeadshotMarketingContext\";\nimport { useHeadshotmarketingBootstrap, usePagination } from \"../../hooks\";\nimport { useCreateHeadshotmarketingCampaignFromTemplateMutation } from \"../../../generated/wspace-operations\";\nimport { TemplateCard, type CampaignTemplateItem } from \"./TemplateCard\";\n\nconst sortOptions = [\n { value: \"popular\", label: \"Most Used\" },\n { value: \"name\", label: \"Name A-Z\" },\n { value: \"newest\", label: \"Newest First\" },\n { value: \"budget-low\", label: \"Budget: Low to High\" },\n { value: \"budget-high\", label: \"Budget: High to Low\" },\n];\n\nexport const CampaignTemplatesPage: FC = () => {\n const { navigate, basePath } = useHeadshotMarketing();\n const { data, loading, error, refetch } = useHeadshotmarketingBootstrap();\n const [searchTerm, setSearchTerm] = useState(\"\");\n const [categoryFilter, setCategoryFilter] = useState(\"all\");\n const [sortBy, setSortBy] = useState(\"popular\");\n const pagination = usePagination({ initialPageSize: 9 });\n const { setTotal, setPage } = pagination;\n\n const [createFromTemplate] =\n useCreateHeadshotmarketingCampaignFromTemplateMutation();\n const [submittingId, setSubmittingId] = useState<string | null>(null);\n const [actionError, setActionError] = useState<{\n id: string;\n message: string;\n } | null>(null);\n\n // Real template items straight off the bootstrap payload — these carry the\n // server-provided category / channels / estimatedDuration / defaultBudget /\n // usageCount fields (the shared mapper derives/fabricates those and is not\n // used here on purpose).\n const templates: CampaignTemplateItem[] = useMemo(\n () => data?.headshotmarketingCampaignTemplates.items ?? [],\n [data?.headshotmarketingCampaignTemplates.items],\n );\n\n const totalUses = useMemo(\n () => templates.reduce((sum, t) => sum + t.usageCount, 0),\n [templates],\n );\n const mostUsed = useMemo(\n () =>\n templates.length > 0\n ? templates.reduce(\n (best, t) => (t.usageCount > best.usageCount ? t : best),\n templates[0],\n )\n : null,\n [templates],\n );\n const categoryOptions = useMemo(() => {\n const seen = new Set<string>();\n for (const t of templates) {\n if (t.category) seen.add(t.category);\n }\n return [\n { value: \"all\", label: \"All Categories\" },\n ...Array.from(seen)\n .sort((a, b) => a.localeCompare(b))\n .map((category) => ({ value: category, label: category })),\n ];\n }, [templates]);\n\n const filteredTemplates = useMemo(() => {\n const query = searchTerm.trim().toLowerCase();\n let result = templates.filter((tpl) => {\n const matchesSearch =\n !query ||\n tpl.name.toLowerCase().includes(query) ||\n (tpl.description ?? \"\").toLowerCase().includes(query);\n const matchesCategory =\n categoryFilter === \"all\" || tpl.category === categoryFilter;\n return matchesSearch && matchesCategory;\n });\n\n switch (sortBy) {\n case \"popular\":\n result = [...result].sort((a, b) => b.usageCount - a.usageCount);\n break;\n case \"name\":\n result = [...result].sort((a, b) => a.name.localeCompare(b.name));\n break;\n case \"newest\":\n result = [...result].sort(\n (a, b) =>\n new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),\n );\n break;\n case \"budget-low\":\n result = [...result].sort(\n (a, b) => (a.defaultBudget ?? 0) - (b.defaultBudget ?? 0),\n );\n break;\n case \"budget-high\":\n result = [...result].sort(\n (a, b) => (b.defaultBudget ?? 0) - (a.defaultBudget ?? 0),\n );\n break;\n }\n\n return result;\n }, [templates, searchTerm, categoryFilter, sortBy]);\n\n // Reset to page 1 whenever filters/sort change, and keep the pager's total in\n // sync with the filtered result set (client-side pagination over the snapshot).\n useEffect(() => {\n setPage(1);\n }, [searchTerm, categoryFilter, sortBy, setPage]);\n useEffect(() => {\n setTotal(filteredTemplates.length);\n }, [filteredTemplates.length, setTotal]);\n\n const pageTemplates = useMemo(\n () =>\n filteredTemplates.slice(\n pagination.offset,\n pagination.offset + pagination.pageSize,\n ),\n [filteredTemplates, pagination.offset, pagination.pageSize],\n );\n\n const handleUseTemplate = useCallback(\n async (template: CampaignTemplateItem) => {\n if (submittingId) return;\n setSubmittingId(template.id);\n setActionError(null);\n try {\n const result = await createFromTemplate({\n variables: { templateId: template.id },\n });\n const created =\n result.data?.createHeadshotmarketingCampaignFromTemplate;\n // Refresh the bootstrap snapshot so the new campaign + the template's\n // bumped usageCount are reflected everywhere before we leave the page.\n await refetch();\n navigate(\n created?.id\n ? `${basePath}/campaigns/${created.id}`\n : `${basePath}/campaigns`,\n );\n } catch (err) {\n setActionError({\n id: template.id,\n message:\n err instanceof Error\n ? err.message\n : \"Failed to create a campaign from this template. Please try again.\",\n });\n } finally {\n setSubmittingId(null);\n }\n },\n [submittingId, createFromTemplate, refetch, navigate, basePath],\n );\n\n return (\n <PageLayout\n title=\"Campaign Templates\"\n description=\"Ready-to-use templates to launch your campaigns faster\"\n actions={\n <button\n onClick={() => navigate(basePath + \"/campaigns\")}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-seam bg-gloss-card shadow-pop px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"h-4 w-4\" />\n Back to Campaigns\n </button>\n }\n >\n <PagePurpose>\n Start from a proven playbook instead of a blank page. Each template\n bundles a recommended channel mix, budget and timeline for a specific\n goal so you can spin up a campaign in minutes — pick one and we'll\n create the campaign for you.\n </PagePurpose>\n\n {/* Stats — primary emphasis zone */}\n <EmphasisPanel>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n title=\"Templates\"\n value={String(templates.length)}\n icon={<LayoutTemplate className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Total Uses\"\n value={String(totalUses)}\n icon={<Users className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Categories\"\n value={String(Math.max(categoryOptions.length - 1, 0))}\n icon={<Tag className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Most Used\"\n value={mostUsed?.name ?? \"-\"}\n icon={<Award className=\"h-5 w-5\" />}\n />\n </div>\n </EmphasisPanel>\n\n {/* Filters */}\n <FilterBar\n searchValue={searchTerm}\n onSearchChange={setSearchTerm}\n searchPlaceholder=\"Search templates...\"\n filters={\n <>\n <select\n value={categoryFilter}\n onChange={(e) => setCategoryFilter(e.target.value)}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n {categoryOptions.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n <select\n value={sortBy}\n onChange={(e) => setSortBy(e.target.value)}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n >\n {sortOptions.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n </>\n }\n />\n\n <QueryStateBoundary\n loading={loading}\n error={error}\n onRetry={() => void refetch()}\n hasData={Boolean(data)}\n >\n {/* Template Grid */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {pageTemplates.map((template) => (\n <TemplateCard\n key={template.id}\n template={template}\n onUse={handleUseTemplate}\n submitting={submittingId === template.id}\n disabled={submittingId !== null}\n errorMessage={\n actionError?.id === template.id\n ? actionError.message\n : undefined\n }\n />\n ))}\n </div>\n\n {filteredTemplates.length === 0 && (\n <EmptyState\n illustration={\n templates.length === 0 ? \"empty-generic\" : \"empty-search\"\n }\n title={\n templates.length === 0\n ? \"No templates available\"\n : \"No templates found\"\n }\n description={\n templates.length === 0\n ? \"Templates will appear here once they're added to your workspace.\"\n : \"Try adjusting your search or filter criteria.\"\n }\n />\n )}\n\n {filteredTemplates.length > 0 && (\n <Pagination\n className=\"mt-6\"\n page={pagination.page}\n pageSize={pagination.pageSize}\n total={pagination.total}\n onPageChange={pagination.setPage}\n onPageSizeChange={pagination.setPageSize}\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G;OAAI;OAAG;MAC5B,oBAAA;MACA,CAAA;KAEe;;GACV"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { cn as e, formatCurrency as t } from "../../utils/helpers.js";
|
|
2
|
+
import { Clock as n, DollarSign as r, Layers as i, TrendingUp as a } from "lucide-react";
|
|
3
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
|
+
import { Badge as l, Button as u, Spinner as d } from "@burdenoff/fe-libs/ui";
|
|
5
|
+
//#region src/headshotmarketing/pages/campaigns/TemplateCard.tsx
|
|
6
|
+
var f = ({ template: f, onUse: p, submitting: m, disabled: h, errorMessage: g }) => {
|
|
7
|
+
let _ = typeof f.defaultBudget == "number" && Number.isFinite(f.defaultBudget) ? f.defaultBudget : null, v = !!f.estimatedDuration, y = _ !== null || v;
|
|
8
|
+
return /* @__PURE__ */ c("div", {
|
|
9
|
+
"aria-busy": m,
|
|
10
|
+
className: e("flex flex-col rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop transition-shadow hover:shadow-md", m && "opacity-90"),
|
|
11
|
+
children: [
|
|
12
|
+
f.category ? /* @__PURE__ */ s("div", {
|
|
13
|
+
className: "mb-3",
|
|
14
|
+
children: /* @__PURE__ */ s(l, {
|
|
15
|
+
variant: "secondary",
|
|
16
|
+
children: f.category
|
|
17
|
+
})
|
|
18
|
+
}) : null,
|
|
19
|
+
/* @__PURE__ */ s("h3", {
|
|
20
|
+
className: "mb-1 text-sm font-semibold text-text-primary",
|
|
21
|
+
children: f.name
|
|
22
|
+
}),
|
|
23
|
+
f.description ? /* @__PURE__ */ s("p", {
|
|
24
|
+
className: "mb-3 line-clamp-2 text-xs text-text-secondary",
|
|
25
|
+
children: f.description
|
|
26
|
+
}) : null,
|
|
27
|
+
/* @__PURE__ */ c("div", {
|
|
28
|
+
className: "mb-3 flex items-center gap-1.5 text-xs text-text-secondary",
|
|
29
|
+
children: [/* @__PURE__ */ s(a, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ c("span", { children: [
|
|
30
|
+
"Used ",
|
|
31
|
+
f.usageCount,
|
|
32
|
+
" ",
|
|
33
|
+
f.usageCount === 1 ? "time" : "times"
|
|
34
|
+
] })]
|
|
35
|
+
}),
|
|
36
|
+
y ? /* @__PURE__ */ c("div", {
|
|
37
|
+
className: "mb-3 grid grid-cols-2 gap-2 text-xs",
|
|
38
|
+
children: [_ === null ? null : /* @__PURE__ */ c("div", {
|
|
39
|
+
className: "flex items-center gap-1.5 text-text-secondary",
|
|
40
|
+
children: [/* @__PURE__ */ s(r, { className: "h-3 w-3 shrink-0" }), /* @__PURE__ */ s("span", { children: t(_) })]
|
|
41
|
+
}), v ? /* @__PURE__ */ c("div", {
|
|
42
|
+
className: "flex items-center gap-1.5 text-text-secondary",
|
|
43
|
+
children: [/* @__PURE__ */ s(n, { className: "h-3 w-3 shrink-0" }), /* @__PURE__ */ s("span", { children: f.estimatedDuration })]
|
|
44
|
+
}) : null]
|
|
45
|
+
}) : null,
|
|
46
|
+
f.channels.length > 0 ? /* @__PURE__ */ c("div", {
|
|
47
|
+
className: "mb-4",
|
|
48
|
+
children: [/* @__PURE__ */ c("div", {
|
|
49
|
+
className: "mb-1.5 flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-text-secondary",
|
|
50
|
+
children: [/* @__PURE__ */ s(i, { className: "h-3 w-3" }), /* @__PURE__ */ s("span", { children: "Channels" })]
|
|
51
|
+
}), /* @__PURE__ */ s("div", {
|
|
52
|
+
className: "flex flex-wrap gap-1.5",
|
|
53
|
+
children: f.channels.map((e) => /* @__PURE__ */ s(l, {
|
|
54
|
+
variant: "outline",
|
|
55
|
+
children: e
|
|
56
|
+
}, e))
|
|
57
|
+
})]
|
|
58
|
+
}) : null,
|
|
59
|
+
g ? /* @__PURE__ */ s("p", {
|
|
60
|
+
className: "mb-2 text-xs text-status-error-text",
|
|
61
|
+
role: "alert",
|
|
62
|
+
children: g
|
|
63
|
+
}) : null,
|
|
64
|
+
/* @__PURE__ */ s("div", {
|
|
65
|
+
className: "mt-auto",
|
|
66
|
+
children: /* @__PURE__ */ s(u, {
|
|
67
|
+
type: "button",
|
|
68
|
+
className: "w-full",
|
|
69
|
+
disabled: h,
|
|
70
|
+
"aria-busy": m,
|
|
71
|
+
onClick: () => p(f),
|
|
72
|
+
children: m ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s(d, { size: "sm" }), "Creating…"] }) : "Use Template"
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { f as TemplateCard };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=TemplateCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateCard.js","names":[],"sources":["../../../../src/headshotmarketing/pages/campaigns/TemplateCard.tsx"],"sourcesContent":["/**\n * TemplateCard — campaign-template gallery card.\n *\n * Renders the REAL fields exposed on the bootstrap\n * `headshotmarketingCampaignTemplates.items` payload (category, channels,\n * estimatedDuration, defaultBudget, usageCount) and wires the \"Use Template\"\n * action back to the page-owned mutation with per-card loading + error state.\n *\n * @module headshotmarketing\n */\n\nimport type { FC } from \"react\";\nimport { Clock, DollarSign, Layers, TrendingUp } from \"lucide-react\";\nimport { Badge, Button, Spinner } from \"@burdenoff/fe-libs/ui\";\nimport { cn, formatCurrency } from \"../../utils/helpers\";\nimport type { HeadshotmarketingBootstrapDataQuery } from \"../../../generated/wspace-operations\";\n\n/** A single real campaign-template item as returned by the bootstrap query. */\nexport type CampaignTemplateItem =\n HeadshotmarketingBootstrapDataQuery[\"headshotmarketingCampaignTemplates\"][\"items\"][number];\n\nexport interface TemplateCardProps {\n template: CampaignTemplateItem;\n /** Invoked when the user clicks \"Use Template\". */\n onUse: (template: CampaignTemplateItem) => void;\n /** This card's create-from-template mutation is in flight. */\n submitting: boolean;\n /** Any card's mutation is in flight — block concurrent submissions. */\n disabled: boolean;\n /** Inline error to surface on this card (create-from-template failed). */\n errorMessage?: string;\n}\n\nexport const TemplateCard: FC<TemplateCardProps> = ({\n template,\n onUse,\n submitting,\n disabled,\n errorMessage,\n}) => {\n const budget =\n typeof template.defaultBudget === \"number\" &&\n Number.isFinite(template.defaultBudget)\n ? template.defaultBudget\n : null;\n const hasDuration = Boolean(template.estimatedDuration);\n const hasMeta = budget !== null || hasDuration;\n\n return (\n <div\n aria-busy={submitting}\n className={cn(\n \"flex flex-col rounded-lg border border-border-seam bg-gloss-card p-5 shadow-pop transition-shadow hover:shadow-md\",\n submitting && \"opacity-90\",\n )}\n >\n {/* Category chip (real) */}\n {template.category ? (\n <div className=\"mb-3\">\n <Badge variant=\"secondary\">{template.category}</Badge>\n </div>\n ) : null}\n\n {/* Name & description */}\n <h3 className=\"mb-1 text-sm font-semibold text-text-primary\">\n {template.name}\n </h3>\n {template.description ? (\n <p className=\"mb-3 line-clamp-2 text-xs text-text-secondary\">\n {template.description}\n </p>\n ) : null}\n\n {/* Usage count (real) */}\n <div className=\"mb-3 flex items-center gap-1.5 text-xs text-text-secondary\">\n <TrendingUp className=\"h-3.5 w-3.5\" />\n <span>\n Used {template.usageCount}{\" \"}\n {template.usageCount === 1 ? \"time\" : \"times\"}\n </span>\n </div>\n\n {/* Budget + duration meta (real) */}\n {hasMeta ? (\n <div className=\"mb-3 grid grid-cols-2 gap-2 text-xs\">\n {budget !== null ? (\n <div className=\"flex items-center gap-1.5 text-text-secondary\">\n <DollarSign className=\"h-3 w-3 shrink-0\" />\n <span>{formatCurrency(budget)}</span>\n </div>\n ) : null}\n {hasDuration ? (\n <div className=\"flex items-center gap-1.5 text-text-secondary\">\n <Clock className=\"h-3 w-3 shrink-0\" />\n <span>{template.estimatedDuration}</span>\n </div>\n ) : null}\n </div>\n ) : null}\n\n {/* Channels chips (real) */}\n {template.channels.length > 0 ? (\n <div className=\"mb-4\">\n <div className=\"mb-1.5 flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-text-secondary\">\n <Layers className=\"h-3 w-3\" />\n <span>Channels</span>\n </div>\n <div className=\"flex flex-wrap gap-1.5\">\n {template.channels.map((channel) => (\n <Badge key={channel} variant=\"outline\">\n {channel}\n </Badge>\n ))}\n </div>\n </div>\n ) : null}\n\n {/* Inline error (honest failure state) */}\n {errorMessage ? (\n <p className=\"mb-2 text-xs text-status-error-text\" role=\"alert\">\n {errorMessage}\n </p>\n ) : null}\n\n {/* Use Template action */}\n <div className=\"mt-auto\">\n <Button\n type=\"button\"\n className=\"w-full\"\n disabled={disabled}\n aria-busy={submitting}\n onClick={() => onUse(template)}\n >\n {submitting ? (\n <>\n <Spinner size=\"sm\" />\n Creating…\n </>\n ) : (\n \"Use Template\"\n )}\n </Button>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AAiCA,IAAa,KAAuC,EAClD,aACA,UACA,eACA,aACA,sBACI;CACJ,IAAM,IACJ,OAAO,EAAS,iBAAkB,YAClC,OAAO,SAAS,EAAS,cAAc,GACnC,EAAS,gBACT,MACA,IAAc,EAAQ,EAAS,mBAC/B,IAAU,MAAW,QAAQ;AAEnC,QACE,kBAAC,OAAD;EACE,aAAW;EACX,WAAW,EACT,qHACA,KAAc,aACf;YALH;GAQG,EAAS,WACR,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,GAAD;KAAO,SAAQ;eAAa,EAAS;KAAiB,CAAA;IAClD,CAAA,GACJ;GAGJ,kBAAC,MAAD;IAAI,WAAU;cACX,EAAS;IACP,CAAA;GACJ,EAAS,cACR,kBAAC,KAAD;IAAG,WAAU;cACV,EAAS;IACR,CAAA,GACF;GAGJ,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD,EAAY,WAAU,eAAgB,CAAA,EACtC,kBAAC,QAAD,EAAA,UAAA;KAAM;KACE,EAAS;KAAY;KAC1B,EAAS,eAAe,IAAI,SAAS;KACjC,EAAA,CAAA,CACH;;GAGL,IACC,kBAAC,OAAD;IAAK,WAAU;cAAf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