-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Login Page for Remote Frontend
- Loading branch information
1 parent
a75a175
commit aacc0b7
Showing
28 changed files
with
1,273 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export { | ||
Home, | ||
} from './Home' | ||
export { | ||
Form, | ||
} from './Form' | ||
|
||
export { | ||
Login, | ||
ForgotPassword, | ||
} from './login' | ||
export { | ||
Registered, RegisteredBCToB2B, | ||
} from './registered' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { | ||
useState, | ||
} from 'react' | ||
|
||
import { | ||
Box, | ||
Grid, | ||
} from '@mui/material' | ||
|
||
import { | ||
useForm, | ||
SubmitHandler, | ||
} from 'react-hook-form' | ||
|
||
import { | ||
useB3Lang, | ||
} from '@b3/lang' | ||
|
||
import { | ||
useNavigate, | ||
} from 'react-router-dom' | ||
|
||
import { | ||
getForgotPasswordFields, | ||
sendEmail, | ||
LoginConfig, | ||
} from './config' | ||
|
||
import { | ||
B3CustomForm, | ||
B3Sping, | ||
} from '@/components' | ||
|
||
import { | ||
B3ForgotButton, | ||
} from './styled' | ||
|
||
const ForgotPassword = () => { | ||
const [isLoading, setLoading] = useState<boolean>(false) | ||
const b3Lang = useB3Lang() | ||
const forgotPasswordFields = getForgotPasswordFields(b3Lang) | ||
|
||
const { | ||
control, | ||
handleSubmit, | ||
getValues, | ||
formState: { | ||
errors, | ||
}, | ||
setValue, | ||
} = useForm<LoginConfig>({ | ||
mode: 'onSubmit', | ||
}) | ||
|
||
const navigate = useNavigate() | ||
|
||
const handleLoginClick: SubmitHandler<LoginConfig> = async (data) => { | ||
setLoading(true) | ||
const { | ||
emailAddress, | ||
} = data | ||
try { | ||
await sendEmail(emailAddress) | ||
setLoading(false) | ||
navigate('/login?loginFlag=2') | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
} | ||
|
||
return ( | ||
<Box sx={{ | ||
mr: '25%', | ||
ml: '25%', | ||
}} | ||
> | ||
<Box sx={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
fontSize: '25px', | ||
mt: 3, | ||
mb: 3, | ||
}} | ||
> | ||
{b3Lang('intl.user.forgot.forgotText.resetPassword')} | ||
</Box> | ||
<Box sx={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
mt: '50px', | ||
mb: '50px', | ||
}} | ||
> | ||
{b3Lang('intl.user.forgot.forgotText.requestEmail')} | ||
</Box> | ||
|
||
<Box> | ||
<Grid container> | ||
<Grid | ||
item | ||
xs={8} | ||
> | ||
<B3CustomForm | ||
formFields={forgotPasswordFields} | ||
errors={errors} | ||
control={control} | ||
getValues={getValues} | ||
setValue={setValue} | ||
/> | ||
</Grid> | ||
|
||
<Grid | ||
item | ||
xs={4} | ||
> | ||
<Box sx={{ | ||
pl: 2, | ||
mt: '31px', | ||
}} | ||
> | ||
<B3Sping | ||
isSpinning={isLoading} | ||
size={20} | ||
> | ||
<B3ForgotButton | ||
type="submit" | ||
size="medium" | ||
onClick={handleSubmit(handleLoginClick)} | ||
variant="contained" | ||
> | ||
{b3Lang('intl.user.forgot.forgotText.resetPasswordBtn')} | ||
</B3ForgotButton> | ||
</B3Sping> | ||
|
||
</Box> | ||
|
||
</Grid> | ||
|
||
</Grid> | ||
</Box> | ||
</Box> | ||
) | ||
} | ||
|
||
export default ForgotPassword |
Oops, something went wrong.