From 1f296349fd16351a7e66f0c3c1dd78f6d973ecb1 Mon Sep 17 00:00:00 2001 From: Quang Anh Date: Mon, 8 Apr 2024 22:59:55 -0500 Subject: [PATCH 1/5] Fix FE file structure --- apps/frontend/src/App.tsx | 18 +-- .../{CourseDetail => }/CourseDetail.tsx | 22 +-- apps/frontend/src/Components/CourseTree.tsx | 145 ++++++++++++++++++ .../src/Components/CourseTree/CourseTree.tsx | 129 ---------------- .../src/Components/{Navbar => }/Navbar.tsx | 8 +- .../{NavbarLinks => }/NavbarLinks.tsx | 11 +- .../src/Screens/{Calendar => }/Calendar.tsx | 10 +- apps/frontend/src/Screens/DetailScreen.tsx | 2 +- .../PersonalizedRoadmap.tsx | 26 ++-- .../src/Screens/{Roadmap => }/Roadmap.tsx | 8 +- .../src/{Screens/Roadmap => Utils}/data.ts | 0 .../Calendar => Utils}/exportCalendar.ts | 10 +- .../NavbarLinks => Utils}/links.ts | 0 .../src/{Screens/Calendar => Utils}/types.ts | 0 .../CourseTree => css}/CourseTree.css | 0 .../NavbarLinks => css}/NavbarLinks.css | 0 .../Roadmap => css}/RoadmapScreen.css | 0 apps/locust/{hello.py => loadTest.py} | 2 - docker-compose.yml | 15 +- 19 files changed, 203 insertions(+), 203 deletions(-) rename apps/frontend/src/Components/{CourseDetail => }/CourseDetail.tsx (70%) create mode 100644 apps/frontend/src/Components/CourseTree.tsx delete mode 100644 apps/frontend/src/Components/CourseTree/CourseTree.tsx rename apps/frontend/src/Components/{Navbar => }/Navbar.tsx (97%) rename apps/frontend/src/Components/{NavbarLinks => }/NavbarLinks.tsx (68%) rename apps/frontend/src/Screens/{Calendar => }/Calendar.tsx (93%) rename apps/frontend/src/Screens/{PersonalizedRoadmap => }/PersonalizedRoadmap.tsx (87%) rename apps/frontend/src/Screens/{Roadmap => }/Roadmap.tsx (90%) rename apps/frontend/src/{Screens/Roadmap => Utils}/data.ts (100%) rename apps/frontend/src/{Screens/Calendar => Utils}/exportCalendar.ts (89%) rename apps/frontend/src/{Components/NavbarLinks => Utils}/links.ts (100%) rename apps/frontend/src/{Screens/Calendar => Utils}/types.ts (100%) rename apps/frontend/src/{Components/CourseTree => css}/CourseTree.css (100%) rename apps/frontend/src/{Components/NavbarLinks => css}/NavbarLinks.css (100%) rename apps/frontend/src/{Screens/Roadmap => css}/RoadmapScreen.css (100%) rename apps/locust/{hello.py => loadTest.py} (99%) diff --git a/apps/frontend/src/App.tsx b/apps/frontend/src/App.tsx index 3bb62ca..f5c7e10 100644 --- a/apps/frontend/src/App.tsx +++ b/apps/frontend/src/App.tsx @@ -1,20 +1,14 @@ import React, {useEffect, useState} from 'react'; import './App.css'; import MainScreen from './Screens/MainScreen'; -import Calendar from './Screens/Calendar/Calendar'; +import Calendar from './Screens/Calendar'; import AddDropCourses from './Screens/AddDropCourses'; -import Roadmap from './Screens/Roadmap/Roadmap'; -import PersonalizedRoadmap - from './Screens/PersonalizedRoadmap/PersonalizedRoadmap'; -import { - Routes, - Route, - useNavigate, - Navigate, -} from 'react-router-dom'; +import Roadmap from './Screens/Roadmap'; +import PersonalizedRoadmap from './Screens/PersonalizedRoadmap'; +import {Routes, Route, useNavigate, Navigate} from 'react-router-dom'; import LookUpScreen from './Screens/LookUpScreen'; import CoursesScreen from './Screens/CoursesScreen'; -import Navbar from './Components/Navbar/Navbar'; +import Navbar from './Components/Navbar'; import LoginScreen from './Screens/LoginScreen'; import SignupScreen from './Screens/SignupScreen'; import DetailScreen from './Screens/DetailScreen'; @@ -26,7 +20,7 @@ const App = () => { const navigate = useNavigate(); const [isLoggedIn, setLoggedIn] = useState( - getTokenFromCookie() !== undefined, + getTokenFromCookie() !== undefined, ); useEffect(() => { diff --git a/apps/frontend/src/Components/CourseDetail/CourseDetail.tsx b/apps/frontend/src/Components/CourseDetail.tsx similarity index 70% rename from apps/frontend/src/Components/CourseDetail/CourseDetail.tsx rename to apps/frontend/src/Components/CourseDetail.tsx index 827a8b4..fd82733 100644 --- a/apps/frontend/src/Components/CourseDetail/CourseDetail.tsx +++ b/apps/frontend/src/Components/CourseDetail.tsx @@ -1,6 +1,6 @@ import {CourseDTO} from '@team8/types/dtos/course/course.dto'; import {Stack, Typography} from '@mui/material'; -import CourseChip from '../CourseChip'; +import CourseChip from './CourseChip'; import React from 'react'; export interface CourseDetailProps { @@ -24,16 +24,16 @@ const CourseDetail = (props: CourseDetailProps) => { Prerequisites:{' '} - {course.prerequisites.length === 0 ? - 'None' : - course.prerequisites.map((prerequisite: CourseDTO) => ( - - ))} + {course.prerequisites.length === 0 + ? 'None' + : course.prerequisites.map((prerequisite: CourseDTO) => ( + + ))} diff --git a/apps/frontend/src/Components/CourseTree.tsx b/apps/frontend/src/Components/CourseTree.tsx new file mode 100644 index 0000000..f96634e --- /dev/null +++ b/apps/frontend/src/Components/CourseTree.tsx @@ -0,0 +1,145 @@ +import React, {useState} from 'react'; +import {CourseDTO} from '@team8/types/dtos/course/course.dto'; +import {Chip, Fade, Grid} from '@mui/material'; +import '../css/CourseTree.css'; +import Tooltip from '@mui/material/Tooltip'; + +export interface CourseTreeProps { + courses: CourseDTO[]; + onRemoveCourse?: (course: CourseDTO) => void | undefined; +} + +interface CourseChipProps { + course: CourseDTO; + isSelected: boolean; + isPrerequisite: boolean; + label: string; +} + +const courseTree = ({courses, onRemoveCourse = undefined}: CourseTreeProps) => { + const [courseChips, setCourseChips] = useState( + courses.map((course: CourseDTO) => { + return { + course, + isSelected: false, + isPrerequisite: false, + label: `${course.department.abbreviation} ${course.courseNumber}`, + }; + }), + ); + const toggleHightlightCourses = ( + selected: CourseDTO, + prerequisite: CourseDTO[], + hightlight = true, + ) => { + const cids = prerequisite.map((course) => course.cid); + const newCourseChips = courseChips + .map((courseChip) => { + if (cids.includes(courseChip.course.cid)) { + courseChip.isPrerequisite = hightlight; + } + return courseChip; + }) + .map((courseChip) => { + if (courseChip.course.cid === selected.cid) { + courseChip.isSelected = hightlight; + } + return courseChip; + }); + setCourseChips(newCourseChips); + }; + + return ( +
+

Recommended courses

+ + {courseChips.map( + ({course, isSelected, isPrerequisite, label}: CourseChipProps) => ( + + + {onRemoveCourse ? ( + + // eslint-disable-next-line max-len + toggleHightlightCourses( + course, + course.prerequisites, + true, + ) + } + onMouseOut={() => + // eslint-disable-next-line max-len + toggleHightlightCourses( + course, + course.prerequisites, + false, + ) + } + onDelete={() => { + if (onRemoveCourse) { + onRemoveCourse(course); + } + }} + /> + ) : ( + + // eslint-disable-next-line max-len + toggleHightlightCourses( + course, + course.prerequisites, + true, + ) + } + onMouseOut={() => + // eslint-disable-next-line max-len + toggleHightlightCourses( + course, + course.prerequisites, + false, + ) + } + /> + )} + + + ), + )} + +
+ ); +}; + +export default courseTree; diff --git a/apps/frontend/src/Components/CourseTree/CourseTree.tsx b/apps/frontend/src/Components/CourseTree/CourseTree.tsx deleted file mode 100644 index c92faf5..0000000 --- a/apps/frontend/src/Components/CourseTree/CourseTree.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import React, {useState} from 'react'; -import {CourseDTO} from '@team8/types/dtos/course/course.dto'; -import {Chip, Fade, Grid} from '@mui/material'; -import './CourseTree.css'; -import Tooltip from '@mui/material/Tooltip'; - -export interface CourseTreeProps { - courses: CourseDTO[]; - onRemoveCourse?: (course: CourseDTO) => void | undefined; -} - -interface CourseChipProps { - course: CourseDTO; - isSelected: boolean; - isPrerequisite: boolean; - label: string; -} - -const courseTree = ({courses, onRemoveCourse = undefined}: CourseTreeProps) => { - const [courseChips, setCourseChips] = useState( - courses.map((course: CourseDTO) => { - return { - course, - isSelected: false, - isPrerequisite: false, - label: `${course.department.abbreviation} ${course.courseNumber}`, - }; - }), - ); - const toggleHightlightCourses = ( - selected: CourseDTO, - prerequisite: CourseDTO[], - hightlight = true, - ) => { - const cids = prerequisite.map((course) => course.cid); - const newCourseChips = courseChips - .map((courseChip) => { - if (cids.includes(courseChip.course.cid)) { - courseChip.isPrerequisite = hightlight; - } - return courseChip; - }) - .map((courseChip) => { - if (courseChip.course.cid === selected.cid) { - courseChip.isSelected = hightlight; - } - return courseChip; - }); - setCourseChips(newCourseChips); - }; - - return ( -
-

Recommended courses

- - {courseChips.map( - ({course, isSelected, isPrerequisite, label}: CourseChipProps) => - ( - - - {onRemoveCourse ? ( - - // eslint-disable-next-line max-len - toggleHightlightCourses(course, course.prerequisites, true) - } - onMouseOut={() => - // eslint-disable-next-line max-len - toggleHightlightCourses(course, course.prerequisites, false) - } - onDelete={() => { - if (onRemoveCourse) { - onRemoveCourse(course); - } - }} - /> - ) : ( - - // eslint-disable-next-line max-len - toggleHightlightCourses(course, course.prerequisites, true) - } - onMouseOut={() => - // eslint-disable-next-line max-len - toggleHightlightCourses(course, course.prerequisites, false) - } - /> - )} - - - ) - )} - -
- ); -}; - -export default courseTree; diff --git a/apps/frontend/src/Components/Navbar/Navbar.tsx b/apps/frontend/src/Components/Navbar.tsx similarity index 97% rename from apps/frontend/src/Components/Navbar/Navbar.tsx rename to apps/frontend/src/Components/Navbar.tsx index be812dd..59b811c 100644 --- a/apps/frontend/src/Components/Navbar/Navbar.tsx +++ b/apps/frontend/src/Components/Navbar.tsx @@ -12,19 +12,17 @@ import MenuItem from '@mui/material/MenuItem'; import Stack from '@mui/material/Stack'; import Divider from '@mui/material/Divider'; import AutoStoriesIcon from '@mui/icons-material/AutoStories'; -import {getTokenFromCookie} from '../../Utils/CookieFunctions'; +import {getTokenFromCookie} from '../Utils/CookieFunctions'; import {useNavigate} from 'react-router-dom'; import axios from 'axios'; -import NavbarLinks from '../NavbarLinks/NavbarLinks'; +import NavbarLinks from './NavbarLinks'; const settings = ['Profile', 'Logout']; - /** * Represents a styled button component with custom color and hover effects. */ - /** * Represents the function signature for the handleLogout function. */ @@ -34,7 +32,7 @@ interface HandleLogoutFunction { const Navbar = (props: {handleLogout: HandleLogoutFunction}) => { const [anchorElUser, setAnchorElUser] = React.useState( - null, + null, ); const navigate = useNavigate(); diff --git a/apps/frontend/src/Components/NavbarLinks/NavbarLinks.tsx b/apps/frontend/src/Components/NavbarLinks.tsx similarity index 68% rename from apps/frontend/src/Components/NavbarLinks/NavbarLinks.tsx rename to apps/frontend/src/Components/NavbarLinks.tsx index 216653c..ecf49d7 100644 --- a/apps/frontend/src/Components/NavbarLinks/NavbarLinks.tsx +++ b/apps/frontend/src/Components/NavbarLinks.tsx @@ -3,20 +3,17 @@ import Toolbar from '@mui/material/Toolbar'; import React from 'react'; import Button from '@mui/material/Button'; -import './NavbarLinks.css'; -import {links} from './links'; +import '../css/NavbarLinks.css'; +import {links} from '../Utils/links'; const NavbarLinks = () => { return ( - + { // Map through navbarScreens and render each as a button links.map((screen) => ( - diff --git a/apps/frontend/src/Screens/Calendar/Calendar.tsx b/apps/frontend/src/Screens/Calendar.tsx similarity index 93% rename from apps/frontend/src/Screens/Calendar/Calendar.tsx rename to apps/frontend/src/Screens/Calendar.tsx index 14024d8..57896df 100644 --- a/apps/frontend/src/Screens/Calendar/Calendar.tsx +++ b/apps/frontend/src/Screens/Calendar.tsx @@ -1,13 +1,13 @@ import React, {useEffect, useState} from 'react'; import Timetable from 'react-timetable-events'; -import {getTokenFromCookie} from '../../Utils/CookieFunctions'; +import {getTokenFromCookie} from '../Utils/CookieFunctions'; import Button, {ButtonProps} from '@mui/material/Button'; import styled from '@emotion/styled'; import {brown} from '@mui/material/colors'; -import exportCalendar from './exportCalendar'; -import '../../css/Calendar.css'; -import {Course, WeeklySchedule} from './types'; -import Screen from '../../Components/Screen/Screen'; +import exportCalendar from '../Utils/exportCalendar'; +import '../css/Calendar.css'; +import {Course, WeeklySchedule} from '../Utils/types'; +import Screen from '../Components/Screen/Screen'; const DAY_MAPPINGS: { [key: string]: string; diff --git a/apps/frontend/src/Screens/DetailScreen.tsx b/apps/frontend/src/Screens/DetailScreen.tsx index 74f317f..ca29723 100644 --- a/apps/frontend/src/Screens/DetailScreen.tsx +++ b/apps/frontend/src/Screens/DetailScreen.tsx @@ -5,7 +5,7 @@ import {SectionDTO} from 'packages/types/dtos/section/section.dto'; import {CourseDTO} from 'packages/types/dtos/course/course.dto'; import {getTokenFromCookie} from '../Utils/CookieFunctions'; import axios from 'axios'; -import CourseDetail from '../Components/CourseDetail/CourseDetail'; +import CourseDetail from '../Components/CourseDetail'; import {displayError} from '../Utils/Errors'; import Screen from '../Components/Screen/Screen'; diff --git a/apps/frontend/src/Screens/PersonalizedRoadmap/PersonalizedRoadmap.tsx b/apps/frontend/src/Screens/PersonalizedRoadmap.tsx similarity index 87% rename from apps/frontend/src/Screens/PersonalizedRoadmap/PersonalizedRoadmap.tsx rename to apps/frontend/src/Screens/PersonalizedRoadmap.tsx index c7b1aa6..013ca26 100644 --- a/apps/frontend/src/Screens/PersonalizedRoadmap/PersonalizedRoadmap.tsx +++ b/apps/frontend/src/Screens/PersonalizedRoadmap.tsx @@ -2,12 +2,12 @@ import {Autocomplete, Box, Button, Grid, TextField} from '@mui/material'; import React, {useEffect, useState} from 'react'; import {CourseDTO} from '@team8/types/dtos/course/course.dto'; import {Roadmap} from '@team8/types/domain/roadmap.model'; -import {makeAuthRequest} from '../../Utils/Request'; -import CourseTree from '../../Components/CourseTree/CourseTree'; -import CourseDetail from '../../Components/CourseDetail/CourseDetail'; -import {getCourse, getCourses} from '../../API/Course.API'; -import {displayError} from '../../Utils/Errors'; -import Screen from '../../Components/Screen/Screen'; +import {makeAuthRequest} from '../Utils/Request'; +import CourseTree from '../Components/CourseTree'; +import CourseDetail from '../Components/CourseDetail'; +import {getCourse, getCourses} from '../API/Course.API'; +import {displayError} from '../Utils/Errors'; +import Screen from '../Components/Screen/Screen'; const PersonalRoadmap = () => { const [courses, setCourses] = useState([]); @@ -60,13 +60,13 @@ const PersonalRoadmap = () => { const saveRoadmap = (roadmap: Roadmap) => { makeAuthRequest('/rest-api/roadmap/personal', 'POST', roadmap.dto) - .then((response) => { - setRoadmap(new Roadmap(response.data.courses)); - onRoadmapChange(false); - }) - .catch((e: Error) => { - displayError(e.message); - }); + .then((response) => { + setRoadmap(new Roadmap(response.data.courses)); + onRoadmapChange(false); + }) + .catch((e: Error) => { + displayError(e.message); + }); }; return ( diff --git a/apps/frontend/src/Screens/Roadmap/Roadmap.tsx b/apps/frontend/src/Screens/Roadmap.tsx similarity index 90% rename from apps/frontend/src/Screens/Roadmap/Roadmap.tsx rename to apps/frontend/src/Screens/Roadmap.tsx index ee10ac3..fbe1834 100644 --- a/apps/frontend/src/Screens/Roadmap/Roadmap.tsx +++ b/apps/frontend/src/Screens/Roadmap.tsx @@ -3,12 +3,12 @@ import {DegreeDTO} from '@team8/types/dtos/degree/degree.dto'; import Autocomplete from '@mui/material/Autocomplete'; import Box from '@mui/material/Box'; import TextField from '@mui/material/TextField'; -import {fetchAvailableDegrees, fetchDegreeWithRoadmap} from './data'; +import {fetchAvailableDegrees, fetchDegreeWithRoadmap} from '../Utils/data'; import {CourseDTO} from '@team8/types/dtos/course/course.dto'; -import CourseTree from '../../Components/CourseTree/CourseTree'; +import CourseTree from '../Components/CourseTree'; import {Grid} from '@mui/material'; -import './RoadmapScreen.css'; -import Screen from '../../Components/Screen/Screen'; +import '../css/RoadmapScreen.css'; +import Screen from '../Components/Screen/Screen'; import Tooltip from '@mui/material/Tooltip'; const Roadmap = () => { diff --git a/apps/frontend/src/Screens/Roadmap/data.ts b/apps/frontend/src/Utils/data.ts similarity index 100% rename from apps/frontend/src/Screens/Roadmap/data.ts rename to apps/frontend/src/Utils/data.ts diff --git a/apps/frontend/src/Screens/Calendar/exportCalendar.ts b/apps/frontend/src/Utils/exportCalendar.ts similarity index 89% rename from apps/frontend/src/Screens/Calendar/exportCalendar.ts rename to apps/frontend/src/Utils/exportCalendar.ts index 0bb115e..37accb2 100644 --- a/apps/frontend/src/Screens/Calendar/exportCalendar.ts +++ b/apps/frontend/src/Utils/exportCalendar.ts @@ -1,4 +1,4 @@ -import {SCHEDULE_STRUCTURE} from './Calendar'; +import {SCHEDULE_STRUCTURE} from '../Screens/Calendar'; import {EventAttributes, createEvents} from 'ics'; import {saveAs} from 'file-saver'; @@ -15,9 +15,7 @@ function exportCalendar(schedule: typeof SCHEDULE_STRUCTURE) { // Mapping function to convert the today's date to the event's date const daysToAdd = (7 - new Date(2024, 8, 9).getDay() + index + 1) % 7; const newDate = new Date( - new Date(2024, 8, 9) - .setDate(new Date(2024, 8, 9) - .getDate() + daysToAdd), + new Date(2024, 8, 9).setDate(new Date(2024, 8, 9).getDate() + daysToAdd), ); const [year, month, date] = [ newDate.getFullYear(), @@ -44,8 +42,8 @@ function exportCalendar(schedule: typeof SCHEDULE_STRUCTURE) { title: schedule[day][0].name, location: schedule[day][0].location, recurrenceRule: `FREQ=WEEKLY;BYDAY=${day.substring( - 0, - 2, + 0, + 2, )};INTERVAL=1;UNTIL=20241227T000000Z`, }; eventsList.push(event); diff --git a/apps/frontend/src/Components/NavbarLinks/links.ts b/apps/frontend/src/Utils/links.ts similarity index 100% rename from apps/frontend/src/Components/NavbarLinks/links.ts rename to apps/frontend/src/Utils/links.ts diff --git a/apps/frontend/src/Screens/Calendar/types.ts b/apps/frontend/src/Utils/types.ts similarity index 100% rename from apps/frontend/src/Screens/Calendar/types.ts rename to apps/frontend/src/Utils/types.ts diff --git a/apps/frontend/src/Components/CourseTree/CourseTree.css b/apps/frontend/src/css/CourseTree.css similarity index 100% rename from apps/frontend/src/Components/CourseTree/CourseTree.css rename to apps/frontend/src/css/CourseTree.css diff --git a/apps/frontend/src/Components/NavbarLinks/NavbarLinks.css b/apps/frontend/src/css/NavbarLinks.css similarity index 100% rename from apps/frontend/src/Components/NavbarLinks/NavbarLinks.css rename to apps/frontend/src/css/NavbarLinks.css diff --git a/apps/frontend/src/Screens/Roadmap/RoadmapScreen.css b/apps/frontend/src/css/RoadmapScreen.css similarity index 100% rename from apps/frontend/src/Screens/Roadmap/RoadmapScreen.css rename to apps/frontend/src/css/RoadmapScreen.css diff --git a/apps/locust/hello.py b/apps/locust/loadTest.py similarity index 99% rename from apps/locust/hello.py rename to apps/locust/loadTest.py index e05c182..2256e2e 100644 --- a/apps/locust/hello.py +++ b/apps/locust/loadTest.py @@ -8,8 +8,6 @@ class QuickstartUser(HttpUser): jwt_token = "" - wait_time = between(1,2) - def on_start(self): self.jwt_token = self.get_jwt_token() diff --git a/docker-compose.yml b/docker-compose.yml index 9e99ca2..e90c0db 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: volumes: - ./:/app ports: - - "3000:3000" + - '3000:3000' command: /bin/sh ./scripts/dev/dev.local.sh depends_on: - database @@ -14,22 +14,21 @@ services: volumes: - ./docker/mysql/provision/init.sql:/docker-entrypoint-initdb.d/init.sql ports: - - "3306:3306" - - "33060:33060" + - '3306:3306' + - '33060:33060' environment: MYSQL_ROOT_PASSWORD: root healthcheck: - test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost'] timeout: 20s retries: 10 - + locust: image: locustio/locust ports: - - "8089:8089" + - '8089:8089' volumes: - ./apps/locust:/locust - command: -f /locust/hello.py + command: -f /locust/loadTest.py depends_on: - apps-dev - From 4f56406061573ea999fe824326645868449693ef Mon Sep 17 00:00:00 2001 From: Quang Anh Date: Mon, 8 Apr 2024 23:42:44 -0500 Subject: [PATCH 2/5] FIx FE test --- apps/frontend/test/unit/calendar.spec.tsx | 2 +- apps/frontend/test/unit/navbar.spec.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/frontend/test/unit/calendar.spec.tsx b/apps/frontend/test/unit/calendar.spec.tsx index 2014732..3011e3a 100644 --- a/apps/frontend/test/unit/calendar.spec.tsx +++ b/apps/frontend/test/unit/calendar.spec.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Calendar from '../../src/Screens/Calendar/Calendar'; +import Calendar from '../../src/Screens/Calendar'; import {render, screen, waitFor} from '@testing-library/react'; import '@testing-library/jest-dom'; diff --git a/apps/frontend/test/unit/navbar.spec.tsx b/apps/frontend/test/unit/navbar.spec.tsx index e20db5a..020114b 100644 --- a/apps/frontend/test/unit/navbar.spec.tsx +++ b/apps/frontend/test/unit/navbar.spec.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import Navbar from '../../src/Components/Navbar/Navbar'; +import Navbar from '../../src/Components/Navbar'; import {render, screen} from '@testing-library/react'; import {BrowserRouter} from 'react-router-dom'; @@ -7,9 +7,9 @@ describe('Render Calendar', () => { test('Should display all the feature buttons', () => { const mockHandleLogout = jest.fn(); render( - - - , + + + , ); const buttonList = [ 'Home', From 329c5aab4a1fb622ab3374da253b3025618a7927 Mon Sep 17 00:00:00 2001 From: Quang Anh Date: Tue, 9 Apr 2024 00:01:58 -0500 Subject: [PATCH 3/5] Update .prettierrc --- .prettierrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index c998e89..88c2e3d 100644 --- a/.prettierrc +++ b/.prettierrc @@ -5,5 +5,5 @@ "useTabs": false, "bracketSpacing": false, "bracketSameLine": false, - "printWidth": 80 + "printWidth": 90 } From 29899b34f8623e0c4e794dab8374293133552bdd Mon Sep 17 00:00:00 2001 From: Quang Anh Date: Tue, 9 Apr 2024 00:15:22 -0500 Subject: [PATCH 4/5] Rename a file to fix lint test --- .prettierrc | 2 +- apps/frontend/src/Screens/Calendar.tsx | 2 +- apps/frontend/src/Utils/{exportCalendar.ts => expCalendar.ts} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename apps/frontend/src/Utils/{exportCalendar.ts => expCalendar.ts} (100%) diff --git a/.prettierrc b/.prettierrc index 88c2e3d..c998e89 100644 --- a/.prettierrc +++ b/.prettierrc @@ -5,5 +5,5 @@ "useTabs": false, "bracketSpacing": false, "bracketSameLine": false, - "printWidth": 90 + "printWidth": 80 } diff --git a/apps/frontend/src/Screens/Calendar.tsx b/apps/frontend/src/Screens/Calendar.tsx index 57896df..a68952d 100644 --- a/apps/frontend/src/Screens/Calendar.tsx +++ b/apps/frontend/src/Screens/Calendar.tsx @@ -4,7 +4,7 @@ import {getTokenFromCookie} from '../Utils/CookieFunctions'; import Button, {ButtonProps} from '@mui/material/Button'; import styled from '@emotion/styled'; import {brown} from '@mui/material/colors'; -import exportCalendar from '../Utils/exportCalendar'; +import exportCalendar from '../Utils/expCalendar'; import '../css/Calendar.css'; import {Course, WeeklySchedule} from '../Utils/types'; import Screen from '../Components/Screen/Screen'; diff --git a/apps/frontend/src/Utils/exportCalendar.ts b/apps/frontend/src/Utils/expCalendar.ts similarity index 100% rename from apps/frontend/src/Utils/exportCalendar.ts rename to apps/frontend/src/Utils/expCalendar.ts From 4774783913b7f7361a24c0f7033e006c5b6aaed2 Mon Sep 17 00:00:00 2001 From: Quang Anh Date: Tue, 9 Apr 2024 00:32:50 -0500 Subject: [PATCH 5/5] Update expCalendar.ts --- apps/frontend/src/Utils/expCalendar.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/frontend/src/Utils/expCalendar.ts b/apps/frontend/src/Utils/expCalendar.ts index 37accb2..6c6d1e5 100644 --- a/apps/frontend/src/Utils/expCalendar.ts +++ b/apps/frontend/src/Utils/expCalendar.ts @@ -15,6 +15,7 @@ function exportCalendar(schedule: typeof SCHEDULE_STRUCTURE) { // Mapping function to convert the today's date to the event's date const daysToAdd = (7 - new Date(2024, 8, 9).getDay() + index + 1) % 7; const newDate = new Date( + // eslint-disable-next-line max-len new Date(2024, 8, 9).setDate(new Date(2024, 8, 9).getDate() + daysToAdd), ); const [year, month, date] = [