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
e5b5a301
Verified
Commit
e5b5a301
authored
3 years ago
by
Defendi Alberto
Browse files
Options
Downloads
Patches
Plain Diff
Hook to return role object.
parent
2697e245
No related branches found
Branches containing commit
No related tags found
2 merge requests
!85
Implement the remaining api calls to make possible to link a driver shift with a reservation.
,
!75
Resolve "Driver shift page where driver inserts shift."
Pipeline
#13317
passed
3 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Dashboard/ReservationPage/ReservationList/ReservationListSwitcher.tsx
+3
-2
3 additions, 2 deletions
...servationPage/ReservationList/ReservationListSwitcher.tsx
src/hooks/useRoleObject.ts
+21
-0
21 additions, 0 deletions
src/hooks/useRoleObject.ts
with
24 additions
and
2 deletions
src/components/Dashboard/ReservationPage/ReservationList/ReservationListSwitcher.tsx
+
3
−
2
View file @
e5b5a301
...
...
@@ -3,13 +3,14 @@ import { useRole } from 'hooks/useRole';
import
{
Roles
}
from
'
roles/userRoles
'
;
import
{
ReservationsListByWeek
}
from
'
components/Dashboard/ReservationPage/ReservationList/ReservationsListByWeek
'
;
import
{
ReservationList
}
from
'
components/Dashboard/ReservationPage/ReservationList/ReservationList
'
;
import
{
useRoleObject
}
from
'
hooks/useRoleObject
'
;
export
const
ReservationListSwitcher
:
FC
=
()
=>
{
const
[
role
]
=
useRole
();
const
role
=
useRole
Object
();
return
(
<>
{
role
==
=
Roles
.
o
perator
?
(
{
typeof
role
!
==
undefined
&&
role
?.
isO
perator
?
(
<
ReservationsListByWeek
/>
)
:
(
<
ReservationList
/>
...
...
This diff is collapsed.
Click to expand it.
src/hooks/useRoleObject.ts
0 → 100644
+
21
−
0
View file @
e5b5a301
import
{
getRole
}
from
'
api/getRole
'
;
import
{
getRoleObject
}
from
'
api/getRoleObject
'
;
import
{
useEffect
,
useState
}
from
'
react
'
;
import
{
RoleObjectType
}
from
'
types/RoleObjectType
'
;
export
const
useRoleObject
=
():
RoleObjectType
|
undefined
=>
{
const
[
role
,
setRole
]
=
useState
<
RoleObjectType
>
();
useEffect
(()
=>
{
let
isMounted
=
true
;
getRoleObject
().
then
((
responseRole
)
=>
{
if
(
isMounted
)
{
setRole
(
responseRole
);
}
});
return
()
=>
{
isMounted
=
false
;
};
},
[]);
return
role
;
};
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