Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description Error Fix #115

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/CardModal/Activity.js
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
34 changes: 18 additions & 16 deletions src/Components/CardModal/CardModal.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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
Expand Down Expand Up @@ -54,7 +60,7 @@ function CardModal({

useEffect(() => {
getCard();
}, [refresh]);
}, []);

const exitIfNotModal = (e) => {
if (
Expand Down Expand Up @@ -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(
Expand All @@ -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 (
<div
id="card-modal-wrapper"
Expand Down Expand Up @@ -348,9 +351,8 @@ function CardModal({
.map((data, index) => (
<Activity
data={data}
refresh={refresh}
setRefresh={setRefresh}
key={index}
getCard={getCard}
postActivity={postActivity}
putActivity={putActivity}
deleteActivity={deleteActivity}
Expand Down