extract shared brandingVars() helper to eliminate duplication
All checks were successful
CI / checks (pull_request) Successful in 35s
All checks were successful
CI / checks (pull_request) Successful in 35s
The { brandName, brandAccent, brandLogo, settingsUrl } object was built
identically 3 times in the /confirm handler. Extract a brandingVars()
helper so it is defined once and reused via spread.
Closes mailship-90c
This commit is contained in:
parent
e86ffbed15
commit
4b43664411
1 changed files with 12 additions and 12 deletions
|
|
@ -299,16 +299,22 @@ addRoute('post', '/notify/:id', async (req: Request, res: Response) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ── Branding helper ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
const brandingVars = () => ({
|
||||||
|
brandName: BRAND_NAME,
|
||||||
|
brandAccent: BRAND_ACCENT,
|
||||||
|
brandLogo: BRAND_LOGO,
|
||||||
|
settingsUrl: `${EVENT_VIEWER_URL}/settings/alerts`,
|
||||||
|
})
|
||||||
|
|
||||||
// Confirmation
|
// Confirmation
|
||||||
addRoute('get', '/confirm', async (req: Request, res: Response) => {
|
addRoute('get', '/confirm', async (req: Request, res: Response) => {
|
||||||
if (typeof req.query.token !== 'string') {
|
if (typeof req.query.token !== 'string') {
|
||||||
return res.send(
|
return res.send(
|
||||||
await render('pages/confirm-error.html', {
|
await render('pages/confirm-error.html', {
|
||||||
message: 'No confirmation token was provided. Please check the link in your email and try again.',
|
message: 'No confirmation token was provided. Please check the link in your email and try again.',
|
||||||
brandName: BRAND_NAME,
|
...brandingVars(),
|
||||||
brandAccent: BRAND_ACCENT,
|
|
||||||
brandLogo: BRAND_LOGO,
|
|
||||||
settingsUrl: `${EVENT_VIEWER_URL}/settings/alerts`,
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -317,10 +323,7 @@ addRoute('get', '/confirm', async (req: Request, res: Response) => {
|
||||||
await confirmSubscriptionAction({ token: req.query.token })
|
await confirmSubscriptionAction({ token: req.query.token })
|
||||||
|
|
||||||
res.send(await render('pages/confirm-success.html', {
|
res.send(await render('pages/confirm-success.html', {
|
||||||
brandName: BRAND_NAME,
|
...brandingVars(),
|
||||||
brandAccent: BRAND_ACCENT,
|
|
||||||
brandLogo: BRAND_LOGO,
|
|
||||||
settingsUrl: `${EVENT_VIEWER_URL}/settings/alerts`,
|
|
||||||
}))
|
}))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const isActionError = error instanceof ActionError
|
const isActionError = error instanceof ActionError
|
||||||
|
|
@ -328,10 +331,7 @@ addRoute('get', '/confirm', async (req: Request, res: Response) => {
|
||||||
|
|
||||||
res.send(await render('pages/confirm-error.html', {
|
res.send(await render('pages/confirm-error.html', {
|
||||||
message,
|
message,
|
||||||
brandName: BRAND_NAME,
|
...brandingVars(),
|
||||||
brandAccent: BRAND_ACCENT,
|
|
||||||
brandLogo: BRAND_LOGO,
|
|
||||||
settingsUrl: `${EVENT_VIEWER_URL}/settings/alerts`,
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (!isActionError) {
|
if (!isActionError) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue