Skip to content

Commit

Permalink
Fix SignIn.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Dec 13, 2024
1 parent 8d7d83e commit 89ee703
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/SocialLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface SocialLoginProps {
facebook?: boolean
apple?: boolean
google?: boolean
redirectToHomepage?: boolean
className?: string
onError?: (error: any) => void
onSignInError?: () => void
Expand All @@ -33,6 +34,7 @@ const SocialLogin = ({
facebook,
apple,
google = true,
redirectToHomepage,
className,
onError,
onSignInError,
Expand All @@ -56,6 +58,8 @@ const SocialLogin = ({
if (onBlackListed) {
onBlackListed()
}
} else if (redirectToHomepage) {
navigate('/')
} else {
navigate(0)
}
Expand Down
14 changes: 9 additions & 5 deletions frontend/src/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import '@/assets/css/signin.css'

const SignIn = () => {
const navigate = useNavigate()

const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [error, setError] = useState(false)
Expand All @@ -45,6 +46,7 @@ const SignIn = () => {
}

const res = await UserService.signin(data)

if (res.status === 200) {
if (res.data.blacklisted) {
await UserService.signout(false)
Expand All @@ -59,10 +61,12 @@ const SignIn = () => {
if (from === 'checkout') {
navigate(`/checkout${window.location.search}`)
} else {
navigate(0)
// navigate(0)
navigate('/')
}
} else {
navigate(0)
// navigate(0)
navigate('/')
}
}
} else {
Expand Down Expand Up @@ -136,13 +140,13 @@ const SignIn = () => {
<Link href="/forgot-password">{strings.RESET_PASSWORD}</Link>
</div>

<SocialLogin />
<SocialLogin redirectToHomepage />

<div className="signin-buttons">
<Button variant="contained" size="small" href="/sign-up" className="btn-secondary btn-margin btn-margin-bottom">
<Button variant="outlined" color="primary" href="/sign-up" className="btn-margin btn-margin-bottom">
{strings.SIGN_UP}
</Button>
<Button type="submit" variant="contained" size="small" className="btn-primary btn-margin btn-margin-bottom">
<Button type="submit" variant="contained" className="btn-primary btn-margin btn-margin-bottom">
{strings.SIGN_IN}
</Button>
</div>
Expand Down

0 comments on commit 89ee703

Please sign in to comment.