Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
concept-front-mojsprat-v2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Djordje Mutavdzic
concept-front-mojsprat-v2
Commits
61b30350
Commit
61b30350
authored
Aug 18, 2022
by
Djordje
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate routing with sidemenu
parent
0f569607
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
20 deletions
+68
-20
App.tsx
src/App.tsx
+1
-1
ApplicationTab.tsx
src/components/ApplicationTab.tsx
+14
-1
LoginForm.tsx
src/components/LoginForm.tsx
+1
-1
SideMenu.tsx
src/components/SideMenu/SideMenu.tsx
+10
-2
SideMenuData.tsx
src/components/SideMenu/SideMenuData.tsx
+7
-7
SideMenuItem.tsx
src/components/SideMenuItem.tsx
+32
-7
internal-types.ts
src/internal-types.ts
+3
-1
No files found.
src/App.tsx
View file @
61b30350
...
@@ -24,7 +24,7 @@ function App() {
...
@@ -24,7 +24,7 @@ function App() {
<
Route
path=
'register/:buildingId'
element=
{
<
EntryPage
children=
{
<
RegisterForm
/>
}
/>
}
/>
<
Route
path=
'register/:buildingId'
element=
{
<
EntryPage
children=
{
<
RegisterForm
/>
}
/>
}
/>
<
Route
path=
'register/error'
element=
{
<
EntryPage
children=
{
<
div
>
Invalid invitational link - screen to be implemented
</
div
>
}
/>
}
/>
<
Route
path=
'register/error'
element=
{
<
EntryPage
children=
{
<
div
>
Invalid invitational link - screen to be implemented
</
div
>
}
/>
}
/>
<
Route
path=
'login'
element=
{
<
EntryPage
children=
{
<
LoginForm
/>
}
/>
}
/>
<
Route
path=
'login'
element=
{
<
EntryPage
children=
{
<
LoginForm
/>
}
/>
}
/>
<
Route
path=
'tenant'
element=
{
<
Application
/>
}
/>
<
Route
path=
'tenant
/*
'
element=
{
<
Application
/>
}
/>
<
Route
path=
'*'
element=
{
<
Navigate
replace
to=
"login"
/>
}
/>
<
Route
path=
'*'
element=
{
<
Navigate
replace
to=
"login"
/>
}
/>
</
Routes
>
</
Routes
>
</
Router
>
</
Router
>
...
...
src/components/ApplicationTab.tsx
View file @
61b30350
import
{
Box
}
from
"@mui/material"
import
{
Box
}
from
"@mui/material"
import
{
Navigate
,
Route
,
Routes
}
from
"react-router-dom"
;
const
classes
=
{
const
classes
=
{
wrapper
:
{
wrapper
:
{
...
@@ -11,6 +12,17 @@ const classes = {
...
@@ -11,6 +12,17 @@ const classes = {
export
const
ApplicationTab
=
()
=>
{
export
const
ApplicationTab
=
()
=>
{
return
(
return
(
<
Box
sx=
{
classes
.
wrapper
}
></
Box
>
<
Box
sx=
{
classes
.
wrapper
}
>
<
Routes
>
<
Route
path=
'overview'
element=
{
<
div
>
Hello from overview
</
div
>
}
/>
<
Route
path=
'notifications'
element=
{
<
div
>
Hello from notifications
</
div
>
}
/>
<
Route
path=
'issues'
element=
{
<
div
>
Hello from issues
</
div
>
}
/>
<
Route
path=
'voting'
element=
{
<
div
>
Hello from voting
</
div
>
}
/>
<
Route
path=
'invoices'
element=
{
<
div
>
Hello from invoices
</
div
>
}
/>
<
Route
path=
'building-invoices'
element=
{
<
div
>
Hello from building invoices
</
div
>
}
/>
<
Route
path=
'documents'
element=
{
<
div
>
Hello from documents
</
div
>
}
/>
<
Route
path=
'*'
element=
{
<
Navigate
replace
to=
"overview"
/>
}
/>
</
Routes
>
</
Box
>
)
)
}
}
\ No newline at end of file
src/components/LoginForm.tsx
View file @
61b30350
...
@@ -89,7 +89,7 @@ export const LoginForm = () => {
...
@@ -89,7 +89,7 @@ export const LoginForm = () => {
}
}
localStorage
.
setItem
(
JWT_TENANT
,
res
);
localStorage
.
setItem
(
JWT_TENANT
,
res
);
navigate
(
'../tenant'
);
navigate
(
'../tenant
/overview
'
);
}
}
const
handleKeyUp
=
(
event
:
React
.
KeyboardEvent
<
HTMLDivElement
>
):
void
=>
{
const
handleKeyUp
=
(
event
:
React
.
KeyboardEvent
<
HTMLDivElement
>
):
void
=>
{
...
...
src/components/SideMenu/SideMenu.tsx
View file @
61b30350
...
@@ -6,6 +6,7 @@ import { UserIcon } from "../icons/UserIcon";
...
@@ -6,6 +6,7 @@ import { UserIcon } from "../icons/UserIcon";
import
{
SideMenuItem
}
from
"../SideMenuItem"
;
import
{
SideMenuItem
}
from
"../SideMenuItem"
;
import
{
subMenu
}
from
"./SideMenuData"
;
import
{
subMenu
}
from
"./SideMenuData"
;
import
"./SideMenu.css"
;
import
"./SideMenu.css"
;
import
{
useLocation
}
from
"react-router-dom"
;
const
classes
=
{
const
classes
=
{
logo
:
{
logo
:
{
...
@@ -39,6 +40,13 @@ const classes = {
...
@@ -39,6 +40,13 @@ const classes = {
export
const
SideMenu
=
({
active
,
toggleSideMenu
}:
{
active
:
boolean
,
toggleSideMenu
:
(
open
:
boolean
)
=>
void
})
=>
{
export
const
SideMenu
=
({
active
,
toggleSideMenu
}:
{
active
:
boolean
,
toggleSideMenu
:
(
open
:
boolean
)
=>
void
})
=>
{
const
[
tenantInfo
,
setTenantInfo
]
=
useState
<
any
>
();
const
[
tenantInfo
,
setTenantInfo
]
=
useState
<
any
>
();
const
location
=
useLocation
();
const
[
selectedItem
,
setSelectedItem
]
=
useState
(
location
.
pathname
.
split
(
'/'
).
at
(
-
1
)
!
);
const
changeSelectedItem
=
(
item
:
string
)
=>
{
setSelectedItem
(
item
);
toggleSideMenu
(
false
);
};
useEffect
(()
=>
{
useEffect
(()
=>
{
getTenantInfo
((
err
:
any
,
data
:
any
)
=>
{
getTenantInfo
((
err
:
any
,
data
:
any
)
=>
{
...
@@ -64,10 +72,10 @@ export const SideMenu = ({ active, toggleSideMenu }: { active: boolean, toggleSi
...
@@ -64,10 +72,10 @@ export const SideMenu = ({ active, toggleSideMenu }: { active: boolean, toggleSi
</
Box
>
</
Box
>
</
Box
>
</
Box
>
{
subMenu
.
map
((
menu
,
index
)
=>
(
{
subMenu
.
map
((
menu
,
index
)
=>
(
<
SideMenuItem
key=
{
index
}
content=
{
menu
}
/>
<
SideMenuItem
key=
{
index
}
content=
{
menu
}
selectedItem=
{
selectedItem
}
changeSelectedItem=
{
changeSelectedItem
}
/>
))
}
))
}
</
div
>
</
div
>
<
div
className=
"transparent"
onClick=
{
()
=>
{
toggleSideMenu
(
false
)
}
}
></
div
>
<
div
className=
"transparent"
onClick=
{
()
=>
{
toggleSideMenu
(
false
)
}
}
></
div
>
</
div
>
</
div
>
}
}
</>
</>
...
...
src/components/SideMenu/SideMenuData.tsx
View file @
61b30350
...
@@ -14,18 +14,18 @@ export const subMenu: SubMenu[] = [
...
@@ -14,18 +14,18 @@ export const subMenu: SubMenu[] = [
{
{
title
:
'Glavni meni'
,
title
:
'Glavni meni'
,
items
:
[
items
:
[
{
title
:
'Pregled'
,
icon
:
<
HomeIcon
/>
},
{
title
:
'Pregled'
,
icon
:
<
HomeIcon
/>
,
path
:
'overview'
},
{
title
:
'Obaveštenja'
,
icon
:
<
NotificationIcon
/>
},
{
title
:
'Obaveštenja'
,
icon
:
<
NotificationIcon
/>
,
path
:
'notifications'
},
{
title
:
'Aktivnosti'
,
icon
:
<
ActivityIcon
/>
},
{
title
:
'Aktivnosti'
,
icon
:
<
ActivityIcon
/>
,
path
:
'issues'
},
{
title
:
'Glasanje'
,
icon
:
<
VotingIcon
/>
}
{
title
:
'Glasanje'
,
icon
:
<
VotingIcon
/>
,
path
:
'voting'
}
]
]
},
},
{
{
title
:
'Računi/Finansije'
,
title
:
'Računi/Finansije'
,
items
:
[
items
:
[
{
title
:
'Moj Račun'
,
icon
:
<
InvoicesIcon
/>
},
{
title
:
'Moj Račun'
,
icon
:
<
InvoicesIcon
/>
,
path
:
'invoices'
},
{
title
:
'Finansije zgrade'
,
icon
:
<
BuidlingInvoicesIcon
/>
},
{
title
:
'Finansije zgrade'
,
icon
:
<
BuidlingInvoicesIcon
/>
,
path
:
'building-invoices'
},
{
title
:
'Dokumenta'
,
icon
:
<
DocumentIcon
/>
}]
{
title
:
'Dokumenta'
,
icon
:
<
DocumentIcon
/>
,
path
:
'documents'
}]
},
},
{
{
title
:
'Aplikacija'
,
title
:
'Aplikacija'
,
...
...
src/components/SideMenuItem.tsx
View file @
61b30350
import
{
Box
,
Typography
}
from
"@mui/material"
;
import
{
Box
,
Typography
}
from
"@mui/material"
;
import
{
useLocation
,
useNavigate
}
from
"react-router-dom"
;
import
{
SubMenu
}
from
"../internal-types"
;
import
{
SubMenu
}
from
"../internal-types"
;
const
classes
=
{
const
classes
=
{
wrapper
:
{
wrapper
:
{
display
:
'flex'
,
display
:
'flex'
,
flexDirection
:
'column'
,
flexDirection
:
'column'
,
color
:
'white'
,
color
:
'white'
,
gap
:
'
10px'
gap
:
'
5px'
},
},
itemTitle
:
{
itemTitle
:
{
color
:
'rgb(24, 95, 167)'
,
color
:
'rgb(24, 95, 167)'
,
...
@@ -18,19 +19,43 @@ const classes = {
...
@@ -18,19 +19,43 @@ const classes = {
gap
:
'15px'
,
gap
:
'15px'
,
alignItems
:
'center'
,
alignItems
:
'center'
,
paddingInline
:
'10%'
,
paddingInline
:
'10%'
,
// boxSizing: 'border-box',
paddingBlock
:
'2.5px'
,
boxSizing
:
'border-box'
,
// backgroundColor: 'red',
// backgroundColor: 'red',
borderRadius
:
'5px'
borderRadius
:
'5px'
,
userSelect
:
'none'
,
':hover'
:
{
backgroundColor
:
'rgba(150, 150, 150, 0.2)'
}
},
selectedItem
:
{
backgroundColor
:
'rgba(200, 200, 200, 0.3)'
,
'& .MuiTypography-root'
:
{
fontWeight
:
'bold'
},
'&:hover'
:
{
backgroundColor
:
'rgba(200, 200, 200, 0.3)'
},
'& .icons-stroke'
:
{
stroke
:
'white'
}
}
}
}
as
const
;
}
as
const
;
export
const
SideMenuItem
=
({
content
}:
{
content
:
SubMenu
})
=>
{
export
const
SideMenuItem
=
({
content
,
selectedItem
,
changeSelectedItem
}:
{
content
:
SubMenu
,
selectedItem
:
string
,
changeSelectedItem
:
(
item
:
string
)
=>
void
})
=>
{
const
navigate
=
useNavigate
();
return
(
return
(
<
Box
sx=
{
classes
.
wrapper
}
>
<
Box
sx=
{
classes
.
wrapper
}
>
<
Typography
sx=
{
classes
.
itemTitle
}
>
{
content
.
title
.
toUpperCase
()
}
</
Typography
>
<
Typography
sx=
{
classes
.
itemTitle
}
>
{
content
.
title
.
toUpperCase
()
}
</
Typography
>
{
content
.
items
.
map
((
item
,
ind
)
=>
(
{
content
.
items
.
map
((
item
,
ind
)
=>
(
<
Box
sx=
{
classes
.
itemsWrapper
}
key=
{
ind
}
>
<
Box
sx=
{
selectedItem
===
item
.
path
?
{
...
classes
.
itemsWrapper
,
...
classes
.
selectedItem
}
:
classes
.
itemsWrapper
}
key=
{
ind
}
onClick=
{
()
=>
{
if
(
item
.
path
)
{
navigate
(
item
.
path
);
changeSelectedItem
(
item
.
path
);
}
}
}
>
{
!!
item
.
icon
&&
item
.
icon
}
{
!!
item
.
icon
&&
item
.
icon
}
<
Typography
>
{
item
.
title
}
</
Typography
>
<
Typography
>
{
item
.
title
}
</
Typography
>
</
Box
>
</
Box
>
...
...
src/internal-types.ts
View file @
61b30350
...
@@ -25,5 +25,6 @@ export type SubMenu = {
...
@@ -25,5 +25,6 @@ export type SubMenu = {
export
type
SubMenuItem
=
{
export
type
SubMenuItem
=
{
icon
?:
ReactElement
,
icon
?:
ReactElement
,
title
:
string
title
:
string
,
path
?:
string
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment