Skip to content

Commit

Permalink
[FE] feat : error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
urimeee committed May 28, 2024
1 parent e1a500f commit 0ff9b32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
4 changes: 2 additions & 2 deletions frontend/moim_front/src/pages/MoimJoinPage/MoimHome/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function MoimHome({ isHost, moimId }) {
}
};

const cardClickHandler = () => {
const cardClickHandler = (noticeId) => {
navigate(`notice/${noticeId}`);
};

Expand Down Expand Up @@ -115,7 +115,7 @@ function MoimHome({ isHost, moimId }) {
title={notice.title}
btn={false}
isMeeting={false}
clickHandler={cardClickHandler}
clickHandler={() => cardClickHandler(notice.noticeId)}
/>
))
) : (
Expand Down
15 changes: 10 additions & 5 deletions frontend/moim_front/src/pages/MoimJoinPage/ToDo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function ToDo() {
startDate = startDate.toISOString().slice(0, 7);

try {
const response = await axios.get(`https://api.moim.today/api/todos/moim/${MoimId}?startDate=${startDate}&months=12`);
const response = await axios.get(
`https://api.moim.today/api/todos/moim/${MoimId}?startDate=${startDate}&months=12`
);
setTodoData(response.data.data);
} catch (error) {
console.log(error);
Expand All @@ -36,7 +38,7 @@ function ToDo() {
const handleTodoCheckboxClick = (todo) => {
// 체크박스 클릭 시 처리할 로직
console.log(todo);
}
};

// todo 데이터를 날짜별로 그룹화하는 함수
const groupTodosByDate = () => {
Expand Down Expand Up @@ -78,13 +80,16 @@ function ToDo() {
{todoGroup.map((todo, todoIndex) => (
<div
key={todo.todoId}
className={`flex items-center gap-2 ${todoIndex === todoGroup.length - 1 ? "" : " mb-4"
}`}
className={`flex items-center gap-2 ${
todoIndex === todoGroup.length - 1 ? "" : " mb-4"
}`}
>
<Checkbox
onChange={() => handleTodoCheckboxClick(todo)}
/>
<Label className="font-Pretendard_Medium">{todo.contents}</Label>
<Label className="font-Pretendard_Medium">
{todo.contents}
</Label>
</div>
))}
</div>
Expand Down
19 changes: 1 addition & 18 deletions frontend/moim_front/src/pages/MoimJoinPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,13 @@ function MoimJoinPage() {
const [isAlertModalOpen, setAlertModalOpen] = useState(false);
const [message, setMessage] = useState("");
const [selected, setSelected] = useState(homeKey);
const [notices, setNotices] = useState([]);
const [moimInfo, setMoimInfo] = useState([]);
const [meetings, setMeetings] = useState([]);
const [writerInfo, setWriterInfo] = useState([]);
const [isHost, setIsHost] = useState(false);

const { MoimId } = useParams();

const getNotices = async () => {
try {
const result = await fetchNotices(MoimId);
console.log(result);
setNotices(result.data.data);
} catch (e) {
console.log(e);
}
};

const getInfo = async () => {
try {
const result = await fetchMoimInfo(MoimId);
Expand All @@ -125,7 +114,6 @@ function MoimJoinPage() {

useEffect(() => {
getHost();
getNotices();
}, []);

return (
Expand Down Expand Up @@ -175,12 +163,7 @@ function MoimJoinPage() {
</div>
</div>
{selected === homeKey ? (
<MoimHome
notices={notices}
meetings={meetings}
isHost={isHost}
moimId={MoimId}
/>
<MoimHome meetings={meetings} isHost={isHost} moimId={MoimId} />
) : selected === availableTimeKey ? (
<AvailableTime moimId={MoimId} />
) : selected === todoKey ? (
Expand Down

0 comments on commit 0ff9b32

Please sign in to comment.