From 338517b7886aee9ead40c1367b72f1aba2e9fa14 Mon Sep 17 00:00:00 2001 From: LoneRifle Date: Wed, 20 Nov 2024 16:30:39 +0800 Subject: [PATCH 1/2] feat(i18n): extract text from modals --- .../components/DirtyModal/DirtyModal.tsx | 5 +++- .../FieldRow/FieldRowContainer.tsx | 2 +- .../BuilderAndDesignContent/PaymentView.tsx | 12 +++++++--- .../BuilderAndDesignContent/StartPageView.tsx | 4 +++- .../DeleteFieldModal/DeleteFieldModal.tsx | 19 ++++++++------- .../DeletePaymentModal/DeletePaymentModal.tsx | 19 +++++++++------ .../i18n/locales/features/admin-form/en-sg.ts | 2 ++ .../i18n/locales/features/admin-form/index.ts | 1 + .../features/admin-form/modals/en-sg.ts | 23 +++++++++++++++++++ .../features/admin-form/modals/index.ts | 22 ++++++++++++++++++ .../src/i18n/locales/features/common/en-sg.ts | 1 + .../src/i18n/locales/features/common/index.ts | 1 + frontend/src/i18n/locales/features/index.ts | 1 + frontend/src/i18n/locales/types.ts | 2 ++ .../NavigationPrompt/NavigationPrompt.tsx | 6 +++++ 15 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 frontend/src/i18n/locales/features/admin-form/modals/en-sg.ts create mode 100644 frontend/src/i18n/locales/features/admin-form/modals/index.ts diff --git a/frontend/src/features/admin-form/common/components/DirtyModal/DirtyModal.tsx b/frontend/src/features/admin-form/common/components/DirtyModal/DirtyModal.tsx index fced365825..5305476ea5 100644 --- a/frontend/src/features/admin-form/common/components/DirtyModal/DirtyModal.tsx +++ b/frontend/src/features/admin-form/common/components/DirtyModal/DirtyModal.tsx @@ -1,3 +1,5 @@ +import { useTranslation } from 'react-i18next' + import { UnsavedChangesModal } from '~templates/NavigationPrompt' import { usePaymentStore } from '~features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/FieldListDrawer/field-panels/usePaymentStore' @@ -93,12 +95,13 @@ export const useDirtyModal = () => { export const DirtyModal = (): JSX.Element => { const { isOpen, handleCancelNavigate, handleConfirmNavigate } = useDirtyModal() + const { t } = useTranslation() return ( diff --git a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/FieldRow/FieldRowContainer.tsx b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/FieldRow/FieldRowContainer.tsx index 1d3f96b566..55636375cc 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/FieldRow/FieldRowContainer.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/FieldRow/FieldRowContainer.tsx @@ -408,7 +408,7 @@ const FieldButtonGroup = ({ } onClick={handleEditFieldClick} /> diff --git a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/PaymentView.tsx b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/PaymentView.tsx index fab0fa421a..7d7a4f6f7a 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/PaymentView.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/PaymentView.tsx @@ -1,5 +1,6 @@ import { useCallback, useEffect, useRef } from 'react' import { FormProvider, useForm } from 'react-hook-form' +import { useTranslation } from 'react-i18next' import { BiCog, BiTrash } from 'react-icons/bi' import { Box, ButtonGroup, Collapse, Flex } from '@chakra-ui/react' @@ -147,11 +148,16 @@ const PaymentButtonGroup = ({ handleBuilderClick(false) } }, [handleBuilderClick, isMobile]) + const { t } = useTranslation() const { deletePaymentModalDisclosure: { onOpen: onDeleteModalOpen }, } = useBuilderAndDesignContext() + const { deleteField, editField } = t('features.common.tooltip', { + returnObjects: true, + }) + return ( } onClick={handleEditFieldClick} /> )} - + } onClick={onDeleteModalOpen} /> diff --git a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/StartPageView.tsx b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/StartPageView.tsx index 87c7dc52e3..acb96de6a8 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/StartPageView.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/StartPageView.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useTranslation } from 'react-i18next' import { BiCog } from 'react-icons/bi' import { Box, ButtonGroup, Collapse, Flex, IconButton } from '@chakra-ui/react' @@ -37,6 +38,7 @@ import { } from '../useFieldBuilderStore' export const StartPageView = () => { + const { t } = useTranslation() const isMobile = useIsMobile() const { data: form, isLoading } = useCreateTabForm() const setFieldBuilderToInactive = useFieldBuilderStore( @@ -259,7 +261,7 @@ export const StartPageView = () => { } onClick={handleEditInstructionsClick} /> diff --git a/frontend/src/features/admin-form/create/builder-and-design/DeleteFieldModal/DeleteFieldModal.tsx b/frontend/src/features/admin-form/create/builder-and-design/DeleteFieldModal/DeleteFieldModal.tsx index 996c22edf9..127a86d5c8 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/DeleteFieldModal/DeleteFieldModal.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/DeleteFieldModal/DeleteFieldModal.tsx @@ -58,21 +58,20 @@ export const DeleteFieldModal = (): JSX.Element => { } }, [deleteFieldMutation, onClose, stateData]) + const { + title, + description: { field, logic }, + confirmButtonText, + } = t('features.adminForm.modals.deleteField', { returnObjects: true }) + return ( - Delete field + {title} - - {fieldIsInLogic - ? `This field is used in your form logic, so deleting it may cause - your logic to stop working correctly. Are you sure you want to - delete this field?` - : `Are you sure you want to delete this field? This action - cannot be undone.`} - + {fieldIsInLogic ? logic : field} { onClick={handleDeleteConfirmation} isLoading={deleteFieldMutation.isLoading} > - Yes, delete field + {confirmButtonText} diff --git a/frontend/src/features/admin-form/create/builder-and-design/DeletePaymentModal/DeletePaymentModal.tsx b/frontend/src/features/admin-form/create/builder-and-design/DeletePaymentModal/DeletePaymentModal.tsx index 733369b8be..2027fa4a3c 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/DeletePaymentModal/DeletePaymentModal.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/DeletePaymentModal/DeletePaymentModal.tsx @@ -1,4 +1,5 @@ import { useCallback } from 'react' +import { useTranslation } from 'react-i18next' import { ButtonGroup, Modal, @@ -28,6 +29,7 @@ export const DeletePaymentModal = (): JSX.Element => { const { deletePaymentModalDisclosure: { onClose }, } = useBuilderAndDesignContext() + const { t } = useTranslation() const { deletePaymentFieldMutation } = useDeleteFormField() @@ -44,29 +46,32 @@ export const DeletePaymentModal = (): JSX.Element => { } }, [deletePaymentFieldMutation, onClose, stateData, setFieldListTabIndex]) + const { + title, + description: { payment: description }, + confirmButtonText, + } = t('features.adminForm.modals.deleteField', { returnObjects: true }) + return ( - Delete field + {title} - - Are you sure you want to delete payment field? This action can't be - undone. - + {description} diff --git a/frontend/src/i18n/locales/features/admin-form/en-sg.ts b/frontend/src/i18n/locales/features/admin-form/en-sg.ts index 88818573df..83e90addd3 100644 --- a/frontend/src/i18n/locales/features/admin-form/en-sg.ts +++ b/frontend/src/i18n/locales/features/admin-form/en-sg.ts @@ -1,4 +1,5 @@ import { enSG as meta } from './meta' +import { enSG as modals } from './modals' import { enSG as navbar } from './navbar' import { enSG as sidebar } from './sidebar' @@ -6,4 +7,5 @@ export const enSG = { navbar, sidebar, meta, + modals, } diff --git a/frontend/src/i18n/locales/features/admin-form/index.ts b/frontend/src/i18n/locales/features/admin-form/index.ts index e53c29786f..9e16f9b6b5 100644 --- a/frontend/src/i18n/locales/features/admin-form/index.ts +++ b/frontend/src/i18n/locales/features/admin-form/index.ts @@ -1,5 +1,6 @@ export * from './en-sg' export { type Meta } from './meta' +export { type Modals } from './modals' export { type Navbar } from './navbar' export { type Fields } from './sidebar' export { type HeaderAndInstructions } from './sidebar' diff --git a/frontend/src/i18n/locales/features/admin-form/modals/en-sg.ts b/frontend/src/i18n/locales/features/admin-form/modals/en-sg.ts new file mode 100644 index 0000000000..0a86a083d4 --- /dev/null +++ b/frontend/src/i18n/locales/features/admin-form/modals/en-sg.ts @@ -0,0 +1,23 @@ +export const enSG = { + deleteField: { + title: 'Delete field', + description: { + field: + 'Are you sure you want to delete this field? This action cannot be undone.', + logic: + 'This field is used in your form logic, so deleting it may cause your logic to stop working correctly. Are you sure you want to delete this field?', + payment: + "Are you sure you want to delete payment field? This action can't be undone.", + }, + confirmButtonText: 'Yes, delete field', + }, + unsavedChanges: { + title: 'You have unsaved changes', + description: 'Are you sure you want to leave? Your changes will be lost.', + confirmButtonText: 'Yes, discard changes', + cancelButtonText: 'No, stay on page', + }, + dirty: { + cancelButtonText: 'No, return to editing', + }, +} diff --git a/frontend/src/i18n/locales/features/admin-form/modals/index.ts b/frontend/src/i18n/locales/features/admin-form/modals/index.ts new file mode 100644 index 0000000000..27a681fbb8 --- /dev/null +++ b/frontend/src/i18n/locales/features/admin-form/modals/index.ts @@ -0,0 +1,22 @@ +export * from './en-sg' + +export interface Modals { + deleteField: { + title: string + description: { + field: string + logic: string + payment: string + } + confirmButtonText: string + } + unsavedChanges: { + title: string + description: string + confirmButtonText: string + cancelButtonText: string + } + dirty: { + cancelButtonText: string + } +} diff --git a/frontend/src/i18n/locales/features/common/en-sg.ts b/frontend/src/i18n/locales/features/common/en-sg.ts index 3942bae1a6..910803c2dd 100644 --- a/frontend/src/i18n/locales/features/common/en-sg.ts +++ b/frontend/src/i18n/locales/features/common/en-sg.ts @@ -55,6 +55,7 @@ export const enSG: Common = { tooltip: { deleteField: 'Delete field', duplicateField: 'Duplicate field', + editField: 'Edit field', }, dropdown: { placeholder: 'Select an option', diff --git a/frontend/src/i18n/locales/features/common/index.ts b/frontend/src/i18n/locales/features/common/index.ts index bc84abddfa..304c1d78c2 100644 --- a/frontend/src/i18n/locales/features/common/index.ts +++ b/frontend/src/i18n/locales/features/common/index.ts @@ -55,6 +55,7 @@ export interface Common { tooltip: { deleteField: string duplicateField: string + editField: string } dropdown: { placeholder: string diff --git a/frontend/src/i18n/locales/features/index.ts b/frontend/src/i18n/locales/features/index.ts index 08617516d5..f687344cb3 100644 --- a/frontend/src/i18n/locales/features/index.ts +++ b/frontend/src/i18n/locales/features/index.ts @@ -3,6 +3,7 @@ export { type HeaderAndInstructions, type Logic, type Meta, + type Modals, type Navbar, type ThankYou, } from './admin-form' diff --git a/frontend/src/i18n/locales/types.ts b/frontend/src/i18n/locales/types.ts index 66205d3cac..1d94ec4214 100644 --- a/frontend/src/i18n/locales/types.ts +++ b/frontend/src/i18n/locales/types.ts @@ -7,6 +7,7 @@ import { Logic, Login, Meta, + Modals, Navbar, PublicForm, ThankYou, @@ -24,6 +25,7 @@ interface Translation { } navbar?: Navbar meta?: Meta + modals?: Modals } common?: Common publicForm?: PublicForm diff --git a/frontend/src/templates/NavigationPrompt/NavigationPrompt.tsx b/frontend/src/templates/NavigationPrompt/NavigationPrompt.tsx index 9bd84ab36f..8860b847a6 100644 --- a/frontend/src/templates/NavigationPrompt/NavigationPrompt.tsx +++ b/frontend/src/templates/NavigationPrompt/NavigationPrompt.tsx @@ -1,4 +1,5 @@ import { memo } from 'react' +import { useTranslation } from 'react-i18next' import { UnsavedChangesModal } from './UnsavedChangesModal' import { useNavigationPrompt } from './useNavigationPrompt' @@ -26,8 +27,13 @@ export const NavigationPrompt = memo( confirmButtonText = 'Yes, discard changes', cancelButtonText = 'No, stay on page', }: NavigationPromptProps) => { + const { t } = useTranslation() const { isPromptShown, onCancel, onConfirm } = useNavigationPrompt(when) + const defaultText = t('features.adminForm.modals.unsavedChanges', { + returnObjects: true, + }) + return ( Date: Wed, 20 Nov 2024 17:10:04 +0800 Subject: [PATCH 2/2] feat(i18n): extract text from admin-form toasts --- .../mutations/useCreateFormField.ts | 13 +++++----- .../mutations/useDeleteFormField.ts | 23 ++++++++-------- .../mutations/useDuplicateFormField.ts | 19 ++++++++------ .../mutations/useEditFormField.ts | 13 +++++----- .../i18n/locales/features/admin-form/en-sg.ts | 2 ++ .../i18n/locales/features/admin-form/index.ts | 1 + .../features/admin-form/toasts/en-sg.ts | 26 +++++++++++++++++++ .../features/admin-form/toasts/index.ts | 15 +++++++++++ frontend/src/i18n/locales/features/index.ts | 1 + frontend/src/i18n/locales/types.ts | 2 ++ 10 files changed, 84 insertions(+), 31 deletions(-) create mode 100644 frontend/src/i18n/locales/features/admin-form/toasts/en-sg.ts create mode 100644 frontend/src/i18n/locales/features/admin-form/toasts/index.ts diff --git a/frontend/src/features/admin-form/create/builder-and-design/mutations/useCreateFormField.ts b/frontend/src/features/admin-form/create/builder-and-design/mutations/useCreateFormField.ts index 8bd5c43595..ab27216ed4 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/mutations/useCreateFormField.ts +++ b/frontend/src/features/admin-form/create/builder-and-design/mutations/useCreateFormField.ts @@ -1,4 +1,5 @@ import { useCallback, useMemo } from 'react' +import { useTranslation } from 'react-i18next' import { useMutation, useQueryClient } from 'react-query' import { useParams } from 'react-router-dom' @@ -22,6 +23,7 @@ import { } from '../utils/getMutationMessage' export const useCreateFormField = () => { + const { t } = useTranslation() const { formId } = useParams() if (!formId) throw new Error('No formId provided') @@ -45,15 +47,14 @@ export const useCreateFormField = () => { if (stateData.state !== FieldBuilderState.CreatingField) { toast({ status: 'warning', - description: - 'Something went wrong when creating your field. Please refresh and try again.', + description: t('features.adminForm.toasts.field.create.error'), }) return } toast({ - description: `The ${getMutationToastDescriptionFieldName( - newField, - )} was created.`, + description: t('features.adminForm.toasts.field.create.success', { + field: getMutationToastDescriptionFieldName(newField), + }), }) queryClient.setQueryData(adminFormKey, (oldForm) => { // Should not happen, should not be able to update field if there is no @@ -65,7 +66,7 @@ export const useCreateFormField = () => { // Switch from creation to editing updateEditState(newField) }, - [adminFormKey, stateData, queryClient, updateEditState, toast], + [adminFormKey, stateData, queryClient, updateEditState, toast, t], ) const handleError = useCallback( diff --git a/frontend/src/features/admin-form/create/builder-and-design/mutations/useDeleteFormField.ts b/frontend/src/features/admin-form/create/builder-and-design/mutations/useDeleteFormField.ts index 151cf696f9..0267708698 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/mutations/useDeleteFormField.ts +++ b/frontend/src/features/admin-form/create/builder-and-design/mutations/useDeleteFormField.ts @@ -1,4 +1,5 @@ import { useCallback } from 'react' +import { useTranslation } from 'react-i18next' import { useMutation, useQueryClient } from 'react-query' import { useParams } from 'react-router-dom' @@ -34,6 +35,7 @@ import { } from '../utils/getMutationMessage' export const useDeleteFormField = () => { + const { t } = useTranslation() const { formId } = useParams() if (!formId) throw new Error('No formId provided') @@ -66,15 +68,14 @@ export const useDeleteFormField = () => { if (stateData.state !== FieldBuilderState.EditingField) { toast({ status: 'warning', - description: - 'Something went wrong when deleting your field. Please refresh and try again.', + description: t('features.adminForm.toasts.field.delete.error'), }) return } toast({ - description: `The ${getMutationToastDescriptionFieldName( - stateData.field, - )} was deleted.`, + description: t('features.adminForm.toasts.field.delete.success', { + field: getMutationToastDescriptionFieldName(stateData.field), + }), }) queryClient.setQueryData(adminFormKey, (oldForm) => { // Should not happen, should not be able to update field if there is no @@ -86,8 +87,7 @@ export const useDeleteFormField = () => { if (deletedFieldIndex < 0) { toast({ status: 'warning', - description: - 'Something went wrong when deleting your field. Please refresh and try again.', + description: t('features.adminForm.toasts.field.delete.error'), }) } else { oldForm.form_fields.splice(deletedFieldIndex, 1) @@ -95,7 +95,7 @@ export const useDeleteFormField = () => { return oldForm }) setToInactive() - }, [adminFormKey, stateData, queryClient, setToInactive, toast]) + }, [adminFormKey, stateData, queryClient, setToInactive, toast, t]) const handleError = useCallback( (error: Error) => { @@ -116,8 +116,7 @@ export const useDeleteFormField = () => { if (paymentState !== PaymentState.EditingPayment) { toast({ status: 'warning', - description: - 'Something went wrong when deleting your field. Please refresh and try again.', + description: t('features.adminForm.toasts.field.delete.error'), }) return } @@ -128,7 +127,9 @@ export const useDeleteFormField = () => { }, ) toast({ - description: 'The payment was deleted.', + description: t('features.adminForm.toasts.field.delete.success', { + field: 'payment', + }), }) setPaymentToInactive() }, diff --git a/frontend/src/features/admin-form/create/builder-and-design/mutations/useDuplicateFormField.ts b/frontend/src/features/admin-form/create/builder-and-design/mutations/useDuplicateFormField.ts index f7381b9859..8c559a6df6 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/mutations/useDuplicateFormField.ts +++ b/frontend/src/features/admin-form/create/builder-and-design/mutations/useDuplicateFormField.ts @@ -1,4 +1,5 @@ import { useCallback } from 'react' +import { useTranslation } from 'react-i18next' import { useMutation, useQueryClient } from 'react-query' import { useParams } from 'react-router-dom' @@ -23,6 +24,7 @@ import { } from '../utils/getMutationMessage' export const useDuplicateFormField = () => { + const { t } = useTranslation() const { formId } = useParams() if (!formId) throw new Error('No formId provided') const fieldBuilderState = useFieldBuilderStore(fieldBuilderStateSelector) @@ -40,20 +42,20 @@ export const useDuplicateFormField = () => { if (fieldBuilderState !== FieldBuilderState.EditingField) { toast({ status: 'warning', - description: - 'Something went wrong when creating your field. Please refresh and try again.', + description: t('features.adminForm.toasts.field.duplicate.error'), }) return } toast({ - description: `The ${getMutationToastDescriptionFieldName( - newField, - )} was duplicated.${ + description: t( logicedFieldIdsSet?.has(fieldId) - ? ' Associated logic was not duplicated.' - : '' - }`, + ? 'features.adminForm.toasts.field.duplicate.successButNoLogic' + : 'features.adminForm.toasts.field.duplicate.success', + { + field: getMutationToastDescriptionFieldName(newField), + }, + ), }) queryClient.setQueryData(adminFormKey, (oldForm) => { @@ -80,6 +82,7 @@ export const useDuplicateFormField = () => { queryClient, adminFormKey, updateEditState, + t, ], ) diff --git a/frontend/src/features/admin-form/create/builder-and-design/mutations/useEditFormField.ts b/frontend/src/features/admin-form/create/builder-and-design/mutations/useEditFormField.ts index 694fd7bab5..f5104cd672 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/mutations/useEditFormField.ts +++ b/frontend/src/features/admin-form/create/builder-and-design/mutations/useEditFormField.ts @@ -1,4 +1,5 @@ import { useCallback } from 'react' +import { useTranslation } from 'react-i18next' import { useMutation, useQueryClient } from 'react-query' import { useParams } from 'react-router-dom' @@ -21,6 +22,7 @@ import { } from '../utils/getMutationMessage' export const useEditFormField = () => { + const { t } = useTranslation() const { formId } = useParams() if (!formId) throw new Error('No formId provided') @@ -36,15 +38,14 @@ export const useEditFormField = () => { if (fieldBuilderState !== FieldBuilderState.EditingField) { toast({ status: 'warning', - description: - 'Something went wrong when editing your field. Please refresh and try again.', + description: t('features.adminForm.toasts.field.update.error'), }) return } toast({ - description: `The ${getMutationToastDescriptionFieldName( - newField, - )} was updated.`, + description: t('features.adminForm.toasts.field.update.success', { + field: getMutationToastDescriptionFieldName(newField), + }), }) queryClient.setQueryData(adminFormKey, (oldForm) => { // Should not happen, should not be able to update field if there is no @@ -57,7 +58,7 @@ export const useEditFormField = () => { return oldForm }) }, - [adminFormKey, fieldBuilderState, queryClient, toast], + [adminFormKey, fieldBuilderState, queryClient, toast, t], ) const handleError = useCallback( diff --git a/frontend/src/i18n/locales/features/admin-form/en-sg.ts b/frontend/src/i18n/locales/features/admin-form/en-sg.ts index 83e90addd3..b194d9d51e 100644 --- a/frontend/src/i18n/locales/features/admin-form/en-sg.ts +++ b/frontend/src/i18n/locales/features/admin-form/en-sg.ts @@ -2,10 +2,12 @@ import { enSG as meta } from './meta' import { enSG as modals } from './modals' import { enSG as navbar } from './navbar' import { enSG as sidebar } from './sidebar' +import { enSG as toasts } from './toasts' export const enSG = { navbar, sidebar, meta, modals, + toasts, } diff --git a/frontend/src/i18n/locales/features/admin-form/index.ts b/frontend/src/i18n/locales/features/admin-form/index.ts index 9e16f9b6b5..34644c6f72 100644 --- a/frontend/src/i18n/locales/features/admin-form/index.ts +++ b/frontend/src/i18n/locales/features/admin-form/index.ts @@ -6,3 +6,4 @@ export { type Fields } from './sidebar' export { type HeaderAndInstructions } from './sidebar' export { type Logic } from './sidebar' export { type ThankYou } from './sidebar' +export { type Toasts } from './toasts' diff --git a/frontend/src/i18n/locales/features/admin-form/toasts/en-sg.ts b/frontend/src/i18n/locales/features/admin-form/toasts/en-sg.ts new file mode 100644 index 0000000000..7bd6036ff7 --- /dev/null +++ b/frontend/src/i18n/locales/features/admin-form/toasts/en-sg.ts @@ -0,0 +1,26 @@ +export const enSG = { + field: { + delete: { + success: 'The {field} was deleted.', + error: + 'Something went wrong when deleting your field. Please refresh and try again.', + }, + create: { + success: 'The {field} was created.', + error: + 'Something went wrong when creating your field. Please refresh and try again.', + }, + update: { + success: 'The {field} was updated.', + error: + 'Something went wrong when editing your field. Please refresh and try again.', + }, + duplicate: { + success: 'The {field} was duplicated.', + successButNoLogic: + 'The {field} was duplicated. Associated logic was not duplicated.', + error: + 'Something went wrong when creating your field. Please refresh and try again.', + }, + }, +} diff --git a/frontend/src/i18n/locales/features/admin-form/toasts/index.ts b/frontend/src/i18n/locales/features/admin-form/toasts/index.ts new file mode 100644 index 0000000000..d82358aa13 --- /dev/null +++ b/frontend/src/i18n/locales/features/admin-form/toasts/index.ts @@ -0,0 +1,15 @@ +export * from './en-sg' + +interface Toast { + success: string + error: string +} + +export interface Toasts { + field: { + delete: Toast + create: Toast + update: Toast + duplicate: Toast & { successButNoLogic: string } + } +} diff --git a/frontend/src/i18n/locales/features/index.ts b/frontend/src/i18n/locales/features/index.ts index f687344cb3..b612fc14f5 100644 --- a/frontend/src/i18n/locales/features/index.ts +++ b/frontend/src/i18n/locales/features/index.ts @@ -6,6 +6,7 @@ export { type Modals, type Navbar, type ThankYou, + type Toasts, } from './admin-form' export { type Common } from './common' export { type Login } from './login' diff --git a/frontend/src/i18n/locales/types.ts b/frontend/src/i18n/locales/types.ts index 1d94ec4214..9bcc910574 100644 --- a/frontend/src/i18n/locales/types.ts +++ b/frontend/src/i18n/locales/types.ts @@ -11,6 +11,7 @@ import { Navbar, PublicForm, ThankYou, + Toasts, } from './features' interface Translation { @@ -26,6 +27,7 @@ interface Translation { navbar?: Navbar meta?: Meta modals?: Modals + toasts?: Toasts } common?: Common publicForm?: PublicForm