issue-179 refetch after image upload to update data. #186

Merged
Irev-Dev merged 1 commits from kurt/179 into main 2020-12-29 09:47:14 +01:00
2 changed files with 10 additions and 8 deletions

View File

@@ -32,7 +32,7 @@ export const Empty = () => <div>Empty</div>
export const Failure = ({ error }) => <div>Error: {error.message}</div>
export const Success = ({ user, variables: { isEditable } }) => {
export const Success = ({ user, refetch, variables: { isEditable } }) => {
const { addMessage } = useFlash()
const [updateUser, { loading, error }] = useMutation(UPDATE_USER_MUTATION, {
onCompleted: ({ updateUserByUserName }) => {
@@ -41,8 +41,9 @@ export const Success = ({ user, variables: { isEditable } }) => {
},
})
const onSave = (userName, input) => {
updateUser({ variables: { userName, input } })
const onSave = async (userName, input) => {
await updateUser({ variables: { userName, input } })
refetch()
}
return (

View File

@@ -106,7 +106,7 @@ export const Failure = ({ error }) => <div>Error: {error.message}</div>
export const Success = ({ userPart, variables: { isEditable }, refetch }) => {
const { currentUser } = useAuth()
const { addMessage } = useFlash()
const [updateUser, { loading, error }] = useMutation(UPDATE_PART_MUTATION, {
const [updatePart, { loading, error }] = useMutation(UPDATE_PART_MUTATION, {
onCompleted: ({ updatePart }) => {
navigate(
routes.part({
@@ -128,12 +128,13 @@ export const Success = ({ userPart, variables: { isEditable }, refetch }) => {
addMessage('Part Created.', { classes: 'rw-flash-success' })
},
})
const onSave = (id, input) => {
const onSave = async (id, input) => {
if (!id) {
createPart({ variables: { input } })
return
await createPart({ variables: { input } })
} else {
await updatePart({ variables: { id, input } })
}
updateUser({ variables: { id, input } })
refetch()
}
const [deletePart] = useMutation(DELETE_PART_MUTATION, {
onCompleted: ({ deletePart }) => {