From 3d7c6576c27a2e7aa7a4761eb08ee4d5ab7c32cb Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Thu, 1 Feb 2024 15:34:41 +0000 Subject: [PATCH 1/9] Removed unnecessary console.logs --- src/components/planner/sidebar/ScheduleListbox.tsx | 1 - src/utils/utils.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/planner/sidebar/ScheduleListbox.tsx b/src/components/planner/sidebar/ScheduleListbox.tsx index 45db0e39..e51bdb79 100644 --- a/src/components/planner/sidebar/ScheduleListbox.tsx +++ b/src/components/planner/sidebar/ScheduleListbox.tsx @@ -25,7 +25,6 @@ const ScheduleListbox = ({ courseOption, multipleOptionsHook, isImportedOptionHo const [showTheoretical, setShowTheoretical] = useState(courseOption.shown.T) const [showPractical, setShowPractical] = useState(courseOption.shown.TP) //FIXME (thePeras): If you are here you probably oberserved a bug. Don't worry its gonna be fixed very very soon - console.log(courseOption.teachers) var teacherOptions = [{ acronym: 'All teachers', name: '' }, ...courseOption.teachers] const [lastSelected, setLastSelected] = useState(selectedOption) const [previewing, setPreviewing] = useState(false) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 21ad2099..a28f9c68 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -187,7 +187,6 @@ const getCourseTeachers = (courseOption: CourseOption) => { const removeDuplicatesFromCourseOption = (courses: CourseOption[]): CourseOption[] => { - console.log(courses) if (!courses) return [] let frequency: Map = new Map() From e17b4461b539cb9f0106561bd34e895617c1cf70 Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Thu, 1 Feb 2024 16:31:06 +0000 Subject: [PATCH 2/9] Bug on paste fixed! --- .../selectedOptionController/PasteOption.tsx | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx b/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx index 2e713bb0..2ca1dcd4 100644 --- a/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx +++ b/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx @@ -25,13 +25,7 @@ type Props = { isImportedOptionHook: [boolean, React.Dispatch>] } -const PasteOption = ({ - majors, - majorHook, - multipleOptionsHook, - checkCourses, - isImportedOptionHook, -}: Props) => { +const PasteOption = ({ majors, majorHook, multipleOptionsHook, checkCourses, isImportedOptionHook }: Props) => { const [multipleOptions, setMultipleOptions] = multipleOptionsHook const [major, setMajor] = majorHook const [modalOpen, setModalOpen] = useState(false) @@ -54,12 +48,14 @@ const PasteOption = ({ } }, []) - const importSchedule = async (value = null) => { - const url = value ?? await navigator.clipboard.readText() + const importSchedule = async (value) => { + const url = value const decoded_url = Buffer.from(url, 'base64').toString() if (!isValidURL(decoded_url)) { - const description = value ? 'O texto inserido não é uma opção válida' : 'O texto do clipboard não é uma opção válida'; + const description = value + ? 'O texto inserido não é uma opção válida' + : 'O texto do clipboard não é uma opção válida' toast({ title: 'Erro ao colar opção', description, @@ -168,8 +164,8 @@ const PasteOption = ({ const selected_option = class_name_option !== 'null' ? course_schedules.find( - (schedule) => schedule.class_name === class_name_option && schedule.lesson_type !== 'T' - ) + (schedule) => schedule.class_name === class_name_option && schedule.lesson_type !== 'T' + ) : null const course_option: CourseOption = { @@ -217,14 +213,25 @@ const PasteOption = ({ return ( <> - {isClipboardSupported - ? - : + ) : ( - @@ -233,7 +240,7 @@ const PasteOption = ({ autoFocus type="text" placeholder="Colar aqui opção" - className="w-full p-2 rounded border border-slate-200 dark:border-slate-800 text-slate-950 dark:text-slate-50 focus:outline-none focus:ring-2 focus:ring-primary" + className="text-slate-950 w-full rounded border border-slate-200 p-2 focus:outline-none focus:ring-2 focus:ring-primary dark:border-slate-800 dark:text-slate-50" onPaste={(e) => importSchedule(e.clipboardData.getData('text/plain'))} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -244,7 +251,7 @@ const PasteOption = ({ /> - } + )} Date: Tue, 6 Feb 2024 19:24:57 +0000 Subject: [PATCH 3/9] Fixed randomizer | Locked button not switching state before switching option needs fix --- .../selectedOptionController/RandomFill.tsx | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx b/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx index 42b77c9c..3dd90bb2 100644 --- a/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx +++ b/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx @@ -15,12 +15,10 @@ type Props = { const RandomFill = ({ multipleOptionsHook, className }: Props) => { const [multipleOptions, setMultipleOptions] = multipleOptionsHook const courseOptions = removeDuplicatesFromCourseOption(multipleOptions.selected) - const [permutations, setPermutations] = useState([]) const [lockedCourses, setLockedCourses] = useState( courseOptions.filter((course) => course.locked).map((course) => course.course.info.acronym) ) - const [randomClasses, setRandomClasses] = useState({}) /* @@ -114,6 +112,14 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { const randomNumber = Math.floor(Math.random() * (newPermutations.length - 1)) + // ================================================================= + // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + console.log('Old permutations: ', permutations.length) + console.log('New permutations: ', newPermutations.length) + // console.log(newPermutations[randomNumber]) + // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + // ================================================================= + applySchedule(newPermutations[randomNumber]) setPermutations(newPermutations) } @@ -175,15 +181,21 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { }) setRandomClasses(keyValue) + }, [multipleOptions]) + useEffect(() => { + // console.warn('Reseting locked courses and generator') // ------------------------------------------------------ // Updating locked courses const newLockedCourses = multipleOptions.selected .filter((course) => course.locked) .map((course) => course.course.info.acronym) // Only update if locked courses changed + console.log('Locked courses changed? ', newLockedCourses.join() !== lockedCourses.join()) if (newLockedCourses.join() !== lockedCourses.join()) { setLockedCourses(newLockedCourses) + setPermutations([]) + setGenerator(getSchedulesGenerator()) } }, [multipleOptions]) @@ -193,12 +205,26 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { * - Selected classes for random generations change */ useEffect(() => { + // console.warn('Reseting generator and permutations') setPermutations([]) setGenerator(getSchedulesGenerator()) - }, [multipleOptions, randomClasses]) + }, [multipleOptions.index, randomClasses]) + // }, [multipleOptions.index, randomClasses]) const [generator, setGenerator] = useState(getSchedulesGenerator()) + // =================================================================================================================================== + // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + console.log( + 'Locked courses: ', + courseOptions.filter((course) => course.locked).map((course) => course.course.info.acronym) + ) + // console.log('Random classes: ', randomClasses) + // console.log('Permutations: ', permutations.length) + // console.log('Multiple options: ', multipleOptions) + // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG + // =================================================================================================================================== + return ( From e9927fca2c1b5678ccc19de96f795691e02b393a Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Wed, 7 Feb 2024 20:14:24 +0000 Subject: [PATCH 4/9] Added tooltip on buttons --- .../selectedOptionController/CopyOption.tsx | 24 ++++-- .../selectedOptionController/PasteOption.tsx | 83 +++++++++++-------- .../selectedOptionController/RandomFill.tsx | 3 + 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/src/components/planner/sidebar/selectedOptionController/CopyOption.tsx b/src/components/planner/sidebar/selectedOptionController/CopyOption.tsx index fa375675..71bd46ab 100644 --- a/src/components/planner/sidebar/selectedOptionController/CopyOption.tsx +++ b/src/components/planner/sidebar/selectedOptionController/CopyOption.tsx @@ -4,11 +4,12 @@ import { CheckIcon, DocumentDuplicateIcon } from '@heroicons/react/24/outline' import { Major, CourseOption } from '../../../../@types' import { useToast } from '../../../ui/use-toast' import { Buffer } from 'buffer' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../../ui/tooltip' type Props = { majorHook: [Major, React.Dispatch>] currentOption: CourseOption[] - className?: string, + className?: string } /** @@ -68,13 +69,20 @@ const CopyOption = ({ majorHook, currentOption, className }: Props) => { } return ( - + + + + + + Copiar horário + + ) } diff --git a/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx b/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx index 2ca1dcd4..b08a6eeb 100644 --- a/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx +++ b/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx @@ -16,6 +16,7 @@ import React, { useEffect, useState } from 'react' import ConfirmationModal from './ConfirmationModal' import { Buffer } from 'buffer' import fillOptions from './fillOptions' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../../ui/tooltip' type Props = { majors: Major[] @@ -214,42 +215,56 @@ const PasteOption = ({ majors, majorHook, multipleOptionsHook, checkCourses, isI return ( <> {isClipboardSupported ? ( - + + + + + + Colar horário + + ) : ( - - - - - importSchedule(e.clipboardData.getData('text/plain'))} - onKeyDown={(e) => { - if (e.key === 'Enter') { - importSchedule(e.currentTarget.value) - } - }} - onBlur={() => setIsDropdownOpen(false)} - /> - + + + + + + + + Colar horário + + importSchedule(e.clipboardData.getData('text/plain'))} + onKeyDown={(e) => { + if (e.key === 'Enter') { + importSchedule(e.currentTarget.value) + } + }} + onBlur={() => setIsDropdownOpen(false)} + /> + + + )} >] @@ -239,6 +240,8 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { +
Preenchimento aleatório
+ {Object.keys(randomClasses).map((key) => (
Date: Wed, 7 Feb 2024 20:37:26 +0000 Subject: [PATCH 5/9] Fixed small bug --- .../selectedOptionController/RandomFill.tsx | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx b/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx index ef99caef..b1c64d67 100644 --- a/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx +++ b/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx @@ -22,6 +22,9 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { ) const [randomClasses, setRandomClasses] = useState({}) + console.log(courseOptions) + console.log(randomClasses) + /* Usage: const generator = cartesianGenerator(...schedules); @@ -55,8 +58,7 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { if (course.locked) { return [course.option] } - let aux = course.schedules.filter((schedule) => schedule.lesson_type != 'T' && randomClasses[schedule.class_name]) - return aux + return course.schedules.filter((schedule) => schedule.lesson_type != 'T' && randomClasses[schedule.class_name]) }) return cartesianGenerator(...allSchedules) @@ -113,19 +115,13 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { const randomNumber = Math.floor(Math.random() * (newPermutations.length - 1)) - // ================================================================= - // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - console.log('Old permutations: ', permutations.length) - console.log('New permutations: ', newPermutations.length) - // console.log(newPermutations[randomNumber]) - // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - // ================================================================= - applySchedule(newPermutations[randomNumber]) setPermutations(newPermutations) } const applySchedule = (schedules: CourseSchedule[]) => { + console.log('schedules: ', schedules) + if (schedules.length <= 0) return setMultipleOptions((prevMultipleOptions) => { @@ -184,15 +180,17 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { setRandomClasses(keyValue) }, [multipleOptions]) + /** + * Reseting generator and permutations when: + * - + */ useEffect(() => { - // console.warn('Reseting locked courses and generator') // ------------------------------------------------------ // Updating locked courses const newLockedCourses = multipleOptions.selected .filter((course) => course.locked) .map((course) => course.course.info.acronym) // Only update if locked courses changed - console.log('Locked courses changed? ', newLockedCourses.join() !== lockedCourses.join()) if (newLockedCourses.join() !== lockedCourses.join()) { setLockedCourses(newLockedCourses) setPermutations([]) @@ -202,30 +200,16 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { /** * Reseting generator and permutations when: - * - Multiple options change + * - Selected option changes * - Selected classes for random generations change */ useEffect(() => { - // console.warn('Reseting generator and permutations') setPermutations([]) setGenerator(getSchedulesGenerator()) }, [multipleOptions.index, randomClasses]) - // }, [multipleOptions.index, randomClasses]) const [generator, setGenerator] = useState(getSchedulesGenerator()) - // =================================================================================================================================== - // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - console.log( - 'Locked courses: ', - courseOptions.filter((course) => course.locked).map((course) => course.course.info.acronym) - ) - // console.log('Random classes: ', randomClasses) - // console.log('Permutations: ', permutations.length) - // console.log('Multiple options: ', multipleOptions) - // DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG - // =================================================================================================================================== - return ( From d972ac231bb33cf50811c00d32849d46885de39f Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Wed, 7 Feb 2024 20:48:49 +0000 Subject: [PATCH 6/9] Fixed print on dark mode --- .../planner/schedule/PrintSchedule.tsx | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/components/planner/schedule/PrintSchedule.tsx b/src/components/planner/schedule/PrintSchedule.tsx index 14ef58ea..5a260bda 100644 --- a/src/components/planner/schedule/PrintSchedule.tsx +++ b/src/components/planner/schedule/PrintSchedule.tsx @@ -1,32 +1,38 @@ -import { useCallback } from 'react' +import { useCallback, useContext } from 'react' +import { ThemeContext } from '../../../contexts/ThemeContext' import { Button } from '../../ui/button' import { CameraIcon } from '@heroicons/react/24/outline' import { toPng } from 'html-to-image' import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '../../ui/tooltip' const PrintSchedule = ({ component }) => { - const takeScreenshot = useCallback(() => { - if (component.current === null) { - return - } + const { enabled, setEnabled } = useContext(ThemeContext) - toPng(component.current, { cacheBust: true, backgroundColor: 'white' }) - .then((dataUrl) => { - const link = document.createElement('a') - link.download = 'horario.png' - link.href = dataUrl - link.click() - }) - .catch((err) => { - console.log(err) - }) - }, [component]) + const takeScreenshot = useCallback( + (isThemeEnabled) => { + if (component.current === null) { + return + } + + toPng(component.current, { cacheBust: true, backgroundColor: isThemeEnabled ? '#252733' : '#fbfbfb' }) + .then((dataUrl) => { + const link = document.createElement('a') + link.download = 'horario.png' + link.href = dataUrl + link.click() + }) + .catch((err) => { + console.log(err) + }) + }, + [component] + ) return ( - From 33857e16a20d1373caef96a87ff74a03729a5dde Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Thu, 8 Feb 2024 15:44:26 +0000 Subject: [PATCH 7/9] Added tooltips to buttons --- src/@types/index.d.ts | 1 - src/api/storage.ts | 5 ++--- src/components/planner/sidebar/OptionsController.tsx | 1 - src/components/planner/sidebar/ScheduleListbox.tsx | 4 ---- .../sidebar/selectedOptionController/PasteOption.tsx | 1 - .../planner/sidebar/selectedOptionController/RandomFill.tsx | 6 ------ .../planner/sidebar/selectedOptionController/fillOptions.ts | 1 - src/pages/TimeTableScheduler.tsx | 4 ++-- 8 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/@types/index.d.ts b/src/@types/index.d.ts index 7c66d2b2..c6f41d1b 100644 --- a/src/@types/index.d.ts +++ b/src/@types/index.d.ts @@ -108,7 +108,6 @@ export type MultipleOptions = { index: number selected: CourseOption[] options: CourseOption[][] - names: string[] } export type ImportedCourses = { diff --git a/src/api/storage.ts b/src/api/storage.ts index efd85b6a..fa972cbf 100644 --- a/src/api/storage.ts +++ b/src/api/storage.ts @@ -3,7 +3,7 @@ import { getCourseTeachers } from '../utils/utils' import API from './backend' -const INITIAL_VALUE = { index: 0, selected: [], options: [], names: Array.from({ length: 10 }, (_, i) => `Horário ${i + 1}`) } +const INITIAL_VALUE = { index: 0, selected: [], options: [] } const isStorageValid = (key: string, daysElapsed: number) => { const stored = JSON.parse(localStorage.getItem(key)) @@ -32,8 +32,6 @@ const getOptionsStorage = (): MultipleOptions => { try { if (isStorageValid(key, 7)) { const courseOptions: MultipleOptions = JSON.parse(localStorage.getItem(key)) - // For older files (which don't have the attribute 'names') - if (courseOptions.names === undefined) courseOptions.names = INITIAL_VALUE.names for (let i = 0; i < courseOptions.options.length; i++) { for (let j = 0; j < courseOptions.options[i].length; j++) { @@ -58,6 +56,7 @@ const getOptionsStorage = (): MultipleOptions => { return courseOptions } else { + console.log('Invalid storage') writeStorageInvalid(key, INITIAL_VALUE) return INITIAL_VALUE } diff --git a/src/components/planner/sidebar/OptionsController.tsx b/src/components/planner/sidebar/OptionsController.tsx index 97e2fa84..1a4fc4ea 100644 --- a/src/components/planner/sidebar/OptionsController.tsx +++ b/src/components/planner/sidebar/OptionsController.tsx @@ -24,7 +24,6 @@ const Option = ({ item, selectedHook, multipleOptionsHook }) => { index: newIndex - 1, selected: prev.options[newIndex - 1], options: [...prev.options], - names: prev.names, })) } diff --git a/src/components/planner/sidebar/ScheduleListbox.tsx b/src/components/planner/sidebar/ScheduleListbox.tsx index e51bdb79..0582966b 100644 --- a/src/components/planner/sidebar/ScheduleListbox.tsx +++ b/src/components/planner/sidebar/ScheduleListbox.tsx @@ -69,7 +69,6 @@ const ScheduleListbox = ({ courseOption, multipleOptionsHook, isImportedOptionHo index: prev.index, selected: [...newCourseOptions], options: prev.options, - names: prev.names, } }) } @@ -122,7 +121,6 @@ const ScheduleListbox = ({ courseOption, multipleOptionsHook, isImportedOptionHo index: prev.index, selected: [...newCourseOptions], options: prev.options, - names: prev.names, } }) } else if (type === 'TP') { @@ -141,7 +139,6 @@ const ScheduleListbox = ({ courseOption, multipleOptionsHook, isImportedOptionHo index: prev.index, selected: [...newCourseOptions], options: prev.options, - names: prev.names, } }) } @@ -183,7 +180,6 @@ const ScheduleListbox = ({ courseOption, multipleOptionsHook, isImportedOptionHo index: prevMultipleOptions.index, selected: resolvedCourseOptions, options: resolvedOptions, - names: prevMultipleOptions.names, } return value diff --git a/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx b/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx index b08a6eeb..83c3e376 100644 --- a/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx +++ b/src/components/planner/sidebar/selectedOptionController/PasteOption.tsx @@ -202,7 +202,6 @@ const PasteOption = ({ majors, majorHook, multipleOptionsHook, checkCourses, isI index: prevMultipleOptions.index, selected: importedOption.courses, options: newOptions, - names: prevMultipleOptions.names, } return value diff --git a/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx b/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx index b1c64d67..55765bd4 100644 --- a/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx +++ b/src/components/planner/sidebar/selectedOptionController/RandomFill.tsx @@ -22,9 +22,6 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { ) const [randomClasses, setRandomClasses] = useState({}) - console.log(courseOptions) - console.log(randomClasses) - /* Usage: const generator = cartesianGenerator(...schedules); @@ -120,8 +117,6 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { } const applySchedule = (schedules: CourseSchedule[]) => { - console.log('schedules: ', schedules) - if (schedules.length <= 0) return setMultipleOptions((prevMultipleOptions) => { @@ -137,7 +132,6 @@ const RandomFill = ({ multipleOptionsHook, className }: Props) => { index: prevMultipleOptions.index, selected: [...newSelected], options: prevMultipleOptions.options, - names: prevMultipleOptions.names, } return value diff --git a/src/components/planner/sidebar/selectedOptionController/fillOptions.ts b/src/components/planner/sidebar/selectedOptionController/fillOptions.ts index 193f0705..932b2bb8 100644 --- a/src/components/planner/sidebar/selectedOptionController/fillOptions.ts +++ b/src/components/planner/sidebar/selectedOptionController/fillOptions.ts @@ -34,7 +34,6 @@ const fillOptions = (importedCourses: ImportedCourses, setMultipleOptions: React index: prevMultipleOptions.index, selected: newOptions[prevMultipleOptions.index], options: newOptions, - names: prevMultipleOptions.names, }; return value; diff --git a/src/pages/TimeTableScheduler.tsx b/src/pages/TimeTableScheduler.tsx index aea67750..524e3ca7 100644 --- a/src/pages/TimeTableScheduler.tsx +++ b/src/pages/TimeTableScheduler.tsx @@ -136,7 +136,6 @@ const TimeTableSchedulerPage = () => { index: 0, selected: [], options: [], - names: Array.from({ length: 10 }, (_, i) => `Horário ${i + 1}`), }) // schedule options and selected schedule const totalSelected = useMemo( () => multipleOptions.options.map((co: CourseOption[]) => co.filter((item) => item.option !== null)).flat(), @@ -352,7 +351,6 @@ const TimeTableSchedulerPage = () => { index: prev.index, selected: newCourseOptions, options: newOptions, - names: prev.names, } }) @@ -397,6 +395,8 @@ const TimeTableSchedulerPage = () => { setCheckedCourses(newCheckedCourses) } + console.log(multipleOptions) + return (
{/* Schedule Preview */} From 1794fc3f861875b9f3a07bc4f3c4fa819c5a8d51 Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Thu, 8 Feb 2024 15:51:07 +0000 Subject: [PATCH 8/9] Updated courses order to mimic sigarra --- .../planner/sidebar/CoursesController.tsx | 8 ++-- .../sessionController/CoursePicker.tsx | 42 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/components/planner/sidebar/CoursesController.tsx b/src/components/planner/sidebar/CoursesController.tsx index 891e6873..8f7521b2 100644 --- a/src/components/planner/sidebar/CoursesController.tsx +++ b/src/components/planner/sidebar/CoursesController.tsx @@ -8,16 +8,16 @@ const CoursesController = ({ multilpleOptionsHook, isImportedOptionHook }) => { return (
{multipleOptions.selected.length > 0 && - removeDuplicatesFromCourseOption(multipleOptions.options[multipleOptions.index]).map( - (courseOption, courseOptionIdx) => ( + removeDuplicatesFromCourseOption(multipleOptions.options[multipleOptions.index]) + .sort((a, b) => a.course.info.sigarra_id - b.course.info.sigarra_id) + .map((courseOption, courseOptionIdx) => ( - ) - )} + ))}
) } diff --git a/src/components/planner/sidebar/sessionController/CoursePicker.tsx b/src/components/planner/sidebar/sessionController/CoursePicker.tsx index 0dc23cdf..1847826f 100644 --- a/src/components/planner/sidebar/sessionController/CoursePicker.tsx +++ b/src/components/planner/sidebar/sessionController/CoursePicker.tsx @@ -396,27 +396,29 @@ const SelectionModal = ({ {/* Children checkboxes */}
- {year.map((course: CheckedCourse, courseIdx: number) => ( -
- handleCheck(event, yearIdx, courseIdx)} - /> -
+ ))}
)) From fe08f99da0c24f689af17ce3bdbe64db28fbf500 Mon Sep 17 00:00:00 2001 From: diogotvf7 Date: Sat, 10 Feb 2024 16:07:25 +0000 Subject: [PATCH 9/9] Removed debug console.logs --- src/api/storage.ts | 1 - src/pages/TimeTableScheduler.tsx | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/api/storage.ts b/src/api/storage.ts index fa972cbf..040e2f81 100644 --- a/src/api/storage.ts +++ b/src/api/storage.ts @@ -56,7 +56,6 @@ const getOptionsStorage = (): MultipleOptions => { return courseOptions } else { - console.log('Invalid storage') writeStorageInvalid(key, INITIAL_VALUE) return INITIAL_VALUE } diff --git a/src/pages/TimeTableScheduler.tsx b/src/pages/TimeTableScheduler.tsx index 524e3ca7..316cc8a6 100644 --- a/src/pages/TimeTableScheduler.tsx +++ b/src/pages/TimeTableScheduler.tsx @@ -395,8 +395,6 @@ const TimeTableSchedulerPage = () => { setCheckedCourses(newCheckedCourses) } - console.log(multipleOptions) - return (
{/* Schedule Preview */}