|
|
@ -1,9 +1,16 @@ |
|
|
|
import { useState } from 'react'; |
|
|
|
import { Assignment as AssignmentIcon } from '@mui/icons-material'; |
|
|
|
import { styled } from '@mui/material/styles'; |
|
|
|
import { AppBar, Box, Button, IconButton, styled } from '@mui/material'; |
|
|
|
import { AppBar, Box, Button } from '@mui/material'; |
|
|
|
import { useRef, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { BORDER_RADIUS, OLD_ICON, RED } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
import { ICONS, ICON_SIZE } from '../lib/consts/ICONS'; |
|
|
|
import { ICONS, ICON_SIZE } from '../lib/consts/ICONS'; |
|
|
|
import { BORDER_RADIUS, RED } from '../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
import AnvilDrawer from './AnvilDrawer'; |
|
|
|
import AnvilDrawer from './AnvilDrawer'; |
|
|
|
|
|
|
|
import FlexBox from './FlexBox'; |
|
|
|
|
|
|
|
import IconWithIndicator, { |
|
|
|
|
|
|
|
IconWithIndicatorForwardedRefContent, |
|
|
|
|
|
|
|
} from './IconWithIndicator'; |
|
|
|
|
|
|
|
import JobSummary, { JobSummaryForwardedRefContent } from './JobSummary'; |
|
|
|
|
|
|
|
|
|
|
|
const PREFIX = 'Header'; |
|
|
|
const PREFIX = 'Header'; |
|
|
|
|
|
|
|
|
|
|
@ -55,43 +62,65 @@ const StyledAppBar = styled(AppBar)(({ theme }) => ({ |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
const Header = (): JSX.Element => { |
|
|
|
const Header = (): JSX.Element => { |
|
|
|
|
|
|
|
const jobIconRef = useRef<IconWithIndicatorForwardedRefContent>({}); |
|
|
|
|
|
|
|
const jobSummaryRef = useRef<JobSummaryForwardedRefContent>({}); |
|
|
|
|
|
|
|
|
|
|
|
const [open, setOpen] = useState(false); |
|
|
|
const [open, setOpen] = useState(false); |
|
|
|
|
|
|
|
|
|
|
|
const toggleDrawer = (): void => setOpen(!open); |
|
|
|
const toggleDrawer = (): void => setOpen(!open); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<StyledAppBar> |
|
|
|
<> |
|
|
|
<Box display="flex" justifyContent="space-between" flexDirection="row"> |
|
|
|
<StyledAppBar> |
|
|
|
<Box className={classes.barElement}> |
|
|
|
<Box display="flex" justifyContent="space-between" flexDirection="row"> |
|
|
|
<Button onClick={toggleDrawer}> |
|
|
|
<FlexBox row> |
|
|
|
<img alt="" src="/pngs/logo.png" width="160" height="40" /> |
|
|
|
<Button onClick={toggleDrawer}> |
|
|
|
</Button> |
|
|
|
<img alt="" src="/pngs/logo.png" width="160" height="40" /> |
|
|
|
</Box> |
|
|
|
</Button> |
|
|
|
<Box className={`${classes.barElement} ${classes.iconBox}`}> |
|
|
|
</FlexBox> |
|
|
|
{ICONS.map( |
|
|
|
<FlexBox className={classes.iconBox} row spacing={0}> |
|
|
|
(icon): JSX.Element => ( |
|
|
|
<Box> |
|
|
|
<a |
|
|
|
<IconButton |
|
|
|
key={icon.uri} |
|
|
|
onClick={({ currentTarget }) => { |
|
|
|
href={ |
|
|
|
jobSummaryRef.current.setAnchor?.call(null, currentTarget); |
|
|
|
icon.uri.search(/^https?:/) !== -1 |
|
|
|
jobSummaryRef.current.setOpen?.call(null, true); |
|
|
|
? icon.uri |
|
|
|
}} |
|
|
|
: `${process.env.NEXT_PUBLIC_API_URL}${icon.uri}` |
|
|
|
sx={{ color: OLD_ICON, padding: '0 .1rem' }} |
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<img |
|
|
|
<IconWithIndicator icon={AssignmentIcon} ref={jobIconRef} /> |
|
|
|
alt="" |
|
|
|
</IconButton> |
|
|
|
key="icon" |
|
|
|
</Box> |
|
|
|
src={icon.image} |
|
|
|
{ICONS.map( |
|
|
|
{...ICON_SIZE} |
|
|
|
(icon): JSX.Element => ( |
|
|
|
className={classes.icons} |
|
|
|
<a |
|
|
|
/> |
|
|
|
key={icon.uri} |
|
|
|
</a> |
|
|
|
href={ |
|
|
|
), |
|
|
|
icon.uri.search(/^https?:/) !== -1 |
|
|
|
)} |
|
|
|
? icon.uri |
|
|
|
|
|
|
|
: `${process.env.NEXT_PUBLIC_API_URL}${icon.uri}` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<img |
|
|
|
|
|
|
|
alt="" |
|
|
|
|
|
|
|
key="icon" |
|
|
|
|
|
|
|
src={icon.image} |
|
|
|
|
|
|
|
{...ICON_SIZE} |
|
|
|
|
|
|
|
className={classes.icons} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
</FlexBox> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</StyledAppBar> |
|
|
|
<AnvilDrawer open={open} setOpen={setOpen} /> |
|
|
|
<AnvilDrawer open={open} setOpen={setOpen} /> |
|
|
|
</StyledAppBar> |
|
|
|
<JobSummary |
|
|
|
|
|
|
|
onFetchSuccessAppend={(jobs) => { |
|
|
|
|
|
|
|
jobIconRef.current.indicate?.call(null, Object.keys(jobs).length > 0); |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
ref={jobSummaryRef} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|