Skip to content

Commit 28199ce

Browse files
authored
Merge pull request #497 from atharvaSharma17/prod
Fix: filter + sort bug
2 parents 74f39eb + 9649fb5 commit 28199ce

7 files changed

Lines changed: 17 additions & 31 deletions

File tree

src/components/CatalogueContent.tsx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -177,31 +177,6 @@ const CatalogueContentInner = ({ subject }: { subject: string | null }) => {
177177
void fetchPapers();
178178
}, [subject, isMounted, setPapers, setFilterOptions]);
179179

180-
useEffect(() => {
181-
if (!papers.length) return;
182-
183-
const filtered = [...papers];
184-
185-
if (sortOption === "asc") {
186-
filtered.sort((a, b) => a.year.localeCompare(b.year));
187-
} else if (sortOption === "desc") {
188-
filtered.sort((a, b) => b.year.localeCompare(a.year));
189-
}
190-
191-
setFilteredPapers(filtered);
192-
}, [
193-
papers,
194-
selectedExams,
195-
selectedSlots,
196-
selectedYears,
197-
selectedSemesters,
198-
selectedCampuses,
199-
selectedAnswerKeyIncluded,
200-
sortOption,
201-
setFilteredPapers,
202-
setAppliedFilters,
203-
]);
204-
205180
useEffect(() => {
206181
if (!papers.length) return;
207182

@@ -255,6 +230,7 @@ const CatalogueContentInner = ({ subject }: { subject: string | null }) => {
255230
selectedSemesters,
256231
selectedCampuses,
257232
selectedAnswerKeyIncluded,
233+
sortOption,
258234
setFilteredPapers,
259235
setAppliedFilters,
260236
]);

src/components/ReportButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export default function ReportButton(){
1010
const { paperId, subject, exam, slot, year } = usePaper();
1111
const [open, setOpen] = useState(false);
1212
return (
13-
<>
13+
<>
1414
<Button
15+
1516
onClick={() => setOpen(true)}
1617
className="h-10 w-10 rounded p-0 text-white transition hover:bg-red-600 bg-red-500"
18+
title="Report this paper"
1719
>
1820
<FaFlag className="text-sm" />
1921
</Button>

src/components/ShareButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function ShareButton() {
3030
return (
3131
<Dialog>
3232
<DialogTrigger asChild>
33-
<Button className="aspect-square h-10 w-10 p-0 rounded text-white bg-[#6536c1] transition hover:bg-[#7d4fc7]">
33+
<Button className="aspect-square h-10 w-10 p-0 rounded text-white bg-[#6536c1] transition hover:bg-[#7d4fc7]" title="Share this paper">
3434
<FaShare />
3535
</Button>
3636
</DialogTrigger>
@@ -47,6 +47,7 @@ export default function ShareButton() {
4747
type="submit"
4848
size="sm"
4949
className="flex w-fit items-center justify-between gap-5 px-3"
50+
title="Copy link to clipboard"
5051
onClick={async () => {
5152
await toast.promise(
5253
navigator.clipboard.writeText(paperPath), // This is a promise

src/components/SideBar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ function SideBar() {
1919
handleApplyFilters,
2020
} = useFilters();
2121
const exams =
22-
filterOptions?.unique_exams.map((exam) => ({ label: exam, value: exam })) ??
23-
[];
22+
filterOptions?.unique_exams
23+
.sort((a, b) => a.localeCompare(b))
24+
.map((exam) => ({ label: exam, value: exam })) ?? [];
2425
const slots =
2526
filterOptions?.unique_slots
2627
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }))

src/components/UpcomingPaper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export default function PaperCard({ subject, slots }: PaperCardProps) {
105105

106106
{
107107
<div className="mt-4 flex flex-wrap gap-2 font-play">
108-
{slots?.map((slotValue, index) => (
108+
{[...slots].sort().map((slotValue, index) => (
109109
<Capsule key={index}>{slotValue}</Capsule>
110110
))}
111111
</div>

src/components/multi-select.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ export const MultiSelect = React.forwardRef<
307307
</div>
308308
<span>(Select All)</span>
309309
</CommandItem>
310-
{options.map((option) => {
310+
{options
311+
.sort((a, b) => a.label.localeCompare(b.label))
312+
.map((option) => {
311313
const isSelected = selectedValues.includes(option.value);
312314
return (
313315
<CommandItem

src/components/newPdfViewer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr
114114
<Button
115115
onClick={toggleFullscreen}
116116
className="h-10 w-10 rounded p-0 text-white bg-[#6536c1] transition hover:bg-[#7d4fc7]"
117+
title={isFullscreen ? "Exit fullscreen" : "Enter fullscreen"}
117118
>
118119
{isFullscreen ? <Minimize2 size={24} /> : <Maximize2 size={24} />}
119120
</Button>
120121

121122
<Button
122123
onClick={onDownload}
123124
className="h-10 w-10 rounded p-0 text-white bg-[#6536c1] transition hover:bg-[#7d4fc7]"
125+
title="Download PDF"
124126
>
125127
<Download size={24} />
126128
</Button>
@@ -131,6 +133,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr
131133
onClick={zoomOut}
132134
disabled={typeof zoomLevel === "number" && zoomLevel <= 0.25}
133135
className="h-10 w-10 rounded p-0 text-white bg-[#6536c1] transition hover:bg-[#7d4fc7] disabled:bg-gray-400"
136+
title="Zoom out"
134137
>
135138
<ZoomOut size={24} />
136139
</Button>
@@ -143,6 +146,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr
143146
onClick={zoomIn}
144147
disabled={typeof zoomLevel === "number" && zoomLevel >= 3}
145148
className="h-10 w-10 rounded p-0 text-white bg-[#6536c1] transition hover:bg-[#7d4fc7] disabled:bg-gray-400"
149+
title="Zoom in"
146150
>
147151
<ZoomIn size={24} />
148152
</Button>

0 commit comments

Comments
 (0)