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
c78b805e
Commit
c78b805e
authored
Jun 17, 2018
by
David Haynes
🙆
Browse files
entry -> CourseSection
parent
5b727f45
Changes
9
Hide whitespace changes
Inline
Side-by-side
schedules_web/src/actions/schedule/schedule.action-types.ts
View file @
c78b805e
export
const
ADD_
ENTRY
:
string
=
'
[Schedule] ADD_
ENTRY
'
;
export
const
REMOVE_
ENTRY
:
string
=
'
[Schedule] REMOVE_
ENTRY
'
;
export
const
ADD_
COURSE_SECTION
:
string
=
'
[Schedule] ADD_
COURSE_SECTION
'
;
export
const
REMOVE_
COURSE_SECTION
:
string
=
'
[Schedule] REMOVE_
COURSE_SECTION
'
;
schedules_web/src/actions/schedule/schedule.actions.ts
View file @
c78b805e
import
{
CourseSection
}
from
'
../../util/CourseSection
'
;
import
{
ADD_
ENTRY
,
REMOVE_ENTRY
}
from
'
./schedule.action-types
'
;
import
{
ADD_
COURSE_SECTION
,
REMOVE_COURSE_SECTION
}
from
'
./schedule.action-types
'
;
export
interface
ScheduleAction
{
type
:
string
;
// What action is to be performed
entry
:
CourseSection
;
// The section that is being added/removed
courseSection
:
CourseSection
;
// The section that is being added/removed
}
/**
* Add a section to the Schedule
* @param section The section that is to be added
*/
export
const
add
Entry
=
(
entry
:
CourseSection
):
ScheduleAction
=>
({
type
:
ADD_
ENTRY
,
entry
:
entry
,
export
const
add
CourseSection
=
(
courseSectionToAdd
:
CourseSection
):
ScheduleAction
=>
({
type
:
ADD_
COURSE_SECTION
,
courseSection
:
courseSectionToAdd
,
});
/**
* Remove a section from the Schedule
* @param section The section that is to be removed
*/
export
const
remove
Entry
=
(
entry
:
CourseSection
):
ScheduleAction
=>
({
type
:
REMOVE_
ENTRY
,
entry
:
entry
,
export
const
remove
CourseSection
=
(
courseSectionToRemove
:
CourseSection
):
ScheduleAction
=>
({
type
:
REMOVE_
COURSE_SECTION
,
courseSection
:
courseSectionToRemove
,
});
schedules_web/src/actions/search/search.actions.ts
View file @
c78b805e
...
...
@@ -6,7 +6,7 @@ export interface SearchAction {
searchResults
:
CourseSection
[];
}
export
const
searchCourses
=
(
crn
:
string
)
=>
async
(
dispatch
:
any
)
=>
{
export
const
searchCourse
Section
s
=
(
crn
:
string
)
=>
async
(
dispatch
:
any
)
=>
{
const
response
=
await
fetch
(
`http://localhost:3000/api/search?crn=
${
crn
}
`
);
const
object
=
await
response
.
json
();
...
...
schedules_web/src/components/ScheduleList.tsx
View file @
c78b805e
...
...
@@ -3,7 +3,7 @@ import { CourseSection } from '../util/CourseSection';
interface
Props
{
courses
:
CourseSection
[];
selectCourseCallback
?:
(
entry
:
CourseSection
)
=>
void
;
selectCourseCallback
?:
(
courseSection
:
CourseSection
)
=>
void
;
}
export
default
class
ScheduleList
extends
React
.
Component
<
Props
,
any
>
{
...
...
schedules_web/src/components/ScheduleRoot.tsx
View file @
c78b805e
...
...
@@ -4,7 +4,7 @@ import ScheduleList from './ScheduleList';
interface
SearchRootProps
{
schedule
:
CourseSection
[];
remove
Entry
:
(
C
ourse
Entry
:
CourseSection
)
=>
any
;
remove
CourseSection
:
(
c
ourse
Section
:
CourseSection
)
=>
any
;
}
// const generateSchedule = (schedule: CourseEntry[]): void => {
...
...
@@ -15,9 +15,9 @@ interface SearchRootProps {
// .then(icalText => downloadCalendar(icalText));
// };
const
ScheduleRoot
=
({
schedule
,
remove
Entry
}:
SearchRootProps
)
=>
(
const
ScheduleRoot
=
({
schedule
,
remove
CourseSection
}:
SearchRootProps
)
=>
(
<
div
>
<
ScheduleList
courses
=
{
schedule
}
selectCourseCallback
=
{
remove
Entry
}
/>
<
ScheduleList
courses
=
{
schedule
}
selectCourseCallback
=
{
remove
CourseSection
}
/>
{
/* <button onClick={generateSchedule}>Generate Schedule</button> */
}
</
div
>
);
...
...
schedules_web/src/components/SearchRoot.tsx
View file @
c78b805e
...
...
@@ -5,14 +5,14 @@ import { CourseSection } from '../util/CourseSection';
interface
SearchRootProps
{
searchResults
:
CourseSection
[];
searchCourses
:
(
crn
:
string
)
=>
void
;
add
Entry
:
(
entry
:
CourseSection
)
=>
void
;
searchCourse
Section
s
:
(
crn
:
string
)
=>
void
;
add
CourseSection
:
(
courseSectionToAdd
:
CourseSection
)
=>
void
;
}
const
SearchRoot
=
({
searchResults
,
searchCourse
s
,
addEntry
}:
SearchRootProps
)
=>
(
const
SearchRoot
=
({
searchResults
,
searchCourse
Sections
,
addCourseSection
}:
SearchRootProps
)
=>
(
<
div
>
<
SearchBar
onSearch
=
{
searchCourses
}
/>
<
SectionList
courses
=
{
searchResults
}
selectCourseCallback
=
{
add
Entry
}
/>
<
SearchBar
onSearch
=
{
searchCourse
Section
s
}
/>
<
SectionList
courses
=
{
searchResults
}
selectCourseCallback
=
{
add
CourseSection
}
/>
</
div
>
);
...
...
schedules_web/src/containers/Schedule.tsx
View file @
c78b805e
import
{
connect
}
from
'
react-redux
'
;
import
{
addEntry
,
removeEntry
}
from
'
../actions/schedule/schedule.actions
'
;
import
{
removeCourseSection
}
from
'
../actions/schedule/schedule.actions
'
;
import
ScheduleRoot
from
'
../components/ScheduleRoot
'
;
import
{
State
}
from
'
../reducers
'
;
...
...
@@ -9,5 +9,5 @@ const mapStateToProps = (state: State) => ({
export
default
connect
(
mapStateToProps
,
{
addEntry
,
removeEntry
}
{
removeCourseSection
}
)(
ScheduleRoot
);
schedules_web/src/containers/Search.tsx
View file @
c78b805e
import
{
connect
}
from
'
react-redux
'
;
import
{
add
Entry
}
from
'
../actions/schedule/schedule.actions
'
;
import
{
searchCourses
}
from
'
../actions/search/search.actions
'
;
import
{
add
CourseSection
}
from
'
../actions/schedule/schedule.actions
'
;
import
{
searchCourse
Section
s
}
from
'
../actions/search/search.actions
'
;
import
SearchRoot
from
'
../components/SearchRoot
'
;
import
{
State
}
from
'
../reducers
'
;
...
...
@@ -10,5 +10,5 @@ const mapStateToProps = (state: State) => ({
export
default
connect
(
mapStateToProps
,
{
searchCourse
s
,
addEntry
}
{
searchCourse
Sections
,
addCourseSection
}
)(
SearchRoot
);
schedules_web/src/reducers/schedule.reducer.ts
View file @
c78b805e
...
...
@@ -4,7 +4,7 @@
* Perform operations on the current state of the "Schedule" list in the store
* and return a new definition of the state.
*/
import
{
ADD_
ENTRY
,
REMOVE_ENTRY
}
from
'
../actions/schedule/schedule.action-types
'
;
import
{
ADD_
COURSE_SECTION
,
REMOVE_COURSE_SECTION
}
from
'
../actions/schedule/schedule.action-types
'
;
import
{
ScheduleAction
}
from
'
../actions/schedule/schedule.actions
'
;
import
{
CourseSection
}
from
'
../util/CourseSection
'
;
...
...
@@ -12,10 +12,12 @@ export type ScheduleState = CourseSection[];
export
const
schedule
=
(
state
:
ScheduleState
=
[],
action
:
ScheduleAction
)
=>
{
switch
(
action
.
type
)
{
case
ADD_ENTRY
:
return
state
.
findIndex
(
s
=>
s
.
crn
===
action
.
entry
.
crn
)
===
-
1
?
[...
state
,
action
.
entry
]
:
state
;
case
REMOVE_ENTRY
:
return
state
.
filter
(
s
=>
s
.
crn
!==
action
.
entry
.
crn
);
case
ADD_COURSE_SECTION
:
return
state
.
findIndex
(
s
=>
s
.
crn
===
action
.
courseSection
.
crn
)
===
-
1
?
[...
state
,
action
.
courseSection
]
:
state
;
case
REMOVE_COURSE_SECTION
:
return
state
.
filter
(
s
=>
s
.
crn
!==
action
.
courseSection
.
crn
);
default
:
return
state
;
}
...
...
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