Commit a7e51015 authored by Zac Wood's avatar Zac Wood

Client only sends CRNs

parent ebd57ef8
......@@ -4,10 +4,10 @@ require 'time'
class CalendarGeneratorController < ApplicationController
def generate
cal = Icalendar::Calendar.new
posted_sections = JSON.parse(request.body.read)
posted_crns = JSON.parse(request.body.read)
posted_sections.each do |posted_section|
section = Section.find_by_crn(posted_section["crn"])
posted_crns.each do |crn|
section = Section.find_by_crn(crn)
event = generate_event_from_section(section)
cal.add_event(event)
end
......
......@@ -26,9 +26,10 @@ class App extends React.Component<any, State> {
}
generateSchedule() {
const crns = this.state.currentSchedule.map(section => section.crn);
fetch('http://localhost:3000/api/generate', {
method: 'POST',
body: JSON.stringify(this.state.currentSchedule),
body: JSON.stringify(crns),
headers: {
'Content-Type': 'text/plain',
},
......@@ -44,7 +45,9 @@ class App extends React.Component<any, State> {
return (
<div>
<h1>Schedules</h1>
<h2>Search</h2>
<Search addSearchResultCallback={this.addSectionToCurrentScheduleIfUnique} />
<h2>Your schedule</h2>
<SectionList sections={this.state.currentSchedule} />
<button onClick={this.generateSchedule}>Generate Schedule</button>
</div>
......
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