Skip to content

Commit

Permalink
Merge pull request #52 from pitvaeltajat/staging
Browse files Browse the repository at this point in the history
Update [id].js
  • Loading branch information
eerosahlberg authored Apr 22, 2024
2 parents fd7bf98 + 4c16729 commit 50b231c
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions pages/item/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import prisma from '/utils/prisma';
import React from 'react';
import { useRouter } from 'next/router';
import {
Editable,
EditableInput,
EditableTextarea,
EditablePreview,
Image,
Heading,
Button,
Modal,
Expand Down Expand Up @@ -95,18 +92,23 @@ export default function ItemView({ item }) {

return (
<>
<Heading>{item.name}</Heading>
<Editable defaultValue={item.name}>
<EditablePreview />
<EditableInput />
</Editable>
<Editable defaultValue={item.description}>
<EditablePreview />
<EditableTextarea />
</Editable>
<Heading marginBottom='1em'>{item.name}</Heading>
{item.description && <p>{item.description}</p>}

{item.image && (
<Image
width='500px'
marginBottom='0.5em'
src={item.image}
alt={item.name}
fallbackSrc='https://via.placeholder.com/500x300'
/>
)}
{session?.user?.group === 'ADMIN' ? (
<>
<Button onClick={() => router.push(`/admin/edititem/${item.id}`)}>Muokkaa</Button>
<Button marginEnd='0.5em' onClick={() => router.push(`/admin/edititem/${item.id}`)}>
Muokkaa
</Button>
<Button onClick={onOpen}>Poista</Button>
</>
) : null}
Expand Down

0 comments on commit 50b231c

Please sign in to comment.