diff --git a/src/Components/CardModal/Activity.js b/src/Components/CardModal/Activity.js index dc5f096..a24348f 100644 --- a/src/Components/CardModal/Activity.js +++ b/src/Components/CardModal/Activity.js @@ -1,7 +1,7 @@ import React, {useState, useRef} from 'react'; import apis from '../../Library/Apis'; -function Activity({data, refresh, setRefresh, postActivity, putActivity, deleteActivity, detail}) { +function Activity({data, getCard, postActivity, putActivity, deleteActivity, detail}) { const inputRef = useRef(); diff --git a/src/Components/CardModal/CardModal.js b/src/Components/CardModal/CardModal.js index c585245..2e4ddd9 100644 --- a/src/Components/CardModal/CardModal.js +++ b/src/Components/CardModal/CardModal.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useRef } from "react"; import "./CardModal.css"; import Activity from "./Activity.js"; import apis from "../../Library/Apis"; @@ -19,7 +19,13 @@ function CardModal({ }) { const [card, setCard] = useState(undefined); const [nameState, setNameState] = useState({ name: cardName, edit: false }); - const [refresh, setRefresh] = useState(false); + + //Description 추가 및 변경하기 + const [description, setDescription] = useState({ + exist: false, + content: undefined, + edit: false, + }); function getCard() { apis.card @@ -54,7 +60,7 @@ function CardModal({ useEffect(() => { getCard(); - }, [refresh]); + }, []); const exitIfNotModal = (e) => { if ( @@ -121,17 +127,6 @@ function CardModal({ setCardName(nameState.name); // 리스트 화면에 보이는 카드 이름 변경 }; - //Description 추가 및 변경하기 - const [description, setDescription] = useState({ - exist: false, - content: "", - edit: false, - }); - useEffect(() => { - // 서버에 description 변경 - putCard({ cId: card_id, description: description.content }); - }, [description.edit && false]); - // 멤버 추가하기 const addMember = () => { alert( @@ -145,6 +140,14 @@ function CardModal({ ); }; + const activities = useRef(); + + const changeDescription = () => { + if (description.content === "") setDescription({...description, edit: false}); + else setDescription({...description, exist: true, edit: false}); + putCard({cId: card_id, description: description}); + } + return (