Skip to content

Commit c041ef5

Browse files
committed
migrate to typescript
1 parent 4ee1fe8 commit c041ef5

25 files changed

+7164
-1458
lines changed

backend/Cargo.lock

Lines changed: 185 additions & 157 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package-lock.json

Lines changed: 6758 additions & 1214 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@fortawesome/fontawesome-svg-core": "^6.5.2",
6+
"@fortawesome/fontawesome-svg-core": "6.5.2",
77
"@fortawesome/free-brands-svg-icons": "^6.5.2",
88
"@fortawesome/free-regular-svg-icons": "^6.5.2",
99
"@fortawesome/free-solid-svg-icons": "^6.5.2",
1010
"@fortawesome/react-fontawesome": "^0.2.2",
1111
"@testing-library/jest-dom": "^5.17.0",
1212
"@testing-library/react": "^13.4.0",
1313
"@testing-library/user-event": "^13.5.0",
14+
"@types/jest": "^29.5.12",
15+
"@types/node": "^22.5.0",
16+
"@types/react": "^18.3.4",
17+
"@types/react-dom": "^18.3.0",
1418
"babel-plugin-macros": "^3.1.0",
1519
"cors": "^2.8.5",
1620
"react": "^18.3.1",
1721
"react-dom": "^18.3.1",
1822
"react-router-dom": "^6.23.1",
1923
"react-scripts": "^5.0.1",
2024
"rsuite": "^5.64.0",
25+
"typescript": "^5.5.4",
2126
"web-vitals": "^2.1.4"
2227
},
2328
"scripts": {
File renamed without changes.

frontend/src/App.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
2+
import Index from "./pages/index";
3+
import Generate from "./pages/generate";
4+
import Browse from "./pages/browse";
5+
import Search from "./pages/search";
6+
import Header from './components/header';
7+
import Footer from './components/footer';
8+
import React from "react";
9+
10+
function App() {
11+
return (
12+
<Router>
13+
<div id="superContainer">
14+
<Header />
15+
<Routes>
16+
<Route path="/" element={<Index />} />
17+
<Route path="/generate" element={<Generate />} />
18+
<Route path="/browse" element={<Browse />} />
19+
<Route path="/search" element={<Search />} />
20+
</Routes>
21+
<Footer />
22+
</div>
23+
</Router>
24+
);
25+
}
26+
27+
export default App;

frontend/src/components/alert.js renamed to frontend/src/components/alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
33
import React, { useState } from "react";
44

5-
const Alert = (props) => {
5+
const Alert = (props: any) => {
66
const [hidden, setHidden] = useState(false);
77
return (
88
<div className="alert alert-info" hidden={hidden}>

frontend/src/components/courseChildren.js renamed to frontend/src/components/courseChildren.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const getCourseChildren = async (searchData, setLoading) => {
1+
const getCourseChildren = async (searchData: any, setLoading: any) => {
22
setLoading(true);
33
return await fetch("/api/generate/getCourseOpts", {
44
method: "POST",
5-
headers: {'Content-Type':'application/json'},
5+
headers: { 'Content-Type': 'application/json' },
66
body: JSON.stringify(searchData),
77
}).then((res) => {
88
if (res.status === 200) {
@@ -20,4 +20,4 @@ const getCourseChildren = async (searchData, setLoading) => {
2020
});
2121
}
2222

23-
export default getCourseChildren;
23+
export default getCourseChildren;

frontend/src/components/coursecart.js renamed to frontend/src/components/coursecart.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
3+
import React from "react";
34

45
const CourseCart = () => {
56
return (
@@ -19,7 +20,7 @@ const CourseCart = () => {
1920
<button
2021
type="button"
2122
className="btn btn-danger pull-right"
22-
disabled="disabled"
23+
disabled={true}
2324
>
2425
<FontAwesomeIcon icon={icon({ name: "minus" })} />
2526
<FontAwesomeIcon icon={icon({ name: "shopping-cart" })} /> All
@@ -33,16 +34,13 @@ const CourseCart = () => {
3334
type="button"
3435
className="btn btn-xs btn-primary hidden-md hidden-lg pull-right"
3536
>
36-
<FontAwesomeIcon icon={icon({ name: "angle-down" })} style={null} />
37+
<FontAwesomeIcon icon={icon({ name: "angle-down" })} />
3738
</button>
3839
</h2>
3940
</div>
40-
<div
41-
className="panel-body course-cart-window hidden-xs hidden-sm"
42-
style={null}
43-
>
41+
<div className="panel-body course-cart-window hidden-xs hidden-sm">
4442
<div className="animate-show-hide">
45-
<div className="alert" style={null}>
43+
<div className="alert">
4644
Add courses to your cart and make a schedule with them. They will
4745
show up here.
4846
</div>

frontend/src/components/footer.js renamed to frontend/src/components/footer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Link } from 'react-router-dom'
2+
import React from 'react';
23

34
const Footer = () => {
45
return (

frontend/src/components/header.js renamed to frontend/src/components/header.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
22
import { Link } from 'react-router-dom'
33
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
4+
import React from 'react';
45

56
const Header = () => {
67
return (
@@ -29,17 +30,17 @@ const Header = () => {
2930
<ul className="nav navbar-nav">
3031
<li ui-sref-active="active">
3132
<Link to="/generate">
32-
<FontAwesomeIcon icon={icon({name: "calendar", style: 'regular'})}/> Make a Schedule
33+
<FontAwesomeIcon icon={icon({ name: "calendar", style: 'regular' })} /> Make a Schedule
3334
</Link>
3435
</li>
3536
<li ui-sref-active="active">
3637
<Link to="/browse">
37-
<FontAwesomeIcon icon={icon({name: "list"})}/> Browse Courses
38+
<FontAwesomeIcon icon={icon({ name: "list" })} /> Browse Courses
3839
</Link>
3940
</li>
4041
<li ui-sref-active="active">
4142
<Link to="/search">
42-
<FontAwesomeIcon icon={icon({name: "search"})}/> Search Courses
43+
<FontAwesomeIcon icon={icon({ name: "search" })} /> Search Courses
4344
</Link>
4445
</li>
4546
</ul>
@@ -49,4 +50,4 @@ const Header = () => {
4950
);
5051
};
5152

52-
export default Header;
53+
export default Header;

frontend/src/components/noCourse.js renamed to frontend/src/components/noCourse.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
3+
import React from "react";
34

4-
function minutesToTime(mins) {
5-
var h = Math.floor(mins / 60);
6-
var m = mins % 60;
5+
function minutesToTime(mins: number) {
6+
var h: number = Math.floor(mins / 60);
7+
var m: string = `${mins % 60}`;
78
var ampm = "am";
89
if (h === 24) {
910
h = 12;
@@ -14,14 +15,14 @@ function minutesToTime(mins) {
1415
if (h === 0) {
1516
h = 12;
1617
}
17-
if (m < 10) {
18+
if (mins % 60 < 10) {
1819
m = "0" + m;
1920
}
2021
return `${h}:${m} ${ampm}`;
2122
}
2223

2324
const NoCourse = () => {
24-
let times = [];
25+
let times: Array<React.JSX.Element> = [];
2526
for (let min = 0; min <= 1440; min += 30) {
2627
times.push(
2728
<option label={minutesToTime(min)} value={`number:${min}`}>
@@ -37,7 +38,7 @@ const NoCourse = () => {
3738
<div className="col-xs-12">
3839
<div className="form-group inline-sm">
3940
<select id="options-startTime" className="form-control">
40-
<option value="" className="" disabled selected="selected">
41+
<option value="" className="" disabled selected={true}>
4142
Start
4243
</option>
4344
{times}
@@ -46,7 +47,7 @@ const NoCourse = () => {
4647
<div className="form-group inline-sm">&nbsp;to&nbsp;</div>
4748
<div className="form-group inline-sm">
4849
<select id="options-endTime" className="form-control">
49-
<option value="" className="" disabled selected="selected">
50+
<option value="" className="" disabled selected={true}>
5051
End
5152
</option>
5253
{times}

frontend/src/components/nonCourse.js renamed to frontend/src/components/nonCourse.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
3+
import React from "react";
34

4-
function minutesToTime(mins) {
5-
var h = Math.floor(mins / 60);
6-
var m = mins % 60;
5+
function minutesToTime(mins: number) {
6+
var h: number = Math.floor(mins / 60);
7+
var m: string = `${mins % 60}`;
78
var ampm = "am";
89
if (h === 24) {
910
h = 12;
@@ -14,14 +15,14 @@ function minutesToTime(mins) {
1415
if (h === 0) {
1516
h = 12;
1617
}
17-
if (m < 10) {
18+
if (mins % 60 < 10) {
1819
m = "0" + m;
1920
}
2021
return `${h}:${m} ${ampm}`;
2122
}
2223

2324
const NonCourse = () => {
24-
let times = [];
25+
let times: Array<React.JSX.Element> = [];
2526
for (let min = 0; min <= 1440; min += 30) {
2627
times.push(
2728
<option label={minutesToTime(min)} value={`number:${min}`}>
@@ -34,7 +35,7 @@ const NonCourse = () => {
3435
<div className="col-lg-2 col-md-12">
3536
<div className="container-fluid">
3637
<input
37-
autocomplete="off"
38+
autoComplete="off"
3839
id="nonCourses0"
3940
className="form-control"
4041
type="text"
@@ -49,7 +50,7 @@ const NonCourse = () => {
4950
<div className="col-xs-12">
5051
<div className="form-group inline-sm">
5152
<select id="options-startTime" className="form-control">
52-
<option value="" className="" disabled selected="selected">
53+
<option value="" className="" disabled selected={true}>
5354
Start
5455
</option>
5556
{times}
@@ -58,7 +59,7 @@ const NonCourse = () => {
5859
<div className="form-group inline-sm">&nbsp;to&nbsp;</div>
5960
<div className="form-group inline-sm">
6061
<select id="options-endTime" className="form-control">
61-
<option value="" className="" disabled selected="selected">
62+
<option value="" className="" disabled selected={true}>
6263
End
6364
</option>
6465
{times}

frontend/src/components/reset.js renamed to frontend/src/components/reset.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
3+
import React from "react";
34

45
const Reset = () => {
56
return (

frontend/src/components/scheduleCourse.js renamed to frontend/src/components/scheduleCourse.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import getCourseChildren from "../components/courseChildren";
33
import SectionOptions from "../components/sectionOptions";
44
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
55
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
6+
import React from "react";
67

78
const EnterCourse = (
89
<button
910
title="Shortcut: Ctrl + Alt + Down"
1011
type="button"
1112
className="btn btn-primary btn-block"
12-
disabled="disabled"
13+
disabled={true}
1314
>
1415
Please enter a course
1516
</button>
@@ -19,7 +20,7 @@ const NoMatches = (
1920
<button className="btn btn-block course-error alert alert-danger alert-sm">No Courses Match</button>
2021
)
2122

22-
const CourseResults = (props) => {
23+
const CourseResults = (props: any) => {
2324
let action = props.opened ? "Hide" : "Show";
2425
let openedIcon = props.opened ? icon({ name: "angle-up" }) : icon({ name: "angle-down" })
2526
return (
@@ -33,14 +34,14 @@ const CourseResults = (props) => {
3334
);
3435
};
3536

36-
const ScheduleCourse = (props) => {
37+
const ScheduleCourse = (props: any) => {
3738
const [courseData, setCourseData] = useState("");
3839
const [courseStatus, setCourseStatus] = useState(EnterCourse);
3940
const [options, setOptions] = useState([]);
4041
const [loading, setLoading] = useState(false);
4142
const [loadIcon, setLoadIcon] = useState(<FontAwesomeIcon icon={icon({ name: "times" })} />);
4243

43-
const updateCourse = (e) => {
44+
const updateCourse = (e: any) => {
4445
setCourseData(e.target.value);
4546
};
4647

@@ -91,7 +92,7 @@ const ScheduleCourse = (props) => {
9192
<input
9293
autoCapitalize="off"
9394
autoCorrect="off"
94-
spellCheck="off"
95+
spellCheck="false"
9596
autoComplete="off"
9697
id="courses1"
9798
className="form-control searchField mousetrap"

frontend/src/components/sectionOptions.js renamed to frontend/src/components/sectionOptions.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22
import { icon } from '@fortawesome/fontawesome-svg-core/import.macro'
3+
import React from "react";
34

4-
const numToDay = {
5-
0: "Sun",
6-
1: "Mon",
7-
2: "Tue",
8-
3: "Wed",
9-
4: "Thu",
10-
5: "Fri",
11-
6: "Sat",
12-
};
5+
const numToDay = [
6+
"Sun",
7+
"Mon",
8+
"Tue",
9+
"Wed",
10+
"Thu",
11+
"Fri",
12+
"Sat",
13+
];
1314

14-
function minutesToTime(mins) {
15+
function minutesToTime(mins: number) {
1516
var h = Math.floor(mins / 60);
16-
var m = mins % 60;
17+
var m: string = `${mins % 60}`;
1718
var ampm = "am";
1819
if (h === 24) {
1920
h = 12;
@@ -24,16 +25,16 @@ function minutesToTime(mins) {
2425
if (h === 0) {
2526
h = 12;
2627
}
27-
if (m < 10) {
28+
if (mins % 60 < 10) {
2829
m = "0" + m;
2930
}
3031
return `${h}:${m}${ampm}`;
3132
}
3233

33-
const sectionOptions = (props) => {
34-
let out = [];
34+
const sectionOptions = (props: any) => {
35+
let out: Array<React.JSX.Element> = [];
3536
for (let i = 0; i < props.options.length; i++) {
36-
let days = props.options[i].times.map((time) => numToDay[time.day]).toString();
37+
let days = props.options[i].times.map((time: { day: number }) => numToDay[time.day]).toString();
3738
let start = days.length > 0 ? minutesToTime(props.options[i].times[0].start) : "N/A";
3839
let end = days.length > 0 ? minutesToTime(props.options[i].times[0].end) : "N/A";
3940
out.push(
@@ -71,11 +72,11 @@ const sectionOptions = (props) => {
7172
<div ng-init="parsedTimes = (section.times | parseSectionTimes)">
7273
<div
7374
ng-repeat="time in parsedTimes"
74-
style={{ "font-size": "small" }}
75+
style={{ fontSize: "small" }}
7576
className="ng-binding ng-scope"
7677
>
7778
{days}{" "}
78-
<span style={{ "white-space": "nowrap" }} className="ng-binding">
79+
<span style={{ whiteSpace: "nowrap" }} className="ng-binding">
7980
{days.length > 0 ? `${start} - ${end}` : ""}
8081
</span>
8182
</div>

0 commit comments

Comments
 (0)