Skip to content

Commit

Permalink
REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
Satyabrat-Ojha committed May 29, 2023
1 parent 6c8da63 commit 14952c4
Show file tree
Hide file tree
Showing 13 changed files with 598 additions and 72 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGO_URL = mongodb+srv://satyabratojha04:[email protected]/pizza?retryWrites=true&w=majority
15 changes: 8 additions & 7 deletions components/PizzaCard.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Image from "next/image";
import styles from "../styles/PizzaCard.module.css";
import Link from "next/link";

const PizzaCard = () => {
const PizzaCard = ({ pizza }) => {
return (
<div className={styles.container}>
<Image src="/img/pizza.png" width={200} height={200} />
<h1 className={styles.title}>FIORI DI ZUCCA</h1>
<span className={styles.price}>$ 19.90</span>
<p className={styles.desc}>
Lorem ipsum dolar sit amet adipisicing elit.
</p>
<Link href={`/product/${pizza._id}`}>
<Image src={pizza.img} width={200} height={200} />
</Link>
<h1 className={styles.title}>{pizza.title}</h1>
<span className={styles.price}>${pizza.prices[0]}</span>
<p className={styles.desc}>{pizza.desc}</p>
</div>
);
};
Expand Down
13 changes: 4 additions & 9 deletions components/PizzaList.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styles from "../styles/PizzaList.module.css";
import PizzaCard from "./PizzaCard";

const PizzaList = () => {
const PizzaList = ({ pizzaList }) => {
return (
<div className={styles.container}>
<h1 className={styles.title}>THE BEST PIZZA IN TOWN</h1>
Expand All @@ -12,14 +12,9 @@ const PizzaList = () => {
voluptatibus.
</p>
<div className={styles.wrapper}>
<PizzaCard />
<PizzaCard />
<PizzaCard />
<PizzaCard />
<PizzaCard />
<PizzaCard />
<PizzaCard />
<PizzaCard />
{pizzaList.map((pizza) => (
<PizzaCard key={pizza._id} pizza={pizza} />
))}
</div>
</div>
);
Expand Down
32 changes: 32 additions & 0 deletions models/Order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Timestamp } from "mongodb";
import mongoose from "mongoose";

const OrderSchema = new mongoose.Schema(
{
customer: {
type: String,
required: true,
maxlength: 60,
},
address: {
type: String,
required: true,
maxlength: 200,
},
total: {
type: Number,
required: true,
},
status: {
type: Number,
default: 0,
},
method: {
type: Number,
required: true,
},
},
{ timestamps: true }
);

export default mongoose.models.Order || mongoose.model("Order", OrderSchema);
37 changes: 37 additions & 0 deletions models/Product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Timestamp } from "mongodb";
import mongoose from "mongoose";

const ProductSchema = new mongoose.Schema(
{
title: {
type: String,
required: true,
maxlength: 60,
},
desc: {
type: String,
required: true,
maxlength: 200,
},
img: {
type: String,
required: true,
},
prices: {
type: [Number],
required: true,
},
extraOptions: {
type: [
{
text: { type: String, required: true },
price: { type: Number, required: true },
},
],
},
},
{ timestamps: true }
);

export default mongoose.models.Product ||
mongoose.model("Product", ProductSchema);
Loading

0 comments on commit 14952c4

Please sign in to comment.