-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' of https://github.com/wri/wri-terramatch-website…
… into epic/TM-853-admin-ui
- Loading branch information
Showing
29 changed files
with
211 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client"; | ||
import { Button } from "@mui/material"; | ||
import { usePathname } from "next/navigation"; | ||
import React from "react"; | ||
import { When } from "react-if"; | ||
|
||
import Text from "@/components/elements/Text/Text"; | ||
|
||
interface LoginLayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const LoginLayout: React.FC<LoginLayoutProps> = props => { | ||
const { children } = props; | ||
const pathname = usePathname(); | ||
|
||
return ( | ||
<div className="relative flex h-screen w-full bg-square-pattern bg-contain bg-right bg-no-repeat"> | ||
<div className="mt-[-78px] flex w-[45%] flex-col items-center justify-center py-[78px]"> | ||
{children} | ||
<When condition={pathname !== "/sign-up"}> | ||
<div className="absolute bottom-[1.5vh] left-6"> | ||
<Button> | ||
<Text variant="text-12-bold" className="text-primary"> | ||
English (United Kingdom) | ||
</Text> | ||
</Button> | ||
</div> | ||
</When> | ||
</div> | ||
<div className="flex w-[55%] items-center justify-end" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LoginLayout; |
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,70 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
interface UsePasswordStrengthProps { | ||
password: string; | ||
} | ||
|
||
interface UsePasswordStrengthResult { | ||
passwordStrength: string; | ||
values: { | ||
hasUppercase: boolean; | ||
hasLowercase: boolean; | ||
hasNumber: boolean; | ||
hasCorrectLength: boolean; | ||
}; | ||
validationCount: number; | ||
} | ||
|
||
const ValidationStrength = { | ||
STRONG: 4, | ||
FAIR: 3, | ||
WEAK: 2, | ||
VERY_WEAK: 1 | ||
}; | ||
const usePasswordStrength = (props: UsePasswordStrengthProps): UsePasswordStrengthResult => { | ||
const { password } = props; | ||
const [passwordStrength, setPasswordStrength] = useState("Very Weak"); | ||
const [values, setValues] = useState({ | ||
hasUppercase: false, | ||
hasLowercase: false, | ||
hasNumber: false, | ||
hasCorrectLength: false | ||
}); | ||
|
||
const [validation, setValidation] = useState<boolean[]>([]); | ||
|
||
useEffect(() => { | ||
const hasCorrectLength = password.length >= 8; | ||
const hasUppercase = (password.match(/[A-Z]/g) ?? []).length > 0; | ||
const hasLowercase = (password.match(/[a-z]/g) ?? []).length > 0; | ||
const hasNumber = (password.match(/[0-9]/g) ?? []).length > 0; | ||
|
||
const _validation = [hasUppercase, hasLowercase, hasNumber, hasCorrectLength]; | ||
|
||
const strengthMap = { | ||
[ValidationStrength.STRONG]: "Strong", | ||
[ValidationStrength.FAIR]: "Fair", | ||
[ValidationStrength.WEAK]: "Weak" | ||
}; | ||
|
||
setValues({ | ||
hasUppercase, | ||
hasLowercase, | ||
hasNumber, | ||
hasCorrectLength | ||
}); | ||
|
||
setValidation(_validation); | ||
const validationCount = _validation.filter(value => value === true).length; | ||
|
||
setPasswordStrength(strengthMap[validationCount]); | ||
}, [password]); | ||
|
||
return { | ||
passwordStrength, | ||
values, | ||
validationCount: validation.filter(Boolean).length | ||
}; | ||
}; | ||
|
||
export default usePasswordStrength; |
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
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
Oops, something went wrong.