Skip to content

Commit

Permalink
Ensure majors list has at least one major (#48)
Browse files Browse the repository at this point in the history
* validate that majors aren't empty

* add 'Engineering Undeclared' option to dropdown

* fix linting and prettier

* add block I

* fix lint

* fix
  • Loading branch information
devksingh4 authored Sep 15, 2024
1 parent 5828309 commit 37ef275
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/util/structs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List, Literal, Optional
from pydantic import BaseModel, ConfigDict, EmailStr, AnyUrl, Field, HttpUrl, validator
from pydantic import BaseModel, ConfigDict, EmailStr, AnyUrl, Field, HttpUrl
from .oai import LENGTH_LIMIT

class DegreeListing(BaseModel):
Expand All @@ -8,7 +8,7 @@ class DegreeListing(BaseModel):
yearStarted: int
yearEnded: Optional[int] = None
institution: str
major: List[str]
major: List[str] = Field(min_length=1)
minor: List[str]
gpa: float

Expand Down
2 changes: 1 addition & 1 deletion clientv2/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['mantine'],
extends: ['mantine', 'prettier'],
parserOptions: {
project: './tsconfig.json',
},
Expand Down
1 change: 1 addition & 0 deletions clientv2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@ungap/with-resolvers": "^0.1.0",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"eslint-config-prettier": "^9.1.0",
"file-saver": "^2.0.5",
"jszip": "^3.10.1",
"pdfjs-dist": "^4.5.136",
Expand Down
Binary file added clientv2/src/blockI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions clientv2/src/components/LoginComponent/AcmLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { Button, ButtonProps } from '@mantine/core';
import { Button, ButtonProps, Image } from '@mantine/core';
import { useMsal } from '@azure/msal-react';
import { InteractionStatus } from '@azure/msal-browser';
import { useAuth } from '../AuthContext';
import blockI from '@/blockI.png';

export function AcmLoginButton(props: ButtonProps & React.ComponentPropsWithoutRef<'button'>) {
const { loginMsal } = useAuth();
const { inProgress } = useMsal();
return (
<Button
disabled={inProgress === InteractionStatus.Login}
leftSection={null}
leftSection={
<Image
src={blockI}
style={{ height: '1.5em', width: 'auto', paddingRight: '0.8em' }}
></Image>
}
color="#FF5F05"
variant="filled"
{...props}
Expand Down
4 changes: 2 additions & 2 deletions clientv2/src/components/LoginComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function LoginComponent(props: PaperProps) {
<Divider label="Student Login" labelPosition="center" my="md" size="lg" />

<Group grow mb="md" mt="md">
<AcmLoginButton radius="xl">Sign in with Illinois NetID</AcmLoginButton>
<AcmLoginButton radius="lg">Sign in with Illinois NetID</AcmLoginButton>
</Group>
<Alert
title={<Title order={5}>Paid ACM@UIUC Members Only</Title>}
Expand All @@ -45,7 +45,7 @@ export function LoginComponent(props: PaperProps) {
</Alert>
<Divider label="Recruiter Login" labelPosition="center" my="md" size="lg" />
<Group grow mb="md" mt="md">
<PartnerLoginButton radius="xl">ACM@UIUC Partner Login</PartnerLoginButton>
<PartnerLoginButton radius="lg">ACM@UIUC Partner Login</PartnerLoginButton>
</Group>
</Paper>
);
Expand Down
1 change: 1 addition & 0 deletions clientv2/src/components/ProfileViewer/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const otherMajors = [
'Theatre',
'Urban Planning',
'Writing Studies',
'Engineering Undeclared',
];

export const degreeOptions = [
Expand Down
10 changes: 9 additions & 1 deletion clientv2/src/pages/student/StudentProfile.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ export function StudentHomePage() {
if (studentData.degrees.length === 0) {
return showErrorSaveNotification('You must specify at least one degree.');
}
for (let i = 0; i < studentData.degrees.length; i++) {
const item = studentData.degrees[i];
if (item.major.length === 0) {
return showErrorSaveNotification(`Degree ${i + 1} does not have a major.`);
}
}
try {
if (file && file.size !== 0) {
setLoading(true);
Expand Down Expand Up @@ -251,7 +257,9 @@ export function StudentHomePage() {
});
setEditToggle(false);
} else if (response.status && response.status === 403) {
showErrorSaveNotification('Failed to validate form.');
showErrorSaveNotification(
'Failed to validate profile. Please ensure all fields are valid and try again.'
);
} else {
showErrorSaveNotification();
}
Expand Down
12 changes: 12 additions & 0 deletions clientv2/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3439,6 +3439,7 @@ __metadata:
eslint-config-airbnb: "npm:19.0.4"
eslint-config-airbnb-typescript: "npm:^18.0.0"
eslint-config-mantine: "npm:^3.2.0"
eslint-config-prettier: "npm:^9.1.0"
eslint-plugin-import: "npm:^2.29.1"
eslint-plugin-jsx-a11y: "npm:^6.9.0"
eslint-plugin-react: "npm:^7.34.3"
Expand Down Expand Up @@ -5242,6 +5243,17 @@ __metadata:
languageName: node
linkType: hard

"eslint-config-prettier@npm:^9.1.0":
version: 9.1.0
resolution: "eslint-config-prettier@npm:9.1.0"
peerDependencies:
eslint: ">=7.0.0"
bin:
eslint-config-prettier: bin/cli.js
checksum: 10c0/6d332694b36bc9ac6fdb18d3ca2f6ac42afa2ad61f0493e89226950a7091e38981b66bac2b47ba39d15b73fff2cd32c78b850a9cf9eed9ca9a96bfb2f3a2f10d
languageName: node
linkType: hard

"eslint-import-resolver-node@npm:^0.3.9":
version: 0.3.9
resolution: "eslint-import-resolver-node@npm:0.3.9"
Expand Down

0 comments on commit 37ef275

Please sign in to comment.