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

Repo cleanup #110

Merged
merged 38 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3865e17
Update _app.tsx
farisashai Jan 2, 2024
99c2e13
Update leaderboard.tsx
farisashai Jan 2, 2024
eb66a2a
Merge branch 'main' into faris/misc-fixes
farisashai Jan 2, 2024
bad83be
Rename permission
farisashai Jan 2, 2024
6c2348e
Merge branch 'faris/misc-fixes' of https://github.com/acmucsd/members…
farisashai Jan 2, 2024
1cf17fd
Remove user specific store 404 details
farisashai Jan 2, 2024
a992ae5
remove magic var and type children correctly
farisashai Jan 2, 2024
b310de3
Refactor community logos to support future changes
farisashai Jan 2, 2024
2e605f1
Update index.tsx
farisashai Jan 2, 2024
434f89e
Merge branch 'main' into faris/misc-fixes
farisashai Jan 7, 2024
b195d8f
Fix package
farisashai Jan 7, 2024
cdfeb1e
fix build
farisashai Jan 7, 2024
839f552
Update style.module.scss
farisashai Jan 7, 2024
8a3e77a
test pwa
farisashai Jan 7, 2024
eb810ce
Upgrade node from 18 to 21
farisashai Jan 7, 2024
3b0ea7e
Update yarn.lock
farisashai Jan 7, 2024
e7b4fbe
Change to LTS
farisashai Jan 7, 2024
6761d5b
Change to LTS
farisashai Jan 7, 2024
42a49ae
Revert "Change to LTS"
farisashai Jan 7, 2024
7548be7
Merge branch 'faris/misc-fixes' of https://github.com/acmucsd/members…
farisashai Jan 7, 2024
20d4847
Revert
farisashai Jan 7, 2024
cfd0f78
undo undo undo
farisashai Jan 7, 2024
8d57315
Update yarn.lock
farisashai Jan 7, 2024
368e5d3
Update .nvmrc
farisashai Jan 7, 2024
f6eecee
Update package.json
farisashai Jan 7, 2024
e937c2c
Update yarn.lock
farisashai Jan 7, 2024
567a050
Update yarn.lock
farisashai Jan 7, 2024
820764f
Configure PWA
farisashai Jan 7, 2024
fffc6e6
Disable lint in service worker
farisashai Jan 7, 2024
7de251b
fix navbar border
farisashai Jan 7, 2024
7631a04
Merge branch 'main' into faris/misc-fixes
farisashai Jan 10, 2024
f2a60c1
Update style.module.scss
farisashai Jan 10, 2024
fe54e3e
Merge branch 'faris/misc-fixes' of https://github.com/acmucsd/members…
farisashai Jan 10, 2024
9796bd4
date selection
farisashai Jan 10, 2024
4d8ec54
center page
farisashai Jan 10, 2024
f7eed9b
center grid items better
farisashai Jan 10, 2024
e930248
Merge branch 'main' into faris/misc-fixes
farisashai Jan 19, 2024
0fc9bac
fixes
farisashai Jan 19, 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
7 changes: 6 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@
}
]
},
"ignorePatterns": "src/**/*.d.ts"
"ignorePatterns": [
"src/**/*.d.ts",
"**/public/sw.js",
"**/public/workbox-*.js",
"**/public/worker-*.js"
]
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# PWA files
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
9 changes: 8 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const env = process.env.NODE_ENV;
const isDevelopment = env !== 'production';

const withPWA = require('next-pwa')({
dest: 'public',
register: true,
skipWaiting: true,
disable: isDevelopment,
});

/** @type {import('next').NextConfig} */
const nextConfig = {
eslint: {
Expand Down Expand Up @@ -37,4 +44,4 @@ const nextConfig = {
},
};

module.exports = nextConfig;
module.exports = withPWA(nextConfig);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"ics": "^3.7.2",
"luxon": "^3.3.0",
"next": "^13.2.5-canary.30",
"next-pwa": "^5.6.0",
"next-themes": "^0.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
Binary file added public/icon-192x192.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/icon-256x256.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/icon-384x384.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/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 27 additions & 10 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
{
"short_name": "ACM Membership Portal",
"name": "Association for Computing Machinery at UC San Diego Student Membership Portal",
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone",
"scope": "/",
"start_url": "/",
"name": "ACM at UCSD Membership Portal",
"short_name": "ACM Portal",
"description": "Association for Computing Machinery at UC San Diego Student Membership Portal",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 16x16",
"type": "image/x-icon"
"src": "/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
]
}
8 changes: 2 additions & 6 deletions src/components/common/Carousel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { ReactNode } from 'react';
import type { PropsWithChildren } from 'react';
import styles from './style.module.scss';

interface CarouselProps {
children: ReactNode[];
}

const Carousel = ({ children }: CarouselProps) => {
const Carousel = ({ children }: PropsWithChildren) => {
return <div className={styles.slider}>{children}</div>;
};

Expand Down
29 changes: 11 additions & 18 deletions src/components/common/CommunityLogo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
import { communityLogos } from '@/lib/constants/communityLogos';
import { Community } from '@/lib/types/enums';
import { capitalize } from '@/lib/utils';
import Image from 'next/image';

import AILogo from '@/public/assets/acm-logos/communities/ai.png';
import CyberLogo from '@/public/assets/acm-logos/communities/cyber.png';
import DesignLogo from '@/public/assets/acm-logos/communities/design.png';
import HackLogo from '@/public/assets/acm-logos/communities/hack.png';
import ACMLogo from '@/public/assets/acm-logos/general/light-mode.png';

interface CommunityLogoProps {
community: string;
size: number;
}

const CommunityLogo = ({ community, size }: CommunityLogoProps) => {
switch (community.toLowerCase()) {
case 'hack':
return <Image src={HackLogo} width={size} alt="ACM Hack Logo" />;
case 'ai':
return <Image src={AILogo} width={size} alt="ACM AI Logo" />;
case 'cyber':
return <Image src={CyberLogo} width={size} alt="ACM Cyber Logo" />;
case 'design':
return <Image src={DesignLogo} width={size} alt="ACM Design Logo" />;
default:
return <Image src={ACMLogo} width={size} alt="ACM General Logo" />;
}
const formattedName = capitalize(community) as Community;

if (!Object.values(Community).includes(formattedName))
return <Image src={communityLogos.General} width={size} alt="ACM General Logo" />;

return (
<Image src={communityLogos[formattedName]} width={size} alt={`ACM ${formattedName} Logo`} />
);
};

export default CommunityLogo;
8 changes: 5 additions & 3 deletions src/components/common/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ interface Option {
label: string;
}

export const DIVIDER = '----';

interface DropdownProps {
name: string;
ariaLabel: string;
options: (Option | '---')[];
options: (Option | typeof DIVIDER)[];
value: string;
onChange: (value: string) => void;
}
Expand All @@ -30,7 +32,7 @@ const Dropdown = ({ name, ariaLabel, options, value, onChange }: DropdownProps)
const optionButtons: ReactNode[] = [];
let dividers = 0;
options.forEach(option => {
if (option === '---') {
if (option === DIVIDER) {
optionButtons.push(<hr key={dividers} />);
dividers += 1;
} else {
Expand Down Expand Up @@ -78,7 +80,7 @@ const Dropdown = ({ name, ariaLabel, options, value, onChange }: DropdownProps)
aria-label={ariaLabel}
>
{options.map(option =>
option !== '---' ? (
option !== DIVIDER ? (
<option value={option.value} key={option.value}>
{option.label}
</option>
Expand Down
8 changes: 5 additions & 3 deletions src/components/events/EventDisplay/style.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.container {
display: flex;
flex-wrap: wrap;
gap: 1rem;
column-gap: 1rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
place-items: center;
row-gap: 2rem;
}
1 change: 1 addition & 0 deletions src/components/home/Hero/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
}

.image {
margin: 0 auto;
max-height: 1080px;
max-width: 1920px;
object-fit: cover;
Expand Down
10 changes: 5 additions & 5 deletions src/components/layout/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ThemeToggle from '@/components/common/ThemeToggle';
import { config } from '@/lib';
import { useWindowSize } from '@/lib/hooks/useWindowSize';
import { PermissionService } from '@/lib/services';
import type { PrivateProfile } from '@/lib/types/apiResponses';
import { UserAccessType } from '@/lib/types/enums';
import LightModeLogo from '@/public/assets/acm-logos/general/light-mode.png';
import CalendarIcon from '@/public/assets/icons/calendar-icon.svg';
import HomeIcon from '@/public/assets/icons/home-icon.svg';
Expand All @@ -16,9 +16,9 @@ import { memo, useCallback, useEffect, useRef, useState } from 'react';
import styles from './style.module.scss';

interface NavbarProps {
user?: PrivateProfile;
accessType?: UserAccessType;
}
const Navbar = ({ user }: NavbarProps) => {
const Navbar = ({ accessType }: NavbarProps) => {
const size = useWindowSize();
const headerRef = useRef<HTMLHeadElement>(null);

Expand Down Expand Up @@ -47,7 +47,7 @@ const Navbar = ({ user }: NavbarProps) => {
if (!isMobile) setMenuOpen(false);
}, [isMobile]);

if (!user) {
if (!accessType) {
return (
<header className={styles.header}>
<div className={styles.content}>
Expand All @@ -62,7 +62,7 @@ const Navbar = ({ user }: NavbarProps) => {
);
}

const isAdmin = PermissionService.canViewAdminPage.includes(user.accessType);
const isAdmin = PermissionService.canViewAdminPage.includes(accessType);

return (
<header className={styles.header} ref={headerRef}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Navbar/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
background: vars.$wainbow;
height: 0.25rem;
margin: 0 -1rem;
width: calc(100% + 2rem);
width: 100vw;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/layout/PageLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Navbar from '@/components/layout/Navbar';
import type { PrivateProfile } from '@/lib/types/apiResponses';
import { UserAccessType } from '@/lib/types/enums';
import { PropsWithChildren } from 'react';
import styles from './style.module.scss';

interface LayoutProps {
user?: PrivateProfile;
accessType?: UserAccessType;
}

const PageLayout = ({ user, children }: PropsWithChildren<LayoutProps>) => (
const PageLayout = ({ accessType, children }: PropsWithChildren<LayoutProps>) => (
<>
<Navbar user={user} />
<Navbar accessType={accessType} />
<main className={styles.content}>{children}</main>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/store/HelpModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import Step3 from '@/public/assets/graphics/store/step3.svg';
import Step4 from '@/public/assets/graphics/store/step4.svg';
import ArrowLeftIcon from '@/public/assets/icons/arrow-left.svg';
import ArrowRightIcon from '@/public/assets/icons/arrow-right.svg';
import { ReactNode } from 'react';
import type { PropsWithChildren } from 'react';
import styles from './style.module.scss';

interface StepProps {
step: number;
children?: ReactNode;
}
const Step = ({ step, children }: StepProps) => {

const Step = ({ step, children }: PropsWithChildren<StepProps>) => {
const Left = step > 1 ? 'a' : 'span';
const Right = step < 4 ? 'a' : 'span';
return (
Expand Down
16 changes: 16 additions & 0 deletions src/lib/constants/communityLogos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable import/prefer-default-export */
import { Community } from '@/lib/types/enums';
import AILogo from '@/public/assets/acm-logos/communities/ai.png';
import CyberLogo from '@/public/assets/acm-logos/communities/cyber.png';
import DesignLogo from '@/public/assets/acm-logos/communities/design.png';
import HackLogo from '@/public/assets/acm-logos/communities/hack.png';
import ACMLogo from '@/public/assets/acm-logos/general/light-mode.png';
import type { StaticImageData } from 'next/image';

export const communityLogos: Record<Community, StaticImageData> = {
AI: AILogo,
Cyber: CyberLogo,
Design: DesignLogo,
Hack: HackLogo,
General: ACMLogo,
};
9 changes: 9 additions & 0 deletions src/lib/services/CookieService.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CookieType } from '@/lib/types/enums';
import { deleteCookie, getCookie, setCookie } from 'cookies-next';
import type { OptionsType } from 'cookies-next/lib/types';

Expand Down Expand Up @@ -33,3 +34,11 @@ export const deleteClientCookie = (key: string): void => {
export const deleteServerCookie = (key: string, options: OptionsType): void => {
deleteCookie(key, options);
};

export const clearClientCookies = (): void => {
Object.keys(CookieType).forEach(key => deleteClientCookie(key));
};

export const clearServerCookies = (options: OptionsType): void => {
Object.keys(CookieType).forEach(key => deleteServerCookie(key, options));
};
7 changes: 6 additions & 1 deletion src/lib/services/PermissionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const canViewAdminPage = [
/**
* @returns Array of all possible user access types
*/
export const allUserTypes = () => Object.values(UserAccessType) as UserAccessType[];
export const allUserTypes = Object.values(UserAccessType);

/**
* @param types to exclude from array
Expand All @@ -32,3 +32,8 @@ export const allUserTypesExcept = (types: UserAccessType[]): UserAccessType[] =>
const values = Object.keys(UserAccessType) as UserAccessType[];
return values.filter(value => !types.includes(value));
};

/**
* @returns Valid logged in user types
*/
export const loggedInUser = allUserTypesExcept([UserAccessType.RESTRICTED]);
8 changes: 8 additions & 0 deletions src/lib/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ export enum CookieType {
ACCESS_TOKEN = 'ACCESS_TOKEN',
}

export enum Community {
HACK = 'Hack',
AI = 'AI',
CYBER = 'Cyber',
DESIGN = 'Design',
GENERAL = 'General',
}

export enum UserAccessType {
RESTRICTED = 'RESTRICTED',
STANDARD = 'STANDARD',
Expand Down
3 changes: 3 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,17 @@ export const getDateRange = (sort: string | number) => {
}
case 'past-week': {
from = now - DAY_SECONDS * 7;
to = now;
break;
}
case 'past-month': {
from = now - DAY_SECONDS * 28;
to = now;
break;
}
case 'past-year': {
from = now - DAY_SECONDS * 365;
to = now;
break;
}
case 'all-time': {
Expand Down
14 changes: 1 addition & 13 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import { SignInButton } from '@/components/auth';
import { VerticalForm } from '@/components/common';
import { Navbar } from '@/components/store';
import { config } from '@/lib';
import { PrivateProfile } from '@/lib/types/apiResponses';
import Cat404 from '@/public/assets/graphics/cat404.png';
import styles from '@/styles/pages/404.module.scss';
import Image from 'next/image';
import { useRouter } from 'next/router';

interface PageNotFoundProps {
user?: PrivateProfile;
}

const PageNotFound = ({ user }: PageNotFoundProps) => {
const router = useRouter();
const PageNotFound = () => {
return (
<div style={{ display: 'flex', flexDirection: 'column', height: 'calc(100vh - 8.25rem)' }}>
{user && router.asPath.startsWith(config.storeRoute) && (
<Navbar balance={user.credits} showBack />
)}
<VerticalForm style={{ alignItems: 'center', flex: 'auto', height: 'unset' }}>
<h1 className={styles.header}>Whoops, we ended up on the wrong page!</h1>
<Image src={Cat404} width={256} height={256} alt="Sad Cat" />
Expand Down
Loading