Skip to content

Commit

Permalink
Merge pull request #106 from JNU-econovation/revert-105-main
Browse files Browse the repository at this point in the history
Revert "[FE/FEAT] API 요청 구현"
  • Loading branch information
bada308 authored Nov 29, 2023
2 parents e48cdec + 5e996b8 commit a8fcc13
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 313 deletions.
4 changes: 2 additions & 2 deletions FE/components/common/form/ProgramForm.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLFormElement>) => void;
Expand All @@ -23,7 +23,7 @@ interface ProgramFormProps {
};
submitText?: string;
isEdit: boolean;
memberList: MemberInfo[];
memberList: defaultMember[];
}

const ProgramForm = ({
Expand Down
4 changes: 2 additions & 2 deletions FE/components/common/memberTable/MemberTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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",
);
Expand All @@ -44,7 +44,7 @@ const MemberTableItem = ({
return (
<div className="grid h-20 grid-cols-[4.75rem_7rem_7.25rem_1fr_20.5rem] items-center justify-items-center gap-4 border-b-2 border-stroke-10 bg-background px-10">
<CheckBox checked={isRelated} onChange={handleCheckBoxChange} />
<span>{activeStatus}</span>
<span>{generation}</span>
<span className="font-bold">{name}</span>
<span></span>
{isEdit && (
Expand Down
39 changes: 17 additions & 22 deletions FE/components/create/ProgramCreateForm.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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",
},
];
Expand Down
4 changes: 2 additions & 2 deletions FE/components/detail/MemberList.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
44 changes: 44 additions & 0 deletions FE/src/apis/member.ts
Original file line number Diff line number Diff line change
@@ -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<getAllMembersResponse>({
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<getMembersByStatusResponse>({
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<updateMembersResponse>({
url: API.MEMBER.UPDATE_ATTENDSTATUS + `/${programId}`,
method: "POST",
data: body,
});
return data.data;
};
69 changes: 0 additions & 69 deletions FE/src/apis/members.ts

This file was deleted.

111 changes: 31 additions & 80 deletions FE/src/apis/program.ts
Original file line number Diff line number Diff line change
@@ -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<GetProgramByIdResponse>({
url: `programs/${programId}`,
export const createProgram = async (body: createProgramRequest) => {
const { data } = await https<createProgramResponse>({
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<GetProgramListResponse>({
url: "programs",
const { data } = await https<getProgramListResponse>({
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<ProgramInfo, "programId"> {
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<getProgramDetailResponse>({
url: API.PROGRAM + `/${programId}`,
method: "GET",
});
return data.data;
};

/**
* 프로그램 수정 및 참여 대상자/참여 상태 수정
*/

interface PatchProgramRequest extends Omit<ProgramInfo, "programId"> {
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;
};
Loading

0 comments on commit a8fcc13

Please sign in to comment.