Skip to content

Commit

Permalink
리드미 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaeyeon1 committed Nov 30, 2023
1 parent 8b2171d commit bb4568e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion client/src/api/readme-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ export const getReadMeApi = async (params: IReadMeParams) => {
};

export const useGetReadMeQuery = (params: IReadMeParams) => {
const { isLoading, error, data } = useQuery([`readMe`, params], () => getReadMeApi(params), {
const {
isLoading,
error,
data: backendData,
} = useQuery([`readMe`, params], () => getReadMeApi(params), {
enabled: !!params.blogId,
});

const data: {
readMeDto: { blogName: string; content: string; isMe: boolean };
} = backendData;
return { data, isLoading, error };
};

Expand Down
8 changes: 6 additions & 2 deletions client/src/app/[blogName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ const Home = ({ params }: { params: { blogName: string } }) => {

const { data: sidebarData } = useGetSidebarQuery({ blogId: blogIdData });
const { data: readMeData } = useGetReadMeQuery({ blogId: blogIdData });
const [readMe, setReadMe] = useState<{ blogName: string; content: string; isMe: boolean }>();
const [readMe, setReadMe] = useState<{
blogName: string;
content: string;
isMe: boolean;
}>();
const router = useRouter();

useEffect(() => {
setWriteList(sidebarData?.sidebarDtos);
setReadMe(readMeData?.content);
setReadMe(readMeData?.readMeDto);
}, [sidebarData, readMeData]);

return (
Expand Down

0 comments on commit bb4568e

Please sign in to comment.