diff --git a/FE/components/common/form/ProgramForm.component.tsx b/FE/components/common/form/ProgramForm.component.tsx index 8d433519..88825b91 100644 --- a/FE/components/common/form/ProgramForm.component.tsx +++ b/FE/components/common/form/ProgramForm.component.tsx @@ -7,8 +7,8 @@ import ProgramCategoryTab, { } from "./ProgramCategoryTab.component"; import ProgramDateInput from "./ProgramDateInput.component"; import ProgramTitleAndDemandInput from "./ProgramTitleAndDemandInput.component"; +import { defaultMember } from "@/src/apis/types/member"; import FORM_INFO from "@/src/constants/FORM_INFO"; -import { MemberInfo } from "@/src/types/member"; interface ProgramFormProps { handleSubmit: (e: React.FormEvent) => void; @@ -23,7 +23,7 @@ interface ProgramFormProps { }; submitText?: string; isEdit: boolean; - memberList: MemberInfo[]; + memberList: defaultMember[]; } const ProgramForm = ({ diff --git a/FE/components/common/memberTable/MemberTable.component.tsx b/FE/components/common/memberTable/MemberTable.component.tsx index 93752a2d..1d38d9bb 100644 --- a/FE/components/common/memberTable/MemberTable.component.tsx +++ b/FE/components/common/memberTable/MemberTable.component.tsx @@ -4,11 +4,11 @@ import { useState } from "react"; import CheckBox from "../CheckBox.component"; import ActiveStatusTab from "./ActiveStatusTab.component"; import MemberTableItem from "./MemberTableItem.component"; +import { defaultMember } from "@/src/apis/types/member"; import ACTIVE_STATUS from "@/src/constants/ACTIVE_STATUS"; -import { MemberInfo } from "@/src/types/member"; interface MemberTableProps { - members: MemberInfo[]; + members: defaultMember[]; isEdit: boolean; } diff --git a/FE/components/common/memberTable/MemberTableItem.component.tsx b/FE/components/common/memberTable/MemberTableItem.component.tsx index d4f20127..fc2560e1 100644 --- a/FE/components/common/memberTable/MemberTableItem.component.tsx +++ b/FE/components/common/memberTable/MemberTableItem.component.tsx @@ -3,16 +3,16 @@ import { useState } from "react"; import AttendStatusSelector from "../attendStatus/AttendStatusSelector.component"; import CheckBox from "../CheckBox.component"; +import { defaultMember } from "@/src/apis/types/member"; import ATTEND_STATUS from "@/src/constants/ATTEND_STATUS"; import { badgeOption } from "@/src/types/common/common"; -import { MemberInfo } from "@/src/types/member"; export const attendStatusList: badgeOption[] = ATTEND_STATUS.BADGE_STYLE.filter( (style) => style.type !== "nonRelated" && style.type !== "nonResponse", ); interface MemberTableItemProps { - data: MemberInfo; + data: defaultMember; isEdit: boolean; setMemberList: () => void; } @@ -22,7 +22,7 @@ const MemberTableItem = ({ isEdit, setMemberList, }: MemberTableItemProps) => { - const { memberId, name, activeStatus } = data; + const { memberId, name, generation } = data; const [isRelated, setIsRelated] = useState( data.attendStatus !== "nonRelated", ); @@ -44,7 +44,7 @@ const MemberTableItem = ({ return (
- {activeStatus} + {generation} {name} {isEdit && ( diff --git a/FE/components/create/ProgramCreateForm.component.tsx b/FE/components/create/ProgramCreateForm.component.tsx index 36fe0918..c218d8c6 100644 --- a/FE/components/create/ProgramCreateForm.component.tsx +++ b/FE/components/create/ProgramCreateForm.component.tsx @@ -5,8 +5,8 @@ import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import ProgramForm from "../common/form/ProgramForm.component"; import { createProgram } from "@/src/apis/program"; +import { defaultMember } from "@/src/apis/types/member"; import ROUTES from "@/src/constants/ROUTES"; -import { MemberInfo } from "@/src/types/member"; import { getLocalStorage, setLocalStorage } from "@/src/utils/localStorage"; const ProgramCreateForm = () => { @@ -42,35 +42,30 @@ const ProgramCreateForm = () => { }, }; - const memberList: MemberInfo[] = [ + const memberList: defaultMember[] = [ { - memberId: "1", - name: "스티브", - activeStatus: "am", + memberId: 1, + name: "김민수", + generation: "24", attendStatus: "attend", }, { - memberId: "2", - name: "김만두", - activeStatus: "am", - attendStatus: "absent", - }, - { - memberId: "3", - name: "김즈우", - activeStatus: "am", - attendStatus: "perceive", + memberId: 2, + name: "고구마", + generation: "25", + attendStatus: "attend", }, + { - memberId: "4", - name: "김오션", - activeStatus: "am", - attendStatus: "nonResponse", + memberId: 3, + name: "강바다", + generation: "25", + attendStatus: "attend", }, { - memberId: "5", - name: "인텔리", - activeStatus: "am", + memberId: 4, + name: "감자", + generation: "23", attendStatus: "attend", }, ]; diff --git a/FE/components/detail/MemberList.component.tsx b/FE/components/detail/MemberList.component.tsx index d44c6917..e8e5e809 100644 --- a/FE/components/detail/MemberList.component.tsx +++ b/FE/components/detail/MemberList.component.tsx @@ -6,12 +6,12 @@ import Image from "next/image"; import LoadingSpinner from "../common/LoadingSpinner"; import MemberListItem from "./MemberListItem.component"; import { getMembersByStatus } from "@/src/apis/member"; +import { attendStatus } from "@/src/apis/types/member"; import ATTEND_STATUS from "@/src/constants/ATTEND_STATUS"; -import { AttendStatus } from "@/src/types/member"; interface MemberListProps { programId: string; - attendStatus: AttendStatus; + attendStatus: attendStatus; } const MemberList = ({ programId, attendStatus }: MemberListProps) => { diff --git a/FE/src/apis/member.ts b/FE/src/apis/member.ts new file mode 100644 index 00000000..f1e8e78b --- /dev/null +++ b/FE/src/apis/member.ts @@ -0,0 +1,44 @@ +import { sortMembers } from "../utils/sort"; +import { + attendStatus, + getAllMembersResponse, + getMembersByStatusResponse, + updateMembersRequest, + updateMembersResponse, +} from "./types/member"; +import { https } from "."; +import API from "@/src/constants/API"; + +export const getAllMembers = async (programId: string) => { + const { data } = await https({ + url: API.MEMBER.GET_ALL_MEMBERS + `/${programId}`, + method: "GET", + }); + + return sortMembers(data.data); +}; + +export const getMembersByStatus = async ( + programId: number, + attendStatus: attendStatus, +) => { + const { data } = await https({ + url: API.MEMBER.GET_MEMBER_LIST_BY_STATUS(programId), + method: "GET", + params: { attendStatus }, + }); + + return data.data; +}; + +export const updateMembers = async ( + programId: string, + body: updateMembersRequest, +) => { + const { data } = await https({ + url: API.MEMBER.UPDATE_ATTENDSTATUS + `/${programId}`, + method: "POST", + data: body, + }); + return data.data; +}; diff --git a/FE/src/apis/members.ts b/FE/src/apis/members.ts deleted file mode 100644 index 421053e9..00000000 --- a/FE/src/apis/members.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { - ActiveStatus, - AttendStatus, - MemberActiveStatusInfo, - MemberAttendStatusInfo, - MemberInfo, -} from "../types/member"; -import { https } from "."; - -/** - * 활동 상태별 회원 정보 조회 - */ - -interface GetMembersByActiveStatusResponse { - data: { members: MemberActiveStatusInfo[] }; -} - -export const getMembersByActiveStatus = async ( - activeStatus: ActiveStatus | "all", -) => { - const { data } = await https({ - url: "members", - method: "GET", - params: { activeStatus }, - }); - - return data.data; -}; - -/** - * 해당 프로그램의 활동 상태별 회원 정보 조회 - */ - -interface GetProgramMembersByActiveStatusResponse { - data: { members: MemberInfo[] }; -} - -export const getProgramMembersByActiveStatus = async ( - programId: string, - activeStatus: ActiveStatus | "all", -) => { - const { data } = await https({ - url: `programs/${programId}/members`, - method: "GET", - params: { activeStatus }, - }); - - return data.data; -}; - -/** - * 해당 프로그램의 출석 상태별 회원 정보 조회 - */ - -interface GetProgramMembersByAttendStatusResponse { - data: { members: MemberAttendStatusInfo[] }; -} - -export const getProgramMembersByAttendStatus = async ( - programId: string, - attendStatus: AttendStatus, -) => { - const { data } = await https({ - url: `programs/${programId}/members`, - method: "GET", - params: { attendStatus }, - }); - return data.data; -}; diff --git a/FE/src/apis/program.ts b/FE/src/apis/program.ts index 3cf183d7..d455d22b 100644 --- a/FE/src/apis/program.ts +++ b/FE/src/apis/program.ts @@ -1,102 +1,53 @@ -/** - * 프로그램 정보 조회 - */ - -import { AttendStatus } from "../types/member"; import { - ProgramCategory, - ProgramInfo, - ProgramListInfo, - ProgramStatus, -} from "../types/program"; + createProgramRequest, + createProgramResponse, + getProgramDetailResponse, + getProgramListResponse, + updateProgramRequest, +} from "./types/program"; import { https } from "."; +import API from "@/src/constants/API"; -interface GetProgramByIdResponse { - data: ProgramInfo; -} - -export const getProgramById = async (programId: string) => { - const { data } = await https({ - url: `programs/${programId}`, +export const createProgram = async (body: createProgramRequest) => { + const { data } = await https({ + url: API.PROGRAM, + method: "POST", + data: body, }); return data.data; }; -/** - * 프로그램 리스트 조회 - */ +export const updateProgram = async ( + programId: string, + body: updateProgramRequest, +) => { + const { data } = await https({ + url: API.PROGRAM + `/${programId}`, + method: "PUT", + data: body, + }); + return data.data; +}; -interface GetProgramListResponse { - data: ProgramListInfo[]; -} export const getProgramList = async ( - category: ProgramCategory, - programStatus: ProgramStatus, + programStatus: string, size: number, page: number, ) => { - const { data } = await https({ - url: "programs", + const { data } = await https({ + url: API.PROGRAM, method: "GET", - params: { - category, - programStatus, - size, - page, - }, + params: { programStatus, size, page }, }); - return data.data; -}; - -/** - * 프로그램 삭제 - */ -export const deleteProgram = async (programId: string) => { - const { data } = await https({ - url: `programs/${programId}`, - method: "DELETE", - }); return data.data; }; -/** - * 프로그램 생성 및 대상자 선정 - */ - -interface PostProgramRequest extends Omit { - members: { memberId: string }[]; -} - -export const postProgram = async (body: PostProgramRequest) => { - const { data } = await https({ - url: "programs", - method: "POST", - data: body, +export const getProgramDetail = async (programId: string) => { + const { data } = await https({ + url: API.PROGRAM + `/${programId}`, + method: "GET", }); - return data.data; -}; -/** - * 프로그램 수정 및 참여 대상자/참여 상태 수정 - */ - -interface PatchProgramRequest extends Omit { - members: { - memberId: string; - beforeAttendStatus: AttendStatus; - afterAttendStatus: AttendStatus; - }[]; -} - -export const patchProgram = async ( - programId: string, - body: PatchProgramRequest, -) => { - const { data } = await https({ - url: `programs/${programId}`, - method: "PATCH", - data: body, - }); return data.data; }; diff --git a/FE/src/apis/types/member.d.ts b/FE/src/apis/types/member.d.ts new file mode 100644 index 00000000..593c6263 --- /dev/null +++ b/FE/src/apis/types/member.d.ts @@ -0,0 +1,32 @@ +type attendStatus = + | "attend" + | "absent" + | "nonRelated" + | "perceive" + | "nonResponse"; + +export interface defaultMember { + memberId: number; + generation: string; + name: string; + attendStatus: attendStatus; +} + +/* getMembersByStatus */ +export type getMembersByStatusResponse = { data: defaultMember[] }; + +/* getAllMembers */ +export type getAllMembersResponse = { data: defaultMember[] }; + +/* updateMembers */ +export interface updateMembersRequest { + memberId: number; + beforeAttendStatus: attendStatus; + afterAttendStatus: attendStatus; +} + +export interface updateMembersResponse { + data: { + programId: number; + }; +} diff --git a/FE/src/apis/types/program.d.ts b/FE/src/apis/types/program.d.ts new file mode 100644 index 00000000..f33cf253 --- /dev/null +++ b/FE/src/apis/types/program.d.ts @@ -0,0 +1,43 @@ +import { programStatusEn } from "../../types/home/home"; + +export interface defaultProgram { + title: string; + programDate: string; + content: string; +} + +/* 행사 생성 */ + +export interface createProgramRequest extends defaultProgram {} + +export interface createProgramResponse { + data: { + programId: number; + }; +} + +/* 행사 수정 */ +export interface updateProgramRequest extends defaultProgram {} + +/* 행사 조회 */ +export interface summaryProgram extends Omit { + programId: number; + programStatus: programStatusEn; +} + +export interface detailProgram extends summaryProgram { + content: string; +} + +export interface getProgramListResponse { + data: { + size: number; + page: number; + totalPage: number; + programs: summaryProgram[]; + }; +} + +export interface getProgramDetailResponse { + data: detailProgram; +} diff --git a/FE/src/apis/user.ts b/FE/src/apis/user.ts deleted file mode 100644 index a2ba5e4f..00000000 --- a/FE/src/apis/user.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { - ActiveStatus, - AttendStatus, - MyActiveStatusInfo, - MyAttendStatusInfo, -} from "../types/member"; -import { https } from "."; - -/** - * 본인의 출석 상태 조회 - */ - -interface GetMyAttendStatusResponse { - data: MyAttendStatusInfo; -} - -export const getMyAttendStatus = async (programId: string) => { - const { data } = await https({ - url: `programs/${programId}/members/attendStatus`, - method: "GET", - }); - return data.data; -}; - -/** - * 본인의 출석 상태 변경 - */ - -interface PutMyAttendStatusRequest { - beforeAttendStatus: AttendStatus; - afterAttendStatus: AttendStatus; -} - -export const putMyAttendStatus = async ( - programId: string, - body: PutMyAttendStatusRequest, -) => { - const { data } = await https({ - url: `programs/${programId}/members/attendStatus`, - method: "PUT", - data: body, - }); - return data.data; -}; - -/** - * 본인의 회원 상태 조회 - */ - -interface GetMyActiveStatusResponse { - data: MyActiveStatusInfo; -} - -export const getMyActiveStatus = async () => { - const { data } = await https({ - url: "members/activeStatus", - method: "GET", - }); - return data.data; -}; - -/** - * 본인의 회원 상태 변경 - */ - -interface PutMyActiveStatusRequest { - activeStatus: ActiveStatus; -} - -interface PutMyActiveStatusResponse { - data: MyActiveStatusInfo; -} - -export const putMyActiveStatus = async (body: PutMyActiveStatusRequest) => { - const { data } = await https({ - url: "members/activeStatus", - method: "PUT", - data: body, - }); - return data.data; -}; diff --git a/FE/src/constants/ATTEND_STATUS.ts b/FE/src/constants/ATTEND_STATUS.ts index ccc36108..86d4d53d 100644 --- a/FE/src/constants/ATTEND_STATUS.ts +++ b/FE/src/constants/ATTEND_STATUS.ts @@ -1,9 +1,9 @@ // FIXME: {type, text, color, icon}[]의 형태로 바꾸기 -import { AttendStatus } from "../types/member"; +import { attendStatus } from "../apis/types/member"; interface badgeStyle { - type: AttendStatus; + type: attendStatus; text: string; color: "gray" | "green" | "yellow" | "red" | "teal"; } diff --git a/FE/src/types/common/common.ts b/FE/src/types/common/common.ts index 6a2ed812..f1bf591b 100644 --- a/FE/src/types/common/common.ts +++ b/FE/src/types/common/common.ts @@ -1,7 +1,7 @@ -import { AttendStatus } from "../member"; +import { attendStatus } from "@/src/apis/types/member"; export interface badgeOption { text: string; color: "green" | "yellow" | "red" | "gray" | "teal"; - type: AttendStatus; + type: attendStatus; } diff --git a/FE/src/types/member.ts b/FE/src/types/member.ts deleted file mode 100644 index 24e8c838..00000000 --- a/FE/src/types/member.ts +++ /dev/null @@ -1,25 +0,0 @@ -export type ActiveStatus = "am" | "rm" | "cm" | "ob"; -export type AttendStatus = - | "attend" - | "absent" - | "perceive" - | "nonResponse" - | "nonRelated"; - -export interface MemberInfo { - memberId: string; - name: string; - attendStatus: AttendStatus; - activeStatus: ActiveStatus; -} - -export interface MemberAttendStatusInfo - extends Omit {} - -export interface MemberActiveStatusInfo - extends Omit {} - -export interface MyActiveStatusInfo - extends Omit {} -export interface MyAttendStatusInfo - extends Omit {} diff --git a/FE/src/types/program.ts b/FE/src/types/program.ts deleted file mode 100644 index 81f9b65c..00000000 --- a/FE/src/types/program.ts +++ /dev/null @@ -1,22 +0,0 @@ -export type ProgramCategory = "weekly" | "presidentTeam" | "eventTema" | "etc"; -export type ProgramStatus = "active" | "end"; -export type ProgramType = "demand" | "notification"; - -export interface ProgramInfo { - programId: string; - title: string; - deadLine: string; - content: string; - category: ProgramCategory; - programStatus: ProgramStatus; - type: ProgramType; -} - -export interface ProgramSimpleInfo extends Omit {} - -export interface ProgramListInfo { - size: number; - page: number; - totalPage: number; - programs: ProgramSimpleInfo[]; -}