Skip to content

Commit

Permalink
fix: アクセス権限がないページに飛んだ場合に forbidden にリダイレクトするように
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Aug 28, 2024
1 parent 6fb04b4 commit c7d3e9a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 <LoadingCircular />;
} else if (
(!isLoadingAnswers && !answer) ||
answer._tag == 'Left' ||
answer._tag === 'Left' ||
(!isLoadingFormQuestions && !formQuestions) ||
formQuestions._tag === 'Left'
) {
Expand Down

0 comments on commit c7d3e9a

Please sign in to comment.