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

Feature: add update form #437

Merged
merged 47 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ff3c770
fix: improved dev container speed
tran-christian Aug 9, 2023
893766b
fix: minor configuration change for dev container and update to script
tran-christian Aug 9, 2023
4c3edd1
feat: added update form
tran-christian Aug 16, 2023
9a3bb94
chore: merge main
tran-christian Aug 16, 2023
e5a53b9
feat: fixed space issue with update form
tran-christian Aug 17, 2023
7152ac1
fix: fix conflict and removed unused dependencies
tran-christian Aug 18, 2023
941c2f2
feat: add dark mode
tran-christian Aug 21, 2023
aff6ed7
feat(darkmode): minor styling update for darkmode
tran-christian Aug 22, 2023
6ed0714
feat(darkmode): added working light and dark mode with persistent sta…
tran-christian Aug 23, 2023
e3106f1
chore(darkmode): remove next-themes
tran-christian Aug 23, 2023
26e6e5c
chore(darkmode): remove random function
tran-christian Aug 23, 2023
356a6da
feat(darkmode): remove unused type
tran-christian Aug 24, 2023
6c3bdf2
fix(dark mode): redesigned mobile nav and login to accomodate dark mode
tran-christian Oct 10, 2023
289966d
fix(dark mode): added skeleton for component flash that would occur f…
tran-christian Oct 10, 2023
6383503
fix(dark mode): fixing user component flash when logged in
tran-christian Oct 10, 2023
d7cb335
feat(dark mode): default user profile pics
tran-christian Oct 10, 2023
5f70cc1
chore(merge main): merge branch 'main' into dark-mode
tran-christian Oct 10, 2023
7265616
fix(dark mode): fix dark mode in form editor and other areas
tran-christian Oct 10, 2023
13ed84b
chore(merge darkmode branch): merge darkmode branch to update form br…
tran-christian Oct 12, 2023
335a2c0
fix(light mode styling): fix light mode styling text
tran-christian Oct 12, 2023
8ed558b
chore(main): merge main
tran-christian Aug 15, 2024
f696ef3
fix(reviewcard): fix style flash when reloading page
tran-christian Aug 16, 2024
2eb7c31
fix(markdown): add other markdown plugins and formatted files
tran-christian Aug 16, 2024
703c733
fix(profile micon): fix get calling profile icon
tran-christian Aug 16, 2024
7704fa8
chore(types): extract generic type `TNullable` to avoid redundancy
awpala Aug 16, 2024
28abca6
chore: simplify backend imports
awpala Aug 16, 2024
9b6ed9f
fix(devcontainer): revert setting to make user `root` the default
awpala Aug 16, 2024
d974188
chore(Dockerfile): minor cleanup and commenting
awpala Aug 16, 2024
c067ac2
fix(devcontainer): fix dependency install and add name `omshub-websit…
awpala Aug 16, 2024
9730323
chore(devcontainer): fix formatting
awpala Aug 16, 2024
58ca4a6
chore(devcontainer): update VS Code extensions
awpala Aug 16, 2024
bd86764
chore(devcontainer): rearrange position of property
awpala Aug 16, 2024
5e6355a
fix(AuthContext): remove email from local storage on logout
awpala Aug 16, 2024
cca3255
chore(example.env): clarify examples for env var `TZ`
awpala Aug 16, 2024
bdd4de4
chore(devcontainer): add caching for firebase emulator JAR files
awpala Aug 17, 2024
c787c08
fix: darkmode
tran-christian Aug 18, 2024
9cddb30
chore(fmt): format files
tran-christian Aug 18, 2024
8b302f2
fix(reviewform): update nullable types
tran-christian Aug 18, 2024
321a281
chore(tiptap): remove unused tiptap file
tran-christian Aug 18, 2024
8cb585b
chore: fix usage of `TNullable` type
awpala Aug 19, 2024
1b2a026
chore: merge 'origin/main' into update-form
awpala Aug 19, 2024
14d69ef
fix(labeler): fix filename
awpala Aug 19, 2024
ad40323
fix(labeler): update filepath for config
awpala Aug 19, 2024
d46007c
fix: correct labeler GitHub Actions workflow
awpala Aug 19, 2024
cadb967
fix(labeler): fix filename
awpala Aug 19, 2024
d6b50d1
chore(label): rename labeler to label
tran-christian Aug 20, 2024
93216a7
fix(label): checkout code for labeler.yml
tran-christian Aug 20, 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
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
ARG VARIANT="20-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}

RUN apt-get update && apt-get install -y openjdk-11-jdk \
RUN apt-get update && apt-get install -y \
# Note: `openjdk-11-jdk` required for Firebase Emulators suite
openjdk-11-jdk \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
30 changes: 13 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,36 @@
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": ["--name", "omshub-website-dev"],
"mounts": [
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
// cache `node_modules`
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume",
// cache firebase emulators suite JAR files -- ref: https://firebase.google.com/docs/emulator-suite/install_and_configure#integrate_with_your_ci_system
"source=${localWorkspaceFolderBasename}-fb_emulators_root,target=/root/.cache/firebase/emulators/,type=volume", // root user
"source=${localWorkspaceFolderBasename}-fb_emulators_nonroot,target=/home/${containerUser}/.cache/firebase/emulators/,type=volume" // non-root user (e.g., `node`)
],
"customizations": {
"vscode": {
"settings": {},
"workspaceFolder":"${containerWorkspaceFolder}",
"workspaceFolder": "${containerWorkspaceFolder}",
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-azuretools.vscode-docker",
"oderwat.indent-rainbow",
"mhutchie.git-graph"
],
]
}
},
"containerEnv": {
"CHOKIDAR_USEPOLLING":"true",
"WATCHPACK_POLLING":"true"
"CHOKIDAR_USEPOLLING": "true",
"WATCHPACK_POLLING": "true"
},
"forwardPorts": [
// Application and Storybook
3000,
6006,
3000, 6006,
// Local Firebase Emulator Suite
4000,
4400,
4500,
5000,
5001,
8080,
9099,
9150,
9199
4000, 4400, 4500, 5000, 5001, 8080, 9099, 9150, 9199
],
"portsAttributes": {
// Application and Storybook
Expand Down
17 changes: 11 additions & 6 deletions context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TContextProviderProps,
TSignInAction,
} from '@context/types';
import { TNullable } from '@globals/types';
import { isGTEmail, isOutlookEmail } from '@globals/utilities';
import {
FacebookAuthProvider,
Expand All @@ -23,28 +24,31 @@ import router from 'next/router';
import { createContext, useContext, useEffect, useState } from 'react';

export type TAuthContext = {
user: FirebaseAuthUser | null;
user: TNullable<FirebaseAuthUser>;
loading: Boolean;
signInWithProvider: TSignInAction;
signWithMagic: TSignInAction;
logout: () => void;
};

const AuthContext = createContext<TAuthContext | null>(null);
// local storage key
const EMAIL_FOR_SIGN_IN = 'emailForSignIn';

const AuthContext = createContext<TNullable<TAuthContext>>(null);

export const useAuth = () => useContext(AuthContext);

// eslint-disable-next-line no-undef
export const AuthContextProvider = ({ children }: TContextProviderProps) => {
const [user, setUser] = useState<FirebaseAuthUser | null>(null);
const [user, setUser] = useState<TNullable<FirebaseAuthUser>>(null);
const [loading, setLoading] = useState<Boolean>(true);
const { setAlert } = useAlert();

useEffect(() => {
setLoading(true);
const unsubscribe = onAuthStateChanged(
auth,
(user: FirebaseAuthUser | null) => {
(user: TNullable<FirebaseAuthUser>) => {
if (user) {
setUser(user);
setLoading(false);
Expand All @@ -55,7 +59,7 @@ export const AuthContextProvider = ({ children }: TContextProviderProps) => {
},
);
// OAuth Providers
const email = window.localStorage.getItem('emailForSignIn');
const email = window.localStorage.getItem(EMAIL_FOR_SIGN_IN);

if (isSignInWithEmailLink(auth, window.location.href) && !!email) {
// Sign the user in
Expand All @@ -74,6 +78,7 @@ export const AuthContextProvider = ({ children }: TContextProviderProps) => {
};
const logout = async () => {
setUser(null);
window.localStorage.removeItem(EMAIL_FOR_SIGN_IN);
await signOut(auth);
router.push('/');
};
Expand All @@ -84,7 +89,7 @@ export const AuthContextProvider = ({ children }: TContextProviderProps) => {
handleCodeInApp: true,
}).then(() => {
// Save the users email to verify it after they access their email
window.localStorage.setItem('emailForSignIn', email);
window.localStorage.setItem(EMAIL_FOR_SIGN_IN, email);
const additionalInstructions =
isGTEmail(email) || isOutlookEmail(email)
? ' NOTE: gatech.edu or outlook.com domain may require release from Quarantine. See https://security.microsoft.com/quarantine'
Expand Down
57 changes: 31 additions & 26 deletions context/ColorContext.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { TContextProviderProps } from '@context/types';
import { Experimental_CssVarsProvider as CssVarsProvider, experimental_extendTheme as extendTheme } from '@mui/material/styles';
import {
Experimental_CssVarsProvider as CssVarsProvider,
experimental_extendTheme as extendTheme,
} from '@mui/material/styles';
import { getDesignTokens } from '@src/theme';

const { palette: lightPalette } = getDesignTokens('light');
const { palette: darkPalette } = getDesignTokens('dark');

export const theme = extendTheme({
typography: {
fontFamily:[
fontFamily: [
'-apple-system',
'BlinkMacSystemFont',
'"Segoe UI"',
Expand All @@ -20,34 +23,36 @@ export const theme = extendTheme({
'"Segoe UI Symbol"',
].join(','),
},
cssVarPrefix:'omshub',
colorSchemes:{
light:{
palette: lightPalette
cssVarPrefix: 'omshub',
colorSchemes: {
light: {
palette: lightPalette,
},
dark: {
palette: darkPalette,
},
dark:{
palette: darkPalette
}
},
components: {
MuiDrawer: {
styleOverrides: {
paper: {
backgroundColor: "123",
boxShadow:"",
backgroundImage:"",
}
}
}
}
})
MuiDrawer: {
styleOverrides: {
paper: {
backgroundColor: '123',
boxShadow: '',
backgroundImage: '',
},
},
},
},
});

export const ColorProvider = ({ children }: TContextProviderProps) => {


return (
<CssVarsProvider theme={theme} defaultMode="system" disableTransitionOnChange>
{children}
</CssVarsProvider>
<CssVarsProvider
theme={theme}
defaultMode='system'
disableTransitionOnChange
>
{children}
</CssVarsProvider>
);
};
};
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=
# firebase emulator suite vars
NEXT_PUBLIC_IS_EMULATOR_MODE= # <true | false>
NEXT_PUBLIC_FIRESTORE_EMULATOR_HOST= # <localhost:8080> -- ref: https://stackoverflow.com/a/66790889
TZ= # <US/Pacific | US/Mountain | US/Central | US/Eastern | etc.> -- Use same timezone as local to match NodeJS/Emulator to it; ref: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
12 changes: 6 additions & 6 deletions firebase/utilityFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TCourseId, TNullableNumber } from '@globals/types';
import { TCourseId, TNullable } from '@globals/types';
const LEN_SIMPLE_COURSE_NUMBER = 5; // DD-CCCC-... (e.g., CS-6200-...) [total 5 * `-`]
const LEN_COMPOUND_COURSE_NUMBER = 6; // DD-CCCC-CCC-... (e.g., CS-8803-O08-...) [total 6 * `-`]
const SEPARATOR_TOKEN = '-';
Expand Down Expand Up @@ -44,7 +44,7 @@ export const parseReviewId = (reviewId: string) => {
};

export type TAveragesData = {
oldAverage?: TNullableNumber;
oldAverage?: TNullable<number>;
oldCount?: number;
newCount: number;
oldValue?: number;
Expand Down Expand Up @@ -87,10 +87,10 @@ export const updateAverage = ({
type TAveragesInputData = {
courseId: TCourseId;
// N.B. `avg`s are null when `numReviews` === 0
avgWorkload?: TNullableNumber;
avgDifficulty?: TNullableNumber;
avgOverall?: TNullableNumber;
avgStaffSupport?: TNullableNumber;
avgWorkload?: TNullable<number>;
avgDifficulty?: TNullable<number>;
avgOverall?: TNullable<number>;
avgStaffSupport?: TNullable<number>;
oldWorkload?: number;
oldDifficulty?: number;
oldOverall?: number;
Expand Down
19 changes: 9 additions & 10 deletions globals/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* --- TYPE DEFINITIONS --- */

export type TNullableNumber = number | null;
export type TNullableString = string | null;
export type TNullable<T> = T | null;
export type TObjectKey = string | number;

export type TKeyMap = {
Expand All @@ -28,7 +27,7 @@ export interface CourseDataStatic {
name: TCourseName;
departmentId: TDepartmentId;
courseNumber: string;
url: TNullableString; // url may be null (i.e., no existing page)
url: TNullable<string>; // url may be null (i.e., no existing page)
aliases: string[];
isDeprecated: boolean;
isFoundational: boolean;
Expand All @@ -38,10 +37,10 @@ export interface CourseDataStatic {
export interface CourseDataDynamic {
courseId: TCourseId;
numReviews: number;
avgWorkload: TNullableNumber;
avgDifficulty: TNullableNumber;
avgOverall: TNullableNumber;
avgStaffSupport: TNullableNumber;
avgWorkload: TNullable<number>;
avgDifficulty: TNullable<number>;
avgOverall: TNullable<number>;
avgStaffSupport: TNullable<number>;
reviewsCountsByYearSem: TReviewsCountsByYearSemObject;
}

Expand All @@ -56,7 +55,7 @@ export interface Review {
reviewerId: string; // `userId` of review author
isGTVerifiedReviewer: boolean;
created: number; // Unix timestamp
modified: TNullableNumber; // Unix timestamp
modified: TNullable<number>; // Unix timestamp
body: string;
upvotes: number;
downvotes: number;
Expand All @@ -78,14 +77,14 @@ export interface Review {
programmingLanguagesIds?: TProgrammingLanguageId[];
/* --- user background review data --- */
preparation?: TRatingScale;
omsCoursesTaken?: TNullableNumber;
omsCoursesTaken?: TNullable<number>;
hasRelevantWorkExperience?: boolean;
experienceLevelId?: TExperienceLevelId;
gradeId?: string;
}

export interface User {
userId: TNullableString; // invalid request returns null
userId: TNullable<string>; // invalid request returns null
hasGTEmail: boolean;
educationLevelId?: TEducationLevelId;
subjectAreaId?: string;
Expand Down
11 changes: 9 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module.exports = {
reactStrictMode: true,

env: {
baseUrl: process.env.BASE_URL,
apiKey: process.env.API_KEY,
Expand All @@ -12,8 +13,14 @@ module.exports = {
appId: process.env.APP_ID,
measurementId: process.env.MEASUREMENT_ID,
},
compiler:{
compiler: {
removeConsole: true,
styledComponents: true,
},
transpilePackages: ['@mui/system', '@mui/material', '@mui/icons-material','@mui/styles'],
transpilePackages: [
'@mui/system',
'@mui/material',
'@mui/icons-material',
'@mui/styles',
],
};
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"npm": "please-use-yarn"
},
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev",
"dev": "cross-env NODE_OPTIONS='--inspect' next dev",
"build": "next build",
"build-sitemap": "next-sitemap",
"start": "next start",
Expand Down Expand Up @@ -38,17 +38,22 @@
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.14.5",
"@mui/x-data-grid": "^6.6.0",
"@toast-ui/editor-plugin-code-syntax-highlight": "^3.1.0",
"@toast-ui/react-editor": "^3.2.2",
"@types/prismjs": "^1.26.4",
"firebase": "^9.15.0",
"html-to-image": "^1.11.11",
"isomorphic-dompurify": "^1.8.0",
"next": "^14.2.3",
"prismjs": "^1.29.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.45.2",
"react-markdown": "^8.0.5",
"rehype-raw": "^6.1.1",
"remark-gfm": "^3.0.1",
"react-markdown": "^9.0.1",
"rehype-katex": "^7.0.0",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"string-width": "^6.1.0",
"swr": "^2.2.4",
"tsconfig-paths-webpack-plugin": "^4.0.0"
Expand Down
Loading