Skip to content

Commit

Permalink
feat(EMS-3665): move logic into conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Aug 2, 2024
1 parent b3c0ba3 commit baa1d8e
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ export const post = async (req: Request, res: Response) => {

const validationErrors = generateValidationErrors(payload);

const sanitised = sanitiseData(payload) as ObjectType;

/**
* Map the payload into an AWARD_METHOD object structure with an id property.
* Otherwise, the nunjucks template needs 2x conditions.
*/
const submittedValues = {
...sanitised,
[AWARD_METHOD]: {
id: sanitised[AWARD_METHOD],
},
};

if (validationErrors) {
const sanitised = sanitiseData(payload) as ObjectType;

/**
* Map the payload into an AWARD_METHOD object structure with an id property.
* Otherwise, the nunjucks template needs 2x conditions.
*/
const submittedValues = {
...sanitised,
[AWARD_METHOD]: {
id: sanitised[AWARD_METHOD],
},
};

return res.render(TEMPLATE, {
...insuranceCorePageVariables({
PAGE_CONTENT_STRINGS,
Expand Down

0 comments on commit baa1d8e

Please sign in to comment.