ImageUploader Userform #56

Merged
Yash-R merged 3 commits from main into main 2020-10-30 09:12:30 +01:00
4 changed files with 29 additions and 9 deletions
Showing only changes of commit d868b507ba - Show all commits

View File

@@ -15,14 +15,14 @@ export const schema = gql`
input CreateUserInput {
email: String!
issuer: String!
# issuer: String!
image: String
Irev-Dev commented 2020-10-30 08:52:54 +01:00 (Migrated from github.com)
Review

What was happening here, was this causing problems?

What was happening here, was this causing problems?
Yash-R commented 2020-10-30 09:00:21 +01:00 (Migrated from github.com)
Review

Yes, The error was Field "issuer" of required type "String!" was not provided.
The Schema you have created does not use this field.

Yes, The error was Field "issuer" of required type "String!" was not provided. The Schema you have created does not use this field.
bio: String
}
input UpdateUserInput {
email: String
issuer: String
# issuer: String
image: String
bio: String
}

View File

@@ -117,3 +117,4 @@ function getCroppedImg(image, crop, fileName) {
}, 'image/jpeg', 1);
});
}

View File

@@ -1,6 +1,6 @@
import { useMutation, useFlash } from '@redwoodjs/web'
import { Link, routes, navigate } from '@redwoodjs/router'
import { Image as CloudinaryImage } from 'cloudinary-react'
const DELETE_USER_MUTATION = gql`
mutation DeleteUserMutation($id: Int!) {
deleteUser(id: $id) {
@@ -72,7 +72,13 @@ const User = ({ user }) => {
</tr>
<tr>
<th>Image</th>
<td>{user.image}</td>
<td><CloudinaryImage
className="object-cover w-full rounded shadow"
cloudName="irevdev"
publicId={user.image}
width="300"
crop="scale"
/></td>
</tr>
<tr>
<th>Bio</th>

View File

@@ -6,10 +6,21 @@ import {
TextField,
Submit,
} from '@redwoodjs/forms'
import { useState } from 'react';
import { navigate, routes } from '@redwoodjs/router'
import { useFlash } from '@redwoodjs/web'
import ImageUploader from '../PartForm/ImageUploader'
const UserForm = (props) => {
const onSubmit = (data) => {
props.onSave(data, props?.user?.id)
const { addMessage } = useFlash()
// const [bio, setBio] = useState(props?.user?.bio)
const [imageUrl, setImageUrl] = useState(props?.user?.image)
const onSubmit = async (data, e) => {
await props.onSave({
...data,
image: imageUrl
}, props?.user?.id)
addMessage('User updated.', { classes: 'rw-flash-success' })
}
return (
@@ -38,7 +49,7 @@ const UserForm = (props) => {
/>
<FieldError name="email" className="rw-field-error" />
<Label
{/* <Label
name="image"
className="rw-label"
errorClassName="rw-label rw-label-error"
@@ -51,7 +62,8 @@ const UserForm = (props) => {
className="rw-input"
errorClassName="rw-input rw-input-error"
/>
<FieldError name="image" className="rw-field-error" />
<FieldError name="image" className="rw-field-error" /> */}
<ImageUploader onImageUpload={({cloudinaryPublicId}) => setImageUrl(cloudinaryPublicId)} />
<Label
name="bio"
@@ -65,6 +77,7 @@ const UserForm = (props) => {
defaultValue={props.user?.bio}
className="rw-input"
errorClassName="rw-input rw-input-error"
validation={{ required: true }}
/>
<FieldError name="bio" className="rw-field-error" />