Skip to content

Commit

Permalink
[Fix] Login return url and minor UI problems (#7)
Browse files Browse the repository at this point in the history
* feat(logout): add logout feature

* chore(home-page): add test logout and organization fetch as test

* fix(auth-guard): fix a breakage with empty localstorage

* fix(login): fix some minor ui issues with the login

* fix(login): fix return url
  • Loading branch information
sijav authored Sep 21, 2023
1 parent ce15c94 commit be1e86b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/containers/auth/AuthContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const AuthWrapper = styled(Container)(({ theme }) => ({
right: 0,
top: 0,
background: theme.palette.common.white,
height: '100vh',
height: '100%',
width: '50%',
opacity: 0,
animationDelay: '1s',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/auth/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function LoginPage() {
<Grid
component="form"
container
spacing={3}
rowSpacing={3}
maxWidth={350}
m="0 auto"
alignItems="stretch"
Expand Down
4 changes: 3 additions & 1 deletion src/pages/auth/login/LoginSocialMedia.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Grid } from '@mui/material'
import { useQuery } from '@tanstack/react-query'
import { useSearchParams } from 'react-router-dom'
import { SocialMediaButtonFromOauthType } from 'src/shared/social-media-button'
import { oauthProvidersQuery } from './oauthProviders.query'

export const LoginSocialMedia = () => {
const { data } = useQuery([], oauthProvidersQuery)
const [search] = useSearchParams()
const { data } = useQuery(['LoginSocialMedia', search.get('returnUrl') ?? '/'], oauthProvidersQuery)

return (
<>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/auth/login/oauthProviders.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { endPoints } from 'src/shared/constants'
import { OAuthProvidersResponse } from 'src/shared/types/server'
import { simpleAxios } from 'src/shared/utils/axios'

export const oauthProvidersQuery = async ({ signal }: QueryFunctionContext) => {
export const oauthProvidersQuery = async ({ signal, queryKey: [_, redirect_url] }: QueryFunctionContext<['LoginSocialMedia', string]>) => {
return await simpleAxios
.get<OAuthProvidersResponse>(endPoints.auth.oauthProviders, {
signal,
params: { redirect_url },
})
.then((response) => response?.data)
.then((res) => new Promise<OAuthProvidersResponse>((resolve) => window.setTimeout(() => resolve(res), 3000)))
Expand Down
18 changes: 9 additions & 9 deletions src/shared/loading/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ interface SpinnerProps {
isLoading?: boolean
}

const SpinnerContainer = styled(Container, { shouldForwardProp })<{ isLoading?: boolean }>(({ theme, isLoading }) =>
isLoading
? {}
: {
[theme.breakpoints.down('md')]: {
display: 'none',
},
},
)
const SpinnerContainer = styled(Container, { shouldForwardProp })<{ isLoading?: boolean }>(({ theme, isLoading }) => ({
transition: theme.transitions.create(['opacity'], {
duration: 1000,
easing: theme.transitions.easing.easeInOut,
}),
[theme.breakpoints.down('md')]: {
opacity: isLoading ? 1 : 0,
},
}))

export const Spinner = ({ width = 110, isDark, isLoading }: SpinnerProps) => {
return (
Expand Down

0 comments on commit be1e86b

Please sign in to comment.