Wipe slate clean

This commit is contained in:
Kurt Hutten
2020-11-01 18:05:19 +11:00
parent e11593a794
commit 55f9dfd6de
74 changed files with 2 additions and 2169 deletions

View File

@@ -1,50 +0,0 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import UserForm from 'src/components/UserForm'
export const QUERY = gql`
query FIND_USER_BY_ID($id: Int!) {
user: user(id: $id) {
id
email
createdAt
updatedAt
image
bio
}
}
`
const UPDATE_USER_MUTATION = gql`
mutation UpdateUserMutation($id: Int!, $input: UpdateUserInput!) {
updateUser(id: $id, input: $input) {
id
}
}
`
export const Loading = () => <div>Loading...</div>
export const Success = ({ user }) => {
const { addMessage } = useFlash()
const [updateUser, { loading, error }] = useMutation(UPDATE_USER_MUTATION, {
onCompleted: () => {
navigate(routes.users())
addMessage('User updated.', { classes: 'rw-flash-success' })
},
})
const onSave = (input, id) => {
updateUser({ variables: { id, input } })
}
return (
<div className="rw-segment">
<header className="rw-segment-header">
<h2 className="rw-heading rw-heading-secondary">Edit User {user.id}</h2>
</header>
<div className="rw-segment-main">
<UserForm user={user} onSave={onSave} error={error} loading={loading} />
</div>
</div>
)
}