From c7d3e9afdb79b9f2c20301eb1e3716c1d65dc0d2 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:29:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9?= =?UTF-8?q?=E6=A8=A9=E9=99=90=E3=81=8C=E3=81=AA=E3=81=84=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AB=E9=A3=9B=E3=82=93=E3=81=A0=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=20forbidden=20=E3=81=AB=E3=83=AA=E3=83=80=E3=82=A4?= =?UTF-8?q?=E3=83=AC=E3=82=AF=E3=83=88=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forms/[formId]/answers/[answerId]/page.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/(authed)/(standard)/forms/[formId]/answers/[answerId]/page.tsx b/src/app/(authed)/(standard)/forms/[formId]/answers/[answerId]/page.tsx index 964a77f8..250c3dbc 100644 --- a/src/app/(authed)/(standard)/forms/[formId]/answers/[answerId]/page.tsx +++ b/src/app/(authed)/(standard)/forms/[formId]/answers/[answerId]/page.tsx @@ -1,6 +1,7 @@ 'use client'; import { Stack, Typography } from '@mui/material'; +import { redirect } from 'next/navigation'; import useSWR from 'swr'; import ErrorModal from '@/app/_components/ErrorModal'; import LoadingCircular from '@/app/_components/LoadingCircular'; @@ -27,11 +28,16 @@ const Home = ({ params }: { params: { formId: number; answerId: number } }) => { : '' ); - if (!answer || !formQuestions) { + if ( + answer?._tag === 'Left' && + answer.left.errorCode === 'DO_NOT_HAVE_PERMISSION_TO_GET_ANSWER' + ) { + return redirect('/forbidden'); + } else if (!answer || !formQuestions) { return ; } else if ( (!isLoadingAnswers && !answer) || - answer._tag == 'Left' || + answer._tag === 'Left' || (!isLoadingFormQuestions && !formQuestions) || formQuestions._tag === 'Left' ) {