Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
red-giant
dashboard
Commits
9f9e4ee8
Verified
Commit
9f9e4ee8
authored
3 years ago
by
Defendi Alberto
Browse files
Options
Downloads
Patches
Plain Diff
Configure role setting context.
parent
fb9d3419
No related branches found
No related tags found
2 merge requests
!56
Refined auth flow and new website pages.
,
!43
Move back cookie fetch to SignInForm. Role fetched and saved into a Context. Small refactorings.
Pipeline
#12139
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/App.tsx
+23
-12
23 additions, 12 deletions
src/App.tsx
src/components/AuthUser/AuthContext.tsx
+13
-0
13 additions, 0 deletions
src/components/AuthUser/AuthContext.tsx
src/components/AuthUser/Homepage/HomePage.tsx
+0
-132
0 additions, 132 deletions
src/components/AuthUser/Homepage/HomePage.tsx
with
36 additions
and
144 deletions
src/App.tsx
+
23
−
12
View file @
9f9e4ee8
import
React
,
{
FC
,
useEffect
,
useState
}
from
'
react
'
;
import
{
createMuiTheme
,
ThemeProvider
}
from
'
@material-ui/core/styles
'
;
import
{
BrowserRouter
as
Router
,
Switch
,
Route
}
from
'
react-router-dom
'
;
import
{
HomePage
}
from
'
components/AuthUser/HomePage/HomePage
'
;
import
{
AuthUser
}
from
'
components/AuthUser/AuthUser
'
;
import
{
LandingPage
}
from
'
components/NonAuthUser/LandingPage/LandingPage
'
;
import
{
PrivateRoute
}
from
'
api/PrivateRoute/PrivateRoute
'
;
...
...
@@ -12,6 +11,9 @@ import { Roles } from 'api/userRoles';
import
{
Unauthorized
}
from
'
components/NonAuthUser/Unauthorized/Unauthorized
'
;
import
axios
from
'
axios
'
;
import
{
ReservationPage
}
from
'
components/AuthUser/ReservationPage/ReservationPage
'
;
import
{
HomePage
}
from
'
components/AuthUser/HomePage/HomePage
'
;
import
{
SignInForm
}
from
'
components/AuthUser/SignInForm/SignInForm
'
;
import
{
AuthContext
}
from
'
components/AuthUser/AuthContext
'
;
const
theme
=
createMuiTheme
({
palette
:
{
...
...
@@ -49,6 +51,10 @@ const configDjangoCookieName = (): void => {
export
const
App
:
FC
=
()
=>
{
const
[
isCookieFetched
,
setisCookieFetched
]
=
useState
<
string
>
(
''
);
const
[
role
,
setRole
]
=
useState
(
''
);
const
value
=
{
role
,
setRole
};
configDjangoCookieName
();
useEffect
(()
=>
{
const
fetchCookie
=
async
():
Promise
<
unknown
>
=>
{
...
...
@@ -67,18 +73,23 @@ export const App: FC = () => {
<
Router
>
<
div
data-testid
=
"App"
>
<
Switch
>
<
Route
path
=
{
NonAuthRoutes
.
auth
}
component
=
{
AuthUser
}
/>
<
Route
exact
path
=
{
NonAuthRoutes
.
home
}
component
=
{
LandingPage
}
/>
<
PrivateRoute
path
=
{
AuthRoutes
.
dashboard
}
Component
=
{
HomePage
}
requiredRoles
=
{
[
Roles
.
admin
,
Roles
.
operator
,
Roles
.
senior
]
}
/>
<
PrivateRoute
path
=
{
AuthRoutes
.
profile
}
Component
=
{
ProfilePage
}
requiredRoles
=
{
[
Roles
.
admin
,
Roles
.
operator
,
Roles
.
senior
]
}
/>
<
AuthContext
.
Provider
value
=
{
value
}
>
<
Route
exact
path
=
{
NonAuthRoutes
.
auth
}
component
=
{
AuthUser
}
/>
<
Route
exact
path
=
"/signIn"
component
=
{
SignInForm
}
/>
<
PrivateRoute
path
=
{
AuthRoutes
.
dashboard
}
Component
=
{
HomePage
}
requiredRoles
=
{
[
Roles
.
admin
,
Roles
.
operator
,
Roles
.
senior
]
}
/>
<
PrivateRoute
path
=
{
AuthRoutes
.
profile
}
Component
=
{
ProfilePage
}
requiredRoles
=
{
[
Roles
.
admin
,
Roles
.
operator
,
Roles
.
senior
]
}
/>
</
AuthContext
.
Provider
>
<
Route
path
=
{
AuthRoutes
.
reservation
}
component
=
{
ReservationPage
}
/>
<
Route
path
=
{
NonAuthRoutes
.
unauthorized
}
component
=
{
Unauthorized
}
/>
<
Route
component
=
{
NotFound
}
/>
...
...
This diff is collapsed.
Click to expand it.
src/components/AuthUser/AuthContext.tsx
0 → 100644
+
13
−
0
View file @
9f9e4ee8
import
{
createContext
}
from
'
react
'
;
export
type
AuthData
=
{
role
:
string
;
setRole
:
(
role
:
string
)
=>
void
;
};
export
const
AuthContext
=
createContext
<
AuthData
>
({
role
:
''
,
setRole
:
()
=>
{
// Do nothing
},
});
This diff is collapsed.
Click to expand it.
src/components/AuthUser/Homepage/HomePage.tsx
deleted
100644 → 0
+
0
−
132
View file @
fb9d3419
import
React
,
{
FC
}
from
'
react
'
;
import
{
makeStyles
}
from
'
@material-ui/core/styles
'
;
import
{
CssBaseline
,
Grid
,
Typography
,
Hidden
,
createMuiTheme
,
responsiveFontSizes
,
MuiThemeProvider
,
Container
,
}
from
'
@material-ui/core
'
;
import
{
MapElement
}
from
'
components/AuthUser/HomePage/MapElement
'
;
import
{
NavBar
}
from
'
components/AuthUser/HomePage/NavBar
'
;
import
{
NavBarLogin
}
from
'
components/AuthUser/HomePage/NavBarLogin
'
;
import
{
Steps
}
from
'
components/AuthUser/HomePage/Steps
'
;
import
{
Reservation
}
from
'
components/AuthUser/ReservationPage/Reservation/Reservation
'
;
import
{
Numbers
}
from
'
components/AuthUser/HomePage/Numbers
'
;
let
themeResp
=
createMuiTheme
();
themeResp
=
responsiveFontSizes
(
themeResp
);
const
useStyles
=
makeStyles
(()
=>
({
root
:
{
minHeight
:
'
100vh
'
,
backgroundImage
:
`url(
${
'
/assets/bg3.png
'
}
)`
,
backgroundRepeat
:
'
no-repeat
'
,
backgroundSize
:
'
cover
'
,
},
rightAlign
:
{
marginLeft
:
'
auto
'
,
},
whiteText
:
{
color
:
'
white
'
,
},
imageIcon
:
{
maxHeight
:
'
50%
'
,
},
paddingBottom
:
{
paddingBottom
:
'
65px
'
,
},
paddingTop
:
{
paddingTop
:
'
65px
'
,
},
bodyIcon
:
{
fontSize
:
'
90px
'
,
paddingBottom
:
'
10px
'
,
paddingTop
:
'
10px
'
,
},
contIcon
:
{
width
:
'
100%
'
,
left
:
'
0
'
,
right
:
'
0
'
,
},
noShadow
:
{
border
:
'
none
'
,
boxShadow
:
'
none
'
,
backgroundColor
:
'
transparent
'
,
},
}));
export
const
HomePage
:
FC
=
()
=>
{
const
classes
=
useStyles
();
return
(
<
Grid
container
direction
=
"column"
className
=
{
classes
.
paddingBottom
}
>
<
div
className
=
{
classes
.
root
}
>
<
CssBaseline
/>
<
Grid
item
>
<
NavBar
/>
</
Grid
>
<
MuiThemeProvider
theme
=
{
themeResp
}
>
<
Grid
item
container
className
=
{
classes
.
paddingBottom
}
>
<
Grid
item
xs
=
{
1
}
md
=
{
2
}
lg
=
{
2
}
/>
<
Grid
item
xs
=
{
10
}
md
=
{
6
}
lg
=
{
4
}
>
<
Typography
variant
=
"h2"
className
=
{
classes
.
whiteText
}
>
Book Free Rides Now With
</
Typography
>
<
Typography
variant
=
"h1"
className
=
{
classes
.
whiteText
}
>
MOVE AID
</
Typography
>
</
Grid
>
<
Grid
item
xs
=
{
false
}
md
=
{
3
}
lg
=
{
5
}
>
<
Hidden
mdDown
>
<
Container
>
<
MapElement
/>
</
Container
>
</
Hidden
>
</
Grid
>
<
Grid
item
xs
=
{
1
}
/>
</
Grid
>
<
Steps
/>
</
MuiThemeProvider
>
</
div
>
<
Grid
item
container
className
=
{
classes
.
paddingTop
}
>
<
Grid
item
xs
=
{
2
}
/>
<
Grid
item
xs
=
{
8
}
>
<
Typography
variant
=
"h3"
>
Your Next Reservation
</
Typography
>
</
Grid
>
<
Grid
item
xs
=
{
2
}
/>
</
Grid
>
<
Grid
item
container
style
=
{
{
paddingTop
:
'
20px
'
}
}
>
<
Grid
item
xs
=
{
1
}
lg
=
{
2
}
/>
<
Grid
item
xs
=
{
10
}
lg
=
{
8
}
>
<
Reservation
/>
</
Grid
>
<
Grid
item
xs
=
{
1
}
lg
=
{
2
}
/>
</
Grid
>
<
Grid
item
container
className
=
{
classes
.
paddingTop
}
>
<
Grid
item
xs
=
{
2
}
/>
<
Grid
item
xs
=
{
8
}
>
<
Typography
variant
=
"h3"
align
=
"right"
>
Some Our Numbers
</
Typography
>
</
Grid
>
<
Grid
item
xs
=
{
2
}
/>
</
Grid
>
<
Numbers
/>
</
Grid
>
);
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment