-
Notifications
You must be signed in to change notification settings - Fork 356
Create & Setup Settings page #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f4f5de2
settings sidebar & search & settings/routes setup
Avdhesh-Varshney 05aa009
reusuable protected route lazy loading component
Avdhesh-Varshney f29a801
responsive settings sidebar & header
Avdhesh-Varshney c5a7ebd
create reusuable searchbar component
Avdhesh-Varshney fefd456
create /user/me api to persist users data
Avdhesh-Varshney decb06f
migrate profile section
Avdhesh-Varshney 9380c5e
format code
Avdhesh-Varshney d8f043e
lint fixes
Avdhesh-Varshney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
22 changes: 22 additions & 0 deletions
22
client/src/modules/app/routes/auth-routes/protected-route/index.tsx
This file contains hidden or 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,22 @@ | ||
| import { ComponentType, LazyExoticComponent, Suspense } from 'react'; | ||
| import Loader from '../../../../../shared/components/molecules/loader'; | ||
| import { LOADING } from '../../constants'; | ||
| import ProtectedPlaceholder from './protected'; | ||
|
|
||
| export const ProtectedRoute = ({ | ||
| component: LazyComponent, | ||
| hasAccess, | ||
| }: { | ||
| component: LazyExoticComponent<ComponentType<Record<string, unknown>>>; | ||
| hasAccess: boolean; | ||
| }) => { | ||
| if (hasAccess) { | ||
| return ( | ||
| <Suspense fallback={<Loader size={32} secondary={LOADING} />}> | ||
| <LazyComponent /> | ||
| </Suspense> | ||
| ); | ||
| } | ||
|
|
||
| return <ProtectedPlaceholder />; | ||
| }; |
108 changes: 108 additions & 0 deletions
108
client/src/modules/app/routes/auth-routes/protected-route/protected.tsx
This file contains hidden or 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,108 @@ | ||
| import { FC } from 'react'; | ||
| import { Box, Typography, useTheme } from '@mui/material'; | ||
| import { useCustomNavigate } from '../../../../../shared/hooks/use-custom-navigate'; | ||
| import A2ZButton from '../../../../../shared/components/atoms/button'; | ||
| import { ROUTES_V1 } from '../../constants/routes'; | ||
|
|
||
| interface ProtectedPlaceholderProps { | ||
| onClick?: () => void; | ||
| heading?: string; | ||
| description?: string; | ||
| buttonText?: string; | ||
| showButton?: boolean; | ||
| } | ||
|
|
||
| const ProtectedPlaceholder: FC<ProtectedPlaceholderProps> = ({ | ||
| heading = 'Access Denied', | ||
| description = 'You do not have access to this content.', | ||
| onClick, | ||
| buttonText = 'Go to Home', | ||
| showButton = true, | ||
| }) => { | ||
| const theme = useTheme(); | ||
| const navigate = useCustomNavigate(); | ||
|
|
||
| return ( | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| height: '100%', | ||
| width: '100%', | ||
| }} | ||
| > | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| flexDirection: 'column', | ||
| p: { xs: 3, sm: '36px 72px' }, | ||
| borderRadius: 2, | ||
| bgcolor: | ||
| theme.palette.mode === 'dark' | ||
| ? 'background.paper' | ||
| : theme.palette.grey[50], | ||
| boxShadow: theme.shadows[2], | ||
| maxWidth: { xs: '90%', sm: 'auto' }, | ||
| }} | ||
| > | ||
| <Typography | ||
| variant="h4" | ||
| component="h1" | ||
| sx={{ | ||
| m: 0, | ||
| fontWeight: 600, | ||
| color: 'text.primary', | ||
| textAlign: 'center', | ||
| }} | ||
| > | ||
| {heading} | ||
| </Typography> | ||
| <Typography | ||
| variant="body1" | ||
| component="p" | ||
| sx={{ | ||
| mt: 2, | ||
| color: 'text.secondary', | ||
| textAlign: 'center', | ||
| maxWidth: 400, | ||
| }} | ||
| > | ||
| {description} | ||
| </Typography> | ||
|
|
||
| {showButton && ( | ||
| <A2ZButton | ||
| variant="contained" | ||
| sx={{ | ||
| mt: 6, | ||
| px: 3, | ||
| py: 1.5, | ||
| fontSize: 16, | ||
| transition: 'all 0.2s ease-in-out', | ||
| bgcolor: 'primary.main', | ||
| color: 'primary.contrastText', | ||
| '&:hover': { | ||
| transform: 'scale(1.05)', | ||
| bgcolor: 'primary.dark', | ||
| }, | ||
| }} | ||
| onClick={() => { | ||
| if (onClick) { | ||
| onClick(); | ||
| } else { | ||
| navigate({ pathname: ROUTES_V1.HOME.replace('/*', '/') }); | ||
| } | ||
| }} | ||
| > | ||
| {buttonText} | ||
| </A2ZButton> | ||
| )} | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default ProtectedPlaceholder; | ||
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string manipulation 'ROUTES_V1.HOME.replace('/', '/')' is fragile. ROUTES_V1.HOME is defined as '/v1/home' which doesn't contain '/', so this replace does nothing. If you intend to handle wildcard routes, verify that the route constant actually contains '/*' or remove this unnecessary replace call.