From 5e832a0fb8a917ee3549702d60a1cd93020205f6 Mon Sep 17 00:00:00 2001 From: pbc1017 Date: Sun, 16 Jun 2024 03:29:58 +0900 Subject: [PATCH] fix: devide table --- back/routes/feedback.js | 6 +- .../ClubActivityList/ClubActivityList.tsx | 75 +++++-- .../admin/ClubFundingList/ClubFundingList.tsx | 113 ++++++++-- .../src/pages/club/ClubManage/ClubManage.tsx | 210 ++++++++++++++++-- 4 files changed, 348 insertions(+), 56 deletions(-) diff --git a/back/routes/feedback.js b/back/routes/feedback.js index 3813def..0ce618c 100644 --- a/back/routes/feedback.js +++ b/back/routes/feedback.js @@ -135,9 +135,9 @@ router.get("/club_activity_list", async (req, res) => { ], }); - console.log( - filteredActivities[0].ActivityFeedbackExecutive.student.student.name - ); + // console.log( + // filteredActivities[0].ActivityFeedbackExecutive.student.student.name + // ); // Process and return the response const responseArray = filteredActivities.map((activity) => { diff --git a/front/src/pages/admin/ClubActivityList/ClubActivityList.tsx b/front/src/pages/admin/ClubActivityList/ClubActivityList.tsx index 51b4a66..caab90a 100644 --- a/front/src/pages/admin/ClubActivityList/ClubActivityList.tsx +++ b/front/src/pages/admin/ClubActivityList/ClubActivityList.tsx @@ -52,7 +52,7 @@ export const ClubActivityList = (): JSX.Element => {
{ activityStateProperty1="default" /> {Array.isArray(activities) && - activities.map((activity, index) => ( - - ))} + activities + ?.filter((activity) => { + const recentDate = new Date(activity.recent_edit); + const targetDate = new Date("2024-06-01"); + return recentDate > targetDate; + }) + .map((activity, index) => ( + + ))} +
+
+
+ +
+ + {Array.isArray(activities) && + activities + ?.filter((activity) => { + const recentDate = new Date(activity.recent_edit); + const targetDate = new Date("2024-06-01"); + return recentDate <= targetDate; + }) + .map((activity, index) => ( + + ))}
diff --git a/front/src/pages/admin/ClubFundingList/ClubFundingList.tsx b/front/src/pages/admin/ClubFundingList/ClubFundingList.tsx index ea47aa6..c6d15b2 100644 --- a/front/src/pages/admin/ClubFundingList/ClubFundingList.tsx +++ b/front/src/pages/admin/ClubFundingList/ClubFundingList.tsx @@ -29,6 +29,8 @@ export const ClubFundingList = (): JSX.Element => { const [clubName, setClubName] = useState(""); const [totalExpenditureAmount, setTotalExpenditureAmount] = useState(0); const [totalApprovedAmount, setTotalApprovedAmount] = useState(0); + const [springExpenditureAmount, setSpringExpenditureAmount] = useState(0); + const [springApprovedAmount, setSpringApprovedAmount] = useState(0); useEffect(() => { const fetchActivities = async () => { @@ -40,6 +42,32 @@ export const ClubFundingList = (): JSX.Element => { setClubName(data.clubName); setTotalExpenditureAmount(data.totalExpenditureAmount); setTotalApprovedAmount(data.totalApprovedAmount); + setSpringExpenditureAmount( + data.fundings + ?.filter((funding: Funding) => { + const recentDate = new Date(funding.recent_edit); + const targetDate = new Date("2024-06-01"); + return recentDate > targetDate; + }) + .reduce( + (total: number, funding: Funding) => + total + funding.expenditureAmount, + 0 + ) + ); + setSpringApprovedAmount( + data.fundings + ?.filter((funding: Funding) => { + const recentDate = new Date(funding.recent_edit); + const targetDate = new Date("2024-06-01"); + return recentDate > targetDate; + }) + .reduce( + (total: number, funding: Funding) => + total + funding.approvedAmount, + 0 + ) + ); }, (error) => console.error("Failed to fetch activities:", error) ); @@ -59,31 +87,78 @@ export const ClubFundingList = (): JSX.Element => {
{Array.isArray(fundings) && - fundings.map((funding, index) => ( - - ))} + fundings + ?.filter((activity) => { + const recentDate = new Date(activity.recent_edit); + const targetDate = new Date("2024-06-01"); + return recentDate > targetDate; + }) + .map((funding, index) => ( + + ))} +
+
+
+ +
+ + {Array.isArray(fundings) && + fundings + ?.filter((activity) => { + const recentDate = new Date(activity.recent_edit); + const targetDate = new Date("2024-06-01"); + return recentDate <= targetDate; + }) + .map((funding, index) => ( + + ))} +
diff --git a/front/src/pages/club/ClubManage/ClubManage.tsx b/front/src/pages/club/ClubManage/ClubManage.tsx index 83dc17e..e6ff3fe 100644 --- a/front/src/pages/club/ClubManage/ClubManage.tsx +++ b/front/src/pages/club/ClubManage/ClubManage.tsx @@ -41,6 +41,7 @@ type FundingInfo = { name: string; activityName: string; expenditureAmount: number; + expenditureDate: string; approvedAmount: number; feedbackType: number; }; @@ -79,6 +80,9 @@ export const ClubManage = (): JSX.Element => { const [loadedClubIds, setLoadedClubIds] = useState([]); const [totalApprovedMoney, setTotalApprovedMoney] = useState(0); const [totalExpenditureMoney, setTotalExpenditureMoney] = useState(0); + const [springApprovedMoney, setSpringApprovedMoney] = useState(0); + const [springExpenditureMoney, setSpringExpenditureMoney] = + useState(0); useEffect(() => { userRepresentativeStatuses.userStatuses.forEach((status) => { @@ -133,7 +137,43 @@ export const ClubManage = (): JSX.Element => { })); setTotalExpenditureMoney(data.totalExpenditureAmount); setTotalApprovedMoney(data.totalApprovedAmount); - console.log(fundingLists[clubId]); + + setSpringApprovedMoney( + data.funding + ?.filter((funding: FundingInfo) => { + const expenditureDate = new Date(funding.expenditureDate); + const targetStartDate = new Date("2023-12-16"); + const targetEndDate = new Date("2024-06-14"); + return ( + expenditureDate >= targetStartDate && + expenditureDate <= targetEndDate + ); + }) + .reduce( + (total: number, funding: FundingInfo) => + total + funding.approvedAmount, + 0 + ) + ); + setSpringExpenditureMoney( + data.funding + ?.filter((funding: FundingInfo) => { + const expenditureDate = new Date(funding.expenditureDate); + const targetStartDate = new Date("2023-12-16"); + const targetEndDate = new Date("2024-06-14"); + return ( + expenditureDate >= targetStartDate && + expenditureDate <= targetEndDate + ); + }) + .reduce( + (total: number, funding: FundingInfo) => + total + funding.expenditureAmount, + 0 + ) + ); + + // console.log(fundingLists[clubId]); }, (error) => { console.error("Error fetching activities:", error); @@ -166,7 +206,7 @@ export const ClubManage = (): JSX.Element => { await getRequest( `member/list?club_id=${clubId}`, (data) => { - console.log(data.data[0]); + // console.log(data.data[0]); const formattedData = data.data.map( (item: { student_id: any; @@ -189,7 +229,7 @@ export const ClubManage = (): JSX.Element => { ...applyLists, [clubId]: formattedData, })); - console.log(formattedData); + // console.log(formattedData); }, (error) => { console.error("Error fetching applies:", error); @@ -430,11 +470,12 @@ export const ClubManage = (): JSX.Element => { )}
+ {/* 활동보고서 */}
{ activityStateProperty1={2} id={0} /> - {activitiesLists[status.clubId]?.map( - (activity, index) => ( + {activitiesLists[status.clubId] + ?.filter((activity) => { + const startDate = new Date(activity.startDate); + const endDate = new Date(activity.endDate); + const targetStartDate = new Date("2023-12-16"); + const targetEndDate = new Date("2024-06-14"); + return ( + startDate >= targetStartDate && + endDate <= targetEndDate + ); + }) + .map((activity, index) => ( { activityStateProperty1={activity.feedbackType} id={activity.id} /> - ) - )} + ))}
{activitiesLists[status.clubId]?.length < 20 && @@ -487,6 +537,45 @@ export const ClubManage = (): JSX.Element => { )}
+ {status.typeId < 4 && ( +
+ +
+ + {activitiesLists[status.clubId] + ?.filter((activity) => { + const startDate = new Date(activity.startDate); + const endDate = new Date(activity.endDate); + const targetStartDate = new Date("2023-06-17"); + const targetEndDate = new Date("2023-12-15"); + return ( + startDate >= targetStartDate && + endDate <= targetEndDate + ); + }) + .map((activity, index) => ( + + ))} +
+
+ )} {currentClubInfo.advisor && (
{

2023.12.16. ~ 2024.06.14. 기간 중
- {clubInfos[status.clubId].clubName}의 동아리 - 활동이 위 활동보고서와 일치함을 확인하고 이에 - 서명합니다. + {clubInfos[status.clubId].clubName}의 동아리 활동이 + 위 활동보고서와 일치함을 확인하고 이에 서명합니다.

@@ -541,7 +629,7 @@ export const ClubManage = (): JSX.Element => {
{ activityStateProperty1={2} id={0} /> - {fundingLists[status.clubId]?.map( - (funding, index) => ( + {fundingLists[status.clubId] + ?.filter((funding) => { + const expenditureDate = new Date( + funding.expenditureDate + ); + const targetStartDate = new Date("2023-12-16"); + const targetEndDate = new Date("2024-06-14"); + return ( + expenditureDate >= targetStartDate && + expenditureDate <= targetEndDate + ); + }) + .map((funding, index) => ( { activityStateProperty1={funding.feedbackType} id={funding.id} /> - ) + ))} + +
+
+ {status.typeId < 4 && fundingStatus === 1 && ( + <> +
navigate("/add_funding")} + style={{ cursor: "pointer" }} + /> + +
navigate("/add_funding")} + style={{ cursor: "pointer" }} + > +
+
+
+
+
+
+
+
+ 지원금 추가하기 +
+
+ )} +
+
+ )} + {status.typeId < 4 && ( +
+ +
+ + {fundingLists[status.clubId] + ?.filter((funding) => { + const expenditureDate = new Date( + funding.expenditureDate + ); + const targetStartDate = new Date("2023-06-17"); + const targetEndDate = new Date("2023-12-15"); + return ( + expenditureDate >= targetStartDate && + expenditureDate <= targetEndDate + ); + }) + .map((funding, index) => ( + + ))}