From 5e2d61d285de8b68a958eb51799909a8f6b61f0e Mon Sep 17 00:00:00 2001 From: Borghild Date: Wed, 6 Nov 2024 14:54:24 +0100 Subject: [PATCH] :art: reuse text snippets and use description field --- sanityv3/schemas/textSnippets.ts | 183 +++--------------- .../topicPages/Form/CareerFairForm.tsx | 4 +- .../topicPages/Form/ContactEquinorForm.tsx | 14 +- .../topicPages/Form/OrderReportsForm.tsx | 10 +- .../topicPages/Form/PensionForm.tsx | 29 ++- .../topicPages/Form/SubscribeForm.tsx | 6 +- .../careersContactForm/CareersContactForm.tsx | 10 +- 7 files changed, 65 insertions(+), 191 deletions(-) diff --git a/sanityv3/schemas/textSnippets.ts b/sanityv3/schemas/textSnippets.ts index 6629a5865..751f5b564 100644 --- a/sanityv3/schemas/textSnippets.ts +++ b/sanityv3/schemas/textSnippets.ts @@ -14,6 +14,7 @@ export const groups = { form: { title: 'Form', hidden: !Flags.HAS_FORMS }, cookie: { title: 'Cookie' }, others: { title: 'Others' }, + common: { title: 'Common' }, } const snippets: textSnippet = { country_code_format: { @@ -162,26 +163,11 @@ const snippets: textSnippet = { defaultValue: 'Please choose one or more of the following', group: groups.subscribeForm, }, - subscribe_form_first_name: { - title: 'First name', - defaultValue: 'First name', - group: groups.subscribeForm, - }, - subscribe_form_name_validation: { - title: 'Name validation', - defaultValue: 'Please fill out your name', - group: groups.subscribeForm, - }, subscribe_form_email: { title: 'Email', defaultValue: 'Email', group: groups.subscribeForm, }, - subscribe_form_email_validation: { - title: 'Email validation', - defaultValue: 'Please fill out a valid email address', - group: groups.subscribeForm, - }, subscribe_form_general_news: { title: 'General News', defaultValue: 'General News', @@ -255,31 +241,11 @@ const snippets: textSnippet = { 'Want the full picture? We’d love to share this content with you, but first you must accept {type1}, {type2} and {type3} cookies by enabling them in our cookie settings.', group: groups.cookie, }, - contact_form_name: { - title: 'Name', - defaultValue: 'Name *', - group: groups.contactForm, - }, - contact_form_name_placeholder: { - title: 'Name Placeholder', - defaultValue: 'Jane Doe', - group: groups.contactForm, - }, contact_form_email: { title: 'Email', defaultValue: 'Email *', group: groups.contactForm, }, - contact_form_name_validation: { - title: 'Name validation', - defaultValue: 'Please fill out your name', - group: groups.contactForm, - }, - contact_form_email_validation: { - title: 'Email validation', - defaultValue: 'Please fill out a valid email address', - group: groups.contactForm, - }, contact_form_category: { title: 'Category', defaultValue: 'Category', @@ -290,11 +256,6 @@ const snippets: textSnippet = { defaultValue: 'How can we help you?', group: groups.contactForm, }, - contact_form_how_to_help_placeholder: { - title: `Please don't enter any personal information`, - defaultValue: `Please don't enter any personal information`, - group: groups.contactForm, - }, contact_form_how_to_help_validation: { title: 'Please let us know how we may help you', defaultValue: 'Please let us know how we may help you', @@ -340,37 +301,6 @@ const snippets: textSnippet = { defaultValue: 'Submit form', group: groups.contactForm, }, - pension_form_name: { - title: 'Name', - defaultValue: 'Name *', - group: groups.pensionForm, - }, - pension_form_name_placeholder: { - title: 'Name Placeholder', - defaultValue: 'Jane Doe', - group: groups.pensionForm, - }, - pension_form_name_validation: { - title: 'Name validation', - defaultValue: 'Please fill out your name', - group: groups.pensionForm, - }, - - pension_form_email: { - title: 'Email', - defaultValue: 'Email *', - group: groups.pensionForm, - }, - pension_form_email_validation: { - title: 'Email validation', - defaultValue: 'Please fill out a valid email address', - group: groups.pensionForm, - }, - pension_form_category: { - title: 'Category', - defaultValue: 'Category', - group: groups.pensionForm, - }, pension_form_category_pension: { title: 'Pension Category', defaultValue: 'Pension', @@ -386,35 +316,21 @@ const snippets: textSnippet = { defaultValue: 'Other Pension/Insurance Related', group: groups.pensionForm, }, - pension_form_what_is_your_request: { title: 'What is your request?', defaultValue: 'What is your request?', group: groups.pensionForm, }, - pension_form_what_is_your_request_placeholder: { - title: `Requests Placeholder`, - defaultValue: `Please don't enter any personal information`, - group: groups.pensionForm, - }, pension_form_what_is_your_request_validation: { title: 'Requests Validation', defaultValue: 'Please let us know how we may help you', group: groups.pensionForm, }, - pension_form_submit: { title: 'Submit Button Text', defaultValue: 'Submit Form', group: groups.pensionForm, }, - - pension_form_all_fields_mandatory: { - title: 'All fields with * are mandatory', - defaultValue: 'All fields with * are mandatory', - group: groups.pensionForm, - }, - career_fair_form_organisation: { title: 'Organisation', defaultValue: 'School / Organisation', @@ -456,11 +372,6 @@ const snippets: textSnippet = { defaultValue: 'Email', group: groups.careerFairForm, }, - career_fair_form_email_validation: { - title: 'Email validation', - defaultValue: 'Please fill out a valid email address', - group: groups.careerFairForm, - }, career_fair_form_event: { title: 'Event', defaultValue: 'Event', @@ -512,34 +423,6 @@ const snippets: textSnippet = { defaultValue: 'Submit form', group: groups.careerFairForm, }, - - order_reports_form_name: { - title: 'Name', - defaultValue: 'Name', - group: groups.orderAnnualReportsForm, - }, - - order_reports_form_name_validation: { - title: 'Enter name', - defaultValue: 'Please enter your name', - group: groups.orderAnnualReportsForm, - }, - order_reports_form_name_placeholder: { - title: 'Name placeholder', - defaultValue: 'Jane Doe', - group: groups.orderAnnualReportsForm, - }, - - order_reports_form_email: { - title: 'Email', - defaultValue: 'Email', - group: groups.orderAnnualReportsForm, - }, - order_reports_form_email_validation: { - title: 'Email validation', - defaultValue: 'Please fill out a valid email address', - group: groups.orderAnnualReportsForm, - }, order_reports_form_company: { title: 'Company', defaultValue: 'Company', @@ -590,13 +473,11 @@ const snippets: textSnippet = { defaultValue: 'Please enter your country', group: groups.orderAnnualReportsForm, }, - order_reports_form_cta: { title: 'CTA', defaultValue: 'Order printed copies', group: groups.orderAnnualReportsForm, }, - order_reports_form_choose: { title: 'Choose validation', defaultValue: 'Please select atleast one of the reports', @@ -612,37 +493,6 @@ const snippets: textSnippet = { defaultValue: 'Annual report (norwegian version)', group: groups.orderAnnualReportsForm, }, - careers_contact_form_name: { - title: 'Name', - defaultValue: 'Your Name *', - group: groups.careerContactForm, - }, - - careers_contact_form_name_placeholder: { - title: 'Name Placeholder', - defaultValue: 'Jane Doe', - group: groups.careerContactForm, - }, - careers_contact_form_email: { - title: 'Email', - defaultValue: 'Email', - group: groups.careerContactForm, - }, - careers_contact_form_name_validation: { - title: 'Name validation', - defaultValue: 'Please fill out your name', - group: groups.careerContactForm, - }, - careers_contact_form_email_validation: { - title: 'Email validation', - defaultValue: 'Please fill out a valid email address', - group: groups.careerContactForm, - }, - careers_contact_form_category: { - title: 'Category', - defaultValue: 'Category', - group: groups.careerContactForm, - }, careers_contact_form_questions: { title: 'Type your questions', defaultValue: 'Type your questions', @@ -749,7 +599,6 @@ const snippets: textSnippet = { defaultValue: 'Tick the box if you would like to send supporting documents, and we will get in touch with you', group: groups.careerContactForm, }, - form_sending: { title: 'Sending...', defaultValue: 'Sending...', @@ -932,6 +781,36 @@ const snippets: textSnippet = { defaultValue: 'Remove', group: groups.others, }, + name: { + title: 'Name', + defaultValue: 'Name', + group: groups.common, + }, + email: { + title: 'Email', + defaultValue: 'Email', + group: groups.common, + }, + category: { + title: 'Category', + defaultValue: 'Category', + group: groups.common, + }, + name_validation: { + title: 'Name validation', + defaultValue: 'Please fill out your name', + group: groups.common, + }, + email_validation: { + title: 'Email validation', + defaultValue: 'Please fill out a valid email address', + group: groups.common, + }, + dont_enter_personal_info: { + title: `Please don't enter any personal information`, + defaultValue: `Please don't enter any personal information`, + group: groups.common, + }, } type textSnippetGroup = { title: string; hidden?: boolean } diff --git a/web/pageComponents/topicPages/Form/CareerFairForm.tsx b/web/pageComponents/topicPages/Form/CareerFairForm.tsx index 670474e06..bde94b27a 100644 --- a/web/pageComponents/topicPages/Form/CareerFairForm.tsx +++ b/web/pageComponents/topicPages/Form/CareerFairForm.tsx @@ -192,13 +192,13 @@ const CareerFairForm = () => { control={control} rules={{ required: intl.formatMessage({ - id: 'career_fair_form_email_validation', + id: 'email_validation', defaultMessage: 'Please fill out a valid email address', }), pattern: { value: /^[\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$/g, message: intl.formatMessage({ - id: 'career_fair_form_email_validation', + id: 'email_validation', defaultMessage: 'Please fill out a valid email address', }), }, diff --git a/web/pageComponents/topicPages/Form/ContactEquinorForm.tsx b/web/pageComponents/topicPages/Form/ContactEquinorForm.tsx index dfc081000..c3013d83b 100644 --- a/web/pageComponents/topicPages/Form/ContactEquinorForm.tsx +++ b/web/pageComponents/topicPages/Form/ContactEquinorForm.tsx @@ -126,7 +126,7 @@ const ContactEquinorForm = (props: ContactEquinorFormProps) => { control={control} rules={{ required: intl.formatMessage({ - id: 'contact_form_name_validation', + id: 'name_validation', defaultMessage: 'Please fill out your name', }), }} @@ -137,7 +137,7 @@ const ContactEquinorForm = (props: ContactEquinorFormProps) => { {...props} id={name} label={`${intl.formatMessage({ - id: 'contact_form_name', + id: 'name', defaultMessage: 'Name', })}*`} inputRef={ref} @@ -154,13 +154,13 @@ const ContactEquinorForm = (props: ContactEquinorFormProps) => { control={control} rules={{ required: intl.formatMessage({ - id: 'contact_form_email_validation', + id: 'email_validation', defaultMessage: 'Please fill out a valid email address', }), pattern: { value: /^[\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$/g, message: intl.formatMessage({ - id: 'contact_form_email_validation', + id: 'email_validation', defaultMessage: 'Please fill out a valid email address', }), }, @@ -172,7 +172,7 @@ const ContactEquinorForm = (props: ContactEquinorFormProps) => { {...props} id={name} label={`${intl.formatMessage({ - id: 'contact_form_email', + id: 'email', defaultMessage: 'Email', })}*`} inputRef={ref} @@ -195,7 +195,7 @@ const ContactEquinorForm = (props: ContactEquinorFormProps) => { selectRef={ref} id={name} disabled={isHumanRightsRequest} - label={intl.formatMessage({ id: 'contact_form_category', defaultMessage: 'Category' })} + label={intl.formatMessage({ id: 'category', defaultMessage: 'Category' })} >