Skip to content

Commit

Permalink
Chore: 병합오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
joanShim committed Jan 20, 2024
2 parents 7fea8c0 + f9909aa commit c6d6535
Show file tree
Hide file tree
Showing 41 changed files with 1,054 additions and 259 deletions.
6 changes: 1 addition & 5 deletions src/@types/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,11 @@ export type subMemberRes = {
message: string;
data: {
tripId: number;
connectedMembers: {
memberId: number;
name: string;
thumbnailUrl: string;
}[];
tripMembers: {
memberId: number;
name: string;
thumbnailUrl: string;
connected: boolean;
}[];
numberOfPeople: number;
} | null;
Expand Down
8 changes: 2 additions & 6 deletions src/@types/socket.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,11 @@ type subMemberMessage = (response: {
message: string;
data: {
tripId: number;
connectedMembers: {
memberId: number;
name: string;
thumbnailUrl: string;
}[];
tripMembers: {
memberId: number;
name: string;
thumbnailUrl: string;
connected: boolean;
}[];
numberOfPeople: number;
};
Expand Down Expand Up @@ -132,7 +128,7 @@ interface pubDeleteItem {
}

interface pubMember {
memberId: number;
token: string;
}

interface pubGetPathAndItems {
Expand Down
32 changes: 32 additions & 0 deletions src/@types/trips.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,35 @@ interface MyTripType {
area: string;
subArea: string;
}

interface ourTripType {
tripLikedItemId: number;
tourItemId: number;
contentTypeId: number;
ratingAverage: number;
reviewCount: number;
smallThumbnailUrl: string;
tourAddress: string;
prefer: boolean;
notPrefer: boolean;
preferTotalCount: number;
notPreferTotalCount: number;
title: string;
}

interface ThumbsProps {
tripId: number;
tourId: number;
prefer: boolean;
notPrefer: boolean;
}

interface AuthorityType {
status: number;
message: string;
data: {
memberId: number;
tripAuthority: string;
TripId: number;
};
}
6 changes: 2 additions & 4 deletions src/api/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export const pubUpdateTripItem = (
body: JSON.stringify(pubUpdateTripItem),
});

console.log(pubUpdateTripItem);
console.log('펍실행');
console.log('데이터', pubUpdateTripItem);
};

// 여행 날짜별 교통 수단 변경 이벤트 발생시 (01/16 업데이트)
Expand Down Expand Up @@ -157,10 +156,9 @@ export const pubDisconnectMember = (pubMember: pubMember, tripId: string) => {
};

// 여정 편집 페이지 입장 이벤트 발생시(모든 sub 다받음)
export const pubEnterMember = (pubMember: pubMember, tripId: string) => {
export const pubEnterMember = (tripId: string) => {
socketClient.publish({
destination: `/pub/trips/${tripId}/enterMember`,
body: JSON.stringify(pubMember),
});
};

Expand Down
37 changes: 17 additions & 20 deletions src/api/trips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,15 @@ export const postTrips = async (tripsData: TripRequest) => {
};

// 우리의 관심목록 조회
export const getTripsLike = async (options: {
tripId: number;
category?: string;
page?: number;
size?: number;
}) => {
const { tripId, category, page = 0, size } = options;

let query = `trips/${tripId}/tripLikedTours?`;

if (category) {
query += `&category=${category}`;
}
query += `&page=${page}`;
export const getTripsLike = async (
tripId: number,
page: number,
size: number,
) => {
const res = await authClient.get(
`trips/${tripId}/tripLikedTours?page=${page}&size=${size}`,
);

if (size) {
query += `&size=${size}`;
}
const res = await authClient.get(query);
return res.data;
};

Expand All @@ -80,9 +70,10 @@ export const postTripsLikeHate = async (
tripId: number,
tourId: number,
prefer: boolean,
notPrefer: boolean,
) => {
const res = await client.post(
`trips/${tripId}/tripLikedTours/${tourId}?prefer=${prefer}`,
const res = await authClient.post(
`trips/${tripId}/tripLikedTours/${tourId}?prefer=${prefer}&notPrefer=${notPrefer}`,
);
return res;
};
Expand All @@ -102,3 +93,9 @@ export const getTripsMembers = async (tripId: number) => {
const res = await client.get(`trips/${tripId}/members`);
return res;
};

// 편집권한 조회
export const getTripsAuthority = async (tripId: string) => {
const res = await authClient.get(`trips/${tripId}/authority`);
return res;
};
64 changes: 25 additions & 39 deletions src/components/DetailSectionTop/DetailTopButton.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
import { useEffect, useRef, useState } from 'react';
import { useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { reviewCountState } from '@recoil/review';
import { TopIcon } from '@components/common/icons/Icons';

export default function DetailTopButton({ parentRef }: any) {
const [isVisible, setIsVisible] = useState<boolean>(false);
const [scrollPosition, setScrollPosition] = useState<number>(0);
const [viewportHeight, setViewportHeight] = useState<number>(0);

const scrollButtonRef = useRef<HTMLDivElement>(null);
export default function DetailTopButton() {
const [visible, setVisible] = useState<boolean>(false);
const getReviewCount = useRecoilValue(reviewCountState);

useEffect(() => {
const handleScroll = () => {
if (scrollButtonRef.current && parentRef.current) {
setViewportHeight(screen.height);

// 부모 요소의 높이보다 적을 때까지 스크롤 허용
if (window.scrollY < parentRef.current.clientHeight - 50) {
// 기기 높이의 절반 이상 스크롤 했을 때
if (window.scrollY >= viewportHeight / 2) {
setIsVisible(true);
setScrollPosition(window.scrollY);
} else {
setIsVisible(false);
}
}
}
};

window.addEventListener('scroll', handleScroll);

return () => {
window.removeEventListener('scroll', handleScroll);
};
}, [parentRef, scrollPosition, setScrollPosition]);

const scrollToTop = () => {
if (getReviewCount > 2) {
setVisible(true);
} else {
setVisible(false);
}
}, [getReviewCount]);

const scrollToTop = (e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
window.scrollTo({ top: 0, behavior: 'smooth' });
};

if (!visible) {
return null;
}

return (
<div
ref={scrollButtonRef}
className={`absolute right-2 flex h-12 w-12 cursor-pointer items-center justify-center rounded-full bg-white shadow-md transition-opacity duration-500 ${
isVisible ? 'opacity-100' : 'opacity-0'
}`}
onClick={scrollToTop}
style={{ top: `${scrollPosition}px` }}>
<TopIcon />
className="sticky bottom-5
mt-[-50px] flex h-12 w-12 cursor-pointer items-center justify-center rounded-full bg-white shadow-md"
style={{ left: 'calc(100%)' }}>
<button onClick={scrollToTop}>
<TopIcon />
</button>
</div>
);
}
5 changes: 5 additions & 0 deletions src/components/DetailSectionTop/DetailToursRating.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-scroll';
import { useSetRecoilState } from 'recoil';
import { reviewCountState } from '@recoil/review';

interface ReviewData {
ratingAverage: number;
reviewTotalCount: number;
Expand All @@ -13,6 +16,7 @@ export default function DetailToursRating({
reviewData,
}: DetailToursRatingProps) {
const { reviewTotalCount, ratingAverage } = reviewData;
const setReviewCount = useSetRecoilState(reviewCountState);

const STAR_IDX_ARR = ['1', '2', '3', '4', '5'];
const [ratedStarArr, setRatedStarArr] = useState([0, 0, 0, 0, 0]);
Expand All @@ -32,6 +36,7 @@ export default function DetailToursRating({

useEffect(() => {
setRatedStarArr(calculateRates(ratingAverage));
setReviewCount(reviewTotalCount);
}, []);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/MyTrip/MyTripItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MyTripItem: React.FC<MyTripItemProps> = ({ myTripList }) => {
<div className="flex min-h-[72px]">
<div>
<img
className="rounded-1 h-[72px] min-h-[72px] w-[72px] rounded-[16px] object-cover"
className="rounded-1 h-[72px] min-h-[72px] min-w-[72px] rounded-[16px] object-cover"
src={tripThumbnailUrl}
alt="여행지 이미지"
/>
Expand Down
8 changes: 3 additions & 5 deletions src/components/Plan/PlanEditItemBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ const PlanEditItemBox = ({
visitDate: visitDate,
tripItemOrder,
});

console.log(newData);
};

useEffect(() => {
Expand Down Expand Up @@ -108,7 +106,7 @@ const PlanEditItemBox = ({
<Droppable droppableId="droppableId">
{(provided) => (
<div {...provided.droppableProps} ref={provided.innerRef}>
<div className="text-left text-sm font-semibold ">{day}</div>
<div className="text-left text-sm font-semibold">{day}</div>
{items.map((item, index) => (
<Draggable
key={item.tripItemId.toString()}
Expand Down Expand Up @@ -162,8 +160,8 @@ const PlanEditItemBox = ({
)}
</Droppable>
</DragDropContext>
<div className="flex w-full justify-center">
<div className="flex h-14">
<div className="justify-cente fixed bottom-0 left-0 right-0 z-10 flex">
<div className="mx-auto flex h-14 max-w-md">
<Alert
title={'여행지 삭제'}
message={<>선택한 장소를 삭제하시겠습니까?</>}
Expand Down
Loading

0 comments on commit c6d6535

Please sign in to comment.