로딩 중...
;
}
- // 해당 월의 일수 채우기
- for (let day = 1; day <= totalDays; day++) {
- days.push(day);
+ if (error) {
+ return 로딩 중...
;
- }
-
- if (error) {
- return
- {/* 달력 헤더 */}
-
-
-
-
- {currentDate.getFullYear()}년 {monthNames[currentDate.getMonth()]}
-
-
-
-
-
- {/* 요일 표시 */}
-
- {['S', 'M', 'T', 'W', 'T', 'F', 'S'].map((day) => (
-
- {day}
-
- ))}
-
-
- {/* 날짜 표시 */}
-
- {calendarDays.map((day, index) => {
- // 현재 월과 일자를 기반으로 날짜 문자열 생성
- const year = currentDate.getFullYear();
- const month = currentDate.getMonth() + 1; // 0-based
- const dayString = day
- ? `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
- : null;
-
- // 해당 날짜의 성취도 가져오기
- const achieved = dayString && dayAchieveMap.has(dayString) ? dayAchieveMap.get(dayString) : 0;
-
- return (
-
- {day}
+ return (
+
+ {/* 달력 헤더 */}
+
+
+
+
+ {currentDate.getFullYear()}년{' '}
+ {monthNames[currentDate.getMonth()]}
+
+
+
+
+
+ {/* 요일 표시 */}
+
+ {['S', 'M', 'T', 'W', 'T', 'F', 'S'].map((day) => (
+
+ {day}
+
+ ))}
+
+
+ {/* 날짜 표시 */}
+
+ {calendarDays.map((day, index) => {
+ // 현재 월과 일자를 기반으로 날짜 문자열 생성
+ const year = currentDate.getFullYear();
+ const month = currentDate.getMonth() + 1; // 0-based
+ const dayString = day
+ ? `${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`
+ : null;
+
+ // 해당 날짜의 성취도 가져오기
+ const achieved =
+ dayString && dayAchieveMap.has(dayString)
+ ? dayAchieveMap.get(dayString)
+ : 0;
+
+ return (
+
+ {day}
+
+ );
+ })}
- );
- })}
-
-
- );
+
+ );
};
export default Calendar;
diff --git a/src/components/Mypage/Goals/DDayCounter.tsx b/src/components/Mypage/Goals/DDayCounter.tsx
index ab3570c2..6c312f8a 100644
--- a/src/components/Mypage/Goals/DDayCounter.tsx
+++ b/src/components/Mypage/Goals/DDayCounter.tsx
@@ -4,55 +4,54 @@ import dayjs from 'dayjs';
import cn from '../../../lib/cn';
const DDayCounter: React.FC = () => {
- const [dDay, setDDay] = useState
(null);
- const [myGoal, setMyGoal] = useState(null);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- const fetchCalendar = async () => {
- try {
- // 현재 날짜 기준으로 월을 형식에 맞게 설정 (예: '2024-09')
- const currentMonth = dayjs().format('YYYY-MM');
- const response = await API.User.getCalendar(currentMonth);
-
- // dDay 업데이트
- setDDay(response.data.dDay);
- setMyGoal(response.data.goal);
- } catch (err: any) {
- console.error('캘린더 데이터를 가져오는 중 오류 발생:', err);
- setError(err.message || '캘린더 데이터를 불러오는 데 실패했습니다.');
- } finally {
- setLoading(false);
- }
- };
-
- fetchCalendar();
- }, []); // 빈 의존성 배열로 컴포넌트 마운트 시 한 번 실행
-
- if (loading) {
- return 로딩 중...
;
- }
-
- if (error) {
- return {error}
;
- }
-
- return (
-
-
- D-{dDay}
-
-
- {myGoal}
-
-
- );
+ const [dDay, setDDay] = useState(null);
+ const [myGoal, setMyGoal] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ const fetchCalendar = async () => {
+ try {
+ // 현재 날짜 기준으로 월을 형식에 맞게 설정 (예: '2024-09')
+ const currentMonth = dayjs().format('YYYY-MM');
+ const response = await API.User.getCalendar(currentMonth);
+
+ // dDay 업데이트
+ setDDay(response.data.dDay);
+ setMyGoal(response.data.goal);
+ } catch (err: any) {
+ console.error('캘린더 데이터를 가져오는 중 오류 발생:', err);
+ setError(
+ err.message || '캘린더 데이터를 불러오는 데 실패했습니다.'
+ );
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchCalendar();
+ }, []); // 빈 의존성 배열로 컴포넌트 마운트 시 한 번 실행
+
+ if (loading) {
+ return 로딩 중...
;
+ }
+
+ if (error) {
+ return {error}
;
+ }
+
+ return (
+
+ );
};
-export default DDayCounter;
\ No newline at end of file
+export default DDayCounter;
From fd742bd6afe50853e367e6bc8c4168ee91686905 Mon Sep 17 00:00:00 2001
From: Yunseok
Date: Sat, 28 Sep 2024 22:33:36 +0900
Subject: [PATCH 02/17] =?UTF-8?q?[FEAT]=20-=20=EC=9E=90=EA=B8=B0=20?=
=?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=96=BB=EB=8A=94=20api?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/lib/api/user/index.ts | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/lib/api/user/index.ts b/src/lib/api/user/index.ts
index 6c4c5b18..196f613e 100644
--- a/src/lib/api/user/index.ts
+++ b/src/lib/api/user/index.ts
@@ -80,4 +80,14 @@ export namespace __User {
tokenOn: true,
});
}
+
+ export async function getMyInfo() {
+ const url = `${BASE_URL}/user/info`;
+
+ return fetchData({
+ url,
+ method: 'GET',
+ tokenOn: true,
+ });
+ }
}
From 7869033552d7a661c1dc20c948607765b0f9d4f5 Mon Sep 17 00:00:00 2001
From: liupei8979
Date: Sat, 28 Sep 2024 22:34:00 +0900
Subject: [PATCH 03/17] =?UTF-8?q?Coding=20=ED=95=98=EC=9E=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Mypage/Goals/SettingGoals.tsx | 18 +++++++++++++++++-
src/lib/api/team/index.ts | 12 ++++++++++++
src/pages/goal.tsx | 5 +++--
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/src/components/Mypage/Goals/SettingGoals.tsx b/src/components/Mypage/Goals/SettingGoals.tsx
index cbd4a63b..6600d5d0 100644
--- a/src/components/Mypage/Goals/SettingGoals.tsx
+++ b/src/components/Mypage/Goals/SettingGoals.tsx
@@ -1,12 +1,28 @@
+import { useEffect, useState } from 'react';
+
+import { API } from '../../../lib/api'; // API 모듈 경로에 맞게 import
import CreateTeam from './Setting/CreateTeam'; // CreateTeam 컴포넌트를 임포트합니다.
import InputCodeField from './Setting/InputCodeField'; // InviteCodeField 컴포넌트를 임포트합니다.
import NotGood from '../../../assets/NotGood.svg';
-import { useState } from 'react';
const SettingGoals: React.FC = () => {
const [showCreateTeam, setShowCreateTeam] = useState(false);
const [showInviteCode, setShowInviteCode] = useState(false);
+ // 화면 렌더될 때 기록 조회
+ useEffect(() => {
+ const fetchHistories = async () => {
+ try {
+ const response = await API.Team.getHistories();
+ console.log('기록 조회 성공:', response);
+ } catch (error) {
+ console.error('기록 조회 실패:', error);
+ }
+ };
+
+ fetchHistories();
+ }, []); // 빈 배열을 사용하여 컴포넌트가 처음 렌더링될 때만 실행
+
const handleCreateTeamClick = () => {
setShowCreateTeam(true);
};
diff --git a/src/lib/api/team/index.ts b/src/lib/api/team/index.ts
index 2ec28f7b..14835080 100644
--- a/src/lib/api/team/index.ts
+++ b/src/lib/api/team/index.ts
@@ -57,4 +57,16 @@ export namespace __Team {
tokenOn: true, // 인증이 필요한 경우 토큰 포함
});
}
+
+ // 기록 조회 함수
+ export async function getHistories() {
+ const url = `${BASE_URL}/histories`;
+
+ // 서버에서 기록 조회 요청 (GET)
+ return fetchData({
+ url,
+ method: 'GET',
+ tokenOn: true, // 인증이 필요한 경우 토큰 포함
+ });
+ }
}
diff --git a/src/pages/goal.tsx b/src/pages/goal.tsx
index f96a2529..81525147 100644
--- a/src/pages/goal.tsx
+++ b/src/pages/goal.tsx
@@ -1,8 +1,9 @@
import { useEffect, useState } from 'react';
-import NeedLoginComponents from '../components/NeedLoginComponents.tsx';
+
import GoormScreen from '../components/Goalpage/GoormScreen.tsx';
-import cn from '../lib/cn.ts';
import MemberList from '../components/Goalpage/MemberList.tsx';
+import NeedLoginComponents from '../components/NeedLoginComponents.tsx';
+import cn from '../lib/cn.ts';
export default function Goal() {
const [isLogin, setIsLogin] = useState(false);
From 69772a8b275188d48aee95d4dd27cac8a41f4ba4 Mon Sep 17 00:00:00 2001
From: liupei8979
Date: Sat, 28 Sep 2024 22:48:55 +0900
Subject: [PATCH 04/17] =?UTF-8?q?[FEAT]=20-=20Button=20disabled=20?=
=?UTF-8?q?=EC=B2=98=EB=A6=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Goalpage/GoormScreen.tsx | 26 +++++++++----------
src/components/Goalpage/MemberList.tsx | 1 -
.../Goalpage/MemberList/ShowImageModal.tsx | 25 +++++++++++-------
src/components/Header/Header.tsx | 2 +-
.../Mypage/Goals/Setting/InputCodeField.tsx | 18 ++++++++++---
5 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/src/components/Goalpage/GoormScreen.tsx b/src/components/Goalpage/GoormScreen.tsx
index 4945c392..78dde855 100644
--- a/src/components/Goalpage/GoormScreen.tsx
+++ b/src/components/Goalpage/GoormScreen.tsx
@@ -80,33 +80,33 @@ export default function GoormScreen() {
- {clouds.map((cloud, index) => (
-
- ))}
-
+ {clouds.map((cloud, index) => (
+
+ ))}
+
{/* 무지개 이미지를 절대 위치로 배치 */}
{/* 무지개 이미지 */}
= 2 ? "" : "invisible"}`}
+ className={`w-1/4 ${stage >= 2 ? '' : 'invisible'}`}
/>
= 3 ? "" : "invisible"}`}
+ className={`w-1/4 ${stage >= 3 ? '' : 'invisible'}`}
/>
= 4 ? "" : "invisible"}`}
+ className={`w-1/4 ${stage >= 4 ? '' : 'invisible'}`}
/>
diff --git a/src/components/Goalpage/MemberList.tsx b/src/components/Goalpage/MemberList.tsx
index f6c1fcb4..fdb4e7a6 100644
--- a/src/components/Goalpage/MemberList.tsx
+++ b/src/components/Goalpage/MemberList.tsx
@@ -7,7 +7,6 @@ interface Member {
username: string;
}
-
export default function MemberList() {
const [members, setMembers] = useState