Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleveille committed Jun 1, 2024
1 parent 23c2067 commit 703db97
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/app/[name_slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { API } from "@services";

export const generateStaticParams = async () => {
const discs = await API.getDiscs();
const paths = discs.map(({ name_slug }) => ({ params: { name_slug } }));
return paths;
return discs.map(({ name_slug }) => ({ params: { name_slug } }));
};

export default function DiscDetailPage({ params: { name_slug } }: { params: { name_slug: string } }) {
Expand Down
12 changes: 6 additions & 6 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export default async function RootLayout({
}>) {
const discs = await API.getDiscs();
return (
<html lang="en">
<body className={inter.className}>
<DiscContextProvider discs={discs}>
<DiscContextProvider discs={discs}>
<html lang="en">
<body className={inter.className}>
{children}
{modal}
</DiscContextProvider>
</body>
</html>
</body>
</html>
</DiscContextProvider>
);
}

Expand Down
18 changes: 14 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { Home } from "@components";
"use client";

import { ClerkProvider } from "@clerk/nextjs";
import { DiscCount, DiscGrid, Filters, Header, ScrollToTop } from "@components";
import { config } from "@services";

export default function HomePage() {
return (
<main>
<Home />
</main>
<ClerkProvider publishableKey={config.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}>
<main>
<Header />
<Filters />
<DiscCount />
<DiscGrid />
<ScrollToTop />
</main>
</ClerkProvider>
);
}
17 changes: 0 additions & 17 deletions src/components/Home.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export * from "./DiscModal";
export * from "./DiscNotFound";
export * from "./Filters";
export * from "./Header";
export * from "./Home";
export * from "./ScrollToTop";
4 changes: 2 additions & 2 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { config } from "@services";

import type { Disc, RequestParams } from "@types";

const request = async <T = unknown>({ url, method, body, tags }: RequestParams) => {
const requestJson = async <T = unknown>({ url, method, body, tags }: RequestParams) => {
const res = await fetch(url, {
method,
headers: {
Expand All @@ -17,7 +17,7 @@ const request = async <T = unknown>({ url, method, body, tags }: RequestParams)

export const API = {
getDiscs: async () =>
request<Disc[]>({
requestJson<Disc[]>({
url: `${config.API_URL}/disc`,
method: RequestMethod.GET,
tags: ["disc"]
Expand Down

0 comments on commit 703db97

Please sign in to comment.