Commit 5b727f45 authored by David Haynes's avatar David Haynes 🙆
Browse files

CourseEntry -> CourseSection

parent f55ae767
import { CourseEntry } from '../../util/CourseEntry';
import { CourseSection } from '../../util/CourseSection';
import { ADD_ENTRY, REMOVE_ENTRY } from './schedule.action-types';
export interface ScheduleAction {
type: string; // What action is to be performed
entry: CourseEntry; // The section that is being added/removed
entry: 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 addEntry = (entry: CourseEntry): ScheduleAction => ({
export const addEntry = (entry: CourseSection): 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: CourseEntry): ScheduleAction => ({
export const removeEntry = (entry: CourseSection): ScheduleAction => ({
type: REMOVE_ENTRY,
entry: entry,
});
import { CourseEntry } from '../../util/CourseEntry';
import { CourseSection } from '../../util/CourseSection';
import { SET_SEARCH_RESULTS } from './search.action-types';
export interface SearchAction {
type: string;
searchResults: CourseEntry[];
searchResults: CourseSection[];
}
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: CourseEntry[] = [
const results: CourseSection[] = [
{
id: object.id,
name: object.name,
......
import * as React from 'react';
import { CourseEntry } from '../util/CourseEntry';
import { CourseSection } from '../util/CourseSection';
interface Props {
courses: CourseEntry[];
selectCourseCallback?: (entry: CourseEntry) => void;
courses: CourseSection[];
selectCourseCallback?: (entry: CourseSection) => 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: CourseEntry[]): JSX.Element[] {
renderRowsForCourses(courses: CourseSection[]): 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): CourseEntry {
getcourseWithCRN(crn: string): CourseSection {
return this.props.courses.find(course => course.crn === crn);
}
}
import * as React from 'react';
import { CourseEntry } from '../util/CourseEntry';
import { CourseSection } from '../util/CourseSection';
import ScheduleList from './ScheduleList';
interface SearchRootProps {
schedule: CourseEntry[];
removeEntry: (CourseEntry: CourseEntry) => any;
schedule: CourseSection[];
removeEntry: (CourseEntry: CourseSection) => any;
}
// const generateSchedule = (schedule: CourseEntry[]): void => {
......
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: CourseEntry[];
searchResults: CourseSection[];
searchCourses: (crn: string) => void;
addEntry: (entry: CourseEntry) => void;
addEntry: (entry: CourseSection) => void;
}
const SearchRoot = ({ searchResults, searchCourses, addEntry }: SearchRootProps) => (
......
......@@ -6,9 +6,9 @@
*/
import { ADD_ENTRY, REMOVE_ENTRY } from '../actions/schedule/schedule.action-types';
import { ScheduleAction } from '../actions/schedule/schedule.actions';
import { CourseEntry } from '../util/CourseEntry';
import { CourseSection } from '../util/CourseSection';
export type ScheduleState = CourseEntry[];
export type ScheduleState = CourseSection[];
export const schedule = (state: ScheduleState = [], action: ScheduleAction) => {
switch (action.type) {
......
......@@ -6,9 +6,9 @@
*/
import { SET_SEARCH_RESULTS } from '../actions/search/search.action-types';
import { SearchAction } from '../actions/search/search.actions';
import { CourseEntry } from '../util/CourseEntry';
import { CourseSection } from '../util/CourseSection';
export type SearchState = CourseEntry[];
export type SearchState = CourseSection[];
export const search = (state: SearchState = [], action: SearchAction): SearchState => {
switch (action.type) {
......
/**
* util/CourseEntry.ts
* util/CourseSection.ts
*
* Common object interface for all "Section"s.
*/
export interface CourseEntry {
export interface CourseSection {
id: number;
name: string;
title: string;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment