Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
client-user
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
한성재
client-user
Commits
e9006e13
Commit
e9006e13
authored
1 year ago
by
Minseo Lee
Browse files
Options
Downloads
Patches
Plain Diff
fix: limit admin behavior
parent
a4c7fbf9
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/_app/App.tsx
+13
-1
13 additions, 1 deletion
src/_app/App.tsx
src/components/header/Header.module.css
+6
-0
6 additions, 0 deletions
src/components/header/Header.module.css
src/components/header/Header.tsx
+16
-1
16 additions, 1 deletion
src/components/header/Header.tsx
with
35 additions
and
2 deletions
src/_app/App.tsx
+
13
−
1
View file @
e9006e13
import
{
useEffect
,
useRef
,
useState
}
from
'
react
'
;
import
'
../common/css/common.css
'
;
import
'
../common/css/reset.css
'
;
import
{
Routes
,
Route
,
useNavigate
}
from
"
react-router-dom
"
;
import
{
Routes
,
Route
,
useNavigate
,
useLocation
}
from
"
react-router-dom
"
;
import
{
ALERT
}
from
"
../common/constants
"
;
import
Connector
from
"
../common/instances/Connector
"
;
import
BottomSheet
from
"
../components/bottom-sheet/BottomSheet
"
;
import
Header
from
"
../components/header/Header
"
;
...
...
@@ -34,6 +35,7 @@ function App() {
const
connector
:
MutableRefObject
<
Connector
|
null
>
=
useRef
(
null
);
const
navigator
=
useNavigate
();
const
location
=
useLocation
();
useEffect
(()
=>
{
...
...
@@ -47,6 +49,16 @@ function App() {
}
},
[
login
]);
useEffect
(()
=>
{
if
(
!
connector
.
current
||
!
login
)
return
;
if
(
connector
.
current
?.
getIsAdmin
())
{
if
(
location
.
pathname
.
split
(
'
/
'
).
at
(
1
)
!==
'
admin
'
)
{
alert
(
ALERT
.
REQ_WRONG
);
navigator
(
APP_ROUTE
.
ADMIN
);
}
}
},
[
location
]);
return
(
<
BSProvider
>
...
...
This diff is collapsed.
Click to expand it.
src/components/header/Header.module.css
+
6
−
0
View file @
e9006e13
...
...
@@ -55,3 +55,9 @@
align-items
:
center
;
justify-content
:
space-between
;
}
.admin
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
}
This diff is collapsed.
Click to expand it.
src/components/header/Header.tsx
+
16
−
1
View file @
e9006e13
...
...
@@ -68,6 +68,21 @@ const HistoryHeader = () => {
);
};
const
AdminHeader
:
GFC
=
({
connector
})
=>
{
const
handleLogOut
=
()
=>
{
if
(
confirm
(
"
로그아웃 하시겠습니까?
"
))
{
connector
.
current
?.
logout
();
}
};
return
(
<
div
className
=
{
S
[
'
admin
'
]
}
>
<
span
className
=
{
'
bold
'
}
>
AJOUORDER
</
span
>
<
span
onClick
=
{
handleLogOut
}
className
=
{
'
cursor-pointer
'
}
>
🚀
</
span
>
</
div
>
);
};
interface
MenuHeaderProps
{
headerName
:
Props
[
'
headerName
'
];
}
const
MenuHeader
:
GFCWithProp
<
MenuHeaderProps
>
=
({
headerName
,
connector
})
=>
{
return
(
...
...
@@ -93,7 +108,7 @@ const Header: GFCWithProp<Props> = ({ headerName, connector }) => {
if
(
_loc
===
'
menu
'
)
setReturnEl
(<
MenuHeader
headerName
=
{
headerName
}
connector
=
{
connector
}
/>);
if
(
_loc
===
'
cart
'
)
setReturnEl
(<
CartHeader
/>);
if
(
_loc
===
'
history
'
)
setReturnEl
(<
HistoryHeader
/>);
if
(
_loc
===
'
admin
'
)
setReturnEl
(<
Home
Header
connector
=
{
connector
}
/>);
if
(
_loc
===
'
admin
'
)
setReturnEl
(<
Admin
Header
connector
=
{
connector
}
/>);
},
[
location
,
headerName
]);
return
(
...
...
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