Skip to content

Commit

Permalink
readme bug 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaeyeon1 committed Nov 30, 2023
1 parent 58a14ef commit cd458dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/src/app/write/readme/[blogName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
'use client';

import { Stack } from '@mui/material';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import MDEditor from '@uiw/react-md-editor';
import '@uiw/react-md-editor/markdown-editor.css';
import '@uiw/react-markdown-preview/markdown.css';
import { useUserThemeSSR } from '../../../../../hooks/useRecoilSSR';
import Button from '@/components/Button/Button';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { PutReadMeApi } from '@/api/readme-api';
import { PutReadMeApi, useGetReadMeQuery, usegetblogIdQuery } from '@/api/readme-api';
import { useRouter } from 'next/navigation';

const ReadMe = ({ params }: { params: { blogName: string } }) => {
const [userTheme] = useUserThemeSSR();
const [content, setContent] = useState<string | undefined>('');
const queryClient = useQueryClient();
const router = useRouter();
const { data: blogIdData } = usegetblogIdQuery({ blogUrl: params.blogName });
const { data: readMeData } = useGetReadMeQuery({ blogId: blogIdData });

const putReadmeQuery = useMutation(PutReadMeApi, {
onSuccess: () => {
Expand All @@ -24,6 +26,10 @@ const ReadMe = ({ params }: { params: { blogName: string } }) => {
},
});

useEffect(() => {
setContent(readMeData.content);
}, [readMeData]);

const readmeSaveOnClick = () => {
const newReadMeBody = {
content: content,
Expand Down

0 comments on commit cd458dd

Please sign in to comment.