From bf8209ca2ec575f7a2d5efec69d2c13aeb23be60 Mon Sep 17 00:00:00 2001 From: JeongHunHui Date: Thu, 3 Oct 2024 03:48:18 +0900 Subject: [PATCH] =?UTF-8?q?HOTFIX:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/s/[surveyId]/layout.tsx | 2 +- .../management/result/PieChartComponent.tsx | 10 ++++++---- src/components/mypage/SurveyCreateButton.tsx | 19 ++++++++----------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/app/s/[surveyId]/layout.tsx b/src/app/s/[surveyId]/layout.tsx index cc44648..11a396e 100644 --- a/src/app/s/[surveyId]/layout.tsx +++ b/src/app/s/[surveyId]/layout.tsx @@ -26,7 +26,7 @@ export async function generateMetadata( title, openGraph: { description, - images: [thumbnail, ...previousImages], + images: [thumbnail ?? '/path/to/default-image.png', ...previousImages], // thumbnail이 null인 경우 기본 이미지 사용 }, }; } diff --git a/src/components/management/result/PieChartComponent.tsx b/src/components/management/result/PieChartComponent.tsx index 6c45642..ebe4b97 100644 --- a/src/components/management/result/PieChartComponent.tsx +++ b/src/components/management/result/PieChartComponent.tsx @@ -61,10 +61,12 @@ export default function PieChartComponent({ responses }: { responses: Response[] callbacks: { label: (context) => { const value = context.parsed; - const total = context.chart.data.datasets[context.datasetIndex].data.reduce( - (acc: number, val: number) => acc + val, - 0 - ); + const total = (context.chart.data.datasets[0].data as number[]).reduce((acc, val) => { + if (typeof val === 'number') { + return acc + val; + } + return acc; + }, 0); const percentage = ((value / total) * 100).toFixed(1); return ` ${value} (${percentage}%)`; }, diff --git a/src/components/mypage/SurveyCreateButton.tsx b/src/components/mypage/SurveyCreateButton.tsx index 101e412..88476b5 100644 --- a/src/components/mypage/SurveyCreateButton.tsx +++ b/src/components/mypage/SurveyCreateButton.tsx @@ -9,17 +9,14 @@ export default function SurveyCreateButton() { const mutation = useCreateSurvey(); async function createNewSurvey() { - mutation.mutate( - {}, - { - onSuccess: (data) => { - nextRouter.push(`/workbench/${data.surveyId}`); - }, - onError: (error) => { - showToast('error', (error.cause as ErrorCause).message); - }, - } - ); + mutation.mutate(undefined, { + onSuccess: (data) => { + nextRouter.push(`/workbench/${data.surveyId}`); + }, + onError: (error) => { + showToast('error', (error.cause as ErrorCause).message); + }, + }); } return (