Skip to content

Commit

Permalink
Merge pull request #1080 from academic-relations/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
pbc1017 authored Sep 18, 2024
2 parents 889a4f0 + 6906c13 commit caed2aa
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,27 @@ export default class ActivityRepository {
return result;
}

/**
* @param param
* @returns activityId를 기준으로 반려 피드백 리스트를 리턴합니다.
* 급하게 짜서 오류있는지 점검필요 으어ㅏ
*/
async selectActivityFeedbackByActivityId(param: { activityId: number }) {
const result = await this.db
.select({
comment: ActivityFeedback.comment,
createdAt: ActivityFeedback.createdAt,
})
.from(ActivityFeedback)
.where(
and(
eq(ActivityFeedback.activityId, param.activityId),
isNull(ActivityFeedback.deletedAt),
),
);
return result;
}

async selectDeadlineByDate(date: Date) {
const result = await this.db
.select()
Expand Down
30 changes: 30 additions & 0 deletions packages/api/src/feature/activity/service/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ export default class ActivityService {
})),
);

const comments =
await this.activityRepository.selectActivityFeedbackByActivityId({
activityId: activity.id,
});

return {
clubId: activity.clubId,
name: activity.name,
Expand All @@ -301,6 +306,11 @@ export default class ActivityService {
startTerm: e.startTerm,
endTerm: e.endTerm,
})),
activityStatusEnumId: activity.activityStatusEnumId,
comments: comments.map(e => ({
content: e.comment,
createdAt: e.createdAt,
})),
};
}

Expand Down Expand Up @@ -700,6 +710,11 @@ export default class ActivityService {
})),
);

const comments =
await this.activityRepository.selectActivityFeedbackByActivityId({
activityId: activity.id,
});

return {
clubId: activity.clubId,
name: activity.name,
Expand All @@ -719,6 +734,11 @@ export default class ActivityService {
startTerm: e.startTerm,
endTerm: e.endTerm,
})),
activityStatusEnumId: activity.activityStatusEnumId,
comments: comments.map(e => ({
content: e.comment,
createdAt: e.createdAt,
})),
};
}

Expand All @@ -744,6 +764,11 @@ export default class ActivityService {
})),
);

const comments =
await this.activityRepository.selectActivityFeedbackByActivityId({
activityId: activity.id,
});

return {
clubId: activity.clubId,
name: activity.name,
Expand All @@ -763,6 +788,11 @@ export default class ActivityService {
startTerm: e.startTerm,
endTerm: e.endTerm,
})),
activityStatusEnumId: activity.activityStatusEnumId,
comments: comments.map(e => ({
content: e.comment,
createdAt: e.createdAt,
})),
};
}

Expand Down
12 changes: 11 additions & 1 deletion packages/interface/src/api/activity/endpoint/apiAct002.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { HttpStatusCode } from "axios";
import { z } from "zod";

import { ActivityTypeEnum } from "@sparcs-clubs/interface/common/enum/activity.enum";
import {
ActivityStatusEnum,
ActivityTypeEnum,
} from "@sparcs-clubs/interface/common/enum/activity.enum";

/**
* @version v0.1
Expand Down Expand Up @@ -52,6 +55,13 @@ const responseBodyMap = {
name: z.string().max(255),
}),
),
activityStatusEnumId: z.nativeEnum(ActivityStatusEnum),
comments: z.array(
z.object({
content: z.string(),
createdAt: z.coerce.date(),
}),
),
}),
};

Expand Down
19 changes: 19 additions & 0 deletions packages/web/src/common/components/FileUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useMemo, useState } from "react";

import { ApiFil001RequestBody } from "@sparcs-clubs/interface/api/file/apiFil001";
import { overlay } from "overlay-kit";
import styled from "styled-components";

import Icon from "@sparcs-clubs/web/common/components/Icon";
Expand All @@ -12,6 +13,8 @@ import usePutFileS3 from "../services/putFileS3";
import { FileDetail } from "./File/attachment";
import ThumbnailPreviewList from "./File/ThumbnailPreviewList";
import FlexWrapper from "./FlexWrapper";
import Modal from "./Modal";
import ConfirmModalContent from "./Modal/ConfirmModalContent";
import Typography from "./Typography";

type FileWithId = {
Expand Down Expand Up @@ -179,6 +182,22 @@ const FileUpload: React.FC<FileUploadProps> = ({
},
);
},
onError: error => {
overlay.open(({ isOpen, close }) => (
<Modal isOpen={isOpen}>
<ConfirmModalContent
onConfirm={() => {
close();
}}
>
파일 업로드에 실패했습니다.
<Typography color="GRAY.300" fs={12} lh={16} fw="REGULAR">
{error.message}
</Typography>
</ConfirmModalContent>
</Modal>
));
},
},
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/common/components/RejectReasonToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface RejectReasonToastProps {

const ForceBorderRadius = styled.div`
position: sticky;
top: 100px;
top: 0px;
border-radius: 8px;
width: 100%;
overflow: hidden;
Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/features/clubs/services/useGetClubsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const useGetClubsList = () =>
switch (status) {
case 200:
case 304:
return apiClb001.responseBodyMap[200].parse(data);
// return apiClb001.responseBodyMap[200].parse(data);
return data;
default:
throw new UnexpectedAPIResponseError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export type PastActivityReport = {
id: number;
name: string;
activityTypeEnumId: number;
activityStatusEnumId: ActivityStatusEnum;
durations: {
startTerm: Date;
endTerm: Date;
Expand Down Expand Up @@ -272,5 +273,11 @@ export const mockActivityDetailData: ApiAct002ResponseOkTemp = {
name: "스팍스",
},
],
comments: [
{
content: "그냥 맘에 안듬",
createdAt: new Date(),
},
],
advisorProfessorApproval: ActivityProfessorApprovalEnum.Requested,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";

import { ApiAct011ResponseOk } from "@sparcs-clubs/interface/api/activity/endpoint/apiAct011";
import {
createColumnHelper,
getCoreRowModel,
Expand All @@ -12,13 +13,15 @@ import Table from "@sparcs-clubs/web/common/components/Table";
import Tag from "@sparcs-clubs/web/common/components/Tag";
import Typography from "@sparcs-clubs/web/common/components/Typography";

import { ActStatusTagList } from "@sparcs-clubs/web/constants/tableTagList";
import PastActivityReportModal from "@sparcs-clubs/web/features/register-club/components/_atomic/PastActivityReportModal";

import {
getActivityTypeTagColor,
getActivityTypeTagLabel,
} from "@sparcs-clubs/web/features/register-club/utils/activityType";
import { formatDate } from "@sparcs-clubs/web/utils/Date/formatDate";
import { getTagDetail } from "@sparcs-clubs/web/utils/getTagDetail";

import { PastActivityReport } from "../_mock/mock";

Expand All @@ -29,13 +32,23 @@ interface ActivityReportListProps {
refetch?: () => void;
}

const columnHelper = createColumnHelper<PastActivityReport>();
const columnHelper =
createColumnHelper<ApiAct011ResponseOk["activities"][number]>();

const columns = [
columnHelper.accessor("activityStatusEnumId", {
id: "activityStatusEnumId",
header: "상태",
cell: info => {
const { color, text } = getTagDetail(info.getValue(), ActStatusTagList);
return <Tag color={color}>{text}</Tag>;
},
size: 64,
}),
columnHelper.accessor("name", {
header: "활동명",
cell: info => info.getValue(),
size: 35,
size: 128,
}),
columnHelper.accessor("activityTypeEnumId", {
header: "활동 분류",
Expand All @@ -44,15 +57,15 @@ const columns = [
{getActivityTypeTagLabel(info.getValue())}
</Tag>
),
size: 30,
size: 128,
}),
columnHelper.accessor(
row =>
`${formatDate(row.durations[0].startTerm)} ~ ${formatDate(row.durations[0].endTerm)}${row.durations.length > 1 ? ` 외 ${row.durations.length - 1}개` : ""}`,
{
header: "활동 기간",
cell: info => info.getValue(),
size: 40,
size: 255,
},
),
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import apiAct002, {
ApiAct002ResponseOk,
} from "@sparcs-clubs/interface/api/activity/endpoint/apiAct002";
import { ActivityStatusEnum } from "@sparcs-clubs/interface/common/enum/activity.enum";
import { useQuery } from "@tanstack/react-query";
import { z } from "zod";

Expand Down Expand Up @@ -72,6 +73,13 @@ defineAxiosMock(mock => {
name: "이도라",
},
],
activityStatusEnumId: ActivityStatusEnum.Rejected,
comments: [
{
content: "그냥 맘에 안듬",
createdAt: new Date(),
},
],
};
return [200, dummy];
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, { useCallback, useEffect } from "react";

import { ApiAct008RequestBody } from "@sparcs-clubs/interface/api/activity/endpoint/apiAct008";
import { ActivityStatusEnum } from "@sparcs-clubs/interface/common/enum/activity.enum";

import { useForm } from "react-hook-form";

import AsyncBoundary from "@sparcs-clubs/web/common/components/AsyncBoundary";
import FlexWrapper from "@sparcs-clubs/web/common/components/FlexWrapper";
import Modal from "@sparcs-clubs/web/common/components/Modal";
import RejectReasonToast from "@sparcs-clubs/web/common/components/RejectReasonToast";
import { useGetActivityReport } from "@sparcs-clubs/web/features/manage-club/activity-report/services/useGetActivityReport";

import usePutActivityReportForNewClub from "@sparcs-clubs/web/features/register-club/services/usePutActivityReportForNewClub";
Expand Down Expand Up @@ -85,16 +88,31 @@ const EditActivityReportModal: React.FC<EditActivityReportModalProps> = ({
formCtx.handleSubmit(_data => submitHandler(_data, e))();
};

if (!data) return null;

return (
<Modal isOpen={isOpen} width="full">
<AsyncBoundary isLoading={isLoading} isError={isError}>
<ActivityReportForm
/* eslint-disable @typescript-eslint/no-explicit-any */
clubId={data!.clubId}
formCtx={formCtx as any}
onCancel={handleCancel}
onSubmit={handleSubmit}
/>
<FlexWrapper gap={20} direction="column">
{data.activityStatusEnumId === ActivityStatusEnum.Rejected &&
data.comments.length > 0 && (
<RejectReasonToast
title="반려 사유"
reasons={data.comments.map(comment => ({
datetime: comment.createdAt,
reason: comment.content,
}))}
/>
)}

<ActivityReportForm
/* eslint-disable @typescript-eslint/no-explicit-any */
clubId={data.clubId}
formCtx={formCtx as any}
onCancel={handleCancel}
onSubmit={handleSubmit}
/>
</FlexWrapper>
</AsyncBoundary>
</Modal>
);
Expand Down
Loading

0 comments on commit caed2aa

Please sign in to comment.