From 2629e225af4c2c4d1ad16e5fb52ceca9227b7ac9 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Fri, 15 Nov 2024 22:19:14 +0100 Subject: [PATCH] feat: add actions for waitlist feature --- .../api/controllers/waitlist/join-waitlist.js | 30 +++++++++++++++++++ .../{home => waitlist}/view-waitlist.js | 0 2 files changed, 30 insertions(+) create mode 100644 templates/ascent-react/api/controllers/waitlist/join-waitlist.js rename templates/ascent-react/api/controllers/{home => waitlist}/view-waitlist.js (100%) diff --git a/templates/ascent-react/api/controllers/waitlist/join-waitlist.js b/templates/ascent-react/api/controllers/waitlist/join-waitlist.js new file mode 100644 index 0000000..b645ab3 --- /dev/null +++ b/templates/ascent-react/api/controllers/waitlist/join-waitlist.js @@ -0,0 +1,30 @@ +module.exports = { + friendlyName: 'Join waitlist', + + description: '', + + inputs: { + email: { + type: 'string', + required: true, + isEmail: true, + maxLength: 200 + } + }, + + exits: { + success: { + responseType: 'redirect', + description: 'Successfully joined waitlist' + }, + badRequest: { + description: 'The provided email address is invalid.', + responseType: 'badRequest' + } + }, + + fn: async function ({ email }) { + await Waitlist.create({ email }).intercept('E_UNIQUE', 'badRequest') + return '/' + } +} diff --git a/templates/ascent-react/api/controllers/home/view-waitlist.js b/templates/ascent-react/api/controllers/waitlist/view-waitlist.js similarity index 100% rename from templates/ascent-react/api/controllers/home/view-waitlist.js rename to templates/ascent-react/api/controllers/waitlist/view-waitlist.js