Skip to content

Commit

Permalink
[FE] 모집중 이외의 방 클릭시에도 방 참여 알림이 보여지는 문제 해결(#754) (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 authored Nov 13, 2024
2 parents 722a6dd + 7ab28c0 commit 1eed2aa
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 5 deletions.
1 change: 1 addition & 0 deletions frontend/src/@types/roomInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface BaseRoomInfo {
keywords: string[];
limitedParticipants: number;
classification: Classification;
isPrivate: boolean;
}
export interface CreateRoomInfo extends BaseRoomInfo {
recruitmentDeadline: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mockBaseRoomInfo: RoomInfo = {
recruitmentDeadline: "2024-10-05T10:30:00+09:00",
reviewDeadline: "2024-10-08T10:30:00+09:00",
message: "테스트 메세지",
isPrivate: false,
};

describe("RoomInfoCard 컴포넌트 테스트", () => {
Expand Down
63 changes: 63 additions & 0 deletions frontend/src/components/roomForm/RoomFormLayout.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,66 @@ export const ContentInput = styled.div`
gap: 1rem;
width: 100%;
`;

export const ContentWrapper = styled.div`
display: flex;
flex-direction: row;
gap: 1rem;
align-items: center;
font: ${({ theme }) => theme.TEXT.medium};
`;

export const ContentRadioInput = styled.input`
display: none; /* 기본 라디오 버튼은 숨김 */
`;

export const RadioLabel = styled.label`
cursor: pointer;
position: relative;
padding-left: 2.5rem;
font-size: 1rem;
color: ${({ theme }) => theme.COLOR.grey2};
/* 라디오 버튼 원 모양 스타일링 */
&::before {
content: "";
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
width: 1.5rem;
height: 1.5rem;
background-color: ${({ theme }) => theme.COLOR.white};
border: 2px solid ${({ theme }) => theme.COLOR.grey3};
border-radius: 50%;
transition: 0.2s all ease-in-out;
}
input:checked + &::before {
background-color: ${({ theme }) => theme.COLOR.primary2};
border-color: ${({ theme }) => theme.COLOR.primary2};
}
input:checked + &::after {
content: "";
position: absolute;
top: 50%;
left: 0.6rem;
transform: translateY(-50%);
width: 0.75rem;
height: 0.75rem;
background-color: ${({ theme }) => theme.COLOR.white};
border-radius: 50%;
}
`;
25 changes: 25 additions & 0 deletions frontend/src/components/roomForm/RoomFormLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const getInitialFormState = (data?: RoomInfo): CreateRoomInfo => ({
recruitmentDeadline: data ? new Date(data.recruitmentDeadline) : new Date(),
reviewDeadline: data ? new Date(data.reviewDeadline) : new Date(),
classification: data?.classification || "ALL",
isPrivate: false,
});

const RoomFormLayout = ({ formType, roomId, data }: RoomFormLayoutProps) => {
Expand Down Expand Up @@ -237,6 +238,30 @@ const RoomFormLayout = ({ formType, roomId, data }: RoomFormLayoutProps) => {
</S.ContentInput>
</S.RowContainer>

<S.RowContainer>
<S.ContentLabel>방 공개 여부</S.ContentLabel>
<S.ContentWrapper>
<S.ContentRadioInput
type="radio"
id="yes"
name="isPrivate"
checked={formState.isPrivate}
onChange={() => handleInputChange("isPrivate", true)}
/>
<S.RadioLabel htmlFor="yes"></S.RadioLabel>
</S.ContentWrapper>
<S.ContentWrapper>
<S.ContentRadioInput
type="radio"
id="no"
name="isPrivate"
checked={!formState.isPrivate}
onChange={() => handleInputChange("isPrivate", false)}
/>
<S.RadioLabel htmlFor="no">아니요</S.RadioLabel>
</S.ContentWrapper>
</S.RowContainer>

<Button
onClick={() => {
if (isFormValid) handleOpenModal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const sampleRoomList = {
| "PULL_REQUEST_NOT_SUBMITTED",
memberRole: roomInfo.memberRole as "BOTH" | "REVIEWER" | "REVIEWEE" | "NONE",
classification: roomInfo.classification as "ALL" | "FRONTEND" | "BACKEND" | "ANDROID",
isPrivate: false,
} satisfies RoomInfo;

const meta = {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/shared/roomCard/RoomCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const mockBaseRoomInfo: RoomInfo = {
recruitmentDeadline: "2024-10-05T10:30:00+09:00",
reviewDeadline: "2024-10-08T10:30:00+09:00",
message: "테스트 메세지",
isPrivate: false,
};

describe("RoomCard 컴포넌트 날짜 테스트", () => {
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/components/shared/roomCard/RoomCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import RoomCardModal from "@/components/shared/roomCardModal/RoomCardModal";
import { RoomInfo } from "@/@types/roomInfo";
import { MAX_KEYWORDS } from "@/constants/room";
import { theme } from "@/styles/theme";
import { convertdDayToKorean } from "@/utils/convertToKorean";
import { convertedDayToKorean } from "@/utils/convertToKorean";
import { convertDateToKorean, formatDday, formatLeftTime } from "@/utils/dateFormatter";

const DisplayLeftTime = (roomInfo: RoomInfo) => {
Expand All @@ -24,7 +24,7 @@ const DisplayLeftTime = (roomInfo: RoomInfo) => {
{dDay !== "종료됨" && "모집 마감"}
<S.StyledDday aria-hidden>{dDay === "D-Day" ? leftTime : dDay}</S.StyledDday>
<S.ScreenReader>
{dDay === "D-Day" ? convertDateToKorean(leftTime) : convertdDayToKorean(dDay)}
{dDay === "D-Day" ? convertDateToKorean(leftTime) : convertedDayToKorean(dDay)}
</S.ScreenReader>
</>
);
Expand All @@ -39,7 +39,7 @@ const DisplayLeftTime = (roomInfo: RoomInfo) => {
{dDay !== "종료됨" && "리뷰 마감"}
<S.StyledDday aria-hidden>{dDay === "D-Day" ? leftTime : dDay}</S.StyledDday>
<S.ScreenReader>
{dDay === "D-Day" ? convertDateToKorean(leftTime) : convertdDayToKorean(dDay)}
{dDay === "D-Day" ? convertDateToKorean(leftTime) : convertedDayToKorean(dDay)}
</S.ScreenReader>
</>
);
Expand Down Expand Up @@ -74,7 +74,11 @@ const RoomCard = React.memo(({ roomInfo }: RoomCardProps) => {
<>
<RoomCardModal isOpen={isModalOpen} onClose={handleCloseModal} roomInfo={roomInfo} />

<S.RoomCardContainer onClick={handleOpenModal}>
<S.RoomCardContainer
onClick={
roomInfo.roomStatus === "OPEN" && roomInfo.isPrivate ? handleNoticeModal : handleOpenModal
}
>
<S.ClassificationBadgeWrapper>
<ClassificationBadge text={roomInfo.classification} />
</S.ClassificationBadgeWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const sampleRoomList = {
| "PULL_REQUEST_NOT_SUBMITTED",
memberRole: roomInfo.memberRole as "BOTH" | "REVIEWER" | "REVIEWEE" | "NONE",
classification: roomInfo.classification as "ALL" | "FRONTEND" | "BACKEND" | "ANDROID",
isPrivate: false,
} satisfies RoomInfo;

const meta: Meta<typeof RoomCardModal> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const sampleRoomList = roomInfos.rooms.map((roomInfo) => ({

memberRole: roomInfo.memberRole as "BOTH" | "REVIEWER" | "REVIEWEE" | "NONE",
classification: roomInfo.classification as "ALL" | "FRONTEND" | "BACKEND" | "ANDROID",
isPrivate: false,
})) satisfies RoomInfo[];

const meta = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/convertToKorean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const convertClassificationToKorean = (text: Classification) => {
}
};

export const convertdDayToKorean = (dDay: string) => {
export const convertedDayToKorean = (dDay: string) => {
const leftDay = dDay.split("-")[1];

return `${leftDay}일 전`;
Expand Down

0 comments on commit 1eed2aa

Please sign in to comment.