Commit b13cda05 authored by Zac Wood's avatar Zac Wood
Browse files

Started typescript conversion

parent ff0fd7a4
{
"prettier.printWidth": 120,
"prettier.tabWidth": 4,
"prettier.singleQuote": true,
"prettier.useTabs": false,
"prettier.jsxBracketSameLine": true,
"prettier.stylelintIntegration": true,
"prettier.trailingComma": "es5",
"editor.formatOnSave": true
}
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=React},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0);t.Hello=function(e){return n.createElement("h1",null,"Hello from ",e.compilier," and ",e.framework)}},function(e,t){e.exports=ReactDOM},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(2),u=r(1);o.render(n.createElement(u.Hello,{compilier:"TypeScript",framework:"React"}),document.getElementById("root"))}]);
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.tsx");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/components/App.tsx":
/*!********************************!*\
!*** ./src/components/App.tsx ***!
\********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
const SectionList_1 = __webpack_require__(/*! ./SectionList */ "./src/components/SectionList.tsx");
const Search_1 = __webpack_require__(/*! ./Search */ "./src/components/Search.tsx");
class App extends React.Component {
constructor(props) {
super(props);
this.state = { currentSchedule: [] };
this.addSectionToCurrentSchedule = this.addSectionToCurrentSchedule.bind(this);
}
addSectionToCurrentSchedule(section) {
this.setState({
currentSchedule: [...this.state.currentSchedule, section],
});
}
render() {
return (React.createElement("div", null,
React.createElement("h1", null, "Schedules"),
React.createElement(Search_1.default, null),
React.createElement(SectionList_1.default, { addToScheduleCallback: this.addSectionToCurrentSchedule }),
React.createElement(SectionList_1.default, null)));
}
}
exports.default = App;
/***/ }),
/***/ "./src/components/Search.tsx":
/*!***********************************!*\
!*** ./src/components/Search.tsx ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
class Search extends React.Component {
constructor(props) {
super(props);
this.state = { searchTerm: '' };
this.onSearch = this.onSearch.bind(this);
this.updateSearchTerm = this.updateSearchTerm.bind(this);
}
updateSearchTerm(event) {
this.setState({
searchTerm: event.target.value,
});
}
onSearch(event) {
event.preventDefault();
}
render() {
return (React.createElement("form", { onSubmit: this.onSearch },
React.createElement("input", { type: "text", placeholder: "Enter CRN...", value: this.state.searchTerm, onChange: this.updateSearchTerm }),
React.createElement("input", { type: "submit", value: "Search" })));
}
}
exports.default = Search;
/***/ }),
/***/ "./src/components/SectionList.tsx":
/*!****************************************!*\
!*** ./src/components/SectionList.tsx ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
const section_1 = __webpack_require__(/*! ../section */ "./src/section.ts");
class SectionList extends React.Component {
constructor(props) {
super(props);
this.state = { sections: [] };
section_1.fetchSections().then(sections => this.updateStateWithSections(sections));
this.updateStateWithSections = this.updateStateWithSections.bind(this);
}
updateStateWithSections(sections) {
this.setState({
sections,
});
}
render() {
return (React.createElement("table", null,
React.createElement("tr", null,
React.createElement("th", null, "Course"),
React.createElement("th", null, "Section Name"),
React.createElement("th", null, "CRN"),
React.createElement("th", null, "Days"),
React.createElement("th", null, "Instructor"),
React.createElement("th", null, "Location"),
React.createElement("th", null, "Time")),
this.renderRowsForSections(this.state.sections)));
}
renderRowsForSections(sections) {
return sections.map(section => {
return (React.createElement("tr", null,
React.createElement("td", null, section.name),
React.createElement("td", null, section.title),
React.createElement("td", null, section.crn),
React.createElement("td", null, section.days),
React.createElement("td", null, section.instructor),
React.createElement("td", null, section.location),
React.createElement("td", null, [section.startTime, section.endTime].join(' - '))));
});
}
}
exports.default = SectionList;
/***/ }),
/***/ "./src/index.tsx":
/*!***********************!*\
!*** ./src/index.tsx ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = __webpack_require__(/*! react */ "react");
const ReactDOM = __webpack_require__(/*! react-dom */ "react-dom");
const App_1 = __webpack_require__(/*! ./components/App */ "./src/components/App.tsx");
ReactDOM.render(React.createElement(App_1.default, null), document.getElementById('root'));
/***/ }),
/***/ "./src/section.ts":
/*!************************!*\
!*** ./src/section.ts ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
function fetchSections() {
return __awaiter(this, void 0, void 0, function* () {
const response = yield fetch('http://localhost:3001/api/courses/1/sections');
const jsonObjects = yield response.json();
let sections = [];
jsonObjects.forEach((object) => {
sections.push({
id: object.id,
name: object.name,
title: object.title,
crn: object.crn,
instructor: object.instructor,
location: object.location,
days: object.days,
startTime: object.start_time,
endTime: object.end_time,
});
});
return sections;
});
}
exports.fetchSections = fetchSections;
/***/ }),
/***/ "react":
/*!************************!*\
!*** external "React" ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = React;
/***/ }),
/***/ "react-dom":
/*!***************************!*\
!*** external "ReactDOM" ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = ReactDOM;
/***/ })
/******/ });
//# sourceMappingURL=bundle.js.map
\ No newline at end of file
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///external \"React\"","webpack:///./src/components/Hello.tsx","webpack:///external \"ReactDOM\"","webpack:///./src/index.tsx"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","object","property","prototype","hasOwnProperty","p","s","React","Hello","props","createElement","compilier","framework","ReactDOM","Hello_1","render","document","getElementById"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,GAAA,EACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAjB,GACAY,OAAAC,eAAAb,EAAA,cAAiDkB,OAAA,KAIjDpB,EAAAqB,EAAA,SAAAlB,GACA,IAAAS,EAAAT,KAAAmB,WACA,WAA2B,OAAAnB,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAH,EAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAU,EAAAC,GAAsD,OAAAV,OAAAW,UAAAC,eAAAnB,KAAAgB,EAAAC,IAGtDxB,EAAA2B,EAAA,GAIA3B,IAAA4B,EAAA,mBCnEAzB,EAAAD,QAAA2B,qFCAA,IAAAA,EAAA7B,EAAA,GAOaE,EAAA4B,MAAQ,SAACC,GAAiB,OAAAF,EAAAG,cAAA,wBAAgBD,EAAME,kBAAgBF,EAAMG,2BCPnF/B,EAAAD,QAAAiC,wFCAA,IAAAN,EAAA7B,EAAA,GACAmC,EAAAnC,EAAA,GAEAoC,EAAApC,EAAA,GAEAmC,EAASE,OACLR,EAAAG,cAACI,EAAAN,OAAMG,UAAU,aAAaC,UAAU,UACxCI,SAASC,eAAe","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","module.exports = React;","import * as React from 'react';\n\nexport interface Props {\n compilier: string;\n framework: string;\n}\n\nexport const Hello = (props: Props) => <h1>Hello from {props.compilier} and {props.framework}</h1>;","module.exports = ReactDOM;","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\nimport { Hello } from './components/Hello';\n\nReactDOM.render(\n <Hello compilier=\"TypeScript\" framework=\"React\" />,\n document.getElementById(\"root\")\n);"],"sourceRoot":""}
\ No newline at end of file
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/components/App.tsx","webpack:///./src/components/Search.tsx","webpack:///./src/components/SectionList.tsx","webpack:///./src/index.tsx","webpack:///./src/section.ts","webpack:///external \"React\"","webpack:///external \"ReactDOM\""],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;ACnEA,wDAA+B;AAE/B,mGAAwC;AACxC,oFAA8B;AAM9B,SAAU,SAAQ,KAAK,CAAC,SAAqB;IACzC,YAAY,KAAU;QAClB,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;QAErC,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AAO,CAAC,QAAQ,CAAM;gBAC3B,gCAAK,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAM,CAC1D,CACR,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAhDD,8BAgDC;;;;;;;;;;;;;;;AC3DD,wDAA+B;AAC/B,mEAAsC;AAEtC,sFAAmC;AAEnC,QAAQ,CAAC,MAAM,CAAC,oBAAC,aAAG,OAAG,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;ACO1D;;QACI,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7E,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,QAAQ,GAAc,EAAE,CAAC;QAC7B,WAAW,CAAC,OAAO,CAAC,CAAC,MAAW,EAAE,EAAE;YAChC,QAAQ,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,SAAS,EAAE,MAAM,CAAC,UAAU;gBAC5B,OAAO,EAAE,MAAM,CAAC,QAAQ;aAC3B,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IACpB,CAAC;CAAA;AAlBD,sCAkBC;;;;;;;;;;;;AC9BD,uB;;;;;;;;;;;ACAA,0B","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.tsx\");\n","import * as React from 'react';\nimport Section from '../section';\nimport SectionList from './SectionList';\nimport Search from './Search';\n\ninterface State {\n currentSchedule: Section[];\n}\n\nclass App extends React.Component<any, State> {\n constructor(props: any) {\n super(props);\n this.state = { currentSchedule: [] };\n\n this.addSectionToCurrentSchedule = this.addSectionToCurrentSchedule.bind(this);\n }\n\n addSectionToCurrentSchedule(section: Section) {\n this.setState({\n currentSchedule: [...this.state.currentSchedule, section],\n });\n }\n\n render() {\n return (\n <div>\n <h1>Schedules</h1>\n <Search />\n <SectionList addToScheduleCallback={this.addSectionToCurrentSchedule} />\n <SectionList />\n </div>\n );\n }\n}\nexport default App;\n","import * as React from 'react';\n\ninterface State {\n searchTerm: string;\n}\n\nexport default class Search extends React.Component<any, State> {\n constructor(props: any) {\n super(props);\n this.state = { searchTerm: '' };\n\n this.onSearch = this.onSearch.bind(this);\n this.updateSearchTerm = this.updateSearchTerm.bind(this);\n }\n\n updateSearchTerm(event: any) {\n this.setState({\n searchTerm: event.target.value,\n });\n }\n\n onSearch(event: any) {\n event.preventDefault();\n }\n\n render() {\n return (\n <form onSubmit={this.onSearch}>\n <input\n type=\"text\"\n placeholder=\"Enter CRN...\"\n value={this.state.searchTerm}\n onChange={this.updateSearchTerm}\n />\n <input type=\"submit\" value=\"Search\" />\n </form>\n );\n }\n}\n","import * as React from 'react';\nimport Section, { fetchSections } from '../section';\n\ninterface Props {\n addToScheduleCallback?: (section: Section) => void;\n}\n\ninterface State {\n sections: Section[];\n}\n\nexport default class SectionList extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n\n this.state = { sections: [] };\n fetchSections().then(sections => this.updateStateWithSections(sections));\n\n this.updateStateWithSections = this.updateStateWithSections.bind(this);\n }\n\n updateStateWithSections(sections: Section[]) {\n this.setState({\n sections,\n });\n }\n\n render() {\n return (\n <table>\n <tr>\n <th>Course</th>\n <th>Section Name</th>\n <th>CRN</th>\n <th>Days</th>\n <th>Instructor</th>\n <th>Location</th>\n <th>Time</th>\n </tr>\n {this.renderRowsForSections(this.state.sections)}\n </table>\n );\n }\n\n renderRowsForSections(sections: Section[]): JSX.Element[] {\n return sections.map(section => {\n return (\n <tr>\n <td>{section.name}</td>\n <td>{section.title}</td>\n <td>{section.crn}</td>\n <td>{section.days}</td>\n <td>{section.instructor}</td>\n <td>{section.location}</td>\n <td>{[section.startTime, section.endTime].join(' - ')}</td>\n </tr>\n );\n });\n }\n}\n","import * as React from 'react';\nimport * as ReactDOM from 'react-dom';\n\nimport App from './components/App';\n\nReactDOM.render(<App />, document.getElementById('root'));\n","export default interface Section {\n id: number;\n name: string;\n title: string;\n crn: string;\n instructor: string;\n location: string;\n days: string;\n startTime: string;\n endTime: string;\n}\n\nexport async function fetchSections(): Promise<Section[]> {\n const response = await fetch('http://localhost:3001/api/courses/1/sections');\n const jsonObjects = await response.json();\n let sections: Section[] = [];\n jsonObjects.forEach((object: any) => {\n sections.push({\n id: object.id,\n name: object.name,\n title: object.title,\n crn: object.crn,\n instructor: object.instructor,\n location: object.location,\n days: object.days,\n startTime: object.start_time,\n endTime: object.end_time,\n });\n });\n return sections;\n}\n","module.exports = React;","module.exports = ReactDOM;"],"sourceRoot":""}
\ No newline at end of file
{
"name": "schedules_web",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no tests specified\" && exit 1",
"build": "webpack"
},
"license": "Apache",
"private": true,
"devDependencies": {
"awesome-typescript-loader": "^5.0.0",
"source-map-loader": "^0.2.3",
"typescript": "^2.8.3",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"dependencies": {
"@types/react": "^16.3.12",
"@types/react-dom": "^16.0.5",
"react": "^16.3.2",
"react-dom": "^16.3.2"
}
"name": "schedules_web",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no tests specified\" && exit 1",
"build": "webpack",
"start": "yarn build && open index.html"
},
"license": "Apache",
"private": true,
"devDependencies": {
"@types/node": "^9.6.6",
"awesome-typescript-loader": "^5.0.0",
"source-map-loader": "^0.2.3",
"typescript": "^2.8.3",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"dependencies": {
"@types/react": "^16.3.12",
"@types/react-dom": "^16.0.5",
"react": "^16.3.2",
"react-dom": "^16.3.2"
}
}
import * as React from 'react';
import Section from '../section';
import SectionList from './SectionList';
import Search from './Search';
interface State {
currentSchedule: Section[];
}
class App extends React.Component<any, State> {
constructor(props: any) {
super(props);
this.state = { currentSchedule: [] };
this.addSectionToCurrentSchedule = this.addSectionToCurrentSchedule.bind(this);
}
addSectionToCurrentSchedule(section: Section) {
this.setState({
currentSchedule: [...this.state.currentSchedule, section],
});
}
render() {
return (
<div>
<h1>Schedules</h1>
<Search />
<SectionList sections={this.state.currentSchedule} />
</div>
);
}
}
export default App;
......@@ -5,4 +5,8 @@ export interface Props {
framework: string;
}
export const Hello = (props: Props) => <h1>Hello from {props.compilier} and {props.framework}</h1>;
\ No newline at end of file
export const Hello = (props: Props) => (
<h1>
Hello from {props.compilier} and {props.framework}
</h1>
);
import * as React from 'react';
import Section, { fetchSectionsWithCRN } from '../section';
import SearchBar from './SearchBar';
import SectionList from './SectionList';
interface Props {
addSearchResultCallback?: (section: Section) => void;
}
interface State {
sections: Section[];
}
export default class Search extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.setState({ sections: [] });
}
searchForSections(crn: string) {
fetchSectionsWithCRN(crn).then(sections => this.setState({ sections }));
}
render() {
return (
<div>
<SearchBar onSearch={this.searchForSections} />
<SectionList sections={this.state.sections} />
</div>
);
}
}
import * as React from 'react';
interface Props {
onSearch: (searchTerm: string) => void;
}
interface State {
searchTerm: string;
}
export default class SearchBar extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { searchTerm: '' };
this.onSearch = this.onSearch.bind(this);
this.updateSearchTerm = this.updateSearchTerm.bind(this);
}
updateSearchTerm(event: any) {
this.setState({
searchTerm: event.target.value,
});
}
onSearch(event: any) {
this.props.onSearch(this.state.searchTerm);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.onSearch}>
<input
type="text"
placeholder="Enter CRN..."
value={this.state.searchTerm}
onChange={this.updateSearchTerm}
/>
<input type="submit" value="Search" />
</form>
);
}
}
import * as React from 'react';
import Section from '../section';
interface Props {
sections: Section[];
addToScheduleCallback?: (section: Section) => void;
}
export default class SectionList extends React.Component<Props, any> {
render() {
return (
<table>
<tr>
<th>Course</th>
<th>Section Name</th>
<th>CRN</th>
<th>Days</th>
<th>Instructor</th>
<th>Location</th>
<th>Time</th>
</tr>
{this.renderRowsForSections(this.state.sections)}
</table>
);
}
renderRowsForSections(sections: Section[]): JSX.Element[] {
return sections.map(section => {
return (
<tr>
<td>{section.name}</td>
<td>{section.title}</td>
<td>{section.crn}</td>
<td>{section.days}</td>
<td>{section.instructor}</td>
<td>{section.location}</td>
<td>{[section.startTime, section.endTime].join(' - ')}</td>
</tr>
);
});
}
}
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Hello } from './components/Hello';
import App from './components/App';
ReactDOM.render(
<Hello compilier="TypeScript" framework="React" />,
document.getElementById("root")
);
\ No newline at end of file
ReactDOM.render(<App />, document.getElementById('root'));
export default interface Section {
id: number;
name: string;
title: string;
crn: string;
instructor: string;
location: string;
days: string;
startTime: string;
endTime: string;
}
export async function fetchSectionsWithCRN(crn: string): Promise<Section[]> {
const response = await fetch('http://localhost:3001/api/courses/1/sections');
const jsonObjects = await response.json();
let sections: Section[] = [];
jsonObjects.forEach((object: any) => {
sections.push({
id: object.id,
name: object.name,
title: object.title,
crn: object.crn,
instructor: object.instructor,
location: object.location,
days: object.days,
startTime: object.start_time,
endTime: object.end_time,
});
});
return sections;
}
......@@ -4,10 +4,8 @@
"sourceMap": true,