Skip to content

Commit 9b4fbb3

Browse files
committed
Merge branch 'develop'
2 parents 7808051 + bb9290e commit 9b4fbb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3127
-1455
lines changed

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
"axios": "^0.19.2",
1616
"date-fns": "^2.10.0",
1717
"react": "^16.13.0",
18+
"react-code-input": "^3.9.0",
1819
"react-dom": "^16.13.0",
1920
"react-hook-form": "^5.0.3",
2021
"react-mobile-picker-scroll": "^0.2.14",
2122
"react-router-dom": "^5.1.2",
22-
"react-scripts": "3.4.0"
23+
"react-scripts": "3.4.0",
24+
"uniqid": "^5.2.0"
2325
},
2426
"scripts": {
2527
"precommit": "NODE_ENV=production lint-staged",
Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
11
import React from 'react';
22
import { withStyles } from '@material-ui/styles';
33
import MuiButton from '@material-ui/core/Button';
4+
import Box from '@material-ui/core/Box';
45

5-
const Button = withStyles(() => ({
6+
const ButtonSuccess = withStyles(() => ({
67
contained: {
7-
backgroundColor: '#007E3A',
8+
minWidth: '100%',
9+
backgroundColor: '#397F3A',
10+
textTransform: 'none',
811
color: '#fff'
912
}
1013
}))(MuiButton);
1114

12-
export default ({ children, ...rest }) => (
13-
// eslint-disable-next-line react/jsx-props-no-spreading
14-
<Button variant="contained" {...rest}>
15-
{children}
16-
</Button>
15+
const ButtonSecondary = withStyles(theme => ({
16+
contained: {
17+
minWidth: '100%',
18+
backgroundColor: theme.palette.secondary,
19+
color: '#000'
20+
},
21+
root: {
22+
minWidth: '100%',
23+
textTransform: 'none',
24+
}
25+
}))(MuiButton);
26+
27+
const ButtonPrimmary = withStyles(() => ({
28+
contained: {
29+
minWidth: '100%',
30+
textTransform: 'none',
31+
backgroundColor: '#fff',
32+
color: '#000'
33+
}
34+
}))(MuiButton);
35+
36+
export default ({ children, color, width, ...rest }) => (
37+
<Box width={width}>
38+
{
39+
{
40+
// eslint-disable-next-line react/jsx-props-no-spreading
41+
success: <ButtonSuccess {...rest}>{children}</ButtonSuccess>,
42+
secondary: <ButtonSecondary {...rest}>{children}</ButtonSecondary>,
43+
primmary: <ButtonPrimmary {...rest}>{children}</ButtonPrimmary>
44+
}[color]
45+
}
46+
</Box>
1747
);

frontend/src/common/Components/DatePicker/index.js

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import DateFnsUtils from '@date-io/date-fns';
33
import { DatePicker, MuiPickersUtilsProvider } from '@material-ui/pickers';
4-
import { TextField, Input } from '@material-ui/core';
5-
import ErrorMsg from '../ErrorMsg/';
4+
import Input from '../Input/Input';
65

76
export default ({
8-
label = 'Date symptomps first apeared',
9-
placeholder = 'Date symptomps first apeared',
10-
required = true,
7+
label,
8+
placeholder,
9+
required,
1110
register,
1211
errors,
12+
setValue,
13+
unregister,
1314
name
1415
}) => {
15-
const [selectedDate, handleDateChange] = useState(null);
16+
const [selectedDate, setSelectedDate] = useState(null);
1617
const [open, setOpen] = useState(false);
1718
const handleOpen = event => {
1819
event.preventDefault();
1920
setOpen(true);
2021
};
22+
useEffect(() => {
23+
register({ name }, { required });
24+
return () => unregister(name); // unregister input after component unmount
25+
}, [register]);
2126

22-
const renderInput = props => (
23-
<>
24-
<TextField
25-
name={name}
26-
label={label}
27-
placeholder={placeholder}
28-
value={props.value}
29-
inputRef={register({ required })}
30-
onClick={event => handleOpen(event)}
31-
onTouchEnd={event => handleOpen(event)}
32-
onKeyUp={() => handleOpen()}
33-
variant="outlined"
34-
style={{ width: '100%' }}
35-
autoComplete="off"
36-
InputProps={{
37-
readOnly: true
38-
}}
39-
/>
40-
<ErrorMsg>
41-
{errors && errors.date_of_onset && 'This field is required'}
42-
</ErrorMsg>
43-
</>
27+
const handleDateChange = date => {
28+
setSelectedDate(date);
29+
setValue(name, date);
30+
};
31+
const renderInput = ({ value }) => (
32+
<Input
33+
name={name}
34+
label={label}
35+
placeholder={placeholder}
36+
value={value}
37+
onClick={event => handleOpen(event)}
38+
onTouchEnd={event => handleOpen(event)}
39+
onKeyUp={() => handleOpen()}
40+
variant="outlined"
41+
autoComplete="off"
42+
readOnly
43+
errors={errors}
44+
/>
4445
);
4546

4647
return (

frontend/src/common/Components/Dialog/index.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { withStyles } from '@material-ui/core/styles';
33
import MuiDialogTitle from '@material-ui/core/DialogTitle';
44
import MuiDialogContent from '@material-ui/core/DialogContent';
5-
import { Dialog, Box, Slide, Typography } from '@material-ui/core';
5+
import { Dialog, Slide, Grid, Typography } from '@material-ui/core';
66
import IconButton from '@material-ui/core/IconButton';
77
import CloseIcon from '@material-ui/icons/Close';
88

@@ -24,23 +24,44 @@ const styles = theme => ({
2424
}
2525
});
2626

27-
const Transition = React.forwardRef(function Transition(props, ref) {
27+
export const Transition = React.forwardRef(function Transition(props, ref) {
2828
// eslint-disable-next-line react/jsx-props-no-spreading
2929
return <Slide direction="up" ref={ref} {...props} />;
3030
});
3131

3232
const DialogTitle = withStyles(styles)(props => {
33-
const { children, classes, onClose, ...other } = props;
33+
const { title, classes, onClose, align, handleClose, handleSave, ...other } = props;
3434
return (
3535
<MuiDialogTitle
3636
disableTypography
3737
className={classes.root}
3838
// eslint-disable-next-line react/jsx-props-no-spreading
3939
{...other}
4040
>
41-
<Box mr={2} ml={2}>
42-
<Typography variant="h5">{children}</Typography>
43-
</Box>
41+
<Grid
42+
container
43+
direction='row'
44+
alignItems='center'
45+
alignContent='center'
46+
spacing={2}
47+
48+
>
49+
<Grid item>
50+
{handleClose && (
51+
<IconButton
52+
edge="start"
53+
color="inherit"
54+
onClick={handleClose}
55+
aria-label="close"
56+
>
57+
<CloseIcon />
58+
</IconButton>)}
59+
</Grid>
60+
<Grid item>
61+
<Typography align="center" variant="h5">{title}</Typography>
62+
</Grid>
63+
</Grid>
64+
4465
</MuiDialogTitle>
4566
);
4667
});
@@ -52,29 +73,17 @@ const DialogContent = withStyles(theme => ({
5273
}
5374
}))(MuiDialogContent);
5475

55-
export default ({ title, children, open, openAction, handleClose }) => {
76+
export default ({ title, children, open, openAction, fullScreen, handleClose, alignTitle }) => {
5677
return (
5778
<>
5879
{openAction}
5980
<Dialog
60-
fullScreen
81+
fullScreen={fullScreen}
6182
open={open}
6283
onClose={handleClose}
6384
TransitionComponent={Transition}
6485
>
65-
<DialogTitle onClose={() => handleClose()}>
66-
{handleClose && (
67-
<IconButton
68-
edge="start"
69-
color="inherit"
70-
onClick={handleClose}
71-
aria-label="close"
72-
>
73-
<CloseIcon />
74-
</IconButton>
75-
)}
76-
{title}
77-
</DialogTitle>
86+
{title && <DialogTitle title={title} onClose={() => handleClose()} handleClose={handleClose} align={alignTitle} />}
7887
<DialogContent>{children}</DialogContent>
7988
</Dialog>
8089
</>
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import React from 'react';
22
import { Box } from '@material-ui/core';
3+
import { ErrorMessage } from 'react-hook-form';
4+
import { makeStyles } from '@material-ui/core/styles';
35

4-
export default ({ children }) => (
5-
<Box m={1}>
6-
<span style={{ color: 'red' }}>{children}</span>
7-
</Box>
8-
);
6+
const useStyles = makeStyles({
7+
root: {
8+
color: '#bf1650'
9+
}
10+
});
11+
12+
export default ({ name, errors }) => {
13+
const classes = useStyles();
14+
15+
return (
16+
<Box m={1}>
17+
<ErrorMessage name={name} errors={errors}>
18+
{({ message }) => <p className={classes.root}>{message}</p>}
19+
</ErrorMessage>{' '}
20+
</Box>
21+
);
22+
};

frontend/src/common/Components/IdentityCard/index.js

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
import React from 'react';
2+
import { withStyles } from '@material-ui/core/styles';
23
import { Box, TextField } from '@material-ui/core';
4+
import ErrorMessage from '../ErrorMsg';
5+
import useWindowDimensions from '../../../core/hooks/useWindowDimensions';
36

4-
export default ({ label, name, endAdornment, ...props }) => {
7+
const styles = {
8+
input: {
9+
minWidth: '100%',
10+
backgroundColor: 'transparent'
11+
}
12+
};
13+
14+
const CustomizedInputs = ({
15+
classes,
16+
inputRef,
17+
label,
18+
name,
19+
errors,
20+
endAdornment,
21+
readOnly,
22+
...props
23+
}) => {
24+
const { width } = useWindowDimensions();
525
return (
6-
<Box m={1}>
26+
<Box p={1} width={width - 32}>
727
<TextField
828
label={label}
929
readOnly
10-
variant="outlined"
1130
style={{ width: '100%' }}
1231
autoComplete="off"
1332
name={name}
33+
inputRef={inputRef}
1434
InputProps={{
1535
// eslint-disable-next-line react/destructuring-assignment
1636
...props.InputProps,
17-
endAdornment: endAdornment
37+
readOnly,
38+
className: classes.input,
39+
endAdornment
1840
}}
1941
{...props}
2042
/>
43+
<ErrorMessage name={name} errors={errors} />
2144
</Box>
2245
);
2346
};
47+
export default withStyles(styles)(CustomizedInputs);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React, { useEffect } from 'react';
2+
import MenuItem from '@material-ui/core/MenuItem';
3+
import uniqid from 'uniqid';
4+
import Input from './Input';
5+
6+
export default ({
7+
options,
8+
label,
9+
name,
10+
required,
11+
register,
12+
unregister,
13+
setValue,
14+
errors
15+
}) => {
16+
const [gender, setGender] = React.useState('');
17+
18+
const handleChange = event => {
19+
setGender(event.target.value);
20+
setValue(name, event.target.value);
21+
};
22+
useEffect(() => {
23+
register({ name }, { required });
24+
return () => unregister(name); // unregister input after component unmount
25+
}, [register]);
26+
27+
return (
28+
<Input
29+
errors={errors}
30+
variant="outlined"
31+
id="select"
32+
onChange={handleChange}
33+
label={label}
34+
value={gender}
35+
name={name}
36+
select
37+
>
38+
{options &&
39+
options.map(item => (
40+
<MenuItem key={uniqid()} value={item.value}>
41+
{item.name}
42+
</MenuItem>
43+
))}
44+
</Input>
45+
);
46+
};

0 commit comments

Comments
 (0)