issue-179 refetch after image upload to update data. #186
@@ -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 (
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user