@matija2209/payload-plugin-admin-feedback 1.0.0 → 1.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.
@@ -1,100 +0,0 @@
1
- 'use client';
2
-
3
- import React from 'react';
4
- import { usePathname } from 'next/navigation';
5
-
6
- import { FeedbackWidget } from './FeedbackWidget';
7
- import { pathMatchesAllowlist } from './routeMatcher';
8
-
9
- type FrontendFeedbackWidgetProps = {
10
- include: string[];
11
- locales?: string[];
12
- title?: string;
13
- submitLabel?: string;
14
- uploadLabel?: string;
15
- };
16
-
17
- const normalizePathname = (pathname: string, locales: string[]): string => {
18
- if (locales.length === 0) {
19
- return pathname;
20
- }
21
-
22
- const segments = pathname.split('/').filter(Boolean);
23
- const maybeLocale = segments[0];
24
- if (maybeLocale && locales.includes(maybeLocale)) {
25
- return `/${segments.slice(1).join('/')}`;
26
- }
27
-
28
- return pathname;
29
- };
30
-
31
- export function FrontendFeedbackWidget({
32
- include,
33
- locales = [],
34
- title = 'Feedback',
35
- submitLabel = 'Send',
36
- uploadLabel = 'Upload image',
37
- }: FrontendFeedbackWidgetProps) {
38
- const pathname = usePathname();
39
- const normalizedPathname = normalizePathname(pathname, locales);
40
-
41
- if (!pathMatchesAllowlist(normalizedPathname, include)) {
42
- return null;
43
- }
44
-
45
- return (
46
- <FeedbackWidget
47
- title={title}
48
- submitLabel={submitLabel}
49
- uploadLabel={uploadLabel}
50
- allowScreenshotUpload
51
- onSubmit={async (payload) => {
52
- const response = await fetch('/api/admin-feedback/submit', {
53
- method: 'POST',
54
- credentials: 'include',
55
- headers: { 'content-type': 'application/json' },
56
- body: JSON.stringify(payload),
57
- });
58
-
59
- const result = (await response.json()) as { success: boolean; error?: string };
60
- if (!result.success) {
61
- return { success: false as const, error: result.error || 'Submit failed.' };
62
- }
63
-
64
- return { success: true as const };
65
- }}
66
- onUpload={async (formData) => {
67
- const response = await fetch('/api/admin-feedback/upload', {
68
- method: 'POST',
69
- credentials: 'include',
70
- body: formData,
71
- });
72
-
73
- const result = (await response.json()) as {
74
- success: boolean;
75
- error?: string;
76
- mediaId?: number;
77
- };
78
-
79
- if (!result.success || typeof result.mediaId !== 'number') {
80
- return { success: false as const, error: result.error || 'Upload failed.' };
81
- }
82
-
83
- return { success: true as const, mediaId: result.mediaId };
84
- }}
85
- onDeleteScreenshot={async (mediaId) => {
86
- const response = await fetch(`/api/admin-feedback/upload/${mediaId}`, {
87
- method: 'DELETE',
88
- credentials: 'include',
89
- });
90
-
91
- const result = (await response.json()) as { success: boolean; error?: string };
92
- if (!result.success) {
93
- return { success: false as const, error: result.error || 'Delete failed.' };
94
- }
95
-
96
- return { success: true as const };
97
- }}
98
- />
99
- );
100
- }
@@ -1,4 +0,0 @@
1
- export { FeedbackWidget } from './FeedbackWidget';
2
- export { AdminFeedbackWidget } from './AdminFeedbackWidget';
3
- export { FrontendFeedbackWidget } from './FrontendFeedbackWidget';
4
- export { pathMatchesAllowlist } from './routeMatcher';
@@ -1,18 +0,0 @@
1
- const escapeRegex = (input: string): string => input.replace(/[.+^${}()|[\]\\]/g, '\\$&');
2
-
3
- const toRegExp = (pattern: string): RegExp => {
4
- const escaped = pattern
5
- .split('*')
6
- .map((segment) => escapeRegex(segment))
7
- .join('.*');
8
-
9
- return new RegExp(`^${escaped}$`);
10
- };
11
-
12
- export const pathMatchesAllowlist = (pathname: string, patterns: string[]): boolean => {
13
- if (patterns.length === 0) {
14
- return false;
15
- }
16
-
17
- return patterns.some((pattern) => toRegExp(pattern).test(pathname));
18
- };
@@ -1,325 +0,0 @@
1
- import type { CollectionConfig, PayloadRequest } from 'payload';
2
- import { headersWithCors } from 'payload';
3
-
4
- import { sendFeedbackEmail } from '../server/sendFeedbackEmail';
5
- import type { ResolvedAdminFeedbackPluginOptions } from '../types';
6
-
7
- const trim = (value: unknown): string | null => {
8
- if (typeof value !== 'string') {
9
- return null;
10
- }
11
-
12
- const nextValue = value.trim();
13
- return nextValue.length > 0 ? nextValue : null;
14
- };
15
-
16
- const corsHeaders = (req: PayloadRequest, init?: HeadersInit): Headers =>
17
- headersWithCors({
18
- headers: new Headers(init),
19
- req: req as unknown as Request,
20
- });
21
-
22
- export const createAdminFeedbackCollection = (
23
- options: ResolvedAdminFeedbackPluginOptions,
24
- mediaCollectionSlug: string,
25
- ): CollectionConfig => {
26
- return {
27
- slug: 'admin-feedback',
28
- admin: {
29
- group: {
30
- sl: 'System',
31
- en: 'System',
32
- ru: 'System',
33
- },
34
- useAsTitle: 'message',
35
- defaultColumns: ['createdAt', 'pagePath', 'status'],
36
- },
37
- access: {
38
- read: ({ req }) => Boolean(req.user),
39
- create: () => true,
40
- update: ({ req }) => Boolean(req.user),
41
- delete: ({ req }) => Boolean(req.user),
42
- },
43
- endpoints: [
44
- {
45
- path: '/submit',
46
- method: 'post',
47
- handler: async (req) => {
48
- try {
49
- const body = await req.json!();
50
- const message = trim(body?.message);
51
- if (!message) {
52
- return Response.json(
53
- { success: false, error: 'Message is required.' },
54
- { status: 400, headers: corsHeaders(req) },
55
- );
56
- }
57
-
58
- const doc = await req.payload.create({
59
- collection: 'admin-feedback',
60
- data: {
61
- message,
62
- pagePath: trim(body?.pagePath) || '/',
63
- selector: trim(body?.selector) || undefined,
64
- selectedText: trim(body?.selectedText) || undefined,
65
- screenshot: body?.screenshotId || undefined,
66
- createdBy: req.user?.id,
67
- meta: {
68
- createdAt: new Date().toISOString(),
69
- userAgent: trim(body?.meta?.userAgent),
70
- locale: trim(body?.meta?.locale),
71
- viewport: trim(body?.meta?.viewport),
72
- },
73
- },
74
- });
75
-
76
- return Response.json(
77
- { success: true, id: doc.id },
78
- { headers: corsHeaders(req) },
79
- );
80
- } catch (error) {
81
- return Response.json(
82
- { success: false, error: error instanceof Error ? error.message : 'Unknown error' },
83
- { status: 500, headers: corsHeaders(req) },
84
- );
85
- }
86
- },
87
- },
88
- {
89
- path: '/upload',
90
- method: 'post',
91
- handler: async (req) => {
92
- try {
93
- if (!req.user) {
94
- return Response.json(
95
- { success: false, error: 'Unauthorized' },
96
- { status: 401, headers: corsHeaders(req) },
97
- );
98
- }
99
-
100
- const formData = await req.formData!();
101
- const file = formData.get('file');
102
- const altRaw = formData.get('alt');
103
- const alt = typeof altRaw === 'string' ? altRaw.trim() : '';
104
-
105
- if (!(file instanceof File)) {
106
- return Response.json(
107
- { success: false, error: 'Missing file.' },
108
- { status: 400, headers: corsHeaders(req) },
109
- );
110
- }
111
-
112
- if (file.size === 0) {
113
- return Response.json(
114
- { success: false, error: 'File is empty.' },
115
- { status: 400, headers: corsHeaders(req) },
116
- );
117
- }
118
-
119
- const media = await req.payload.create({
120
- collection: mediaCollectionSlug,
121
- data: {
122
- alt: alt || file.name,
123
- },
124
- file: {
125
- data: Buffer.from(await file.arrayBuffer()),
126
- mimetype: file.type || 'application/octet-stream',
127
- name: file.name,
128
- size: file.size,
129
- },
130
- });
131
-
132
- return Response.json(
133
- { success: true, mediaId: Number(media.id) },
134
- { headers: corsHeaders(req) },
135
- );
136
- } catch (error) {
137
- return Response.json(
138
- { success: false, error: error instanceof Error ? error.message : 'Unknown error' },
139
- { status: 500, headers: corsHeaders(req) },
140
- );
141
- }
142
- },
143
- },
144
- {
145
- path: '/upload/:id',
146
- method: 'delete',
147
- handler: async (req) => {
148
- try {
149
- if (!req.user) {
150
- return Response.json(
151
- { success: false, error: 'Unauthorized' },
152
- { status: 401, headers: corsHeaders(req) },
153
- );
154
- }
155
-
156
- const id = req.routeParams?.id as string | undefined;
157
- if (!id) {
158
- return Response.json(
159
- { success: false, error: 'Missing media ID.' },
160
- { status: 400, headers: corsHeaders(req) },
161
- );
162
- }
163
-
164
- await req.payload.delete({
165
- collection: mediaCollectionSlug,
166
- id,
167
- });
168
-
169
- return Response.json(
170
- { success: true },
171
- { headers: corsHeaders(req) },
172
- );
173
- } catch (error) {
174
- return Response.json(
175
- { success: false, error: error instanceof Error ? error.message : 'Unknown error' },
176
- { status: 500, headers: corsHeaders(req) },
177
- );
178
- }
179
- },
180
- },
181
- ],
182
- hooks: {
183
- beforeChange: [
184
- ({ data, req, operation }) => {
185
- if (!data) {
186
- return data;
187
- }
188
-
189
- const nextData = { ...data };
190
- const message = trim(nextData.message);
191
- const pagePath = trim(nextData.pagePath);
192
-
193
- nextData.message = message || '';
194
- nextData.pagePath = pagePath || '/';
195
- nextData.selector = trim(nextData.selector);
196
- nextData.selectedText = trim(nextData.selectedText);
197
-
198
- const existingMeta =
199
- typeof nextData.meta === 'object' && nextData.meta !== null
200
- ? (nextData.meta as Record<string, unknown>)
201
- : {};
202
-
203
- nextData.meta = {
204
- ...existingMeta,
205
- createdAt: new Date().toISOString(),
206
- userAgent: trim(existingMeta.userAgent),
207
- locale: trim(existingMeta.locale),
208
- viewport: trim(existingMeta.viewport),
209
- };
210
-
211
- if (operation === 'create' && req.user && !nextData.createdBy) {
212
- nextData.createdBy = req.user.id;
213
- }
214
-
215
- return nextData;
216
- },
217
- ],
218
- afterChange: [
219
- async ({ doc, operation, req }) => {
220
- if (operation !== 'create') {
221
- return doc;
222
- }
223
-
224
- const screenshotDoc =
225
- typeof doc.screenshot === 'object' && doc.screenshot !== null
226
- ? (doc.screenshot as Record<string, unknown>)
227
- : null;
228
- const createdByDoc =
229
- typeof doc.createdBy === 'object' && doc.createdBy !== null
230
- ? (doc.createdBy as Record<string, unknown>)
231
- : null;
232
- const screenshotUrl =
233
- typeof screenshotDoc?.url === 'string'
234
- ? screenshotDoc.url
235
- : typeof screenshotDoc?.filename === 'string'
236
- ? screenshotDoc.filename
237
- : null;
238
-
239
- try {
240
- await sendFeedbackEmail(req.payload, options, {
241
- id: doc.id,
242
- message: String(doc.message || ''),
243
- pagePath: String(doc.pagePath || '/'),
244
- selector: typeof doc.selector === 'string' ? doc.selector : null,
245
- selectedText: typeof doc.selectedText === 'string' ? doc.selectedText : null,
246
- screenshotUrl,
247
- createdByEmail:
248
- createdByDoc && typeof createdByDoc.email === 'string' ? createdByDoc.email : null,
249
- createdByName:
250
- createdByDoc && typeof createdByDoc.first_name === 'string'
251
- ? `${createdByDoc.first_name} ${String(createdByDoc.last_name || '')}`.trim()
252
- : null,
253
- createdAt: typeof doc.createdAt === 'string' ? doc.createdAt : null,
254
- });
255
- } catch (error) {
256
- req.payload.logger.error(
257
- `Failed to send admin feedback email: ${error instanceof Error ? error.message : 'unknown error'}`,
258
- );
259
- }
260
-
261
- return doc;
262
- },
263
- ],
264
- },
265
- fields: [
266
- {
267
- name: 'message',
268
- type: 'textarea',
269
- required: true,
270
- maxLength: options.maxMessageLength || 3000,
271
- },
272
- {
273
- name: 'pagePath',
274
- type: 'text',
275
- required: true,
276
- },
277
- {
278
- name: 'selector',
279
- type: 'text',
280
- },
281
- {
282
- name: 'selectedText',
283
- type: 'text',
284
- },
285
- {
286
- name: 'screenshot',
287
- type: 'upload',
288
- relationTo: mediaCollectionSlug as never,
289
- required: false,
290
- admin: {
291
- description: 'Uploaded screenshot preview',
292
- },
293
- },
294
- {
295
- name: 'createdBy',
296
- type: 'relationship',
297
- relationTo: 'users',
298
- admin: {
299
- position: 'sidebar',
300
- readOnly: true,
301
- },
302
- },
303
- {
304
- name: 'status',
305
- type: 'select',
306
- defaultValue: 'new',
307
- options: [
308
- { label: 'New', value: 'new' },
309
- { label: 'Triaged', value: 'triaged' },
310
- { label: 'Resolved', value: 'resolved' },
311
- ],
312
- admin: {
313
- position: 'sidebar',
314
- },
315
- },
316
- {
317
- name: 'meta',
318
- type: 'json',
319
- admin: {
320
- readOnly: true,
321
- },
322
- },
323
- ],
324
- };
325
- };
package/src/index.ts DELETED
@@ -1,108 +0,0 @@
1
- import { definePlugin, type CollectionConfig, type Config } from 'payload';
2
-
3
- import { createAdminFeedbackCollection } from './collections/AdminFeedback';
4
- import type { AdminFeedbackPluginOptions, ResolvedAdminFeedbackPluginOptions } from './types';
5
-
6
- const PLUGIN_SLUG = 'payload-plugin-admin-feedback';
7
- const DEFAULT_MEDIA_COLLECTION_SLUG = 'media';
8
- const DEFAULT_ORDER = 10;
9
-
10
- const isUploadCollection = (collection: CollectionConfig): boolean => Boolean(collection.upload);
11
-
12
- const getCollectionLabel = (slug: string): string => `Collection "${slug}"`;
13
-
14
- const resolveMediaCollectionSlug = (
15
- config: Config,
16
- options: Pick<ResolvedAdminFeedbackPluginOptions, 'mediaCollectionSlug' | 'strictMediaCollection'>,
17
- ): string => {
18
- const collections = config.collections || [];
19
- const targetCollection = collections.find((collection) => collection.slug === options.mediaCollectionSlug);
20
-
21
- if (!targetCollection) {
22
- if (!options.strictMediaCollection && options.mediaCollectionSlug !== DEFAULT_MEDIA_COLLECTION_SLUG) {
23
- const defaultCollection = collections.find(
24
- (collection) => collection.slug === DEFAULT_MEDIA_COLLECTION_SLUG,
25
- );
26
- if (defaultCollection && isUploadCollection(defaultCollection)) {
27
- return defaultCollection.slug;
28
- }
29
- }
30
-
31
- throw new Error(
32
- `${PLUGIN_SLUG}: ${getCollectionLabel(
33
- options.mediaCollectionSlug,
34
- )} was not found. Add an upload-enabled collection or set mediaCollectionSlug explicitly.`,
35
- );
36
- }
37
-
38
- if (!isUploadCollection(targetCollection)) {
39
- throw new Error(
40
- `${PLUGIN_SLUG}: ${getCollectionLabel(
41
- targetCollection.slug,
42
- )} is not upload-enabled. Configure an upload collection and set mediaCollectionSlug to that slug.`,
43
- );
44
- }
45
-
46
- return targetCollection.slug;
47
- };
48
-
49
- const resolveOptions = (
50
- pluginOptions: AdminFeedbackPluginOptions,
51
- ): ResolvedAdminFeedbackPluginOptions => ({
52
- enabled: true,
53
- allowScreenshotUpload: true,
54
- maxMessageLength: 3000,
55
- mediaCollectionSlug: DEFAULT_MEDIA_COLLECTION_SLUG,
56
- strictMediaCollection: true,
57
- ...pluginOptions,
58
- frontend: {
59
- enabled: true,
60
- include: [],
61
- ...pluginOptions.frontend,
62
- },
63
- screenshot: {
64
- enabled: true,
65
- maxFileSizeBytes: 5 * 1024 * 1024,
66
- allowedMimeTypes: ['image/png', 'image/jpeg', 'image/webp'],
67
- capturePolicy: 'current-tab-first',
68
- ...pluginOptions.screenshot,
69
- },
70
- });
71
-
72
- export const adminFeedbackPlugin = definePlugin<AdminFeedbackPluginOptions>({
73
- slug: PLUGIN_SLUG,
74
- order: DEFAULT_ORDER,
75
- plugin: ({ config, ...pluginOptions }) => {
76
- const options = resolveOptions(pluginOptions);
77
-
78
- if (!options.enabled) {
79
- return config;
80
- }
81
-
82
- if (!options.emailTo || (Array.isArray(options.emailTo) && options.emailTo.length === 0)) {
83
- throw new Error('adminFeedbackPlugin requires emailTo option.');
84
- }
85
-
86
- // Hook into emailAdapter if provided
87
- if (pluginOptions.email && !config.email) {
88
- config.email = pluginOptions.email;
89
- }
90
-
91
- const resolvedMediaCollectionSlug = resolveMediaCollectionSlug(config, options);
92
- const feedbackCollection = createAdminFeedbackCollection(options, resolvedMediaCollectionSlug);
93
-
94
- return {
95
- ...config,
96
- collections: [...(config.collections || []), feedbackCollection],
97
- };
98
- },
99
- });
100
-
101
- export type { AdminFeedbackPluginOptions } from './types';
102
- export { pathMatchesAllowlist } from './client/routeMatcher';
103
-
104
- declare module 'payload' {
105
- interface RegisteredPlugins {
106
- 'payload-plugin-admin-feedback': AdminFeedbackPluginOptions;
107
- }
108
- }
@@ -1,141 +0,0 @@
1
- import type { Payload } from 'payload';
2
-
3
- import type { AdminFeedbackPluginOptions, FeedbackEmailData } from '../types';
4
-
5
- export async function sendFeedbackEmail(
6
- payload: Payload,
7
- options: AdminFeedbackPluginOptions,
8
- data: FeedbackEmailData,
9
- ): Promise<void> {
10
- if (!options.emailTo) {
11
- return;
12
- }
13
-
14
- const to = Array.isArray(options.emailTo) ? options.emailTo : [options.emailTo];
15
- const sourceLabel = options.fromLabel || 'Admin Feedback';
16
- const createdBy = data.createdByName || data.createdByEmail || 'Unknown';
17
-
18
- let formattedDate = 'Unknown';
19
- try {
20
- formattedDate = data.createdAt ? new Date(data.createdAt).toLocaleString('sl-SI', {
21
- day: 'numeric',
22
- month: 'long',
23
- year: 'numeric',
24
- hour: '2-digit',
25
- minute: '2-digit',
26
- }) : new Date().toLocaleString();
27
- } catch (e) {
28
- formattedDate = data.createdAt || 'Unknown';
29
- }
30
-
31
- const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:34572';
32
- const adminUrl = data.id ? `${serverUrl}/admin/collections/admin-feedback/${data.id}` : null;
33
-
34
- const from = options.fromAddress
35
- ? `${options.fromName || options.fromLabel || 'Admin Feedback'} <${options.fromAddress}>`
36
- : undefined;
37
-
38
- const screenshotHtml = data.screenshotUrl && data.screenshotUrl !== '-'
39
- ? `
40
- <div style="margin-top: 24px;">
41
- <p style="margin: 0 0 8px 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: #8b8b8b; font-weight: 600;">Screenshot Preview</p>
42
- <div style="border-radius: 12px; overflow: hidden; border: 1px solid #d6e3e7; background: #00455a;">
43
- <img src="${data.screenshotUrl}" alt="Feedback Screenshot" style="width: 100%; height: auto; display: block;" />
44
- </div>
45
- <p style="margin: 8px 0 0 0; font-size: 12px; color: #8b8b8b;">
46
- Full URL: <a href="${data.screenshotUrl}" style="color: #00455a; text-decoration: none;">${data.screenshotUrl}</a>
47
- </p>
48
- </div>
49
- `
50
- : '';
51
-
52
- const html = `
53
- <!DOCTYPE html>
54
- <html>
55
- <head>
56
- <meta charset="utf-8">
57
- <style>
58
- body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; color: #353535; background-color: #f7f7f7; margin: 0; padding: 40px 20px; }
59
- .container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 20px; overflow: hidden; border: 1px solid #d6e3e7; box-shadow: 0 12px 36px rgba(0, 69, 90, 0.08); }
60
- .header { background: #00455a; color: #fbfbfb; padding: 32px 24px; text-align: center; }
61
- .header h1 { margin: 0; font-size: 24px; font-weight: 700; }
62
- .content { padding: 36px 30px; }
63
- .section { margin-bottom: 24px; }
64
- .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #8b8b8b; font-weight: 700; margin-bottom: 4px; }
65
- .value { font-size: 16px; color: #353535; margin: 0; }
66
- .message-box { background: #f1f7f8; border-left: 4px solid #00455a; padding: 16px 20px; border-radius: 8px; margin-top: 8px; }
67
- .footer { background: #fbfbfb; padding: 24px; text-align: center; border-top: 1px solid #e3edef; color: #8b8b8b; font-size: 13px; }
68
- .button { display: inline-block; background: #00455a; color: #fbfbfb !important; padding: 12px 24px; border-radius: 999px; text-decoration: none; font-weight: 600; margin-top: 20px; }
69
- </style>
70
- </head>
71
- <body>
72
- <div class="container">
73
- <div class="header">
74
- <h1>New Admin Feedback</h1>
75
- <p style="margin: 8px 0 0 0; opacity: 0.8; font-size: 14px;">[${sourceLabel}] Received via Feedback Widget</p>
76
- </div>
77
- <div class="content">
78
- <div class="section">
79
- <p class="label">Message</p>
80
- <div class="message-box">
81
- <p class="value" style="white-space: pre-wrap;">${data.message}</p>
82
- </div>
83
- </div>
84
-
85
- <div style="display: flex; flex-wrap: wrap; gap: 20px; border-top: 1px solid #e3edef; padding-top: 24px;">
86
- <div style="flex: 1; min-width: 200px; margin-bottom: 16px;">
87
- <p class="label">Page Path</p>
88
- <p class="value" style="word-break: break-all;">${data.pagePath}</p>
89
- </div>
90
- <div style="flex: 1; min-width: 200px; margin-bottom: 16px;">
91
- <p class="label">Created By</p>
92
- <p class="value">${createdBy}</p>
93
- </div>
94
- </div>
95
-
96
- <div style="display: flex; flex-wrap: wrap; gap: 20px;">
97
- <div style="flex: 1; min-width: 200px; margin-bottom: 16px;">
98
- <p class="label">Selector</p>
99
- <p class="value" style="font-family: monospace; font-size: 13px;">${data.selector || '-'}</p>
100
- </div>
101
- <div style="flex: 1; min-width: 200px; margin-bottom: 16px;">
102
- <p class="label">Created At</p>
103
- <p class="value">${formattedDate}</p>
104
- </div>
105
- </div>
106
-
107
- ${data.selectedText && data.selectedText !== '-' ? `
108
- <div class="section">
109
- <p class="label">Selected Text</p>
110
- <p class="value" style="font-style: italic; color: #555;">"${data.selectedText}"</p>
111
- </div>
112
- ` : ''}
113
-
114
- ${screenshotHtml}
115
-
116
- ${adminUrl ? `
117
- <div style="text-align: center; margin-top: 32px;">
118
- <a href="${adminUrl}" class="button">View in Admin Panel</a>
119
- </div>
120
- ` : ''}
121
- </div>
122
- <div class="footer">
123
- <p>This automated notification was sent from your Store Admin.</p>
124
- </div>
125
- </div>
126
- </body>
127
- </html>
128
- `;
129
-
130
- const emailMessage: any = {
131
- to,
132
- subject: `[${sourceLabel}] New feedback from ${createdBy}`,
133
- html,
134
- };
135
-
136
- if (from) {
137
- emailMessage.from = from;
138
- }
139
-
140
- await payload.sendEmail(emailMessage);
141
- }