-
Notifications
You must be signed in to change notification settings - Fork 0
Schedule changes #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Schedule changes #310
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,11 @@ import { Database } from "../db/database.types"; | |
| export interface Settings { | ||
| theme: "light" | "dark" | "system"; | ||
| compact: boolean; | ||
| sortBySchedule: boolean; | ||
| sortBySchedule: boolean; //disabled (does not work) | ||
| homepageAssignments: "all" | "student" | "none"; | ||
| homepageView: "auto" | "tabbed" | "student" | "teacher"; | ||
| showAMPM: boolean; | ||
| schedulesToShow: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for future reference, it might be easier to use an enum or normal numbers, but this works just as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tried that, turns out that settings wanted strings and I was too tired to deal with it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, my bad then |
||
| } | ||
|
|
||
| interface SettingsStore { | ||
|
|
@@ -25,6 +26,7 @@ const defaultSettings: Settings = { | |
| homepageAssignments: "student", | ||
| homepageView: "auto", | ||
| showAMPM: false, | ||
| schedulesToShow: "2", | ||
| }; | ||
|
|
||
| export const useSettings = create<SettingsStore>()( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,17 +5,14 @@ import HomepageClassesUI from "../components/class/homepage"; | |
| //import { sortClasses } from "../components/class/sorting"; | ||
| import { AssignmentPreview } from "../components/assignments/assignments"; | ||
| import ScheduleComponent from "../components/complete/schedule"; | ||
| import { | ||
| AllClasses, | ||
| AllClassesResponse, | ||
| getAllClasses, | ||
| } from "../lib/db/classes"; | ||
| import { AllClasses, getAllClasses } from "../lib/db/classes"; | ||
| import { Database } from "../lib/db/database.types"; | ||
| import { ScheduleInterface, getSchedulesForXDays } from "../lib/db/schedule"; | ||
| import { useSettings } from "../lib/stores/settings"; | ||
| import blankCanvas from "@/public/svgs/blank-canvas.svg"; | ||
| import Layout from "@/components/layout/layout"; | ||
| import Image from "next/image"; | ||
| import { Button } from "@/components/misc/button"; | ||
|
|
||
| const Home = () => { | ||
| const supabaseClient = useSupabaseClient<Database>(); | ||
|
|
@@ -25,12 +22,16 @@ const Home = () => { | |
| const [schedules, setSchedules] = useState< | ||
| { schedule: ScheduleInterface[]; date: Date }[] | ||
| >([]); | ||
| const [showMoreSchedules, setShowMoreSchedules] = useState(false); | ||
| const dateFormat = new Intl.DateTimeFormat("en-US", { | ||
| weekday: "long", | ||
| month: "long", | ||
| day: "numeric", | ||
| timeZone: "Europe/London", | ||
| }); | ||
| const { | ||
| data: { schedulesToShow }, | ||
| } = useSettings(); | ||
|
|
||
| useEffect(() => { | ||
| const [classes, schedule] = [ | ||
|
|
@@ -71,7 +72,11 @@ const Home = () => { | |
| getAllClasses(supabaseClient, user.id), | ||
| // read comment in above useEffect as to why I'm fetching 3 dates -Lukas | ||
| // I'm going to fetch like 5 because weekends or some excuse - Bill | ||
| getSchedulesForXDays(supabaseClient, new Date(), 1), | ||
| getSchedulesForXDays( | ||
| supabaseClient, | ||
| new Date(), | ||
| parseInt(schedulesToShow) - 1 | ||
| ), | ||
| ]); | ||
|
|
||
| if (classes.data && classes.data[0]) { | ||
|
|
@@ -138,9 +143,9 @@ const Home = () => { | |
| {/* Schedule UI */} | ||
| <section | ||
| id="Schedule" | ||
| className="flex grow flex-col md:flex-row lg:ml-10 lg:flex-col" | ||
| className="flex grow flex-col md:flex-row lg:ml-10 lg:flex-col max-lg:" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you add max-lg here |
||
| > | ||
| {schedules.map((schedule, index) => ( | ||
| {schedules.slice(0, 2).map((schedule, index) => ( | ||
| <div key={index} className="w-full md:mr-4 lg:mr-0"> | ||
| <h2 className="title mr-2"> | ||
| {dateFormat.format(schedule.date)} | ||
|
|
@@ -153,6 +158,37 @@ const Home = () => { | |
| /> | ||
| </div> | ||
| ))} | ||
| {schedules.length > 2 && !showMoreSchedules && ( | ||
| <Button | ||
| className="justify-center max-lg:hidden" | ||
| onClick={() => setShowMoreSchedules(true)} | ||
| > | ||
| Show More Schedules | ||
| </Button> | ||
| )} | ||
| {showMoreSchedules && ( | ||
| <div className="max-lg:hidden"> | ||
| {schedules.slice(2).map((schedule, index) => ( | ||
| <div key={index} className="w-full md:mr-4 lg:mr-0"> | ||
| <h2 className="title mr-2"> | ||
| {dateFormat.format(schedule.date)} | ||
| </h2> | ||
|
|
||
| <ScheduleComponent | ||
| classes={classes} | ||
| schedule={schedule.schedule} | ||
| loading={loading} | ||
| /> | ||
| </div> | ||
| ))} | ||
| <Button | ||
| className="justify-center" | ||
| onClick={() => setShowMoreSchedules(false)} | ||
| > | ||
| Show Fewer Schedules | ||
| </Button> | ||
| </div> | ||
| )} | ||
|
Comment on lines
+161
to
+191
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple issues with this button:
let's remove this for now, or at least find a better way to implement it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that's what you wanted.... k. should have been draft though, ur right
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, my bad. probably should've discussed this one more |
||
| </section> | ||
| </div> | ||
| {Array.isArray(classes) && | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason the dropdown section isn't always to the right