Skip to content

Commit

Permalink
fix: club manage filtering logic change
Browse files Browse the repository at this point in the history
  • Loading branch information
pbc1017 committed Jun 25, 2024
1 parent e9eec99 commit 5569297
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 57 deletions.
2 changes: 2 additions & 0 deletions back/routes/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ router.get("/activity_list", async (req, res) => {
"activity_type_id",
"start_date",
"end_date",
"recent_edit",
"feedback_type",
],
order: [["recent_edit", "DESC"]],
Expand All @@ -664,6 +665,7 @@ router.get("/activity_list", async (req, res) => {
activityType: activity.activity_type.type,
startDate: formatDateString(activity.start_date),
endDate: formatDateString(activity.end_date),
recentEdit: formatDateString(activity.recent_edit),
feedbackType: activity.feedback_type,
})),
});
Expand Down
2 changes: 2 additions & 0 deletions back/routes/funding.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ router.get("/funding_list", async (req, res) => {
"approved_amount",
"purpose",
"funding_feedback_type",
"recent_edit",
// Add other required fields
],
order: [
Expand Down Expand Up @@ -100,6 +101,7 @@ router.get("/funding_list", async (req, res) => {
approvedAmount: funding.approved_amount,
feedbackType: funding.funding_feedback_type,
activityName: activityName,
recentEdit: funding.recent_edit,
// Map other required fields
};
})
Expand Down
81 changes: 24 additions & 57 deletions front/src/pages/club/ClubManage/ClubManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ActivityInfo = {
startDate: string;
endDate: string;
feedbackType: number;
recentEdit: string;
};

type FundingInfo = {
Expand All @@ -44,6 +45,7 @@ type FundingInfo = {
expenditureDate: string;
approvedAmount: number;
feedbackType: number;
recentEdit: string;
};

type ApplyInfo = {
Expand Down Expand Up @@ -141,13 +143,9 @@ export const ClubManage = (): JSX.Element => {
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
);
const recentDate = new Date(funding.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate > targetDate;
})
.reduce(
(total: number, funding: FundingInfo) =>
Expand All @@ -158,13 +156,9 @@ export const ClubManage = (): JSX.Element => {
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
);
const recentDate = new Date(funding.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate > targetDate;
})
.reduce(
(total: number, funding: FundingInfo) =>
Expand Down Expand Up @@ -485,14 +479,9 @@ export const ClubManage = (): JSX.Element => {
/>
{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
);
const recentDate = new Date(activity.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate > targetDate;
})
.map((activity, index) => (
<Activity
Expand All @@ -509,14 +498,9 @@ export const ClubManage = (): JSX.Element => {
</div>
<div className="frame-28">
{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
);
const recentDate = new Date(activity.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate > targetDate;
}).length < 20 &&
status.typeId < 4 &&
durationStatus === 1 && (
Expand Down Expand Up @@ -561,14 +545,9 @@ export const ClubManage = (): JSX.Element => {
/>
{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
);
const recentDate = new Date(activity.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate <= targetDate;
})
.map((activity, index) => (
<Activity
Expand Down Expand Up @@ -648,15 +627,9 @@ export const ClubManage = (): JSX.Element => {
/>
{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
);
const recentDate = new Date(funding.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate > targetDate;
})
.map((funding, index) => (
<Funding
Expand Down Expand Up @@ -721,16 +694,10 @@ export const ClubManage = (): JSX.Element => {
id={0}
/>
{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
);
?.filter((activity) => {
const recentDate = new Date(activity.recentEdit);
const targetDate = new Date("2024-06-01");
return recentDate <= targetDate;
})
.map((funding, index) => (
<Funding
Expand Down

0 comments on commit 5569297

Please sign in to comment.