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

QA를 main에 반영한다. #1069

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ private void updateChecklistMaintenances(ChecklistRequest checklistRequest, Chec
}

private void updateChecklistStations(RoomRequest roomRequest, Checklist checklist) {
double latitude = roomRequest.latitude();
double longitude = roomRequest.longitude();
Double latitude = roomRequest.latitude();
Double longitude = roomRequest.longitude();
checklistStationService.updateChecklistStation(checklist, latitude, longitude);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ChecklistStationService {
private final SubwayStationService subwayStationService;

@Transactional
public void createChecklistStations(Checklist checklist, double latitude, double longitude) {
public void createChecklistStations(Checklist checklist, Double latitude, Double longitude) {
saveChecklistStations(checklist, latitude, longitude);
}

Expand All @@ -28,7 +28,7 @@ public List<ChecklistStation> readChecklistStationsByChecklist(Checklist checkli
}

@Transactional
public void updateChecklistStation(Checklist checklist, double latitude, double longitude) {
public void updateChecklistStation(Checklist checklist, Double latitude, Double longitude) {
checklistStationRepository.deleteAllByChecklistId(checklist.getId());
saveChecklistStations(checklist, latitude, longitude);
}
Expand All @@ -38,7 +38,10 @@ public void deleteChecklistStation(Long checklistId) {
checklistStationRepository.deleteAllByChecklistId(checklistId);
}

private void saveChecklistStations(Checklist checklist, double latitude, double longitude) {
private void saveChecklistStations(Checklist checklist, Double latitude, Double longitude) {
if (latitude == null || longitude == null) {
return;
}
List<SubwayStationResponse> responses = subwayStationService.readNearestStation(latitude, longitude)
.getStations();
List<ChecklistStation> checklistStations = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public static ChecklistRequestV1 CHECKLIST_CREATE_REQUEST_V1() {
);
}

public static ChecklistRequestV1 CHECKLIST_CREATE_REQUEST_V1_EMPTY_LOCATION() {
return new ChecklistRequestV1(
RoomFixture.ROOM_CREATE_REQUEST_EMPTY_LOCATION(),
List.of(Option.REFRIGERATOR.getId(), Option.SINK.getId(), Option.INDUCTION.getId(),
Option.SHOE_RACK.getId()),
List.of(QUESTION_1_CREATE_REQUEST(), QUESTION_2_CREATE_REQUEST(),
QUESTION_3_CREATE_REQUEST(), QUESTION_5_CREATE_REQUEST())
);
}

public static ChecklistRequest CHECKLIST_CREATE_REQUEST2() {
return new ChecklistRequest(
RoomFixture.ROOM_CREATE_REQUEST(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ void createChecklistV1() {
assertThat(checklistId).isGreaterThan(0);
}

@DisplayName("체크리스트 작성 v1 성공 : 위도, 경도가 null 인 경우")
@Test
void createChecklistV1_emptyLocation() {
//given
User user = userRepository.save(UserFixture.USER1());
ChecklistRequestV1 checklistRequestV1 = ChecklistFixture.CHECKLIST_CREATE_REQUEST_V1_EMPTY_LOCATION();

// when
long checklistId = checklistManageService.createChecklistV1(user, checklistRequestV1);

//then
assertThat(checklistId).isGreaterThan(0);
}

@DisplayName("작성된 체크리스트 조회 성공")
@Test
void readChecklist() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public static RoomRequest ROOM_CREATE_REQUEST() {
);
}

public static RoomRequest ROOM_CREATE_REQUEST_EMPTY_LOCATION() {
return new RoomRequest(
"방이름", "부산광역시 북구", "루터회관", "잠실",
10, 1000, 50, 5,
List.of(1, 3), FloorLevel.GROUND.getName(), 10,
Structure.TWO_ROOM.getName(), 3.3, null, null,
12, OccupancyMonth.APRIL.getMonth(),
OccupancyPeriod.EARLY.getPeriod(),
"방끗공인중개사", "메모", "한줄평"
);
}

public static RoomRequest ROOM_UPDATE_REQUEST() {
return new RoomRequest(
"방이름", "부산광역시 루터회관", "잠실역", "루터회관",
Expand Down
Binary file not shown.
6 changes: 5 additions & 1 deletion frontend/src/components/RoomCompare/CompareCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ interface Props {
const CompareCard = ({ room, openOptionModal, openCategoryModal }: Props) => {
return (
<S.Container>
<CompareCardItem height={7} label={'주소'} item={<S.Item>{room.address}</S.Item>} />
<CompareCardItem
height={7}
label={'주소'}
item={<S.Item>{room.address?.length ? room.address : EMPTY_INDICATOR}</S.Item>}
/>
<CompareCardItem label={'층수'} item={<S.Item>{room.floor ? `${room.floor}층` : EMPTY_INDICATOR}</S.Item>} />
<CompareCardItem
label={'보증금 / 월세'}
Expand Down
137 changes: 137 additions & 0 deletions frontend/src/components/RoomCompare/RoomCompareContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import styled from '@emotion/styled';
import { useSearchParams } from 'react-router-dom';

import RoomCompareMap from '@/components/_common/Map/RoomCompareMap';
import Marker from '@/components/_common/Marker/Marker';
import CategoryDetailModal from '@/components/RoomCompare/CategoryDetailModal';
import CompareCard from '@/components/RoomCompare/CompareCard';
import OptionDetailModal from '@/components/RoomCompare/OptionDetailModal';
import SkRoomCompare from '@/components/skeleton/RoomCompare/SkRoomCompare';
import { OPTIONS } from '@/constants/options';
import useGetCompareRoomsQuery from '@/hooks/query/useGetCompareRoomsQuery';
import useModal from '@/hooks/useModal';
import { OptionDetail } from '@/pages/RoomComparePage';
import { flexCenter, flexRow } from '@/styles/common';
import theme from '@/styles/theme';

const RoomCompareContent = () => {
const [searchParams, setSearchParams] = useSearchParams();
const { isModalOpen: isOptionModalOpen, openModal: openOptionModal, closeModal: closeOptionModal } = useModal();
const { isModalOpen: isCategoryModalOpen, openModal: openCategoryModal, closeModal: closeCategoryModal } = useModal();

const roomId1 = Number(searchParams.get('roomId1'));
const roomId2 = Number(searchParams.get('roomId2'));

const { data: rooms, isLoading } = useGetCompareRoomsQuery(roomId1, roomId2);

if (isLoading) return <SkRoomCompare />;

if (!rooms) throw new Error('데이터를 불러오는데 실패했습니다.');

const positions = rooms?.map(room => ({
latitude: room?.latitude ?? null,
longitude: room?.longitude ?? null,
}));

const formattedOptionDetail = () => {
const optionsState: OptionDetail[] = OPTIONS.map(option => ({
optionId: option.id,
optionName: option.displayName,
hasOption: [false, false],
}));

rooms?.forEach((room, index) => {
room.options.forEach(optionId => {
const targetOption = optionsState.find(option => option.optionId === optionId)!;
targetOption.hasOption[index] = true;
});
});
return optionsState;
};

const handleOpenCategoryDetailModal = (roomId: number, categoryId: number) => {
openCategoryModal();
searchParams.append('targetRoomId', String(roomId));
searchParams.append('categoryId', String(categoryId));
setSearchParams(searchParams);
};

const handleCloseategoryDetailModal = () => {
closeCategoryModal();
searchParams.delete('targetRoomId');
searchParams.delete('categoryId');
setSearchParams(searchParams);
};

return (
<>
<S.RoomGrid>
<S.TitleFlex>
<S.RoomTitle>
<S.Title key={rooms[0].checklistId}>{rooms[0].roomName}</S.Title>
<Marker isCircle={true} size={'medium'} backgroundColor={theme.palette.yellow500} text={'A'} />
</S.RoomTitle>
<S.RoomTitle>
<S.Title key={rooms[1].checklistId}>{rooms[1].roomName}</S.Title>
<Marker isCircle={true} size={'medium'} backgroundColor={theme.palette.green500} text={'B'} />
</S.RoomTitle>
</S.TitleFlex>
</S.RoomGrid>
{positions && <RoomCompareMap positions={positions} />}
<S.RoomGrid>
{rooms?.map((room, index) => (
<CompareCard
key={room.checklistId}
room={room}
index={index}
openOptionModal={openOptionModal}
openCategoryModal={handleOpenCategoryDetailModal}
/>
))}
</S.RoomGrid>
{/*방 옵션 비교 모달*/}
{isOptionModalOpen && (
<OptionDetailModal
optionCounts={[rooms[0].options.length, rooms[1].options.length]}
hasOptions={formattedOptionDetail()}
roomTitle1={rooms[0].roomName ?? ''}
roomTitle2={rooms[1].roomName ?? ''}
isOpen={isOptionModalOpen}
closeModal={closeOptionModal}
/>
)}
{/*방 카테고리 디테일 모달*/}
{isCategoryModalOpen && (
<CategoryDetailModal isOpen={isCategoryModalOpen} closeModal={handleCloseategoryDetailModal} />
)}
</>
);
};

export default RoomCompareContent;

const S = {
RoomGrid: styled.div`
${flexRow}
`,
TitleFlex: styled.div`
display: flex;
width: 100vw;
`,
RoomTitle: styled.div`
width: 50%;
margin-bottom: 0.5rem;
${flexCenter}
gap:0.8rem;
`,
Title: styled.span`
display: inline;
width: calc(100% - 3rem);
padding: 0.8rem 0;

font-weight: ${({ theme }) => theme.text.weight.bold};
font-size: 1.8rem;
text-align: center;
border-radius: 0.8rem;
`,
};
10 changes: 9 additions & 1 deletion frontend/src/components/_common/Map/RealTimeMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,15 @@ const RealTimeMap = ({
mapRef.current = map;

/*마커 생성*/
const marker = createMarker(kakao, map, new kakao.maps.LatLng(position.latitude, position.longitude), 'primary');
const marker = createMarker(
kakao,
map,
new kakao.maps.LatLng(
position.latitude ?? DEFAULT_POSITION.latitude,
position.longitude ?? DEFAULT_POSITION.longitude,
),
'primary',
);
markerRef.current = marker;

/*인포윈도우 생성*/
Expand Down
Loading
Loading