+function task_rows(projects, model) {
+ let _pipe = projects;
+ return flat_map(_pipe, (project) => {
+ let _pipe$1 = project.tasks;
+ let _pipe$2 = filter(_pipe$1, (task) => {
+ return task_matches(model, task);
+ });
+ return map2(_pipe$2, (task) => {
+ return [project.name, task];
+ });
+ });
+}
+function calendar_tasks(projects, model, date2) {
+ let _pipe = task_rows(projects, model);
+ return filter(_pipe, (row) => {
+ return row[1].due_date === date2;
+ });
+}
+function calendar_day(date2, day_of_week, tasks) {
+ return div(toList([
+ styles(toList([
+ ["min-height", "260px"],
+ ["padding", "14px"],
+ ["border-right", "1px solid #e2d9cc"],
+ ["background", "#fff"]
+ ]))
+ ]), toList([
+ h3(toList([style("margin-bottom", "1px")]), toList([text3(day_of_week)])),
+ h3(toList([style("margin-top", "0px")]), toList([text3(date2)])),
+ div(List$Empty$const, map2(tasks, (row) => {
+ let project = row[0];
+ let task = row[1];
+ return div(toList([class$("task")]), toList([
+ strong(List$Empty$const, toList([text3(task.title)])),
+ small(List$Empty$const, toList([
+ strong(List$Empty$const, toList([text3("Project: ")])),
+ text3(project)
+ ])),
+ span(List$Empty$const, toList([
+ strong(List$Empty$const, toList([
+ text3("DEFCON " + to_string(task.defcon))
+ ]))
+ ]))
+ ]));
+ }))
+ ]));
+}
+function num_to_day(day2) {
+ if (day2 === 0) {
+ return "Mon";
+ } else if (day2 === 1) {
+ return "Tue";
+ } else if (day2 === 2) {
+ return "Wed";
+ } else if (day2 === 3) {
+ return "Thu";
+ } else if (day2 === 4) {
+ return "Fri";
+ } else if (day2 === 5) {
+ return "Sat";
+ } else if (day2 === 6) {
+ return "Sun";
+ } else {
+ return "";
+ }
+}
+function days_in_month(year2, month2) {
+ if (month2 === 2) {
+ let divisible_by_400 = isEqual(remainder(year2, 400), new Ok(0));
+ let divisible_by_4 = isEqual(remainder(year2, 4), new Ok(0));
+ let divisible_by_100 = isEqual(remainder(year2, 100), new Ok(0));
+ let $ = divisible_by_400 || divisible_by_4 && !divisible_by_100;
+ if ($) {
+ return 29;
+ } else {
+ return 28;
+ }
+ } else if (month2 === 4) {
+ return 30;
+ } else if (month2 === 6) {
+ return 30;
+ } else if (month2 === 9) {
+ return 30;
+ } else if (month2 === 11) {
+ return 30;
+ } else {
+ return 31;
+ }
+}
+function add_days(loop$date_value, loop$count) {
+ while (true) {
+ let date_value = loop$date_value;
+ let count = loop$count;
+ if (count === 0) {
+ return date_value;
+ } else {
+ let year2 = date_value[0];
+ let month2 = date_value[1];
+ let day2 = date_value[2];
+ let _block;
+ let $1 = day2 === days_in_month(year2, month2);
+ if ($1) {
+ let $2 = month2 === 12;
+ if ($2) {
+ _block = [year2 + 1, 1, 1];
+ } else {
+ _block = [year2, month2 + 1, 1];
+ }
+ } else {
+ _block = [year2, month2, day2 + 1];
+ }
+ let $ = _block;
+ let next_year = $[0];
+ let next_month = $[1];
+ let next_day = $[2];
+ loop$date_value = [next_year, next_month, next_day];
+ loop$count = count - 1;
+ }
+ }
+}
+function two_digits(value3) {
+ let text4 = to_string(value3);
+ let $ = string_length(text4);
+ if ($ === 1) {
+ return "0" + text4;
+ } else {
+ return text4;
+ }
+}
+function format_date(date_value) {
+ let year2 = date_value[0];
+ let month2 = date_value[1];
+ let day2 = date_value[2];
+ return to_string(year2) + "-" + two_digits(month2) + "-" + two_digits(day2);
+}
+function format_date_no_year(date_value) {
+ let month2 = date_value[1];
+ let day2 = date_value[2];
+ return two_digits(month2) + "-" + two_digits(day2);
+}
+function subtract_days(loop$year, loop$month, loop$day, loop$count) {
+ while (true) {
+ let year2 = loop$year;
+ let month2 = loop$month;
+ let day2 = loop$day;
+ let count = loop$count;
+ if (count === 0) {
+ return [year2, month2, day2];
+ } else {
+ let _block;
+ if (day2 === 1) {
+ let _block$1;
+ if (month2 === 1) {
+ _block$1 = 12;
+ } else {
+ _block$1 = month2 - 1;
+ }
+ let month$1 = _block$1;
+ let _block$2;
+ let $1 = month$1 === 12;
+ if ($1) {
+ _block$2 = year2 - 1;
+ } else {
+ _block$2 = year2;
+ }
+ let year$1 = _block$2;
+ _block = [year$1, month$1, days_in_month(year$1, month$1)];
+ } else {
+ _block = [year2, month2, day2 - 1];
+ }
+ let $ = _block;
+ let previous_year = $[0];
+ let previous_month = $[1];
+ let previous_day = $[2];
+ loop$year = previous_year;
+ loop$month = previous_month;
+ loop$day = previous_day;
+ loop$count = count - 1;
+ }
+ }
+}
+function subtract_date_days(date_value, days) {
+ let year2 = date_value[0];
+ let month2 = date_value[1];
+ let day2 = date_value[2];
+ return subtract_days(year2, month2, day2, days);
+}
+function shift_week(date_value, weeks) {
+ if (weeks === 0) {
+ return date_value;
+ } else {
+ let value3 = weeks;
+ if (value3 > 0) {
+ return add_days(date_value, value3 * 7);
+ } else {
+ let value4 = weeks;
+ return subtract_date_days(date_value, 0 - value4 * 7);
+ }
+ }
+}
+function current_week_dates(week_offset) {
+ let today = now();
+ let _block;
+ let $ = day(today);
+ if ($ === 0) {
+ _block = 6;
+ } else {
+ let day2 = $;
+ _block = day2 - 1;
+ }
+ let days_from_monday = _block;
+ let current_week_start = subtract_days(year(today), month(today) + 1, date(today), days_from_monday);
+ let start5 = shift_week(current_week_start, week_offset);
+ let _pipe = toList([0, 1, 2, 3, 4, 5, 6]);
+ return map2(_pipe, (offset) => {
+ return [
+ format_date_no_year(add_days(start5, offset)),
+ format_date(add_days(start5, offset)),
+ (() => {
+ let _pipe$1 = offset;
+ return num_to_day(_pipe$1);
+ })()
+ ];
+ });
+}
+function week_label(week_offset) {
+ let dates = current_week_dates(week_offset);
+ let _block;
+ let _pipe = first(dates);
+ _block = unwrap2(_pipe, ["", "", ""]);
+ let first2 = _block;
+ let _block$1;
+ let _pipe$1 = last(dates);
+ _block$1 = unwrap2(_pipe$1, ["", "", ""]);
+ let last2 = _block$1;
+ return first2[1] + " โ " + last2[1];
+}
+function calendar_view(model) {
+ let $ = model.dashboard;
+ if ($ instanceof Some) {
+ let board = $[0];
+ return main(toList([class$("page")]), toList([
+ styles2(),
+ header(List$Empty$const, toList([
+ div(List$Empty$const, toList([
+ text3("FRC 972 ยท IRON CLAW"),
+ h1(List$Empty$const, toList([text3("calendar")]))
+ ])),
+ nav(List$Empty$const, toList([
+ button(toList([on_click(Message$DashboardView$const)]), toList([text3("Board view")])),
+ button(toList([on_click(Message$ListView$const)]), toList([text3("List view")])),
+ button(toList([on_click(Message$LogOut$const)]), toList([text3("Sign out")]))
+ ]))
+ ])),
+ section(toList([class$("panel")]), toList([
+ h2(List$Empty$const, toList([text3("Find tasks")])),
+ input(toList([
+ class$("task-search"),
+ placeholder("Search owner or assignees"),
+ on_input((var0) => {
+ return new TaskSearchChanged(var0);
+ }),
+ styles(toList([["width", "100%"], ["box-sizing", "border-box"]]))
+ ])),
+ select(toList([
+ class$("subteam-filter"),
+ on_change((var0) => {
+ return new SubteamFilterChanged(var0);
+ }),
+ styles(toList([
+ ["width", "100%"],
+ ["margin-top", "8px"],
+ ["box-sizing", "border-box"],
+ ["padding", "12px 13px"],
+ ["border", "1px solid #d9cfc2"],
+ ["border-radius", "0"],
+ ["background", "#fffcf8"],
+ ["color", "#28231e"],
+ ["font", "inherit"],
+ ["appearance", "auto"]
+ ]))
+ ]), toList([
+ option(toList([value("all")]), "All subteams"),
+ option(toList([value("none")]), "No subteam"),
+ option(toList([value("electrical")]), "Electrical"),
+ option(toList([value("software")]), "Software"),
+ option(toList([value("CAD")]), "CAD"),
+ option(toList([value("machining")]), "Machining"),
+ option(toList([value("operations")]), "Operations")
+ ]))
+ ])),
+ section(toList([
+ class$("panel"),
+ styles(toList([["padding", "0"], ["overflow", "hidden"]]))
+ ]), toList([
+ div(toList([
+ styles(toList([
+ ["display", "flex"],
+ ["justify-content", "space-between"],
+ ["align-items", "center"],
+ ["padding", "14px 16px"],
+ ["border-bottom", "1px solid #e2d9cc"]
+ ]))
+ ]), toList([
+ button(toList([on_click(Message$PreviousWeek$const)]), toList([text3("โ Previous week")])),
+ strong(List$Empty$const, toList([text3(week_label(model.calendar_week))])),
+ button(toList([on_click(Message$NextWeek$const)]), toList([text3("Next week โ")]))
+ ])),
+ div(toList([
+ class$("calendar-grid"),
+ styles(toList([
+ ["display", "grid"],
+ ["grid-template-columns", "repeat(7, minmax(150px, 1fr))"],
+ ["overflow-x", "auto"]
+ ]))
+ ]), map2(current_week_dates(model.calendar_week), (x2) => {
+ let day_no_year = x2[0];
+ let day2 = x2[1];
+ let day_of_week = x2[2];
+ return calendar_day(day_no_year, day_of_week, calendar_tasks(board.projects, model, day2));
+ }))
+ ]))
+ ]));
+ } else {
+ return main(toList([class$("auth")]), toList([
+ styles2(),
+ h1(List$Empty$const, toList([text3("Loading Iron Claw")]))
+ ]));
+ }
+}