Skip to content

Commit

Permalink
completed individual item pages
Browse files Browse the repository at this point in the history
  • Loading branch information
celinechoiii committed Oct 31, 2023
2 parents c3108e9 + d317c3d commit 33193d5
Show file tree
Hide file tree
Showing 17 changed files with 192 additions and 75 deletions.
Binary file added public/images/Arrow_Left_MD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/Cart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/Profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/ShantiLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/images/profile (1).svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/images/profile blue version-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/app/[productId]/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useState } from 'react';
import {
ButtonsWrapper,
AddToCartButton,
QuantityButton,
PlusMinusButton,
} from './styles';

export default function Buttons() {
const [quantity, setQuantity] = useState<number>(1);

const increaseQuantity = () => {
setQuantity(quantity + 1);
};

const decreaseQuantity = () => {
if (quantity > 1) {
setQuantity(quantity - 1);
}
};

// used hyphen instead of dash for display
return (
<ButtonsWrapper>
<QuantityButton>
<PlusMinusButton type="button" onClick={decreaseQuantity}>
</PlusMinusButton>
<span>{quantity}</span>
<PlusMinusButton type="button" onClick={increaseQuantity}>
+
</PlusMinusButton>
</QuantityButton>
<AddToCartButton>Add to cart</AddToCartButton>
</ButtonsWrapper>
);
}
48 changes: 22 additions & 26 deletions src/app/[productId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
'use client';

import Link from 'next/link';
import Image from 'next/image';
import { useEffect, useState } from 'react';
import { fetchProductByID } from '../../api/supabase/queries/product_queries';
import {
BackButton,
ImageContainer,
TextContainer,
DescriptionContainer,
ButtonsContainer,
QuantityButton,
AddToCartButton,
} from './styles';
import {
GlobalStyle,
StickyHeader,
Logo,
NavButton,
} from '../../styles/components';
import { GlobalStyle } from '../../styles/components';
import NavBar from '../../components/NavBar';
import { Product } from '../../schema/schema';
import Buttons from './Buttons';

export default function ItemDisplay({
params,
Expand All @@ -36,28 +31,27 @@ export default function ItemDisplay({
setItem(response);
}
} catch (error) {
console.error(error);
// console.error(error);
}
}

fetchProducts();
}, []);

// replace the sticky header by importing
return (
<main>
<GlobalStyle />
<StickyHeader>
<Logo />
<NavButton>
<Link href="/checkout">Cart</Link>
</NavButton>
<NavButton>
<Link href="/profileScreen">Profile</Link>
</NavButton>
</StickyHeader>
<NavBar />
<BackButton>
<Link href="/storefront">Back</Link>
<Link href="/storefront">
<Image
src="/images/Arrow_Left_MD.png"
alt="Back Arrow"
width={20}
height={20}
/>
<span style={{ marginLeft: '8px' }}>Back</span>
</Link>
</BackButton>
<DescriptionContainer>
<ImageContainer>
Expand All @@ -69,11 +63,13 @@ export default function ItemDisplay({
</ImageContainer>
<TextContainer>
<h1>{Item?.name}</h1>
<p>{Item?.category}</p>
<ButtonsContainer>
<QuantityButton>1</QuantityButton>
<AddToCartButton>Add to cart</AddToCartButton>
</ButtonsContainer>
<h4 style={{ fontWeight: 'normal', paddingTop: '5px' }}>
{Item?.category}
</h4>
<Buttons />
<p style={{ paddingTop: '50px' }}>Product ID: {Item?.product_id}</p>
<p style={{ paddingTop: '20px' }}>Product Details:</p>
<p>{Item?.description}</p>
</TextContainer>
</DescriptionContainer>
</main>
Expand Down
33 changes: 22 additions & 11 deletions src/app/[productId]/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import styled from 'styled-components';
import COLORS from '../../styles/colors';

export const BackButton = styled.button`
padding-top: 210px;
display: flex;
padding-top: 230px;
padding-left: 30px;
width: 70px;
width: 100px;
height: 40px;
background-color: transparent;
border-color: transparent;
font-size: 15px;
`;

export const DescriptionContainer = styled.div`
Expand All @@ -30,26 +32,35 @@ export const TextContainer = styled.div`
height: 350px;
`;

export const ButtonsContainer = styled.div`
export const ButtonsWrapper = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
width: 450px;
height: 50px;
border-radius: 30px;
padding: 30px;
margin-top: 20px;
`;

export const QuantityButton = styled.button`
export const QuantityButton = styled.div`
display: flex;
justify-content: space-evenly;
align-items: center;
width: 165px;
height: 50px;
border-radius: 8px;
background-color: ${COLORS.white};
border-color: ${COLORS.navy};
font-family: Public Sans;
border: 2px solid ${COLORS.navy};
color: ${COLORS.navy};
`;

export const PlusMinusButton = styled.button`
width: 25px;
height: 25px;
align-items: center;
justify-content: center;
background-color: transparent;
border-color: transparent;
font-size: 20px;
font-style: normal;
font-weight: 700;
line-height: normal;
color: ${COLORS.navy};
`;
export const AddToCartButton = styled.button`
Expand Down
5 changes: 5 additions & 0 deletions src/app/checkout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use client';

import NavBar from '../../components/NavBar';

export default function Checkout() {
return (
<main>
<NavBar />
<div>Checkout</div>
</main>
);
Expand Down
1 change: 0 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
testFetchUserByUUID,
testAddUserAddress,
} from '../api/supabase/queries/tests/user_test';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import {
testFetchOrderByUUID,
testFetchOrders,
Expand Down
3 changes: 3 additions & 0 deletions src/app/profileScreen/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { LogOutButton, GlobalStyle } from './style';

import { signOut } from '../../api/supabase/auth/auth';

import NavBar from '../../components/NavBar';

export default function Profile() {
return (
<main>
<NavBar />
<GlobalStyle />
<LogOutButton onClick={() => signOut()}>Sign Out</LogOutButton>
</main>
Expand Down
64 changes: 32 additions & 32 deletions src/app/storefront/page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
'use client';

import React, { useState } from 'react';
import Link from 'next/link';
import StorefrontItems from './storefrontItems';
import React, { useEffect, useState } from 'react';
import Storefront from './storefrontItems';
import ProductButtons from './productButtons';
import { Product } from '../../schema/schema';
import {
GlobalStyle,
StickyHeader,
Logo,
NavButton,
} from '../../styles/components';

import { GlobalStyle } from '../../styles/components';
import NavBar from '../../components/NavBar';
import { ButtonsContainer, ShopAllText } from './styles';
import { getProduct } from './helperFunction';
import { Product } from '../../schema/schema';

// https://codesandbox.io/s/filter-with-react-button-r5x4i?file=/src/App.js
export default function App() {
Expand All @@ -38,32 +33,37 @@ export default function App() {
count: 3,
},
];
const [, setFilteredProducts] = useState<null | Product[]>(null);
const [FilteredProducts, setFilteredProducts] = useState<Product[]>([]);

useEffect(() => {
async function fetchProducts() {
try {
const data = (await getProduct()) as Product[];
setFilteredProducts(data);
} catch (error) {
// console.log(error);
}
}

fetchProducts();
}, []);

return (
<main>
<GlobalStyle />
<StickyHeader>
<Logo />
<NavButton>
<Link href="/checkout">Cart</Link>
</NavButton>
<NavButton>
<Link href="/profileScreen">Profile</Link>
</NavButton>
<ButtonsContainer>
{buttons.map(type => (
<ProductButtons
key={type.count}
value={type.value}
setFiltredProducts={setFilteredProducts}
content={type.name}
/>
))}
</ButtonsContainer>
</StickyHeader>
<NavBar />
<ButtonsContainer>
{buttons.map(type => (
<ProductButtons
key={type.count}
value={type.value}
setFiltredProducts={setFilteredProducts}
content={type.name}
/>
))}
</ButtonsContainer>
<ShopAllText>Shop All</ShopAllText>
<StorefrontItems />
<Storefront products={FilteredProducts} />
</main>
);
}
6 changes: 2 additions & 4 deletions src/app/storefront/storefrontItems.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { useState, useEffect } from 'react';

import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import { StorefrontWrapper, StorefrontItem, ItemButtons } from './styles';

import { getProduct } from './helperFunction';
import { StorefrontWrapper, StorefrontItem, ItemButtons } from './styles';

import { Product } from '../../schema/schema';

Expand Down
5 changes: 4 additions & 1 deletion src/app/storefront/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const ButtonsContainer = styled.div`
flex-direction: row;
justify-content: center;
align-items: center;
position: absolute;
z-index: 5;
`;

export const ItemButtons = styled.button`
Expand All @@ -57,12 +59,13 @@ export const ItemButtons = styled.button`
export const StorefrontWrapper = styled.div`
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-evenly;
padding: 30px;
`;

export const StorefrontItem = styled.div`
width: calc(25% - 30px);
width: calc(25% - 40px);
margin-bottom: 50px;
`;

Expand Down
40 changes: 40 additions & 0 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Image from 'next/image';
import Link from 'next/link';
import React from 'react';

import { NavBarComp, ButtonsDiv } from '../styles/components';

export default function NavBar() {
return (
<NavBarComp>
<Link href="../storefront">
<Image
src="/images/ShantiLogo.png"
alt="Shanti Logo"
width={125}
height={70}
/>
</Link>

<ButtonsDiv>
<Link href="../profileScreen">
<Image
src="/images/Profile.png"
alt="Profile icon"
width={40}
height={40}
/>
</Link>

<Link href="../checkout">
<Image
src="/images/Cart.png"
alt="Cart icon"
width={30}
height={40}
/>
</Link>
</ButtonsDiv>
</NavBarComp>
);
}
Loading

0 comments on commit 33193d5

Please sign in to comment.