Skip to content

Commit

Permalink
Merge pull request #99 from EmploymentRescueTeam/feature/#94
Browse files Browse the repository at this point in the history
Fix:main page ssr 타입선언 구현
  • Loading branch information
LeHiHo authored Nov 6, 2023
2 parents 2af0104 + 88a2cff commit 5bd2a08
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/main/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import MainPage from '@/templates/main/mainPage';
import { getProducts } from '@/api/service';

export default async function Main() {
const data = await getProducts();
const { data } = await getProducts();

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions src/components/productList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IProduct } from '@/types/interface';
import { IProduct, IProductProps } from '@/types/interface';
import ProductItem from './productItem';
import '@/styles/components/productList.scss';

export default function ProductList({ data }: { data: IProduct[] }) {
export default function ProductList({ data }: IProductProps) {
return (
<ul className="products">
{data?.map((product: IProduct) => (
{data.map((product: IProduct) => (
<ProductItem key={product.id} product={product} />
))}
</ul>
Expand Down
7 changes: 3 additions & 4 deletions src/templates/main/mainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import { RxHamburgerMenu } from 'react-icons/rx';
import Navbar from '@/components/navbar';
import { useRouter } from 'next/navigation';
import { useSearchParams } from 'next/navigation';
interface MainPageProps {
data: any[]; // Use a more specific type based on your data structure
}
import { IProductProps } from '@/types/interface';

export default function MainPage({ data }: MainPageProps) {
export default function MainPage({ data }: IProductProps) {
const categoryParams = useSearchParams();
const category = categoryParams.get('category') || undefined;

Expand All @@ -39,6 +37,7 @@ export default function MainPage({ data }: MainPageProps) {
</header>
<section className="main__content">
<ProductList data={data} />

<AddBtn />
</section>
<Navbar />
Expand Down
4 changes: 4 additions & 0 deletions src/types/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export interface IProduct {
thumbnail: string;
}

export interface IProductProps {
data: IProduct[];
}

export type Product = {
id: number;
title: string;
Expand Down

0 comments on commit 5bd2a08

Please sign in to comment.