Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
schedules
Commits
5b727f45
Commit
5b727f45
authored
Jun 17, 2018
by
David Haynes
🙆
Browse files
CourseEntry -> CourseSection
parent
f55ae767
Changes
8
Hide whitespace changes
Inline
Side-by-side
schedules_web/src/actions/schedule/schedule.actions.ts
View file @
5b727f45
import
{
Course
Entry
}
from
'
../../util/Course
Entry
'
;
import
{
Course
Section
}
from
'
../../util/Course
Section
'
;
import
{
ADD_ENTRY
,
REMOVE_ENTRY
}
from
'
./schedule.action-types
'
;
export
interface
ScheduleAction
{
type
:
string
;
// What action is to be performed
entry
:
Course
Entry
;
// The section that is being added/removed
entry
:
Course
Section
;
// The section that is being added/removed
}
/**
* Add a section to the Schedule
* @param section The section that is to be added
*/
export
const
addEntry
=
(
entry
:
Course
Entry
):
ScheduleAction
=>
({
export
const
addEntry
=
(
entry
:
Course
Section
):
ScheduleAction
=>
({
type
:
ADD_ENTRY
,
entry
:
entry
,
});
...
...
@@ -19,7 +19,7 @@ export const addEntry = (entry: CourseEntry): ScheduleAction => ({
* Remove a section from the Schedule
* @param section The section that is to be removed
*/
export
const
removeEntry
=
(
entry
:
Course
Entry
):
ScheduleAction
=>
({
export
const
removeEntry
=
(
entry
:
Course
Section
):
ScheduleAction
=>
({
type
:
REMOVE_ENTRY
,
entry
:
entry
,
});
schedules_web/src/actions/search/search.actions.ts
View file @
5b727f45
import
{
Course
Entry
}
from
'
../../util/Course
Entry
'
;
import
{
Course
Section
}
from
'
../../util/Course
Section
'
;
import
{
SET_SEARCH_RESULTS
}
from
'
./search.action-types
'
;
export
interface
SearchAction
{
type
:
string
;
searchResults
:
Course
Entry
[];
searchResults
:
Course
Section
[];
}
export
const
searchCourses
=
(
crn
:
string
)
=>
async
(
dispatch
:
any
)
=>
{
const
response
=
await
fetch
(
`http://localhost:3000/api/search?crn=
${
crn
}
`
);
const
object
=
await
response
.
json
();
const
results
:
Course
Entry
[]
=
[
const
results
:
Course
Section
[]
=
[
{
id
:
object
.
id
,
name
:
object
.
name
,
...
...
schedules_web/src/components/ScheduleList.tsx
View file @
5b727f45
import
*
as
React
from
'
react
'
;
import
{
Course
Entry
}
from
'
../util/Course
Entry
'
;
import
{
Course
Section
}
from
'
../util/Course
Section
'
;
interface
Props
{
courses
:
Course
Entry
[];
selectCourseCallback
?:
(
entry
:
Course
Entry
)
=>
void
;
courses
:
Course
Section
[];
selectCourseCallback
?:
(
entry
:
Course
Section
)
=>
void
;
}
export
default
class
ScheduleList
extends
React
.
Component
<
Props
,
any
>
{
...
...
@@ -31,7 +31,7 @@ export default class ScheduleList extends React.Component<Props, any> {
);
}
renderRowsForCourses
(
courses
:
Course
Entry
[]):
JSX
.
Element
[]
{
renderRowsForCourses
(
courses
:
Course
Section
[]):
JSX
.
Element
[]
{
return
courses
.
map
(
course
=>
{
return
(
<
tr
key
=
{
course
.
id
}
>
...
...
@@ -61,7 +61,7 @@ export default class ScheduleList extends React.Component<Props, any> {
}
}
getcourseWithCRN
(
crn
:
string
):
Course
Entry
{
getcourseWithCRN
(
crn
:
string
):
Course
Section
{
return
this
.
props
.
courses
.
find
(
course
=>
course
.
crn
===
crn
);
}
}
schedules_web/src/components/ScheduleRoot.tsx
View file @
5b727f45
import
*
as
React
from
'
react
'
;
import
{
Course
Entry
}
from
'
../util/Course
Entry
'
;
import
{
Course
Section
}
from
'
../util/Course
Section
'
;
import
ScheduleList
from
'
./ScheduleList
'
;
interface
SearchRootProps
{
schedule
:
Course
Entry
[];
removeEntry
:
(
CourseEntry
:
Course
Entry
)
=>
any
;
schedule
:
Course
Section
[];
removeEntry
:
(
CourseEntry
:
Course
Section
)
=>
any
;
}
// const generateSchedule = (schedule: CourseEntry[]): void => {
...
...
schedules_web/src/components/SearchRoot.tsx
View file @
5b727f45
import
*
as
React
from
'
react
'
;
import
SearchBar
from
'
../components/SearchBar
'
;
import
SectionList
from
'
../components/ScheduleList
'
;
import
{
CourseEntry
}
from
'
../util/CourseEntry
'
;
import
SearchBar
from
'
../components/SearchBar
'
;
import
{
CourseSection
}
from
'
../util/CourseSection
'
;
interface
SearchRootProps
{
searchResults
:
Course
Entry
[];
searchResults
:
Course
Section
[];
searchCourses
:
(
crn
:
string
)
=>
void
;
addEntry
:
(
entry
:
Course
Entry
)
=>
void
;
addEntry
:
(
entry
:
Course
Section
)
=>
void
;
}
const
SearchRoot
=
({
searchResults
,
searchCourses
,
addEntry
}:
SearchRootProps
)
=>
(
...
...
schedules_web/src/reducers/schedule.reducer.ts
View file @
5b727f45
...
...
@@ -6,9 +6,9 @@
*/
import
{
ADD_ENTRY
,
REMOVE_ENTRY
}
from
'
../actions/schedule/schedule.action-types
'
;
import
{
ScheduleAction
}
from
'
../actions/schedule/schedule.actions
'
;
import
{
Course
Entry
}
from
'
../util/Course
Entry
'
;
import
{
Course
Section
}
from
'
../util/Course
Section
'
;
export
type
ScheduleState
=
Course
Entry
[];
export
type
ScheduleState
=
Course
Section
[];
export
const
schedule
=
(
state
:
ScheduleState
=
[],
action
:
ScheduleAction
)
=>
{
switch
(
action
.
type
)
{
...
...
schedules_web/src/reducers/search.reducer.ts
View file @
5b727f45
...
...
@@ -6,9 +6,9 @@
*/
import
{
SET_SEARCH_RESULTS
}
from
'
../actions/search/search.action-types
'
;
import
{
SearchAction
}
from
'
../actions/search/search.actions
'
;
import
{
Course
Entry
}
from
'
../util/Course
Entry
'
;
import
{
Course
Section
}
from
'
../util/Course
Section
'
;
export
type
SearchState
=
Course
Entry
[];
export
type
SearchState
=
Course
Section
[];
export
const
search
=
(
state
:
SearchState
=
[],
action
:
SearchAction
):
SearchState
=>
{
switch
(
action
.
type
)
{
...
...
schedules_web/src/util/Course
Entry
.ts
→
schedules_web/src/util/Course
Section
.ts
View file @
5b727f45
/**
* util/Course
Entry
.ts
* util/Course
Section
.ts
*
* Common object interface for all "Section"s.
*/
export
interface
Course
Entry
{
export
interface
Course
Section
{
id
:
number
;
name
:
string
;
title
:
string
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment