Skip to content

Commit

Permalink
fix: old records visible to executive and representative
Browse files Browse the repository at this point in the history
  • Loading branch information
pbc1017 committed Jun 13, 2024
1 parent 8fa69cb commit a394b94
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 309 deletions.
11 changes: 8 additions & 3 deletions back/routes/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ router.get("/is_report_duration", async (req, res) => {

router.get("/activity_list", async (req, res) => {
const clubId = req.query.club_id;
const isAdvisor = req.query.is_advisor === 1;
const currentDate = new Date();

if (!clubId) {
Expand Down Expand Up @@ -621,8 +622,12 @@ router.get("/activity_list", async (req, res) => {
const activities = await Activity.findAll({
where: {
club_id: clubId,
start_date: { [Op.gte]: activityDuration.start_date },
end_date: { [Op.lte]: activityDuration.end_date },
...(isAdvisor
? {
start_date: { [Op.gte]: activityDuration.start_date },
end_date: { [Op.lte]: activityDuration.end_date },
}
: {}),
},
include: [
{
Expand All @@ -639,7 +644,7 @@ router.get("/activity_list", async (req, res) => {
"end_date",
"feedback_type",
],
order: [["start_date", "ASC"]],
order: [["recent_edit", "DESC"]],
});

const formatDateString = (date) => {
Expand Down
10 changes: 5 additions & 5 deletions back/routes/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ router.get("/club_activity_list", async (req, res) => {
const filteredActivities = await Activity.findAll({
where: {
club_id: club_id,
[Sequelize.Op.and]: [
{ start_date: { [Sequelize.Op.gte]: activityDuration.start_date } },
{ end_date: { [Sequelize.Op.lte]: activityDuration.end_date } },
],
// [Sequelize.Op.and]: [
// { start_date: { [Sequelize.Op.gte]: activityDuration.start_date } },
// { end_date: { [Sequelize.Op.lte]: activityDuration.end_date } },
// ],
},
include: [
{
Expand Down Expand Up @@ -125,7 +125,7 @@ router.get("/club_activity_list", async (req, res) => {
],
},
],
order: [["feedback_type", "ASC"]],
order: [["recent_edit", "DESC"]],
attributes: [
"id",
"title",
Expand Down
7 changes: 4 additions & 3 deletions back/routes/funding.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ router.get("/funding_list", async (req, res) => {
const fundings = await Funding.findAll({
where: {
club_id: clubId,
semester_id: currentSemester.id,
// semester_id: currentSemester.id,
},
attributes: [
"id",
Expand All @@ -66,8 +66,9 @@ router.get("/funding_list", async (req, res) => {
// Add other required fields
],
order: [
["purpose", "ASC"],
["expenditure_date", "ASC"],
["recent_edit", "DESC"],
// ["purpose", "ASC"],
// ["expenditure_date", "ASC"],
],
});

Expand Down
9 changes: 3 additions & 6 deletions back/routes/funding_feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ router.get("/club_funding_list", async (req, res) => {
const filteredFundings = await Funding.findAll({
where: {
club_id: club_id,
semester_id: currentSemester.id,
// semester_id: currentSemester.id,
},
include: [
{
Expand All @@ -87,7 +87,7 @@ router.get("/club_funding_list", async (req, res) => {
attributes: ["student_id", "name"],
},
],
order: [["funding_feedback_type", "ASC"]],
order: [["recent_edit", "DESC"]],
attributes: [
"id",
"name",
Expand Down Expand Up @@ -688,15 +688,12 @@ router.get("/funding_submit_list", async (req, res) => {
);

clubData.sort((a, b) => b.feedbackTypeOne - a.feedbackTypeOne);
const filteredClubData = clubData.filter(
(data) => data.totalClubActivities > 0
);

res.json({
totalActivities,
nonFeedbackTypeOneActivities,
ratio,
clubData: filteredClubData,
clubData: clubData,
});
} catch (error) {
console.error("Error in /activity_submit_list:", error);
Expand Down
36 changes: 21 additions & 15 deletions front/src/pages/activity/ActivityDetail/ActivityDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export const ActivityDetail = (): JSX.Element => {
feedbackResults: [],
});

const minDate = "2023-12-16";
const maxDate = "2024-06-14";

const [searchTerm, setSearchTerm] = useState("");
const [searchResults, setSearchResults] = useState<Participant[]>([]);
const [originalSearchResults, setOriginalSearchResults] = useState<
Expand Down Expand Up @@ -401,26 +404,29 @@ export const ActivityDetail = (): JSX.Element => {
</div>
</div>
<UnderBar />
{typeId < 4 && durationStatus > 0 && (
<div className="frame-16">
<div
className="frame-17"
onClick={() => navigate(`/edit_activity/${id}`)}
style={{ cursor: "pointer" }}
>
수정
</div>
{durationStatus == 1 && (
{typeId < 4 &&
durationStatus > 0 &&
minDate <= activity.startDate &&
activity.endDate <= maxDate && (
<div className="frame-16">
<div
className="frame-17"
onClick={handleDeleteActivity}
onClick={() => navigate(`/edit_activity/${id}`)}
style={{ cursor: "pointer" }}
>
삭제
수정
</div>
)}
</div>
)}
{durationStatus == 1 && (
<div
className="frame-17"
onClick={handleDeleteActivity}
style={{ cursor: "pointer" }}
>
삭제
</div>
)}
</div>
)}
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions front/src/pages/activity/AddActivity/AddActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export const AddActivity = (): JSX.Element => {

// Validation for date range and order
//TODO: 서버에서 불러와서 적용
const minDate = new Date("2023-06-17");
const maxDate = new Date("2023-12-15");
const minDate = new Date("2023-12-16");
const maxDate = new Date("2024-06-14");

const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value;
Expand Down
4 changes: 2 additions & 2 deletions front/src/pages/activity/EditActivity/EditActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ export const EditActivity = (): JSX.Element => {
// Validation for date range and order
const startDate = new Date(activity.startDate);
const endDate = new Date(activity.endDate);
const minDate = new Date("2023-06-17");
const maxDate = new Date("2023-12-15");
const minDate = new Date("2023-12-16");
const maxDate = new Date("2024-06-14");

if (
startDate > endDate ||
Expand Down
40 changes: 23 additions & 17 deletions front/src/pages/admin/ActivityAdminDetail/ActivityAdminDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export const ActivityAdminDetail = (): JSX.Element => {

const [reviewResult, setReviewResult] = useState("");

const minDate = "2023-12-16";
const maxDate = "2024-06-14";
// const maxDate = new Date("2024-06-14");

const handleReviewResultChange = (
event: React.ChangeEvent<HTMLTextAreaElement>
) => {
Expand Down Expand Up @@ -241,26 +245,28 @@ export const ActivityAdminDetail = (): JSX.Element => {
))}
</div>
</div>
<div className="frame-11">
<SubTitle className="sub-title-instance" text="검토 결과" />
<div className="frame-9">
<textarea
className="text-area"
value={reviewResult}
onChange={handleReviewResultChange}
/>
<div className="frame-14">
<div
className="frame-15"
style={{ cursor: "pointer" }}
onClick={handleReviewComplete}
>
<div className="text-wrapper-11">검토 완료</div>
{activity.startDate >= minDate && activity.endDate <= maxDate && (
<div className="frame-11">
<SubTitle className="sub-title-instance" text="검토 결과" />
<div className="frame-9">
<textarea
className="text-area"
value={reviewResult}
onChange={handleReviewResultChange}
/>
<div className="frame-14">
<div
className="frame-15"
style={{ cursor: "pointer" }}
onClick={handleReviewComplete}
>
<div className="text-wrapper-11">검토 완료</div>
</div>
</div>
{renderActivityFeedback()}
</div>
{renderActivityFeedback()}
</div>
</div>
)}
</div>
</div>
<UnderBar />
Expand Down
Loading

0 comments on commit a394b94

Please sign in to comment.