├── .eslintrc.json ├── styles ├── globals.css └── Home.module.css ├── public ├── skis.jpg ├── favicon.ico ├── logo-landscape.png ├── logo-mountain.png ├── vercel.svg └── cart.js ├── postcss.config.js ├── pages ├── api │ ├── [pid].js │ ├── hello.js │ ├── index.js │ └── api.js ├── _app.js ├── index.js ├── products.js ├── product │ └── [slug].js ├── contact.js └── about.js ├── next.config.js ├── tailwind.config.js ├── .gitignore ├── package.json ├── README.md └── Components ├── NavBar.js └── Footer.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /styles/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; -------------------------------------------------------------------------------- /public/skis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IshanSingla/NextJsProjects/HEAD/public/skis.jpg -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IshanSingla/NextJsProjects/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo-landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IshanSingla/NextJsProjects/HEAD/public/logo-landscape.png -------------------------------------------------------------------------------- /public/logo-mountain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IshanSingla/NextJsProjects/HEAD/public/logo-mountain.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /pages/api/[pid].js: -------------------------------------------------------------------------------- 1 | export default function handler(req, res) { 2 | const { pid } = req.query 3 | res.end(`Post: ${pid}`) 4 | } -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | swcMinify: true, 5 | } 6 | 7 | module.exports = nextConfig 8 | -------------------------------------------------------------------------------- /pages/api/hello.js: -------------------------------------------------------------------------------- 1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction 2 | 3 | export default function handler(req, res) { 4 | res.status(200).json({ name: 'John Doe' }) 5 | } 6 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./pages/**/*.{js,ts,jsx,tsx}", 5 | "./components/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .env 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | .pnpm-debug.log* 28 | 29 | # local env files 30 | .env*.local 31 | 32 | # vercel 33 | .vercel 34 | 35 | # typescript 36 | *.tsbuildinfo 37 | next-env.d.ts 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ishansingla", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "next": "12.3.0", 13 | "react": "18.2.0", 14 | "react-dom": "18.2.0", 15 | "simple-currency-format": "^2.3.0" 16 | }, 17 | "devDependencies": { 18 | "autoprefixer": "^10.4.9", 19 | "eslint": "8.23.1", 20 | "eslint-config-next": "12.3.0", 21 | "postcss": "^8.4.16", 22 | "tailwindcss": "^3.1.8" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /pages/_app.js: -------------------------------------------------------------------------------- 1 | import '../styles/globals.css' 2 | import { useState } from 'react' 3 | import NavBar from '../Components/NavBar' 4 | import Footer from '../Components/Footer' 5 | 6 | function MyApp({ Component, pageProps }) { 7 | 8 | const [cart, setCart] = useState([]) 9 | const [cartQty, setCartQty] = useState(0) 10 | 11 | const addToCart = (slug, qty, product) => { 12 | let newCart = cart 13 | 14 | const searchIndex = cart.findIndex((item) => item.slug==slug); 15 | 16 | if (searchIndex > -1) { 17 | cart[searchIndex].qty = cart[searchIndex].qty + qty 18 | setCart(cart) 19 | } else { 20 | newCart.push({slug: slug, qty: qty, price: product.price, name: product.name, image: product.image, category: product.category, currency: product.currency }) 21 | setCart(newCart) 22 | } 23 | 24 | // calculating cart item count 25 | cartQty = cartQty + qty 26 | setCartQty(cartQty) 27 | } 28 | 29 | return <> 30 | 31 | 32 |