Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merch Store #73

Merged
merged 114 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
74491c3
wip
PenTest-duck Apr 10, 2024
119e2c4
constants folder
PenTest-duck Apr 10, 2024
952a710
Merge branch 'main' of github.com:coopsoc/website into migration-to-t…
PenTest-duck May 11, 2024
c0ca2b7
migrated everything except merch
PenTest-duck May 11, 2024
8f71c02
fix eslintrc typo
PenTest-duck May 11, 2024
c1942df
migrate merch store
PenTest-duck May 11, 2024
9c0b028
fix eslint error + change merch to txt
PenTest-duck May 11, 2024
9890def
built cart functionality
BlackNinja1369 May 26, 2024
3503add
add ts type check
PenTest-duck May 26, 2024
45e598b
trigger type check only on pr
PenTest-duck May 26, 2024
62d9055
even better deploy.yml
PenTest-duck May 26, 2024
d25468e
revert
PenTest-duck May 26, 2024
f6523ca
fix
PenTest-duck May 26, 2024
cb75a47
use different type checker
PenTest-duck May 26, 2024
34cff91
migrate eslint configs from json to flat
PenTest-duck Jun 1, 2024
68ad66a
run lint + add react & react-hooks plugins + set all eslint errors to…
PenTest-duck Jun 1, 2024
f23d970
wip - product gallery page
PenTest-duck Jun 4, 2024
7e91d73
Complete Cart And Get Working Independently
BlackNinja1369 Jun 4, 2024
d2102c7
Delete 2024MerchImages.jsx File
BlackNinja1369 Jun 4, 2024
ad8e6a4
ts strict mode true
PenTest-duck Jun 5, 2024
b1e45db
Merge branch 'main' of github.com:coopsoc/website into migration-to-t…
PenTest-duck Jun 5, 2024
f896aed
fix type errors
PenTest-duck Jun 5, 2024
8c2d208
Merge branch 'migration-to-typescript' of github.com:coopsoc/website …
PenTest-duck Jun 5, 2024
01a939e
Resize font
BlackNinja1369 Jun 5, 2024
e59c83c
Change Merch-2024 folder to 2024
BlackNinja1369 Jun 5, 2024
02cad27
Address PR Feedback To Include Generics
PenTest-duck Jun 5, 2024
5cb6562
Merge branch 'main' into Checkout
BlackNinja1369 Jun 7, 2024
f1e7cff
build stripe fetch and parse logic
PenTest-duck Jun 8, 2024
cc8c60b
apply PR feedback
PenTest-duck Jun 9, 2024
6009c56
use reusable charityeventprops
PenTest-duck Jun 9, 2024
1783255
Merge branch 'migration-to-typescript' of github.com:coopsoc/website …
PenTest-duck Jun 9, 2024
63071ed
Add .env.local file and implement coop stripe api
BlackNinja1369 Jun 9, 2024
8026618
wip - merch page
PenTest-duck Jun 9, 2024
a021172
Make cart recieve data as a map
BlackNinja1369 Jun 9, 2024
6f743cc
Add images to public/img/merch/2024
BlackNinja1369 Jun 9, 2024
4c69d7d
Merge branch 'add-merch-images' of https://github.com/coopsoc/website…
BlackNinja1369 Jun 9, 2024
7fa8927
Change images to correct ones
BlackNinja1369 Jun 9, 2024
8735843
wip - add image carousel
PenTest-duck Jun 9, 2024
74a1ee3
Merge branch 'Checkout' into merch-staging
BlackNinja1369 Jun 9, 2024
e49e546
[unstable WIP] fix merch and checkout pages
PenTest-duck Jun 12, 2024
2d3292f
Initial, WIP implementation of checkout.jsx
scorpiontornado May 29, 2024
f604411
Change checkout function to match other files
scorpiontornado May 29, 2024
057c787
Add checkout return page MVP
scorpiontornado May 29, 2024
84dcba6
Add test environment variables / example file
scorpiontornado May 29, 2024
2938d38
Attempt to fix checkout issue and implement singleton pattern
scorpiontornado Jun 5, 2024
d8308c0
Clean up checkout index, identify CSP issue
scorpiontornado Jun 5, 2024
cf1865f
Install Stripe libraries
lhvy Jun 12, 2024
1cda46e
Upgrade dependencies
lhvy Jun 12, 2024
45b3881
[WIP] display carousel images
PenTest-duck Jun 12, 2024
d3b093c
WIP NextJS upgrade
lhvy Jun 12, 2024
e0cd437
Add Stripe library
lhvy Jun 12, 2024
d20d77e
Migrate Bootstrap 4 to 5
lhvy Jun 12, 2024
12a01ec
Refactor checkout function
lhvy Jun 12, 2024
ff73030
Improve checkout styling
scorpiontornado Jun 12, 2024
29bca50
Add legacyBehavior prop to navbar Links that contain divs
scorpiontornado Jun 12, 2024
8a755d4
Minor UI changes
scorpiontornado Jun 13, 2024
32e22fa
Update checkout return message
scorpiontornado Jun 13, 2024
5a66489
Change footer copyright to 2024
scorpiontornado Jun 13, 2024
a121e27
Fix navbar layout issues (Container no longer flex by default)
scorpiontornado Jun 13, 2024
4ae8ea7
Fix visual bug of intermittent, coloured horizontal line at bottom of…
scorpiontornado Jun 13, 2024
8874fd5
Navbar/IndexHeader style/mobile changes, migrate bootstrap4 margin/pa…
scorpiontornado Jun 13, 2024
bd5175d
save to localstorage
PenTest-duck Jun 13, 2024
9f3fbed
update to include full name in cart
PenTest-duck Jun 14, 2024
ebc50ba
Merge branch 'main' of https://github.com/coopsoc/website into merch-…
BlackNinja1369 Jun 15, 2024
bc14169
Integrate gallery with cart
BlackNinja1369 Jun 15, 2024
80cec91
pass all linting errors
PenTest-duck Jun 15, 2024
dcf9806
don't display selected items
PenTest-duck Jun 16, 2024
1ded2b9
Merge branch 'stripe-checkout' of github.com:coopsoc/website into mer…
PenTest-duck Jun 16, 2024
d109032
fix eslint error
PenTest-duck Jun 16, 2024
37b2ca7
Change "Checkout" to Cart to disambiguate vs real checkout
scorpiontornado Jun 17, 2024
7a02dda
Update cart UI, still more to do but optional
scorpiontornado Jun 17, 2024
9f6c845
Convert cart to reactstrap (WIP)
scorpiontornado Jun 17, 2024
df96504
Update cart styling more
scorpiontornado Jun 17, 2024
b3642b1
Further modify /cart UI
scorpiontornado Jun 17, 2024
2b57186
Make formatting of clothingItem more consistent with Stripe / homepage
scorpiontornado Jun 17, 2024
ef02d0e
Improve return page
scorpiontornado Jun 18, 2024
110d2a4
Implement checkout with chosen cart items
lhvy Jun 18, 2024
fc8860d
Improve style of /checkout when cart is empty, move file /api/merch.t…
scorpiontornado Jun 19, 2024
cf55aee
Save changes to cart to the local storage
BlackNinja1369 Jun 21, 2024
9957d33
Change variable, using wrong one
BlackNinja1369 Jun 21, 2024
04e1760
Retrieve existing cart data
BlackNinja1369 Jun 21, 2024
c7e4fe9
set loading icon on clicking view cart
PenTest-duck Jun 21, 2024
0a38d5a
add breakpoints and fix image sizing
PenTest-duck Jun 21, 2024
385705d
Fix adding variants to cart
lhvy Jun 21, 2024
cb5d1ac
Merge .env and .env.local
scorpiontornado Jun 21, 2024
ab66fbf
Change .env to .env.local as per NextJS/Stripe docs
scorpiontornado Jun 21, 2024
9d5d2c8
Change github action type checking to NodeJS 20
scorpiontornado Jun 21, 2024
b103b81
Remove extra type dep
lhvy Jun 21, 2024
5f5021b
Apply temporary fix for DigitalOcean build errors
scorpiontornado Jun 21, 2024
818149e
Move dev deps to dev
lhvy Jun 21, 2024
41c524f
Add custom build script for DO
lhvy Jun 21, 2024
a276688
Add image optimisation
lhvy Jun 21, 2024
c8ca46c
Undo hacky typechecking workaround
scorpiontornado Jun 22, 2024
36924c6
Attempt to fix image loading issue
scorpiontornado Jun 22, 2024
ae4efb6
Reduce exec image quality
scorpiontornado Jun 22, 2024
af426b2
Add blur to exec images
scorpiontornado Jun 22, 2024
965492e
Reduce size and quality of merch images
scorpiontornado Jun 22, 2024
2e349f9
Compress merch images
lhvy Jun 23, 2024
efba866
Fix checkout
lhvy Jun 23, 2024
4c47a68
Change merch image quality prop back to default (75)
scorpiontornado Jun 23, 2024
4d54c70
Temporarily remove /merch from navbar
scorpiontornado Jun 23, 2024
b0edff0
Require only active products
lhvy Jun 23, 2024
04a9620
Revert "Temporarily remove /merch from navbar"
lhvy Jun 23, 2024
909d2fc
Fix alignment of cart header vs ClothingItems
scorpiontornado Jun 23, 2024
e579dfc
WIP mobile layout
scorpiontornado Jun 23, 2024
45756b7
Further update cart CSS
scorpiontornado Jun 23, 2024
6b85c07
Add /cart mobile layout
scorpiontornado Jun 23, 2024
0095983
Make h1 styling consistent - reduced padding on mobile
scorpiontornado Jun 23, 2024
149335a
Update padding on merch storefront buttons
matthew-lim-matthew-lim Jun 25, 2024
5d1647d
Remove merch 2024 (#77)
scorpiontornado Jul 24, 2024
3d9c32d
Fix issues with merch 2023 using Product (2024)
scorpiontornado Jul 24, 2024
8f7090f
Update import in clothingItem.tsx
scorpiontornado Jul 24, 2024
33aa68a
Fix any types, remove NextJS dynamic content
scorpiontornado Jul 29, 2024
935f10b
Add documentation on enabling/disabling nominations and merch
scorpiontornado Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# From https://docs.stripe.com/checkout/embedded/quickstart?client=next#set-env-vars

# Copy into .env.local and replace the placeholder values with the real keys.
# https://dashboard.stripe.com/apikeys
# https://dashboard.stripe.com/test/apikeys
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_12345
STRIPE_SECRET_KEY=sk_test_12345

# Set this environment variable to support webhooks — https://stripe.com/docs/webhooks#verify-events
# STRIPE_WEBHOOK_SECRET=whsec_12345
2 changes: 1 addition & 1 deletion .github/workflows/type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env*.local

# vercel
Expand Down
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "yarn dev",
"serverReadyAction": {
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true
"editor.formatOnSave": true,
"cSpell.words": [
"Merch",
"Subcom",
"subcoms"
]
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ To run the website on your local machine, do the following:
should be available at `http://localhost:3000`, where any edits made to the
website's source code should be immediately reflected on the webpage.

## Maintaining

### Enabling/disabling nominations

Change `const showNominations` to `true` or `false` in `pages/nominations.tsx` to enable or disable nominations.

### Enabling/disabling merch

Change `export const isMerchActive = (): boolean => false;` to `true` in `scripts/merch.ts` to enable merch.

## Contributors

The first version of the website was written by the 2020 Co-op Soc IT director,
Expand Down
2 changes: 1 addition & 1 deletion components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Footer = () => {
</a>
</div>
<div className="container">
Copyright &copy; 2023 UNSW Co-op Society
Copyright &copy; 2024 UNSW Co-op Society
</div>
<br></br>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Header = () => {
x="0"
y="0"
>
<polygon className="fill-white" points="4000 0 4000 100 0 100" />
<polygon className="fill-white" points="4000 0 4000 105 0 105" />
</svg>
</div>
</section>
Expand Down
6 changes: 3 additions & 3 deletions components/IndexHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const IndexHeader = () => {
return (
<div className="position-relative">
{/* shape Hero */}
<section className="section section-lg section-shaped pb-250">
<section className="section section-lg section-shaped pb-150">
<div className="shape shape-style-custom shape-primary">
<span className="floating" />
<span className="floating" />
Expand All @@ -19,7 +19,7 @@ const IndexHeader = () => {
<span className="floating" />
</div>

<Container className="py-lg-md d-flex">
<Container className="d-flex px-4 px-sm-3">
<div className="col px-0">
<br></br>
<Row>
Expand Down Expand Up @@ -47,7 +47,7 @@ const IndexHeader = () => {
x="0"
y="0"
>
<polygon className="fill-white" points="4000 0 4000 100 0 100" />
<polygon className="fill-white" points="4000 0 4000 105 0 105" />
</svg>
</div>
</section>
Expand Down
26 changes: 15 additions & 11 deletions components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

import React, { useEffect, useState } from "react";
import Image from "next/image";
import Image from "next/legacy/image";
import Link from "next/link";
import { useRouter } from "next/router";

Expand Down Expand Up @@ -43,6 +43,7 @@ import LogoSmall from "public/img/brand/logo_small.png";
import NextNavbarBrand from "./link/NextNavbarBrand";
import NextNavLink from "./link/NextNavLink";
import NavIcon from "./navigation/NavIcon";
import { isMerchActive } from "scripts/merch";

// Supports both internal and external links, but internal links/redirects are preferred
const navLinks = [
Expand All @@ -56,6 +57,10 @@ const navLinks = [
// ["First Year FB", "/fb"],
];

if (isMerchActive()) {
navLinks.push(["Merch", "/merch"]);
}

const Navigation = () => {
const router = useRouter();
const [open, setOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -83,23 +88,22 @@ const Navigation = () => {
expand="lg"
id="navbar-main"
>
<Container>
<Link href="/" passHref>
<NextNavbarBrand className="mr-lg-5">
<Container className="d-flex align-items-center px-0 px-sm-3">
{/* legacyBehavior to fix: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor */}
<Link href="/" passHref legacyBehavior>
<NextNavbarBrand className="me-lg-5">
<Image alt="..." src={Logo} />
</NextNavbarBrand>
</Link>

<NavbarToggler onClick={() => setOpen(true)} />
<NavbarToggler className="ms-auto" onClick={() => setOpen(true)} />

<Collapse isOpen={open} navbar>
<div className="navbar-collapse-header">
<Row>
<Col className="collapse-brand" xs="6">
<Link href="/">
<a>
<Image alt="..." src={LogoSmall} />
</a>
<Link href="/" passHref>
<Image alt="..." src={LogoSmall} />
</Link>
</Col>

Expand All @@ -115,7 +119,7 @@ const Navigation = () => {
<Nav className="navbar-nav-click align-items-lg-center" navbar>
{navLinks.map(([text, link], index) => (
<NavItem key={`nav-item-${text}-${index}`}>
<Link href={link} passHref>
<Link href={link} passHref legacyBehavior>
<NextNavLink className={getNavLinkClass(link)}>
<span className="nav-link-inner--text">{text}</span>
</NextNavLink>
Expand All @@ -124,7 +128,7 @@ const Navigation = () => {
))}
</Nav>

<Nav className="align-items-lg-center ml-lg-auto" navbar>
<Nav className="align-items-lg-center ms-lg-auto" navbar>
<NavIcon
href="https://www.facebook.com/coopsoc.unsw/"
id="tooltip-facebook"
Expand Down
1 change: 0 additions & 1 deletion components/YearSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const YearSlider = ({ start, end, onChange }: YearSliderProps) => {
sliderNode.noUiSlider.destroy();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand Down
2 changes: 1 addition & 1 deletion components/blog/BlogCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const BlogCard = (blog: Blog) => {
Learn more
</Button>

<CardFooter className="pt-2 pb-0 pl-2 pr-2 bg-white">
<CardFooter className="pt-2 pb-0 ps-2 pe-2 bg-white">
<p className="text-left text-sm text-muted">
{dayjs(blog.published).fromNow()}
</p>
Expand Down
8 changes: 5 additions & 3 deletions components/blog/social_distance/BlogTab.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Image from "next/image";
import Image from "next/legacy/image";
import React, { useState } from "react";
import { Col, Container, Row, TabContent, TabPane } from "reactstrap";
import { partition } from "scripts/list";
Expand Down Expand Up @@ -26,8 +26,10 @@ const BlogTab = (props: BlogTabProps) => {
<Image
src={src}
alt={`${index}`}
width="100%"
height="100%"
style={{
width: "100%",
height: "100%",
}}
layout="responsive"
objectFit="contain"
onClick={() => setTab(index)}
Expand Down
81 changes: 81 additions & 0 deletions components/cart/clothingItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from "react";
import Image from "next/image";

import styles from "styles/modules/Cart.module.scss";

import { Row, Col, Button } from "reactstrap";
import { CartItemWithDetail } from "data/types";

interface ClothingItemProps {
item: CartItemWithDetail;
addToCart: (item: CartItemWithDetail) => void;
removeFromCart: (item: CartItemWithDetail) => void;
}

const ClothingItem = ({
item,
addToCart,
removeFromCart,
}: ClothingItemProps) => {
item.product.images[0] = item.product.images[0]
.replace("https%3A//www.coopsoc.com.au", "")
.replace(".png", ".jpg");
return (
<Row
className={
"mb-5 px-sm-5 ps-md-2 ps-lg-5 py-4 py-sm-1 " + styles["clothingItem"]
}
>
<Col
className="pt-2 pb-sm-3 pb-lg-2 d-flex flex-column flex-lg-row text-center justify-content-start align-items-center"
sm="6"
>
<Image
src={item.product.images[0]}
width={150}
height={150}
alt="Picture of the clothing item"
unoptimized
/>
<p className="fs-5 fw-bold m-0 ms-lg-4 text-center">
{item.product.name}
</p>
</Col>
<Col
className={"d-none d-md-block text-center " + styles["clothingRow"]}
sm="1"
>
<p className="m-0 fs-5 fw-bold">${(item.price.cents ?? 0) / 100}</p>
</Col>
<Col className={styles["clothingRow"]} sm="4">
<div className={styles["quantityButtons"]}>
<Button
color="primary"
target="_blank"
onClick={() => removeFromCart(item)}
>
-
</Button>
<p className="m-0 my-3 mx-lg-3 fw-bold fs-5 text-center">
{item.qty}
</p>
<Button
color="primary"
target="_blank"
onClick={() => addToCart(item)}
>
+
</Button>
</div>
</Col>
<Col sm="1">
<p className="m-0 fw-bold fs-5 text-center">
<span className="d-sm-none">Total: </span>$
{((item.price.cents ?? 0) / 100) * item.qty}
</p>
</Col>
</Row>
);
};

export default ClothingItem;
2 changes: 1 addition & 1 deletion components/charity/CharityList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import Image from "next/image";
import Image from "next/legacy/image";
import { Container, Row, Col } from "reactstrap";

import { SPONSORS } from "data/CharityData";
Expand Down
2 changes: 1 addition & 1 deletion components/charity/CharityUpcoming.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import Image from "next/image";
import Image from "next/legacy/image";
import { Col, Container, Row } from "reactstrap";

import { partition } from "scripts/list";
Expand Down
2 changes: 1 addition & 1 deletion components/charity/events/CharityCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import Image from "next/image";
import Image from "next/legacy/image";

import { Col } from "reactstrap";
import { CharityEvent, CharityEventProps } from "../../../data/types";
Expand Down
2 changes: 1 addition & 1 deletion components/charity/modal/CharityBody.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import Image from "next/image";
import Image from "next/legacy/image";
import { CharityEventProps } from "../../../data/types";

const CharityBody = ({ event }: CharityEventProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useRouter } from "next/router";

import styles from "styles/modules/Merch.module.scss";
import LoadingButton from "components/LoadingButton";
import { Product } from "../../data/types";
import { Product2023 } from "../../data/types";

interface CheckoutFormProps {
cart: Product[];
updateCart: (cart: Product[]) => void;
cart: Product2023[];
updateCart: (cart: Product2023[]) => void;
}

const CheckoutForm = ({ cart, updateCart }: CheckoutFormProps) => {
Expand All @@ -17,7 +17,7 @@ const CheckoutForm = ({ cart, updateCart }: CheckoutFormProps) => {
const router = useRouter();

const removeFromCart = (e: React.MouseEvent<HTMLSpanElement>) => {
const newCart: Product[] = JSON.parse(JSON.stringify(cart)); // this an extremely hacky way of getting a hard copied array
const newCart: Product2023[] = JSON.parse(JSON.stringify(cart)); // this an extremely hacky way of getting a hard copied array
const index: number = Number(
e.currentTarget.parentElement?.getAttribute("data-value"),
); // this is gross chaining
Expand Down
Loading
Loading