From ef84779bbb2bb3c9a86d6c8d09ec234a8a9d600a Mon Sep 17 00:00:00 2001 From: "Brian.Jiang2021" Date: Wed, 20 Jul 2022 14:42:09 +0800 Subject: [PATCH] feat: registration page I18n https://bigc-b2b.atlassian.net/browse/BUN-88 --- apps/storefront/src/locales/en-US/finish.ts | 12 ++++++++++++ apps/storefront/src/locales/en-US/global.ts | 1 + apps/storefront/src/locales/en-US/index.ts | 2 ++ apps/storefront/src/locales/zh-CN/finish.ts | 12 ++++++++++++ apps/storefront/src/locales/zh-CN/global.ts | 1 + apps/storefront/src/locales/zh-CN/index.ts | 2 ++ .../src/pages/registered/RegisterComplete.tsx | 10 ++++++---- .../src/pages/registered/RegisteredFinish.tsx | 9 ++++++--- .../registered/component/RegisteredStepButton.tsx | 2 +- .../src/shared/service/b2b/api/register.ts | 3 +-- 10 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 apps/storefront/src/locales/en-US/finish.ts create mode 100644 apps/storefront/src/locales/zh-CN/finish.ts diff --git a/apps/storefront/src/locales/en-US/finish.ts b/apps/storefront/src/locales/en-US/finish.ts new file mode 100644 index 00000000..52d5b0fd --- /dev/null +++ b/apps/storefront/src/locales/en-US/finish.ts @@ -0,0 +1,12 @@ +export default { + // complete page + 'intl.completePage.title': 'Complete Registration', + 'intl.completePage.passwordMatchPrompt': 'The passwords are different', + 'intl.completePage.email': 'email', + 'intl.completePage.confirmPassword': 'Confirm Password', + + // finish page + 'intl.finishPage.autoApproved.tip': 'Thank you for creating your account at {storeName}. Your company account application has been approved', + 'intl.finishPage.notAutoApproved.tip': 'Your company account application has been received. Please allow 24 hours for account approval and activation.', + 'intl.finishPage.bcSuccess.tip': 'Thank you for creating your account at {storeName}.', +} diff --git a/apps/storefront/src/locales/en-US/global.ts b/apps/storefront/src/locales/en-US/global.ts index 926c4b57..78084a54 100644 --- a/apps/storefront/src/locales/en-US/global.ts +++ b/apps/storefront/src/locales/en-US/global.ts @@ -4,6 +4,7 @@ export default { 'intl.global.button.back': 'Back', 'intl.global.button.next': 'Next', 'intl.global.button.submit': 'Submit', + 'intl.global.button.finish': 'FINISH', 'intl.global.validate.required': '{label} is required', diff --git a/apps/storefront/src/locales/en-US/index.ts b/apps/storefront/src/locales/en-US/index.ts index 5943c004..d2477dcc 100644 --- a/apps/storefront/src/locales/en-US/index.ts +++ b/apps/storefront/src/locales/en-US/index.ts @@ -1,7 +1,9 @@ import users from './users' import global from './global' +import finish from './finish' export const en = { ...global, ...users, + ...finish, } diff --git a/apps/storefront/src/locales/zh-CN/finish.ts b/apps/storefront/src/locales/zh-CN/finish.ts new file mode 100644 index 00000000..cacf7217 --- /dev/null +++ b/apps/storefront/src/locales/zh-CN/finish.ts @@ -0,0 +1,12 @@ +export default { + // complete page + 'intl.completePage.title': '完成注册', + 'intl.completePage.passwordMatchPrompt': '密码不同', + 'intl.completePage.email': '电子邮件', + 'intl.completePage.confirmPassword': '确认密码', + + // finish page + 'intl.finishPage.autoApproved.tip': '感谢您在 {storeName} 创建帐户。 您的公司帐户申请已获批准', + 'intl.finishPage.notAutoApproved.tip': '您的公司账户申请已收到。 请等待 24 小时来批准和激活帐户。', + 'intl.finishPage.bcSuccess.tip': '感谢您在 {storeName} 创建帐户。', +} diff --git a/apps/storefront/src/locales/zh-CN/global.ts b/apps/storefront/src/locales/zh-CN/global.ts index 430df240..49c9e64f 100644 --- a/apps/storefront/src/locales/zh-CN/global.ts +++ b/apps/storefront/src/locales/zh-CN/global.ts @@ -4,6 +4,7 @@ export default { 'intl.global.button.back': '返回', 'intl.global.button.next': '下一步', 'intl.global.button.submit': '提交', + 'intl.global.button.finish': '完成', 'intl.global.validate.required': '{label}是必填的', diff --git a/apps/storefront/src/locales/zh-CN/index.ts b/apps/storefront/src/locales/zh-CN/index.ts index 40f2d0cd..a5cb03dd 100644 --- a/apps/storefront/src/locales/zh-CN/index.ts +++ b/apps/storefront/src/locales/zh-CN/index.ts @@ -1,7 +1,9 @@ import users from './users' import global from './global' +import finish from './finish' export const zh = { ...global, ...users, + ...finish, } diff --git a/apps/storefront/src/pages/registered/RegisterComplete.tsx b/apps/storefront/src/pages/registered/RegisterComplete.tsx index 836c283c..8cf9bf56 100644 --- a/apps/storefront/src/pages/registered/RegisterComplete.tsx +++ b/apps/storefront/src/pages/registered/RegisterComplete.tsx @@ -6,6 +6,7 @@ import { Alert, } from '@mui/material' import { useForm } from 'react-hook-form' +import { useB3Lang } from '@b3/lang' import { RegisteredContext } from './context/RegisteredContext' import RegisteredStepButton from './component/RegisteredStepButton' @@ -30,6 +31,7 @@ interface RegisterCompleteProps { type RegisterCompleteList = Array | undefined export default function RegisterComplete(props: RegisterCompleteProps) { + const b3Lang = useB3Lang() const { handleBack, activeStep, handleNext } = props const [personalInfo, setPersonalInfo] = useState>([]) @@ -57,7 +59,7 @@ export default function RegisterComplete(props: RegisterCompleteProps) { if (list && list.length) { const emailFileds = list.find((item: RegisterFileds) => item.name === emailName) || {} emailItem = { ...emailFileds } - emailItem.label = 'email' + emailItem.label = `${b3Lang('intl.completePage.email')}` emailItem.name = 'email' emailItem.disabled = true newPasswordInformation.push(emailItem) @@ -67,7 +69,7 @@ export default function RegisterComplete(props: RegisterCompleteProps) { newPasswordInformation.push({ default: '', required: true, - label: 'Confirm Password', + label: b3Lang('intl.completePage.confirmPassword'), name: 'ConfirmPassword', id: 'Confirm Password', fieldType: 'password', @@ -250,7 +252,7 @@ export default function RegisterComplete(props: RegisterCompleteProps) { const handleCompleted = (event: MouseEvent) => { handleSubmit(async (completeData: CustomFieldItems) => { if (completeData.password !== completeData.ConfirmPassword) { - setErrorMessage('The passwords are different') + setErrorMessage(b3Lang('intl.completePage.passwordMatchPrompt')) return } try { @@ -329,7 +331,7 @@ export default function RegisterComplete(props: RegisterCompleteProps) { ) } - Complete Registration + {b3Lang('intl.completePage.title')} { personalInfo && ( void}) { const { activeStep, handleFinish } = props const { state } = useContext(RegisteredContext) + const b3Lang = useB3Lang() const { accountType, @@ -23,11 +26,11 @@ export default function RegisteredFinish(props: { activeStep: any; handleFinish: return ( isAutoApproval ? ( - {`Thank you for creating your account at ${storeName}. Your company account application has been approved`} + {b3Lang('intl.finishPage.autoApproved.tip', { storeName })} ) : ( - Your company account application has been received. Please allow 24 hours for account approval and activation. + {b3Lang('intl.finishPage.notAutoApproved.tip')} ) ) @@ -36,7 +39,7 @@ export default function RegisteredFinish(props: { activeStep: any; handleFinish: if (accountType === '2') { return ( - {`Thank you for creating your account at ${storeName}.`} + {b3Lang('intl.finishPage.bcSuccess.tip', { storeName })} ) } diff --git a/apps/storefront/src/pages/registered/component/RegisteredStepButton.tsx b/apps/storefront/src/pages/registered/component/RegisteredStepButton.tsx index afe30a79..2b7dba29 100644 --- a/apps/storefront/src/pages/registered/component/RegisteredStepButton.tsx +++ b/apps/storefront/src/pages/registered/component/RegisteredStepButton.tsx @@ -19,7 +19,7 @@ function RegisteredStepButton(props: any) { {activeStep === steps.length ? ( - + ) : ( diff --git a/apps/storefront/src/shared/service/b2b/api/register.ts b/apps/storefront/src/shared/service/b2b/api/register.ts index e739acea..44a4cd97 100644 --- a/apps/storefront/src/shared/service/b2b/api/register.ts +++ b/apps/storefront/src/shared/service/b2b/api/register.ts @@ -1,12 +1,11 @@ import { B3Request } from '../../request/b3Fetch' import { RequestType } from '../../request/base' +import { storeHash } from '../../../../utils/basicConfig' interface CustomFieldItems { [key: string]: any } -const storeHash = (window as any).b3?.setting?.storeHash || 'rtmh8fqr05' - export const createBCCompanyUser = (data: CustomFieldItems): CustomFieldItems => B3Request.post('/api/v2/proxy', RequestType.B2BRest, data) export const validateBCCompanyExtraFields = (data: CustomFieldItems): CustomFieldItems => B3Request.post('/api/v2/extra-fields/company/validate', RequestType.B2BRest, { ...data, storeHash })