Skip to content

Commit

Permalink
feat: registered page layout
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and kris-liu-smile committed Jun 27, 2023
1 parent a66e378 commit e515d18
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 94 deletions.
13 changes: 13 additions & 0 deletions apps/storefront/src/components/form/B3ControlTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export default function B3ControlTextField({
readOnly,
allowArrow = false,
sx = {},
isTip = false,
tipText = '',
} = rest

const b3Lang = useB3Lang()
Expand Down Expand Up @@ -149,6 +151,17 @@ export default function B3ControlTextField({
)
}
/>
{isTip && (
<Box
sx={{
fontSize: '12px',
color: 'rgba(0, 0, 0, 0.6)',
marginTop: '0.5rem',
}}
>
{tipText}
</Box>
)}
</>
) : null
}
49 changes: 26 additions & 23 deletions apps/storefront/src/pages/registered/RegisterComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { Alert, Box } from '@mui/material'
// Captcha,
// } from '@/components/form'
import { B3CustomForm } from '@/components'
import {
b3HexToRgb,
getContrastColor,
} from '@/components/outSideComponents/utils/b3CustomStyles'
import { getContrastColor } from '@/components/outSideComponents/utils/b3CustomStyles'
import { CustomStyleContext } from '@/shared/customStyleButtton'
import { GlobaledContext } from '@/shared/global'
import {
Expand Down Expand Up @@ -45,6 +42,7 @@ export default function RegisterComplete(props: RegisterCompleteProps) {

const [personalInfo, setPersonalInfo] = useState<Array<CustomFieldItems>>([])
const [errorMessage, setErrorMessage] = useState<string>('')
const [enterEmail, setEnterEmail] = useState<string>('')
// const [captchaMessage, setCaptchaMessage] = useState<string>('')

const {
Expand Down Expand Up @@ -98,23 +96,14 @@ export default function RegisterComplete(props: RegisterCompleteProps) {

useEffect(() => {
if (!accountType) return
let newPasswordInformation: Array<CustomFieldItems> = []
let emailItem: CustomFieldItems = {}
if (list && list.length) {
const emailFields =
const emailFields: CustomFieldItems =
list.find((item: RegisterFields) => item.name === 'email') || {}
emailItem = {
...emailFields,
}
emailItem.label = `${b3Lang('intl.user.register.RegisterComplete.email')}`
emailItem.name = 'email'
emailItem.disabled = true
newPasswordInformation.push(emailItem)
}

newPasswordInformation = [...newPasswordInformation, ...passwordInfo]
setEnterEmail(emailFields?.default || '')
}

setPersonalInfo(newPasswordInformation)
setPersonalInfo(passwordInfo)
}, [contactInformation, bcContactInformation, accountType])

const getBCFieldsValue = (data: CustomFieldItems) => {
Expand Down Expand Up @@ -445,7 +434,6 @@ export default function RegisterComplete(props: RegisterCompleteProps) {
color: customColor,
},
'& input, & .MuiFormControl-root .MuiTextField-root': {
bgcolor: b3HexToRgb('#FFFFFF', 0.87),
borderRadius: '4px',
borderBottomLeftRadius: '0',
borderBottomRightRadius: '0',
Expand All @@ -460,11 +448,26 @@ export default function RegisterComplete(props: RegisterCompleteProps) {
<Box>
<InformationFourLabels>{passwordName}</InformationFourLabels>
{personalInfo && (
<B3CustomForm
formFields={personalInfo}
errors={errors}
control={control}
/>
<>
{enterEmail.length > 0 && (
<Box
sx={{
fontSize: '16px',
fontWeight: 400,
color: '#000000',
marginBottom: '10px',
marginTop: '-12px',
}}
>
{`Create password for ${enterEmail}`}
</Box>
)}
<B3CustomForm
formFields={personalInfo}
errors={errors}
control={control}
/>
</>
)}
</Box>

Expand Down
6 changes: 4 additions & 2 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useB3Lang } from '@b3/lang'
import { Box, ImageListItem } from '@mui/material'

import { B3Card, B3Sping } from '@/components'
import { useScrollBar } from '@/hooks'
import { useMobile, useScrollBar } from '@/hooks'
import { CustomStyleContext } from '@/shared/customStyleButtton'
import { GlobaledContext } from '@/shared/global'
import { getB2BAccountFormFields, getB2BCountries } from '@/shared/service/b2b'
Expand Down Expand Up @@ -49,6 +49,7 @@ function Registered(props: RegisteredProps) {
const [activeStep, setActiveStep] = useState(0)

const b3Lang = useB3Lang()
const [isMobile] = useMobile()

const navigate = useNavigate()

Expand Down Expand Up @@ -286,7 +287,7 @@ function Registered(props: RegisteredProps) {

return (
<B3Card setOpenPage={setOpenPage}>
<RegisteredContainer>
<RegisteredContainer isMobile={isMobile}>
<B3Sping
isSpinning={isLoading}
tip={b3Lang('intl.global.tips.loading')}
Expand All @@ -297,6 +298,7 @@ function Registered(props: RegisteredProps) {
display: 'flex',
flexDirection: 'column',
width: '100%',
alignItems: 'center',
}}
>
{logo && (
Expand Down
15 changes: 12 additions & 3 deletions apps/storefront/src/pages/registered/RegisteredAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,19 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
const additionalInfo: any =
accountType === '1' ? additionalInformation : bcAdditionalInformation

const newContactInformation = contactInformation?.map(
(info: CustomFieldItems) => {
if (info.fieldId === 'field_email' && accountType === '1') {
info.isTip = true
info.tipText = 'This email will be used for sign in to your account'
}

return info
}
)

const contactInfo: any =
accountType === '1' ? contactInformation : bcContactInformation
accountType === '1' ? newContactInformation : bcContactInformation
const contactName =
accountType === '1' ? 'contactInformation' : 'bcContactInformationFields'

Expand Down Expand Up @@ -198,7 +209,6 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
{b3Lang('intl.user.register.registeredAccount.accountType')}
</InformationFourLabels>
<RadioGroup
row
aria-labelledby="demo-row-radio-buttons-group-label"
name="row-radio-buttons-group"
value={accountType}
Expand Down Expand Up @@ -242,7 +252,6 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
},
'& input, & .MuiFormControl-root .MuiTextField-root, & .MuiTextField-root .MuiInputBase-multiline':
{
bgcolor: b3HexToRgb('#FFFFFF', 0.87),
borderRadius: '4px',
borderBottomLeftRadius: '0',
borderBottomRightRadius: '0',
Expand Down
Loading

0 comments on commit e515d18

Please sign in to comment.