From 7ca5ba044c653f79397340fb28db81cad5299d11 Mon Sep 17 00:00:00 2001 From: Raymond Date: Tue, 5 Mar 2024 22:13:15 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EC=A0=95=EC=9B=90=EC=B9=B4=EB=93=9C?= =?UTF-8?q?=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/garden/index.tsx | 139 +++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 82 deletions(-) diff --git a/pages/garden/index.tsx b/pages/garden/index.tsx index 7eeabd4..55f0a29 100644 --- a/pages/garden/index.tsx +++ b/pages/garden/index.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useEffect, useState } from 'react' +import { ReactNode, useEffect, useMemo, useState } from 'react' import BaseLayout from '@/layout/base-layout' import withAuth from '@/layout/HOC/with-auth' import Button from '@/components/button' @@ -67,7 +67,10 @@ const Pages = () => { setFlippedCardIndex(index) } } - + const totalCount = useMemo( + () => surveys?.pages[0].data.totalCount ?? 0, + [surveys], + ) return ( { - +
@@ -105,89 +110,59 @@ const Pages = () => { {surveys?.pages.map((page, pageNo) => - pageNo === 0 && page.data.content.length < 21 ? ( - [ - ...page.data.content, - ...Array.from( - { length: 21 - page.data.content.length }, - (v) => null, - ), - ].map((item, index) => - item ? ( - handleCardClick(index)} + page.data.content.map((item, index) => ( + handleCardClick(index)} + /> + )), + )} + {Array.from( + { length: Math.abs((totalCount % 3) - 3) + 3 }, + () => null, + ).map((_, index) => ( + +
+ + - ) : ( - -
- - - - - - -
- - ), - ) - ) : ( - - {page.data.content.map((item, index) => ( - handleCardClick(index)} + + - ))} - - ), - )} + + +
+
+ ))}
) : (