diff --git a/src/components/CatalogueContent.tsx b/src/components/CatalogueContent.tsx index 340cc51..df84ff6 100644 --- a/src/components/CatalogueContent.tsx +++ b/src/components/CatalogueContent.tsx @@ -177,31 +177,6 @@ const CatalogueContentInner = ({ subject }: { subject: string | null }) => { void fetchPapers(); }, [subject, isMounted, setPapers, setFilterOptions]); - useEffect(() => { - if (!papers.length) return; - - const filtered = [...papers]; - - if (sortOption === "asc") { - filtered.sort((a, b) => a.year.localeCompare(b.year)); - } else if (sortOption === "desc") { - filtered.sort((a, b) => b.year.localeCompare(a.year)); - } - - setFilteredPapers(filtered); - }, [ - papers, - selectedExams, - selectedSlots, - selectedYears, - selectedSemesters, - selectedCampuses, - selectedAnswerKeyIncluded, - sortOption, - setFilteredPapers, - setAppliedFilters, - ]); - useEffect(() => { if (!papers.length) return; @@ -255,6 +230,7 @@ const CatalogueContentInner = ({ subject }: { subject: string | null }) => { selectedSemesters, selectedCampuses, selectedAnswerKeyIncluded, + sortOption, setFilteredPapers, setAppliedFilters, ]); diff --git a/src/components/ReportButton.tsx b/src/components/ReportButton.tsx index 80cd7f8..8453351 100644 --- a/src/components/ReportButton.tsx +++ b/src/components/ReportButton.tsx @@ -10,10 +10,12 @@ export default function ReportButton(){ const { paperId, subject, exam, slot, year } = usePaper(); const [open, setOpen] = useState(false); return ( - <> + <> setOpen(true)} className="h-10 w-10 rounded p-0 text-white transition hover:bg-red-600 bg-red-500" + title="Report this paper" > diff --git a/src/components/ShareButton.tsx b/src/components/ShareButton.tsx index 60fc3c1..e06c7a6 100644 --- a/src/components/ShareButton.tsx +++ b/src/components/ShareButton.tsx @@ -30,7 +30,7 @@ export default function ShareButton() { return ( - + @@ -47,6 +47,7 @@ export default function ShareButton() { type="submit" size="sm" className="flex w-fit items-center justify-between gap-5 px-3" + title="Copy link to clipboard" onClick={async () => { await toast.promise( navigator.clipboard.writeText(paperPath), // This is a promise diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index f5dc1cf..a3b535b 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -19,8 +19,9 @@ function SideBar() { handleApplyFilters, } = useFilters(); const exams = - filterOptions?.unique_exams.map((exam) => ({ label: exam, value: exam })) ?? - []; + filterOptions?.unique_exams + .sort((a, b) => a.localeCompare(b)) + .map((exam) => ({ label: exam, value: exam })) ?? []; const slots = filterOptions?.unique_slots .sort((a, b) => a.localeCompare(b, undefined, { numeric: true })) diff --git a/src/components/UpcomingPaper.tsx b/src/components/UpcomingPaper.tsx index 4da6923..275fb0b 100644 --- a/src/components/UpcomingPaper.tsx +++ b/src/components/UpcomingPaper.tsx @@ -105,7 +105,7 @@ export default function PaperCard({ subject, slots }: PaperCardProps) { { - {slots?.map((slotValue, index) => ( + {[...slots].sort().map((slotValue, index) => ( {slotValue} ))} diff --git a/src/components/multi-select.tsx b/src/components/multi-select.tsx index 1e5a78a..ae11f1b 100644 --- a/src/components/multi-select.tsx +++ b/src/components/multi-select.tsx @@ -307,7 +307,9 @@ export const MultiSelect = React.forwardRef< (Select All) - {options.map((option) => { + {options + .sort((a, b) => a.label.localeCompare(b.label)) + .map((option) => { const isSelected = selectedValues.includes(option.value); return ( {isFullscreen ? : } @@ -121,6 +122,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr @@ -131,6 +133,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr onClick={zoomOut} disabled={typeof zoomLevel === "number" && zoomLevel <= 0.25} className="h-10 w-10 rounded p-0 text-white bg-[#6536c1] transition hover:bg-[#7d4fc7] disabled:bg-gray-400" + title="Zoom out" > @@ -143,6 +146,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr onClick={zoomIn} disabled={typeof zoomLevel === "number" && zoomLevel >= 3} className="h-10 w-10 rounded p-0 text-white bg-[#6536c1] transition hover:bg-[#7d4fc7] disabled:bg-gray-400" + title="Zoom in" >