From 7b426becf45613239e68688722b7e6ebc4515fcc Mon Sep 17 00:00:00 2001 From: Padmaja Date: Fri, 7 Jun 2024 12:37:48 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Updates=20to=20career=20contact=20f?= =?UTF-8?q?orm=20#2338=20(#2342)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚨 Fix lint issues #2338 * ✨ Updates to career contact form #2338 --- web/pageComponents/topicPages/Form/Form.tsx | 2 +- .../CareersContactForm.tsx | 18 ++--------- .../Form/careersContactForm/getRequestType.ts | 32 +++++++++++++++++++ .../api/forms/service-now-careers-contact.ts | 2 ++ web/types/types.ts | 2 +- 5 files changed, 39 insertions(+), 17 deletions(-) rename web/pageComponents/topicPages/Form/{ => careersContactForm}/CareersContactForm.tsx (96%) create mode 100644 web/pageComponents/topicPages/Form/careersContactForm/getRequestType.ts diff --git a/web/pageComponents/topicPages/Form/Form.tsx b/web/pageComponents/topicPages/Form/Form.tsx index b43ca4510..8f503d41f 100644 --- a/web/pageComponents/topicPages/Form/Form.tsx +++ b/web/pageComponents/topicPages/Form/Form.tsx @@ -5,7 +5,7 @@ import ContactEquinorForm from './ContactEquinorForm' import SubscribeForm from './SubscribeForm' import CareerFairForm from './CareerFairForm' import OrderReportsForm from './OrderReportsForm' -import CareersContactForm from './CareersContactForm' +import CareersContactForm from './careersContactForm/CareersContactForm' import type { LinkData, FormData } from '../../../types/types' import { twMerge } from 'tailwind-merge' import CallToActions from '@sections/CallToActions' diff --git a/web/pageComponents/topicPages/Form/CareersContactForm.tsx b/web/pageComponents/topicPages/Form/careersContactForm/CareersContactForm.tsx similarity index 96% rename from web/pageComponents/topicPages/Form/CareersContactForm.tsx rename to web/pageComponents/topicPages/Form/careersContactForm/CareersContactForm.tsx index c6c5039f1..2f8b0b441 100644 --- a/web/pageComponents/topicPages/Form/CareersContactForm.tsx +++ b/web/pageComponents/topicPages/Form/careersContactForm/CareersContactForm.tsx @@ -12,9 +12,9 @@ import { FormSubmitFailureBox, } from '@components' import { BaseSyntheticEvent, useState } from 'react' -import FriendlyCaptcha from './FriendlyCaptcha' +import FriendlyCaptcha from '../FriendlyCaptcha' import styled from 'styled-components' -import { CareersContactFormCatalogType } from '../../../types' +import getCatalogType from './getRequestType' type FormValues = { name: string @@ -43,7 +43,7 @@ const CareersContactForm = () => { body: JSON.stringify({ data, frcCaptchaSolution: (event?.target as any)['frc-captcha-solution'].value, - catalogType: getCatalog(data.category), + catalogType: getCatalogType(intl, data.category, data.candidateType), }), headers: { 'Content-Type': 'application/json', @@ -53,18 +53,6 @@ const CareersContactForm = () => { setSuccessfullySubmitted(res.status == 200) setServerError(res.status != 200) } - const getCatalog = (category: string): CareersContactFormCatalogType | null => { - if ( - category.includes( - intl.formatMessage({ - id: 'careers_contact_form_suspected_recruitment_scam', - defaultMessage: 'Suspected recruitment scam', - }), - ) - ) - return 'suspectedRecruitmentScamRequest' - else return 'others' - } const { handleSubmit, diff --git a/web/pageComponents/topicPages/Form/careersContactForm/getRequestType.ts b/web/pageComponents/topicPages/Form/careersContactForm/getRequestType.ts new file mode 100644 index 000000000..46e27f45e --- /dev/null +++ b/web/pageComponents/topicPages/Form/careersContactForm/getRequestType.ts @@ -0,0 +1,32 @@ +import { CareersContactFormCatalogType } from '../../../../types' +import { IntlShape } from 'react-intl' + +export default function getCatalogType( + intl: IntlShape, + category: string, + candidateType: string, +): CareersContactFormCatalogType | null { + const suspectedRecruitmentScam = intl.formatMessage({ + id: 'careers_contact_form_suspected_recruitment_scam', + defaultMessage: 'Suspected recruitment scam', + }) + + const graduates = intl.formatMessage({ + id: ' careers_contact_form_graduates', + defaultMessage: 'Graduates', + }) + + const interns = intl.formatMessage({ + id: 'careers_contact_form_interns', + defaultMessage: 'Interns (e.g. summer, academic)', + }) + const apprentices = intl.formatMessage({ + id: 'careers_contact_form_apprentices', + defaultMessage: 'Apprentices/lærlinger', + }) + + if (category.includes(suspectedRecruitmentScam)) return 'suspectedRecruitmentScamRequest' + else if (candidateType.includes(graduates) || candidateType.includes(interns) || candidateType.includes(apprentices)) + return 'emergingTalentsQueries' + else return 'others' +} diff --git a/web/pages/api/forms/service-now-careers-contact.ts b/web/pages/api/forms/service-now-careers-contact.ts index 76dcde985..2bffe1b32 100644 --- a/web/pages/api/forms/service-now-careers-contact.ts +++ b/web/pages/api/forms/service-now-careers-contact.ts @@ -7,6 +7,8 @@ const getCatalogIdentifier = (catalogType: CareersContactFormCatalogType | null) switch (catalogType) { case 'suspectedRecruitmentScamRequest': return 'b04a9748832d8610347af830feaad382' + case 'emergingTalentsQueries': + return '3971e24c375a3640615af01643990ebf' default: return '59e02ac8375a3640615af01643990e7c' } diff --git a/web/types/types.ts b/web/types/types.ts index 9fd790bbf..ef9de3bdf 100644 --- a/web/types/types.ts +++ b/web/types/types.ts @@ -801,7 +801,7 @@ export type IframeCarouselData = { export type ContactFormCatalogType = 'humanRightsInformationRequest' | 'loginIssues' -export type CareersContactFormCatalogType = 'suspectedRecruitmentScamRequest' | 'others' +export type CareersContactFormCatalogType = 'suspectedRecruitmentScamRequest' | 'emergingTalentsQueries' | 'others' export type KeyNumberItemData = { type: 'keyNumberItem'