web: use date descending sort

This commit is contained in:
Quaternions 2025-04-06 15:15:23 -07:00
parent 0666685a49
commit c9ba2e3e6e
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
3 changed files with 19 additions and 2 deletions
web/src/app
mapfixes
submissions
ts

@ -8,6 +8,7 @@ import Webpage from "@/app/_components/webpage";
// TODO: MAKE MAPFIX & SUBMISSIONS USE THE SAME COMPONENTS :angry: (currently too lazy)
import "./(styles)/page.scss";
import { ListSortConstants } from "../ts/Sort";
export default function MapfixInfoPage() {
const [mapfixes, setMapfixes] = useState<MapfixList>({Total:0,Mapfixes:[]})
@ -35,7 +36,7 @@ export default function MapfixInfoPage() {
useEffect(() => {
async function fetchMapfixes() {
const res = await fetch(`/api/mapfixes?Page=${currentPage}&Limit=${cardsPerPage}`)
const res = await fetch(`/api/mapfixes?Page=${currentPage}&Limit=${cardsPerPage}&Sort=${ListSortConstants.ListSortDateDescending}`)
if (res.ok) {
setMapfixes(await res.json())
}

@ -6,6 +6,7 @@ import { SubmissionCard } from "../_components/mapCard";
import Webpage from "@/app/_components/webpage";
import "./(styles)/page.scss";
import { ListSortConstants } from "../ts/Sort";
export default function SubmissionInfoPage() {
const [submissions, setSubmissions] = useState<SubmissionList>({Total:0,Submissions:[]})
@ -33,7 +34,7 @@ export default function SubmissionInfoPage() {
useEffect(() => {
async function fetchSubmissions() {
const res = await fetch(`/api/submissions?Page=${currentPage}&Limit=${cardsPerPage}`)
const res = await fetch(`/api/submissions?Page=${currentPage}&Limit=${cardsPerPage}&Sort=${ListSortConstants.ListSortDateDescending}`)
if (res.ok) {
setSubmissions(await res.json())
}

15
web/src/app/ts/Sort.ts Normal file

@ -0,0 +1,15 @@
type ListSort = number;
// Constants
const ListSortConstants = {
ListSortDisabled: 0,
ListSortDisplayNameAscending: 1,
ListSortDisplayNameDescending: 2,
ListSortDateAscending: 3,
ListSortDateDescending: 4,
};
export {
type ListSort,
ListSortConstants,
};