Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StephDietz committed May 9, 2024
1 parent 5c1941c commit 65cfe28
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/components/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRouter } from "next/navigation";
import { useOptimistic, useTransition, useState } from "react";
import { ChevronDownIcon } from "@heroicons/react/24/outline";
import { FunnelIcon } from "@heroicons/react/24/outline";
import clsx from "clsx";

interface ExpandedSections {
[key: string]: boolean;
Expand Down
12 changes: 6 additions & 6 deletions app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function isTableMissing(error: any) {
return error.code === "42P01";
}

function errorMessage(error: any, returnVal: number | never[]) {
function handleDatabaseError(error: any, returnVal: number | never[]) {
if (isTableMissing(error)) {
console.error("Database Error - Table missing:", error);
return returnVal;
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function fetchFilteredBooks(
`;
return books.rows;
} catch (error) {
errorMessage(error, []);
return handleDatabaseError(error, []);
}
}

Expand Down Expand Up @@ -82,7 +82,7 @@ export async function fetchFilteredBooks(
`;
return books.rows;
} catch (error) {
errorMessage(error, []);
return handleDatabaseError(error, []);
}
}

Expand All @@ -100,7 +100,7 @@ export async function fetchAuthors() {
`;
return authors.rows?.map((row) => row.author);
} catch (error) {
errorMessage(error, []);
return handleDatabaseError(error, []);
}
}

Expand All @@ -126,7 +126,7 @@ export async function fetchPages(query: string, selectedAuthors: string[]) {
);
return totalPages;
} catch (error) {
errorMessage(error, 0);
return handleDatabaseError(error, 0);
}
}

Expand All @@ -144,6 +144,6 @@ export async function fetchPages(query: string, selectedAuthors: string[]) {
const totalPages = Math.ceil(Number(count.rows[0].count) / ITEMS_PER_PAGE);
return totalPages;
} catch (error) {
errorMessage(error, 0);
return handleDatabaseError(error, 0);
}
}
1 change: 0 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default async function Page({
const query = searchParams?.query || "";
const currentPage = Number(searchParams?.page) || 1;
const allAuthors = await fetchAuthors();
console.log(allAuthors);
const selectedAuthors = !searchParams.author
? []
: typeof searchParams.author === "string"
Expand Down

0 comments on commit 65cfe28

Please sign in to comment.