Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 방 생성 때 방장도 참여 정할수 있게 변경 & 데이터 타입 변경(#798) #799

Merged
merged 12 commits into from
Dec 9, 2024
Merged
2 changes: 1 addition & 1 deletion frontend/src/@types/profile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface ProfileData {
export interface ProfileData {
profileImage: string;
nickname: string;
receivedReviewCount: number;
Expand Down
86 changes: 72 additions & 14 deletions frontend/src/@types/roomInfo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// 공통 타입 정의
export type Classification = "ALL" | "FRONTEND" | "BACKEND" | "ANDROID";

export type RoomStatus = "OPEN" | "CLOSE" | "PROGRESS" | "FAIL";
Expand All @@ -9,28 +10,21 @@ export type ParticipationStatus =
| "MANAGER"
| "PULL_REQUEST_NOT_SUBMITTED";

export type Role = "BOTH" | "REVIEWER" | "REVIEWEE" | "NONE";
export type MemberRole = "BOTH" | "REVIEWER" | "REVIEWEE" | "NONE";

interface BaseRoomInfo {
// 통합된 roomInfo
export interface BaseRoomInfo {
title: string;
content: string;
repositoryLink: string;
thumbnailLink: string;
matchingSize: number;
keywords: string[];
limitedParticipants: number;
classification: Classification;
isPublic: boolean;
}
export interface CreateRoomInfo extends BaseRoomInfo {
recruitmentDeadline: Date;
reviewDeadline: Date;
}

export interface SubmitRoomInfo extends BaseRoomInfo {
roomId?: number;
recruitmentDeadline: string;
reviewDeadline: string;
repositoryLink: string;
classification: Classification;
isPublic: boolean;
}

export interface RoomInfo extends BaseRoomInfo {
Expand All @@ -40,12 +34,76 @@ export interface RoomInfo extends BaseRoomInfo {
bothCount: number;
roomStatus: RoomStatus;
participationStatus: ParticipationStatus;
memberRole: Role;
message: string;
memberRole: MemberRole;
}

export interface CreateRoomInfo extends BaseRoomInfo {
roomId?: number;
managerMemberRole?: MemberRole;
managerMatchingSize?: number;
}

// 요청(Request) 구조
export interface RoomInfoRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

타입 정의할 때 ~Request, ~Response 이렇게 정의하니 더 명확해지고 좋네요~
그래서 주석은 굳이 없어도 될 것 같아요!

title: string;
content: string;
thumbnailLink: string;
matchingSize: number;
keywords: string[];
limitedParticipants: number;
}

export interface DeadlineRequest {
recruitmentDeadline: string;
reviewDeadline: string;
}

export interface RepositoryRequest {
repositoryLink: string;
classification: Classification;
isPublic: boolean;
}

export interface ManagerParticipationRequest {
memberRole?: MemberRole;
matchingSize?: number;
}

export interface RoomCreateRequest {
roomInfoRequest: RoomInfoRequest;
deadlineRequest: DeadlineRequest;
repositoryRequest: RepositoryRequest;
managerParticipationRequest: ManagerParticipationRequest;
}

// 응답(Response) 구조
export interface RoomInfoResponse extends RoomInfoRequest {
roomId: number;
manager: string;
roomStatus: RoomStatus;
reviewerCount: number;
bothCount: number;
message: string;
}

export interface DeadlineResponse extends DeadlineRequest {}

export interface RepositoryResponse extends RepositoryRequest {}

export interface ParticipationResponse {
participationStatus: ParticipationStatus;
memberRole: MemberRole;
matchingSize: number;
}

export interface RoomDetailResponse {
roomInfoResponse: RoomInfoResponse;
deadlineResponse: DeadlineResponse;
repositoryResponse: RepositoryResponse;
participationResponse: ParticipationResponse;
}

export interface RoomListInfo {
rooms: RoomInfo[];
isLastPage: boolean;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/apis/profile.api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ProfileData } from "@/@types/profile";
import apiClient from "@/apis/apiClient";
import { API_ENDPOINTS } from "@/apis/endpoints";
import MESSAGES from "@/constants/message";
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/apis/rooms.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { API_ENDPOINTS } from "./endpoints";
import { ParticipantListInfo } from "@/@types/participantList";
import {
Classification,
Role,
CreateRoomInfo,
MemberRole,
RoomCreateRequest,
RoomDetailResponse,
RoomInfo,
RoomListInfo,
RoomStatus,
SubmitRoomInfo,
} from "@/@types/roomInfo";
import MESSAGES from "@/constants/message";

Expand Down Expand Up @@ -80,15 +82,15 @@ export const getRoomDetailInfo = async (id: number): Promise<RoomInfo> => {
return res;
};

export const postCreateRoom = async (roomData: SubmitRoomInfo): Promise<void> => {
export const postCreateRoom = async (roomData: RoomCreateRequest): Promise<RoomDetailResponse> => {
return apiClient.post({
endpoint: API_ENDPOINTS.ROOMS,
body: roomData,
errorMessage: MESSAGES.ERROR.POST_CREATE_ROOM,
});
};

export const putEditRoom = async (roomData: SubmitRoomInfo): Promise<void> => {
export const putEditRoom = async (roomData: CreateRoomInfo): Promise<void> => {
return apiClient.put({
endpoint: API_ENDPOINTS.ROOMS,
body: roomData,
Expand All @@ -98,7 +100,7 @@ export const putEditRoom = async (roomData: SubmitRoomInfo): Promise<void> => {

export const postParticipateIn = async (
roomId: number,
role: Role,
role: MemberRole,
matchingSize: number,
): Promise<void> => {
return apiClient.post({
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/common/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const portalElement = document.getElementById("modal") as HTMLElement;
export interface ModalProps {
isOpen: boolean;
onClose: () => void;
onConfirm?: () => void;
onCancel?: () => void;
hasCloseButton?: boolean;
style?: CSSProperties;
children?: ReactNode;
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/components/common/modal/alertModal/AlertModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ import Modal, { ModalProps } from "../Modal";
import Button from "@/components/common/button/Button";
import * as S from "@/components/common/modal/confirmModal/ConfirmModal.style";

type AlertModalProps = Omit<ModalProps, "onCancel" | "onConfirm">;
interface AlertModalProps extends ModalProps {
onConfirm: () => void;
confirmButtonText?: string;
}

const AlertCustomStyle = {
height: "fit-content",
};

const AlertModal = ({ ...rest }: AlertModalProps) => {
const AlertModal = ({ confirmButtonText = "확인", ...rest }: AlertModalProps) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfirmModal과의 통일성을 위해서 작업한 것 같은데 꼼꼼하게 해주셨네요 👍

return (
<Modal style={AlertCustomStyle} {...rest}>
<S.ConfirmModalContainer>{rest.children}</S.ConfirmModalContainer>
<S.ButtonWrapper>
<Button size="small" onClick={rest.onClose}>
확인
<Button size="small" onClick={rest.onConfirm}>
{confirmButtonText}
</Button>
</S.ButtonWrapper>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const ConfirmCustomStyle = {
};

interface ConfirmModalProps extends ModalProps {
onConfirm: () => void;
onCancel: () => void;
confirmButtonText?: string;
cancelButtonText?: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Icon from "@/components/common/icon/Icon";
import Profile from "@/components/common/profile/Profile";
import * as S from "@/components/profile/profileCard/ProfileCard.style";
import { ProfileData } from "@/@types/profile";
import { HoverStyledLink } from "@/styles/common";

const ProfileCard = (profileData: ProfileData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ const ControlButton = ({ roomInfo, participationStatus }: ControlButtonProps) =>
<FocusTrap onEscapeFocusTrap={() => handleToggleDropdown()}>
<S.DropdownItemWrapper>
{dropdownItems.map((item: DropdownItem, index) => (
<>
<React.Fragment key={item.name}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key 를 상위에서 선언해주도록 바꿔준거 좋네요 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

콘솔에 에러 뜨고 있더라구요 ...ㅎ 바로 바꿨습니다😄

<S.DropdownItem
key={item.name}
onClick={() => handleDropdownItemClick(item.action)}
tabIndex={0}
onKeyDown={(e) => {
Expand All @@ -98,7 +97,7 @@ const ControlButton = ({ roomInfo, participationStatus }: ControlButtonProps) =>
{item.name}
</S.DropdownItem>
{index < dropdownItems.length - 1 && <S.Divider />}
</>
</React.Fragment>
))}
</S.DropdownItemWrapper>
</FocusTrap>
Expand Down
28 changes: 27 additions & 1 deletion frontend/src/components/roomForm/RoomFormLayout.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ export const SectionTitle = styled.h1`
color: ${({ theme }) => theme.COLOR.grey4};
`;

export const SubSectionTitle = styled.h1`
display: flex;
gap: 1rem;
align-items: flex-end;

width: 100%;

font: ${({ theme }) => theme.TEXT.medium_bold};
color: ${({ theme }) => theme.COLOR.grey4};
`;

export const HelpText = styled.p`
font: ${({ theme }) => theme.TEXT.xSmall};
color: ${({ theme }) => theme.COLOR.grey3};
Expand Down Expand Up @@ -53,7 +64,7 @@ export const RowContainer = styled.div`
`;

export const ContentLabel = styled.span`
font: ${({ theme }) => theme.TEXT.medium_bold};
font: ${({ theme }) => theme.TEXT.small_bold};
`;

export const RequiredLabel = styled.span`
Expand All @@ -77,6 +88,21 @@ export const ContentWrapper = styled.div`
padding: 1rem 0;
`;

export const ContentRadioWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 2rem;
align-items: flex-start;

padding: 1rem 0;

div {
display: flex;
flex-direction: column;
gap: 1rem;
}
`;

export const ContentRadioInput = styled.input`
display: none;
`;
Expand Down
Loading
Loading