Skip to content

Commit

Permalink
feat : 없는 게시글 NotFound 페이지 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
publdaze committed Oct 3, 2023
1 parent 47b1247 commit 8dab084
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/board/BoardView/BoardView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { useGetEachPostQuery } from '@api/postApi';
import NotFound from '@pages/NotFound/NotFound';
import SecretPostModal from './Modal/SecretPostModal';
import AdjacentPostNavSection from './Section/AdjacentPostNavSection';
import BannerSection from './Section/BannerSection';
Expand All @@ -19,7 +20,7 @@ const BoardView = () => {
const [secretPostModalOpen, setSecretPostModalOpen] = useState(false);
const [password, setPassword] = useState<string>();

const { data: postInfo, isSuccess } = useGetEachPostQuery(postId, isSecret, password);
const { data: postInfo, isSuccess, isError } = useGetEachPostQuery(postId, isSecret, password);

useEffect(() => {
if (!isSuccess) return;
Expand All @@ -33,6 +34,10 @@ const BoardView = () => {
setSecretPostModalOpen(true);
}, [isSecret]);

if (isError) {
return <NotFound from="Post" />;
}

return (
<div className="-mt-16 space-y-8 sm:space-y-12">
{postInfo && (
Expand Down

0 comments on commit 8dab084

Please sign in to comment.