-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from leerob/updates
- Loading branch information
Showing
10 changed files
with
142 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
import Image from 'next/image'; | ||
import React from 'react'; | ||
|
||
export default function Product({product}) { | ||
const {name, description, price, image, category} = product; | ||
return ( | ||
<div className="max-w-xs rounded overflow-hidden shadow-lg" key={product.id}> | ||
<Image className="w-full" width={320} height={160} src={image} alt={name}/> | ||
<div className="px-6 py-4"> | ||
<div className="font-bold text-xl mb-2">{name}</div> | ||
<p className="text-gray-700 text-base"> | ||
{description} | ||
</p> | ||
<p className="text-gray-900 text-xl"> | ||
${price} | ||
</p> | ||
</div> | ||
<div className="px-6 pt-4 pb-2"> | ||
<span className="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">{category.name}</span> | ||
</div> | ||
</div> | ||
) | ||
export default function Product({ product }) { | ||
const { name, description, price, image, category } = product; | ||
|
||
return ( | ||
<div | ||
className="max-w-[250px] rounded overflow-hidden shadow-lg" | ||
key={product.id} | ||
> | ||
<Image | ||
className="w-full" | ||
width={250} | ||
height={250} | ||
objectFit="cover" | ||
src={image} | ||
alt={name} | ||
/> | ||
<div className="px-6 py-4"> | ||
<div className="font-bold text-xl mb-2">{name}</div> | ||
<p className="text-gray-700 text-base">{description}</p> | ||
<p className="text-gray-900 text-xl">${price}</p> | ||
</div> | ||
<div className="px-6 pt-4 pb-2"> | ||
<span className="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2"> | ||
{category.name} | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import '../styles/globals.css' | ||
import '../styles/globals.css'; | ||
|
||
function MyApp({ Component, pageProps }) { | ||
return <Component {...pageProps} /> | ||
export default function MyApp({ Component, pageProps }) { | ||
return <Component {...pageProps} />; | ||
} | ||
|
||
export default MyApp |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
import prisma from "./../../lib/prisma.js"; | ||
import prisma from './../../lib/prisma.js'; | ||
|
||
export default async function handler(req, res) { | ||
if(req.method === 'GET') { | ||
try { | ||
const data = await prisma.product.findMany({}); | ||
return res.status(200).json({ data }); | ||
}catch(err){ | ||
console.error(err) | ||
return res.status(500).json({ msg: 'Something went wrong' }); | ||
} | ||
}else { | ||
return res.status(405).json({ msg: 'Method not allowed' }); | ||
if (req.method === 'GET') { | ||
try { | ||
const data = await prisma.product.findMany({}); | ||
return res.status(200).json({ data }); | ||
} catch (err) { | ||
console.error(err); | ||
return res.status(500).json({ msg: 'Something went wrong' }); | ||
} | ||
} else { | ||
return res.status(405).json({ msg: 'Method not allowed' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
const { Prisma } = require('@prisma/client'); | ||
|
||
const categories = [ | ||
{ | ||
name: "Hats", | ||
description: "Things you can wear on your head" | ||
}, | ||
{ | ||
name: "Socks", | ||
description: "Things you can wear on your feet" | ||
}, | ||
{ | ||
name: "Shirts", | ||
description: "Things you wear on the top half of your body" | ||
} | ||
{ | ||
name: 'Hats', | ||
description: 'Things you can wear on your head', | ||
}, | ||
{ | ||
name: 'Socks', | ||
description: 'Things you can wear on your feet', | ||
}, | ||
{ | ||
name: 'Shirts', | ||
description: 'Things you wear on the top half of your body', | ||
}, | ||
]; | ||
|
||
const products = [ | ||
{ | ||
name: "Cool hat.", | ||
description: "A nice hat to wear on your head", | ||
price: new Prisma.Decimal(19.95), | ||
image: "/images/placeholder.jpg", | ||
category_id: 1, | ||
}, | ||
{ | ||
name: "Grey T-Shirt", | ||
description: "A nice shirt that you can wear on your body", | ||
price: new Prisma.Decimal(22.95), | ||
image: "/images/placeholder.jpg", | ||
category_id: 3, | ||
}, | ||
{ | ||
name: "Socks", | ||
description: "Cool socks that you can wear on your feet", | ||
price: new Prisma.Decimal(12.95), | ||
image: "/images/placeholder.jpg", | ||
category_id: 2, | ||
}, | ||
{ | ||
name: "Sweatshirt", | ||
description: "Cool sweatshirt that you can wear on your body", | ||
price: new Prisma.Decimal(12.95), | ||
image: "/images/placeholder.jpg", | ||
category_id: 3, | ||
} | ||
] | ||
{ | ||
name: 'Cool helmet.', | ||
description: 'A nice helmet to wear on your head', | ||
price: new Prisma.Decimal(19.95), | ||
image: '/images/helmet.jpg', | ||
category_id: 1, | ||
}, | ||
{ | ||
name: 'Grey T-Shirt', | ||
description: 'A nice shirt that you can wear on your body', | ||
price: new Prisma.Decimal(22.95), | ||
image: '/images/shirt.jpg', | ||
category_id: 3, | ||
}, | ||
{ | ||
name: 'Socks', | ||
description: 'Cool socks that you can wear on your feet', | ||
price: new Prisma.Decimal(12.95), | ||
image: '/images/socks.jpg', | ||
category_id: 2, | ||
}, | ||
{ | ||
name: 'Sweatshirt', | ||
description: 'Cool sweatshirt that you can wear on your body', | ||
price: new Prisma.Decimal(12.95), | ||
image: '/images/sweatshirt.jpg', | ||
category_id: 3, | ||
}, | ||
]; | ||
|
||
module.exports = { | ||
products, categories | ||
} | ||
products, | ||
categories, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.