diff --git a/web/src/Routes.js b/web/src/Routes.js index 0efdf9b..437b3e4 100644 --- a/web/src/Routes.js +++ b/web/src/Routes.js @@ -12,7 +12,7 @@ import { Router, Route, Private } from '@redwoodjs/router' const Routes = () => { return ( - + {/* */} @@ -35,7 +35,6 @@ const Routes = () => { - diff --git a/web/src/components/ImageUploader/ImageUploader.js b/web/src/components/ImageUploader/ImageUploader.js index b110b49..ca93f5e 100644 --- a/web/src/components/ImageUploader/ImageUploader.js +++ b/web/src/components/ImageUploader/ImageUploader.js @@ -65,7 +65,7 @@ export default function ImageUploader({ {isEditable && } {(cloudinaryId || !isEditable) &&
{ className="rounded-half rounded-br-lg shadow-md border-2 border-gray-200 border-solid" onImageUpload={() => {}} aspectRatio={1} - imageUrl={userPart.image === 'abc' ? '': userPart.image} + imageUrl={userPart.image} width={300} />

{userPart?.name}

diff --git a/web/src/components/Parts/Parts.js b/web/src/components/Parts/Parts.js index 9e25f6f..1b8af53 100644 --- a/web/src/components/Parts/Parts.js +++ b/web/src/components/Parts/Parts.js @@ -1,112 +1,39 @@ import { useMutation, useFlash } from '@redwoodjs/web' import { Link, routes } from '@redwoodjs/router' -const DELETE_PART_MUTATION = gql` - mutation DeletePartMutation($id: String!) { - deletePart(id: $id) { - id - } - } -` - -const MAX_STRING_LENGTH = 150 - -const truncate = (text) => { - let output = text - if (text && text.length > MAX_STRING_LENGTH) { - output = output.substring(0, MAX_STRING_LENGTH) + '...' - } - return output -} - -const jsonTruncate = (obj) => { - return truncate(JSON.stringify(obj, null, 2)) -} - -const timeTag = (datetime) => { - return ( - - ) -} - -const checkboxInputTag = (checked) => { - return -} - +import ImageUploader from 'src/components/ImageUploader' const PartsList = ({ parts }) => { - const { addMessage } = useFlash() - const [deletePart] = useMutation(DELETE_PART_MUTATION, { - onCompleted: () => { - addMessage('Part deleted.', { classes: 'rw-flash-success' }) - }, - }) - - const onDeleteClick = (id) => { - if (confirm('Are you sure you want to delete part ' + id + '?')) { - deletePart({ variables: { id }, refetchQueries: ['PARTS'] }) - } - } - return ( -
- - - - - - - - - - - - - - - - {parts.map((part) => ( - - - - - - - - - - - - ))} - -
IdTitleDescriptionCodeMain imageCreated atUpdated atUser id 
{truncate(part.id)}{truncate(part.title)}{truncate(part.description)}{truncate(part.code)}{truncate(part.mainImage)}{timeTag(part.createdAt)}{timeTag(part.updatedAt)}{truncate(part.userId)} - -
-
+
+
    + {parts.map(({title, mainImage, user}) => ( +
  • + ))} +
+
) } diff --git a/web/src/components/PartsCell/PartsCell.js b/web/src/components/PartsCell/PartsCell.js index 3e087bd..dc2cd9e 100644 --- a/web/src/components/PartsCell/PartsCell.js +++ b/web/src/components/PartsCell/PartsCell.js @@ -7,12 +7,13 @@ export const QUERY = gql` parts { id title - description - code mainImage createdAt updatedAt - userId + user { + image + userName + } } } ` diff --git a/web/src/components/UserProfile/UserProfile.js b/web/src/components/UserProfile/UserProfile.js index 40e29ce..b7bcc6d 100644 --- a/web/src/components/UserProfile/UserProfile.js +++ b/web/src/components/UserProfile/UserProfile.js @@ -25,7 +25,7 @@ const UserProfile = ({user, isEditable, loading, onSave, error}) => { const editableTextFields = {userName, name} return ( <> -
+
{ })} aspectRatio={1} isEditable={isEditable} - imageUrl={user.image === 'abc' ? '': user.image} + imageUrl={user.image} width={300} />
@@ -66,7 +66,7 @@ const UserProfile = ({user, isEditable, loading, onSave, error}) => { />
-
+ ) } diff --git a/web/src/layouts/MainLayout/MainLayout.js b/web/src/layouts/MainLayout/MainLayout.js index 3efde2b..d5fab0c 100644 --- a/web/src/layouts/MainLayout/MainLayout.js +++ b/web/src/layouts/MainLayout/MainLayout.js @@ -57,7 +57,7 @@ const MainLayout = ({ children }) => { className="rounded-full object-cover" onImageUpload={() => {}} aspectRatio={1} - imageUrl={data?.user?.image === 'abc' ? '': data?.user?.image} + imageUrl={data?.user?.image} width={80} />}