Skip to content

Commit

Permalink
feat: home.tsx 주석 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
minh0518 committed Sep 26, 2024
1 parent dade2d2 commit 19b31b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/app/(afterlogin)/(common_navbar)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,40 @@ import CardList from '../_components/CardList';

export default async function Page() {
const queryClient = new QueryClient();
// const listResponse = await queryClient.fetchInfiniteQuery({
// queryKey: ['home', 'list'],
// queryFn: async ({ pageParam = 0 }) => {
// const response = await serverHomeApi.getPresentationList({ pageParam });
// return await response.json();
// },
// initialPageParam: 0,
// });
const listResponse = await queryClient.fetchInfiniteQuery({
queryKey: ['home', 'list'],
queryFn: async ({ pageParam = 0 }) => {
const response = await serverHomeApi.getPresentationList({ pageParam });
return await response.json();
},
initialPageParam: 0,
});

// const isEmpty = listResponse.pages[0].page.empty;
const isEmpty = listResponse.pages[0].page.empty;

// const latestResponse = await queryClient.fetchQuery({
// queryKey: ['home', 'latest'],
// queryFn: async () => {
// const latestResponse = await serverHomeApi.getLatestPresentation();
// if (latestResponse.status === 204) return 'empty';
// return await latestResponse.json();
// },
// });
const latestResponse = await queryClient.fetchQuery({
queryKey: ['home', 'latest'],
queryFn: async () => {
const latestResponse = await serverHomeApi.getLatestPresentation();
if (latestResponse.status === 204) return 'empty';
return await latestResponse.json();
},
});

const dehydratedState = dehydrate(queryClient);
return (
<>
{/*
{isEmpty ? (
<GuideForNew />
) : (
<div className={styles.container}>
<HydrationBoundary state={dehydratedState}>
{latestResponse !== 'empty' && <HistoryBanner presentation={latestResponse} />}
{/* <ExerciseList /> */}
<CardList />
</HydrationBoundary>
</div>
)}
*/}
<CardList />
</>
);
}
2 changes: 2 additions & 0 deletions src/services/server/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fetch_ServerAuth } from './fetchServer';

export const serverHomeApi = {
getPresentationList: async ({ pageParam }: { pageParam?: number }) => {
console.log(SERVER_BASE_URL);
const response = await fetch_ServerAuth(
`${SERVER_BASE_URL}/api/presentations?page=${pageParam}&size=6`,
{ method: 'GET', cache: 'no-store' },
Expand All @@ -13,6 +14,7 @@ export const serverHomeApi = {
},

getLatestPresentation: async () => {
console.log(SERVER_BASE_URL);
const response = await fetch_ServerAuth(`${SERVER_BASE_URL}/api/presentations/latest`, {
method: 'GET',
cache: 'no-store',
Expand Down

0 comments on commit 19b31b1

Please sign in to comment.