-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [#75] Settings View - components for tabs in profile view and settings * [#75] settings view - adjustments for bigger screens * [#75] settings view - apply changes requested in code review * [#75] settings view - eslint-related corrections
- Loading branch information
1 parent
081e6d5
commit 2f3bc20
Showing
9 changed files
with
270 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
client/src/components/ProfileComponent/CheckboxDaysRevision.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState, ReactElement } from 'react'; | ||
import FormGroup from '@material-ui/core/FormGroup'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import { Checkbox, Typography } from '@material-ui/core'; | ||
|
||
const CheckboxLabels = (): ReactElement => { | ||
const [state, setState] = useState([ | ||
{ label: 'poniedziałki', name: 'mon', checked: false }, | ||
{ label: 'wtorki', name: 'tue', checked: false }, | ||
{ label: 'środy', name: 'wed', checked: false }, | ||
{ label: 'czwartki', name: 'thu', checked: false }, | ||
{ label: 'piątki', name: 'fri', checked: false }, | ||
{ label: 'soboty', name: 'sat', checked: false }, | ||
{ label: 'niedziele', name: 'sun', checked: false } | ||
]); | ||
|
||
const handleChange = (event: { target: { name: string; checked: boolean } }) => { | ||
setState( | ||
state.map((item) => { | ||
return item.name === event.target.name ? { ...item, checked: !item.checked } : item; | ||
}) | ||
); | ||
}; | ||
|
||
return ( | ||
<FormGroup row> | ||
{state.map((item, index) => ( | ||
<FormControlLabel | ||
key={index} | ||
control={ | ||
<Checkbox checked={item.checked} onChange={handleChange} name={item.name} color="secondary" /> | ||
} | ||
label={ | ||
<Typography variant="subtitle1" color="textSecondary"> | ||
{item.label} | ||
</Typography> | ||
} | ||
/> | ||
))} | ||
</FormGroup> | ||
); | ||
}; | ||
export default CheckboxLabels; |
64 changes: 64 additions & 0 deletions
64
client/src/components/ProfileComponent/ProfileInputFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { ReactElement } from 'react'; | ||
import { Paper, TextField, IconButton, Box } from '@material-ui/core'; | ||
import { useState } from 'react'; | ||
import DoneOutlineIcon from '@material-ui/icons/DoneOutline'; | ||
|
||
const ProfileInputFields = (): ReactElement => { | ||
const [username, setUsername] = useState(''); | ||
const [email, setEmail] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
|
||
const updateUsername = (e: React.SyntheticEvent<EventTarget>) => { | ||
setUsername((e.target as HTMLInputElement).value); | ||
}; | ||
const updateEmail = (e: React.SyntheticEvent<EventTarget>) => { | ||
setEmail((e.target as HTMLInputElement).value); | ||
}; | ||
const updatePassword = (e: React.SyntheticEvent<EventTarget>) => { | ||
setPassword((e.target as HTMLInputElement).value); | ||
}; | ||
return ( | ||
<Paper> | ||
<Box m={2} p={1}> | ||
<form> | ||
<TextField | ||
onChange={updateUsername} | ||
autoFocus | ||
label="Nickname" | ||
value={username || ''} | ||
variant="standard" | ||
size="small" | ||
/> | ||
<IconButton edge="end" aria-label="zapisz" color="primary"> | ||
<DoneOutlineIcon /> | ||
</IconButton> | ||
</form> | ||
<form> | ||
<TextField | ||
label="Email" | ||
value={email || ''} | ||
variant="standard" | ||
size="small" | ||
onChange={updateEmail} | ||
/> | ||
<IconButton edge="end" aria-label="zapisz" color="primary"> | ||
<DoneOutlineIcon /> | ||
</IconButton> | ||
</form> | ||
<form> | ||
<TextField | ||
label="Hasło" | ||
value={password || ''} | ||
variant="standard" | ||
size="small" | ||
onChange={updatePassword} | ||
/> | ||
<IconButton edge="end" aria-label="zapisz" color="primary"> | ||
<DoneOutlineIcon /> | ||
</IconButton> | ||
</form> | ||
</Box> | ||
</Paper> | ||
); | ||
}; | ||
export default ProfileInputFields; |
71 changes: 71 additions & 0 deletions
71
client/src/components/ProfileComponent/SettingsComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { ReactElement } from 'react'; | ||
import { Grid, Typography, Button, Box, Switch, FormControlLabel } from '@material-ui/core'; | ||
import { useState } from 'react'; | ||
import DoneOutlineIcon from '@material-ui/icons/DoneOutline'; | ||
import CheckboxLabels from './CheckboxDaysRevision'; | ||
import ProfileInputFields from './ProfileInputFields'; | ||
|
||
const SettingsComponent = (): ReactElement => { | ||
const [notification, setNotifications] = useState({ | ||
checkedA: true, | ||
checkedB: true | ||
}); | ||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setNotifications({ ...notification, [event.target.name]: event.target.checked }); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Grid container direction="column" justify="center" alignItems="center" alignContent="center" spacing={4}> | ||
<Grid item xs={12}> | ||
<ProfileInputFields /> | ||
</Grid> | ||
<Grid container justify="center" alignItems="center" spacing={2}> | ||
<Grid item xs={11} sm={4}> | ||
<Typography variant="body1" align="center" color="textPrimary"> | ||
Harmonogram powtórek | ||
</Typography> | ||
<Box textAlign="center" mb={4} mt={2}> | ||
<CheckboxLabels /> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
size="medium" | ||
type="submit" | ||
startIcon={<DoneOutlineIcon />} | ||
> | ||
Zapisz | ||
</Button> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
<Grid container direction="row" justify="center" alignItems="center" spacing={2}> | ||
<Grid item xs={9} sm={3}> | ||
<Typography variant="body1" color="textPrimary" align="left"> | ||
Powiadomienia e-mail | ||
</Typography> | ||
</Grid> | ||
<Grid item xs={3} sm={1}> | ||
<FormControlLabel | ||
value="bottom" | ||
control={ | ||
<Switch | ||
checked={notification.checkedB} | ||
onChange={handleChange} | ||
name="checkedB" | ||
color="secondary" | ||
edge="end" | ||
aria-label="Włącz" | ||
size="small" | ||
/> | ||
} | ||
label="Włącz" | ||
labelPlacement="bottom" | ||
/> | ||
</Grid> | ||
</Grid> | ||
</> | ||
); | ||
}; | ||
export default SettingsComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { ReactElement } from 'react'; | ||
import { Box, Grid } from '@material-ui/core'; | ||
|
||
interface TabPanelProps { | ||
children?: React.ReactNode; | ||
dir?: string; | ||
index: number; | ||
value: number; | ||
} | ||
|
||
const TabPanel = ({ children, value, index, ...other }: TabPanelProps): ReactElement => { | ||
return ( | ||
<Grid | ||
item | ||
role="tabpanel" | ||
hidden={value !== index} | ||
id={`full-width-tabpanel-${index}`} | ||
aria-labelledby={`full-width-tab-${index}`} | ||
{...other} | ||
> | ||
{value === index && <Box p={3}>{children}</Box>} | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default TabPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { ReactElement, useState } from 'react'; | ||
import TabPanel from '../components/Tabs/TabPanel'; | ||
import { Tabs, Tab } from '@material-ui/core'; | ||
import SettingsIcon from '@material-ui/icons/Settings'; | ||
import LocalLibraryIcon from '@material-ui/icons/LocalLibrary'; | ||
import SettingsComponent from '../components/ProfileComponent/SettingsComponent'; | ||
|
||
const ProfileComponent = (): ReactElement => { | ||
const [value, setValue] = useState(0); | ||
const handleChange = (event: React.SyntheticEvent<EventTarget>, value: number) => { | ||
setValue(value); | ||
}; | ||
return ( | ||
<> | ||
( | ||
<Tabs | ||
value={value} | ||
onChange={handleChange} | ||
variant="fullWidth" | ||
indicatorColor="secondary" | ||
textColor="secondary" | ||
> | ||
<Tab icon={<LocalLibraryIcon />} label={'Statystyki'} value={0} /> | ||
<Tab icon={<SettingsIcon />} label={'Ustawienia'} value={1} /> | ||
</Tabs> | ||
<TabPanel value={value} index={0}> | ||
Treść dla statystyk | ||
</TabPanel> | ||
<TabPanel value={value} index={1}> | ||
<SettingsComponent /> | ||
</TabPanel> | ||
) | ||
</> | ||
); | ||
}; | ||
export default ProfileComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": [ | ||
"@emotion/react" | ||
], | ||
"target": "es5", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@emotion/react" | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
"compilerOptions": { | ||
"types": ["@emotion/react"], | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "es6"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@emotion/react" | ||
}, | ||
"include": ["src"] | ||
} |