Implement modal for user name and profile picture update#2
Merged
andrejsshell merged 2 commits intomainfrom Sep 29, 2022
Merged
Implement modal for user name and profile picture update#2andrejsshell merged 2 commits intomainfrom
andrejsshell merged 2 commits intomainfrom
Conversation
andrejsshell
requested changes
Sep 12, 2022
| }, [asPath]); | ||
|
|
||
| useEffect(() => { | ||
| console.log(user); |
app/renderer/pages/index.tsx
Outdated
Comment on lines
+13
to
+35
| const [uploadedPicture, setUploadedPicture] = useState<File>(null); | ||
| const { user, showOnboardingModal, setUser } = useUser(); | ||
| const { mutateAsync, isLoading, error, isError } = useMutation( | ||
| ['/update-user'], | ||
| async (formData : FormData) => fetcher.put(`/users/${user.id}`, formData, { headers: { 'Content-Type': 'multipart/form-data' } }), | ||
| { onSuccess: (data: UserUpdatedResponse) => { | ||
| const { data: { firstName, lastName, profilePicture } } = data; | ||
| if (data.data.profilePicture){ | ||
| setUser({ ...user, firstName, lastName, profilePicture }); | ||
| } else { | ||
| setUser({ ...user, firstName, lastName }); | ||
| } | ||
| } }, | ||
| ); | ||
| const onDrop = useCallback((acceptedFile) => { | ||
| setUploadedPicture(acceptedFile[0]); | ||
| }, []); | ||
| const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, | ||
| maxFiles: 1, | ||
| accept: { | ||
| 'image/jpeg': [], | ||
| 'image/png': [], | ||
| } }); |
Owner
There was a problem hiding this comment.
Reformat this code a little so it's more readable.
Suggested change
| const [uploadedPicture, setUploadedPicture] = useState<File>(null); | |
| const { user, showOnboardingModal, setUser } = useUser(); | |
| const { mutateAsync, isLoading, error, isError } = useMutation( | |
| ['/update-user'], | |
| async (formData : FormData) => fetcher.put(`/users/${user.id}`, formData, { headers: { 'Content-Type': 'multipart/form-data' } }), | |
| { onSuccess: (data: UserUpdatedResponse) => { | |
| const { data: { firstName, lastName, profilePicture } } = data; | |
| if (data.data.profilePicture){ | |
| setUser({ ...user, firstName, lastName, profilePicture }); | |
| } else { | |
| setUser({ ...user, firstName, lastName }); | |
| } | |
| } }, | |
| ); | |
| const onDrop = useCallback((acceptedFile) => { | |
| setUploadedPicture(acceptedFile[0]); | |
| }, []); | |
| const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, | |
| maxFiles: 1, | |
| accept: { | |
| 'image/jpeg': [], | |
| 'image/png': [], | |
| } }); | |
| const [uploadedPicture, setUploadedPicture] = useState<File>(null); | |
| const { user, showOnboardingModal, setUser } = useUser(); | |
| const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, | |
| maxFiles: 1, | |
| accept: { | |
| 'image/jpeg': [], | |
| 'image/png': [], | |
| } }); | |
| const onDrop = useCallback((acceptedFile) => { | |
| setUploadedPicture(acceptedFile[0]); | |
| }, []); | |
| const { mutateAsync, isLoading, error, isError } = useMutation( | |
| ['/update-user'], | |
| async (formData : FormData) => fetcher.put(`/users/${user.id}`, formData, { headers: { 'Content-Type': 'multipart/form-data' } }), | |
| { onSuccess: (data: UserUpdatedResponse) => { | |
| const { data: { firstName, lastName, profilePicture } } = data; | |
| if (data.data.profilePicture){ | |
| setUser({ ...user, firstName, lastName, profilePicture }); | |
| } else { | |
| setUser({ ...user, firstName, lastName }); | |
| } | |
| } }, | |
| ); |
app/renderer/pages/index.tsx
Outdated
Comment on lines
+42
to
+43
| <ModalHeader>Modal Title</ModalHeader> | ||
| <ModalCloseButton /> |
Owner
There was a problem hiding this comment.
Remove the header and the close button.
andrejsshell
approved these changes
Sep 29, 2022
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement logic for issue#1