-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* MyProfile form * Paper, typography, inputs styled * Flexbox in form * Update user callback * Submit updates user in db, updateUser changed * Redirect * Redirect with Link component * Delete submission by user id * Change password * Responsive view * Add photo input (#284) * Added input button * Files are saved in state * Photos are convert into base64 and showed * Rename methods * Photos are showed in square cards * Add styles to add button * Added trash button * Added delete function * Added fromDb props and property * Show photos from db * Change delete size to small * Added cb for getting photos and deleted photos * Refactor * Added file upload example * Added api method for delete photo * Rename example extension Co-authored-by: Haivex <[email protected]> * Composite keys, updated dummy data (#293) * Composite keys, updated dummy data * Get steps for user * Update user steps * Loading animation (#301) * Added LoadingCircle component (center circle) * Add loading to Gallery * Added loading do animal info card * Added loading to info description * Added circle to animal info * Added user id to visit form * Added disabled button in login * Delete animalId * Added type number * Disabled button in login * Disable button on register * Added bigger size circle * Disabled button and circle in change password * Added loading state and redirect to link page * Added loading state to visit form * Add loading state to survey form * Added animalId prop * Removed submissions Co-authored-by: Haivex <[email protected]> * User adoption/volunteer steps (#297) * Redirect user to current step * Steps automatically adds on submission * Update adoption step on changing submission state * Update volunteer hire steps for form submission * Form for volunteer by step number * Form for volunteer by step number and adoption fix * Volunteer final step fixed * Uncomment email code (#303) Co-authored-by: Haivex <[email protected]> * Adoption sign agreement (#298) * Invitation card wwith styles * Create page with invitation * testing component, nth change * Invitation card wwith styles * Create page with invitation * testing component, nth change * syntax: remove unnecessary imports * Moved paper part to parent component * 1st invitation page * Routing * Stepper borderbox * Deleted unused import Co-authored-by: Mateusz Król <[email protected]> Co-authored-by: Mateusz Król <[email protected]> * Deleted duplicated code Co-authored-by: Haivex <[email protected]> Co-authored-by: Haivex <[email protected]> Co-authored-by: blackrabbit2 <[email protected]>
- Loading branch information
1 parent
f4bbc45
commit bd3f725
Showing
13 changed files
with
198 additions
and
52 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
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
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
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
104 changes: 104 additions & 0 deletions
104
src/presentation/web/src/components/auth/profilePage/ProfilePage.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,104 @@ | ||
import React, { useContext } from 'react'; | ||
import RegisterForm from '../../forms/registerForm/RegisterForm'; | ||
import { AppCtx } from '../../../App'; | ||
import { useDeleteUser, useGetUser, useUpdateUser } from '../../../client'; | ||
import Button from '@material-ui/core/Button'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { Theme, makeStyles } from '@material-ui/core'; | ||
import SvgIcon from '@material-ui/core/SvgIcon' | ||
import PersonOutlineRoundedIcon from '@material-ui/icons/PersonOutlineRounded'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
const useStyles = makeStyles<Theme>((theme: Theme) => ({ | ||
paper: { | ||
backgroundColor: theme.palette.background.paper, | ||
padding: '2rem 4rem', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
[theme.breakpoints.down('sm')]: { | ||
padding: '1rem 2rem' | ||
} | ||
}, | ||
text: { | ||
color: theme.palette.text.primary, | ||
marginBottom: '2rem' | ||
}, | ||
lockBackground: { | ||
backgroundColor: theme.palette.secondary.dark, | ||
borderRadius: 90, | ||
padding: 8, | ||
marginBottom: 10 | ||
}, | ||
lockIcon: { | ||
color: '#FFF', | ||
opacity: .87, | ||
}, | ||
button: { | ||
marginBottom: '2rem', | ||
minWidth: 300, | ||
[theme.breakpoints.down('sm')]: { | ||
width: '70%', | ||
minWidth: 170 | ||
} | ||
} | ||
})) | ||
|
||
const ProfilePage = () => { | ||
const apiKey = { requestOptions: { headers: { access_token: localStorage.getItem('apiKey') ?? '' } } }; | ||
const classes = useStyles(); | ||
const { appState, setAppState } = useContext(AppCtx); | ||
const { data: userData, loading } = useGetUser({ userId: appState.userId!, ...apiKey}); | ||
const { mutate: updateUser } = useUpdateUser({ userId: appState.userId!, ...apiKey}); | ||
const { mutate: deleteUser } = useDeleteUser({ ...apiKey }) | ||
|
||
const handleSubmit = async (data: any) => { | ||
try { | ||
await updateUser(data); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
const handleDeleteAccountButton = async () => { | ||
try { | ||
console.log('Nie działa') | ||
// await deleteUser(appState.userId!); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
if (!loading && userData && userData.birthDate) { | ||
const [year, month, date] = userData.birthDate.split('-').map((value) => parseInt(value)) | ||
return ( | ||
<Paper className={classes.paper}> | ||
<SvgIcon className={classes.lockBackground}> | ||
<PersonOutlineRoundedIcon className={classes.lockIcon} /> | ||
</SvgIcon> | ||
<Typography className={classes.text} variant="h4">Mój profil</Typography> | ||
<RegisterForm handleSubmit={handleSubmit} defaultValues={{ | ||
name: userData.name, | ||
surname: userData.surname, | ||
mail: userData.mail, | ||
phone: userData.phone, | ||
birthDate: new Date(year, month, date) | ||
}} hiddenPassword={true}> | ||
<Button component={Link} to="/auth/change" className={classes.button} size="large" variant="outlined" color="primary"> | ||
Zmień hasło | ||
</Button> | ||
<Button className={classes.button} size="large" variant="outlined" color="primary" onClick={handleDeleteAccountButton}> | ||
Usuń konto | ||
</Button> | ||
<Button className={classes.button} size="large" variant="contained" color="primary" type="submit"> | ||
Zapisz zmiany | ||
</Button> | ||
</RegisterForm> | ||
</Paper> | ||
) | ||
} | ||
return <div>loading</div> | ||
} | ||
|
||
export default ProfilePage |
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
Oops, something went wrong.