Skip to content

Commit

Permalink
chore: Format
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Nov 27, 2024
1 parent 9c8f719 commit 8e23e88
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/modules/project/hooks/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { useMemo, useState } from "react";

import { indexer } from "@/common/api/indexer";
import { toChronologicalOrder } from "@/common/lib";
import {
ByListId,
ChronologicalSortOrder,
ChronologicalSortOrderVariant,
} from "@/common/types";
import { ByListId, ChronologicalSortOrder, ChronologicalSortOrderVariant } from "@/common/types";

import { ProjectCategory, ProjectListingStatusVariant } from "../types";

Expand All @@ -17,11 +13,11 @@ export const useProjectLookup = ({ listId }: ProjectLookupParams) => {
const [searchTerm, setSearchTerm] = useState<string | undefined>(undefined);
const [categoryFilter, setCategoryFilter] = useState<ProjectCategory[]>([]);

const [statusFilter, setStatusFilter] =
useState<ProjectListingStatusVariant>("Approved");
const [statusFilter, setStatusFilter] = useState<ProjectListingStatusVariant>("Approved");

const [sortingOrder, setSortingOrder] =
useState<ChronologicalSortOrderVariant>(ChronologicalSortOrder.recent);
const [sortingOrder, setSortingOrder] = useState<ChronologicalSortOrderVariant>(
ChronologicalSortOrder.recent,
);

const {
data: listRegistrations,
Expand All @@ -36,14 +32,9 @@ export const useProjectLookup = ({ listId }: ProjectLookupParams) => {
});

const results = useMemo(() => {
const oldToRecent = toChronologicalOrder(
"submitted_at",
listRegistrations?.results ?? [],
);
const oldToRecent = toChronologicalOrder("submitted_at", listRegistrations?.results ?? []);

return sortingOrder === ChronologicalSortOrder.older
? oldToRecent
: oldToRecent.toReversed();
return sortingOrder === ChronologicalSortOrder.older ? oldToRecent : oldToRecent.toReversed();
}, [listRegistrations?.results, sortingOrder]);

return {
Expand Down

0 comments on commit 8e23e88

Please sign in to comment.