1- import { createEffect , createSignal , For , onMount , Show } from "solid-js" ;
1+ import { createSignal , For , onMount , Show } from "solid-js" ;
22import toast , { Toaster } from "solid-toast" ;
3- import "./App.scss" ;
3+ import "./stylesheets/ App.scss" ;
44
55import type { Course } from "./utils/types" ;
66import { courseMAX , courseMIN } from "./utils/types" ;
@@ -11,10 +11,13 @@ import {
1111 courses ,
1212 setCourses ,
1313} from "./utils/dataManagement" ;
14+ import Results from "./components/Results" ;
15+ import CourseEntry from "./components/CourseEntry" ;
1416
1517const App = ( ) => {
16- const [ data , setData ] = createSignal ( "No data fetched!" ) ;
17- const [ newCourse , setNewCourse ] = createSignal ( 0 ) ;
18+ const [ courseData , setCourseData ] = createSignal < number [ ] [ ] > ( [ ] ) ;
19+ const [ newCourse , setNewCourse ] = createSignal < number > ( 0 ) ;
20+ const [ fetched , setFetched ] = createSignal < boolean > ( false ) ;
1821
1922 onMount ( ( ) => {
2023 const localStorageItems : string = localStorage . getItem ( "courses" ) || "" ;
@@ -29,7 +32,8 @@ const App = () => {
2932 return ;
3033 }
3134
32- setData ( "Loading" ) ;
35+ setCourseData ( [ ] ) ;
36+ setFetched ( true ) ;
3337 const loadToast = toast . loading ( "Fetching your data" ) ;
3438
3539 const courseArr = courses
@@ -40,7 +44,7 @@ const App = () => {
4044 return el . courseNum ;
4145 } ) ;
4246
43- setData ( await get_courses ( courseArr ) ) ;
47+ setCourseData ( await get_courses ( courseArr ) ) ;
4448
4549 toast . remove ( loadToast ) ;
4650 toast . success ( "Retrieved!" ) ;
@@ -51,37 +55,7 @@ const App = () => {
5155 < Toaster />
5256 < h1 > Georgia Tech self-course checker!</ h1 >
5357 < For each = { courses } >
54- { ( course : Course ) => (
55- < div >
56- < input
57- value = { course . courseNum }
58- min = { courseMIN }
59- max = { courseMAX }
60- type = "number"
61- onChange = { async ( e ) => {
62- const idx = courses . findIndex (
63- ( el : Course ) => el . courseNum === course . courseNum
64- ) ;
65- setCourses ( idx , { courseNum : e . target . value as number } ) ;
66- } }
67- />
68- < button
69- onClick = { ( ) => {
70- setCourses (
71- courses . filter ( ( el : any ) => el . courseNum !== course . courseNum )
72- ) ;
73- } }
74- >
75- & #10060 Remove
76- </ button >
77- < Show when = { course . valid } >
78- < button > & #x2705 Course CRN is valid </ button >
79- </ Show >
80- < Show when = { ! course . valid } >
81- < button > ! CRN Doesn't exist !</ button >
82- </ Show >
83- </ div >
84- ) }
58+ { ( course : Course ) => < CourseEntry course = { course } /> }
8559 </ For >
8660 < hr />
8761 < div class = "row" >
@@ -105,12 +79,13 @@ const App = () => {
10579 < button type = "button" onClick = { saveCourses } >
10680 Save Courses
10781 </ button >
82+
10883 < br />
10984 < button type = "button" onClick = { getData } >
11085 Get Course Data
11186 </ button >
11287
113- < h2 > { data ( ) } </ h2 >
88+ < Results data = { courseData ( ) } fetched = { fetched ( ) } / >
11489
11590 < button type = "button" onClick = { openLink } >
11691 Go register!
0 commit comments