Commit 73caab57 authored by Djordje's avatar Djordje

Add Notification tab

parent 75f4065f
...@@ -6,6 +6,7 @@ import { getBuilding } from "../actions/data-manager"; ...@@ -6,6 +6,7 @@ import { getBuilding } from "../actions/data-manager";
import { JWT_TENANT } from "../actions/network-manager"; import { JWT_TENANT } from "../actions/network-manager";
import { BuildingInvoices } from "./BuildingInvoices/BuildingInvoices"; import { BuildingInvoices } from "./BuildingInvoices/BuildingInvoices";
import { Issues } from "./Issues/Issues"; import { Issues } from "./Issues/Issues";
import { Notifications } from "./Notifications/Notifications";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
import { Voting } from "./Voting/Voting"; import { Voting } from "./Voting/Voting";
...@@ -42,7 +43,7 @@ export const ApplicationTab = () => { ...@@ -42,7 +43,7 @@ export const ApplicationTab = () => {
{ building && { building &&
<Routes> <Routes>
<Route path='overview' element={<div>Hello from overview</div>} /> <Route path='overview' element={<div>Hello from overview</div>} />
<Route path='notifications' element={<div>Hello from notifications</div>} /> <Route path='notifications' element={<Notifications notifications={building.notifications}/>} />
<Route path='issues' element={<Issues issues={building.issues}/>} /> <Route path='issues' element={<Issues issues={building.issues}/>} />
<Route path='voting' element={<Voting buildingId={buildingId} />} /> <Route path='voting' element={<Voting buildingId={buildingId} />} />
<Route path='invoices' element={<div>Hello from invoices</div>} /> <Route path='invoices' element={<div>Hello from invoices</div>} />
......
...@@ -6,44 +6,44 @@ import { Card } from "../Card/Card"; ...@@ -6,44 +6,44 @@ import { Card } from "../Card/Card";
import { ExpandIcon } from "../icons/ExpandIcon"; import { ExpandIcon } from "../icons/ExpandIcon";
const classes = { const classes = {
wrapper: { header: {
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'row',
gap: '50px', alignItems: 'center',
gap: '20px'
}, },
header: { expandWrapper: {
fontWeight: 600, marginLeft: 'auto',
fontSize: '1.6em', transition: 'transform .25s',
},
description: {
display: 'flex',
flexDirection: 'column',
gap: '5px'
}, },
subheader: { subheader: {
color: 'gray', color: 'gray',
fontSize: '0.9rem' fontSize: '0.9rem'
}, },
subject: { title: {
fontSize: '1.2rem' fontSize: '1.2rem'
}, },
button: {
marginLeft: 'auto',
borderRadius: '50px'
}
} as const; } as const;
export const Issue = ({ issue }: { issue: any }) => { export const Issue = ({ issue }: { issue: any }) => {
const [expand, setExpand] = useState(false); const [expand, setExpand] = useState(false);
const {t} = useTranslation(); const { t } = useTranslation();
return ( return (
<Card> <Card>
<Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: '20px' }}> <Box sx={classes.header}>
<Typography sx={classes.subject}>{issue.title}</Typography> <Typography sx={classes.title}>{issue.title}</Typography>
<Box sx={{ marginLeft: 'auto', transition: 'transform .25s', transform: `rotate(${expand ? 180 : 0}deg)`, width: '20px'}} onClick={() => { setExpand(!expand) }}> <Box sx={{ ...classes.expandWrapper, transform: `rotate(${expand ? 180 : 0}deg)`, width: '20px' }} onClick={() => { setExpand(!expand) }}>
<ExpandIcon /> <ExpandIcon />
</Box> </Box>
{/* <Typography sx={{ marginLeft: 'auto', transition: 'transform .5s', transform: `rotate(${expand ? 180 : 0}deg)` }} onClick={() => { setExpand(!expand) }}>V</Typography> */}
</Box> </Box>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '5px' }}> <Box sx={classes.description}>
<Typography sx={classes.subheader}>Opis</Typography> <Typography sx={classes.subheader}>Opis</Typography>
<Typography>{issue.description}</Typography> <Typography>{issue.description}</Typography>
</Box> </Box>
...@@ -54,7 +54,10 @@ export const Issue = ({ issue }: { issue: any }) => { ...@@ -54,7 +54,10 @@ export const Issue = ({ issue }: { issue: any }) => {
<Typography sx={classes.subheader}>Rešenja</Typography> <Typography sx={classes.subheader}>Rešenja</Typography>
{issue.solutions.map((solution: any, ind: number) => ( {issue.solutions.map((solution: any, ind: number) => (
<Box key={ind}> <Box key={ind}>
<Typography >{`${ind + 1}. ${solution.name} - ${t("priceFormat", { num: (solution.price) })}`}</Typography> <Box sx={{ display: 'flex', flexDirection: 'row' }}>
<Typography >{`${ind + 1}. ${solution.name}`}</Typography>
<Typography sx={{ marginLeft: 'auto', fontWeight: 'bold' }}>{`${t("priceFormat", { num: (solution.price) })}`}</Typography>
</Box>
<Typography sx={{ paddingLeft: '10px', fontSize: '15px' }}>{solution.description || 'Opis resenja nije unet.'}</Typography> <Typography sx={{ paddingLeft: '10px', fontSize: '15px' }}>{solution.description || 'Opis resenja nije unet.'}</Typography>
</Box> </Box>
))} ))}
......
import { Box, Typography } from "@mui/material";
import { useTranslation } from "react-i18next";
import { Card } from "../Card/Card";
const classes = {
header: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: '20px'
},
expandWrapper: {
marginLeft: 'auto',
transition: 'transform .25s',
},
description: {
display: 'flex',
flexDirection: 'column',
gap: '5px'
},
subheader: {
color: 'gray',
fontSize: '0.9rem'
},
title: {
fontSize: '1.2rem'
},
} as const;
export const Notification = ({ title, description }: { title: string, description: string }) => {
return (
<Card>
<Typography sx={classes.title}>{title}</Typography>
<Box sx={classes.description}>
<Typography sx={classes.subheader}>Opis</Typography>
<Typography>{description}</Typography>
</Box>
</Card>
);
}
\ No newline at end of file
import { TabWrapper } from "../TabWrapper/TabWrapper";
import { Notification } from "./Notification";
export const Notifications = ({ notifications }: { notifications: any }) => {
return (
<TabWrapper header="Obaveštenja">
{
notifications.map((notification: any, index: number) => (
<Notification title={notification.title} description={notification.description} />
))
}
</TabWrapper>);
}
\ No newline at end of file
...@@ -94,7 +94,7 @@ export const Voting = ({ buildingId }: { buildingId: string }): JSX.Element => { ...@@ -94,7 +94,7 @@ export const Voting = ({ buildingId }: { buildingId: string }): JSX.Element => {
<FormControl> <FormControl>
<FormLabel>Opcije</FormLabel> <FormLabel>Opcije</FormLabel>
<RadioGroup value={selectedCandidateId} onChange={(event) => { setSelectedCandidateId(event.target.value) }}> <RadioGroup value={selectedCandidateId} onChange={(event) => { setSelectedCandidateId(event.target.value) }}>
{voting.candidates.map((candidate, ind: number) => (<FormControlLabel value={candidate._id} control={<Radio />} label={candidate.name} key={ind} />))} {voting.candidates.map((candidate, ind: number) => (<FormControlLabel value={candidate._id} control={<Radio size="small"/>} label={candidate.name} key={ind} />))}
</RadioGroup> </RadioGroup>
</FormControl> </FormControl>
<Button variant='contained' sx={classes.button} disabled={selectedCandidateId === ''} onClick={handleVote}>Glasaj</Button> <Button variant='contained' sx={classes.button} disabled={selectedCandidateId === ''} onClick={handleVote}>Glasaj</Button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment