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

경비 수정 적용, 탭 컴포넌트 패딩 제거 #203

Merged
merged 23 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e1937df
feat: 추가, 엄지 아이콘 추가
NohWookJin Jan 18, 2024
ee88bcf
feat: 우리의 관심여행지 조회
NohWookJin Jan 18, 2024
468b1b8
style: truncate 적용
NohWookJin Jan 18, 2024
5083a61
feat: 추가버튼 클릭시 검색 라우터 이동
NohWookJin Jan 18, 2024
174f969
refactor: 디테일 탑버튼 수정
NohWookJin Jan 18, 2024
f3fe547
Merge pull request #196 from FinalDoubleTen/FE-77--feat/Trips
suehub Jan 18, 2024
e82075b
refactor: API 제목 추가 반영
NohWookJin Jan 18, 2024
a3a4eae
Merge branch 'dev' into FE-83--feat/myTrip
NohWookJin Jan 18, 2024
0f71e77
Update DetailTopButton.tsx
NohWookJin Jan 18, 2024
52920fb
Update LikedToursListItem.tsx
NohWookJin Jan 19, 2024
f8726af
Feat: 소켓통신 리팩토링
LeHiHo Jan 19, 2024
1917a2f
Design: 여행 계획 아이콘 수정
suehub Jan 19, 2024
6d7425a
Design: 편집 버튼 삭제
suehub Jan 19, 2024
e5e954b
Feat: 권한확인 커스텀훅 구현
LeHiHo Jan 19, 2024
f60ed7d
Merge pull request #201 from FinalDoubleTen/FE-94--feat/Trips/DragAnd…
LeHiHo Jan 19, 2024
170cca4
Merge branch 'dev' into FE-83--feat/myTrip
NohWookJin Jan 19, 2024
e0bcf73
Merge pull request #198 from FinalDoubleTen/FE-83--feat/myTrip
NohWookJin Jan 19, 2024
7235e9a
Feat: 경비 수정 소켓 연결
suehub Jan 19, 2024
2bafbe2
Design: Tab 조건부 css
suehub Jan 19, 2024
3e676d1
Merge branch dev of https://github.com/FinalDoubleTen/TenTenFE into F…
suehub Jan 19, 2024
b14d584
Design: Tab padding 제거
suehub Jan 19, 2024
b66f730
Design: 경비 말풍선 추가
suehub Jan 19, 2024
d4eceb9
Chore: 빌드 에러 수정
suehub Jan 19, 2024
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
2 changes: 1 addition & 1 deletion src/@types/socket.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,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
19 changes: 13 additions & 6 deletions src/api/trips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export const postTrips = async (tripsData: TripRequest) => {
// 우리의 관심목록 조회
export const getTripsLike = async (
tripId: number,
category: number,
page: number,
size: number,
) => {
const res = await client.get(
`trips/${tripId}/tripLikedTours?category=${category}&page=${page}$size=${size}`,
const res = await authClient.get(
`trips/${tripId}/tripLikedTours?page=${page}&size=${size}`,
);
return res;

return res.data;
};

// 우리의 관심 목록 등록
Expand All @@ -62,9 +62,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 @@ -84,3 +85,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: 0 additions & 2 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
50 changes: 27 additions & 23 deletions src/components/Plan/PlanItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,59 @@ import PlanItemBox from './PlanItemBox';
import PlanEditItemBox from './PlanEditItemBox';
import { useContext, useEffect, useState } from 'react';
import { socketContext } from '@hooks/useSocket';
import { useRecoilState } from 'recoil';
import { useRecoilState, useRecoilValue } from 'recoil';
import { visitDateState } from '@recoil/socket';
import { pubGetPathAndItems, pubUpdateTransportation } from '@api/socket';
import { tripIdState } from '@recoil/socket';
import { useRecoilValue } from 'recoil';
import { tapState } from '@recoil/plan';

type PlanItemProps = {
date: string;
day: string;
isMount: boolean;
};

const PlanItem: React.FC<PlanItemProps> = ({ date, day }) => {
const PlanItem: React.FC<PlanItemProps> = ({ date, day, isMount }) => {
const navigate = useNavigate();
const [isEdit, SetIsEdit] = useState(false);

const tripId = useRecoilValue(tripIdState);
const tap = useRecoilValue(tapState);

const [visitDate, setVisitDate] = useRecoilState(visitDateState);
const { tripItem, tripPath, callBackPub } = useContext(socketContext);
console.log(visitDate);

useEffect(() => {
setVisitDate({ visitDate: date });
}, [date]);

useEffect(() => {
if (visitDate && tripId) {
callBackPub(() => pubGetPathAndItems(visitDate, tripId));
if (isMount) {
setVisitDate({ visitDate: date });
if (date && tripId) {
callBackPub(() => pubGetPathAndItems({ visitDate: date }, tripId));
console.log('pubGetPathAndItems', tap);
}
}
}, [visitDate]);
}, [tap]);

// useEffect(() => {
// if (date && tripId) {
// callBackPub(() => pubGetPathAndItems({ visitDate: date }, tripId));
// }
// }, [tap]);

const handleEdit = () => {
SetIsEdit((prev) => !prev);
};

const handleTranspo = (
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION',
visitDate: string,
date: string,
tripId: string,
) => {
if (transportation !== transpo) {
callBackPub(() =>
pubUpdateTransportation(
{
visitDate: visitDate,
visitDate: date,
transportation: transportation,
},
tripId,
Expand All @@ -59,6 +69,7 @@ const PlanItem: React.FC<PlanItemProps> = ({ date, day }) => {

const transpo = tripItem?.data?.transportation || '';

// console.log(tripItem?.data?.tripItems.sort((a, b) => a.seqNum - b.seqNum));
return (
<>
{tripPath && <TripMap paths={tripPath.data?.paths || []} />}
Expand All @@ -67,11 +78,9 @@ const PlanItem: React.FC<PlanItemProps> = ({ date, day }) => {
{isEdit ? (
<div />
) : (
<div className="flex items-center justify-center">
<div className="flex items-center justify-center">
<div
onClick={() =>
handleTranspo('CAR', visitDate?.visitDate || '', tripId || '')
}
onClick={() => handleTranspo('CAR', date || '', tripId || '')}
className="flex h-[32px] w-[32px] cursor-pointer items-center justify-center rounded-l-md border border-solid border-gray3">
<CarIcon
size={19}
Expand All @@ -80,11 +89,7 @@ const PlanItem: React.FC<PlanItemProps> = ({ date, day }) => {
</div>
<div
onClick={() =>
handleTranspo(
'PUBLIC_TRANSPORTATION',
visitDate?.visitDate || '',
tripId || '',
)
handleTranspo('PUBLIC_TRANSPORTATION', date || '', tripId || '')
}
className="pointer-cursor -ml-[1px] flex h-[32px] w-[32px] cursor-pointer items-center justify-center rounded-r-md border border-solid border-gray3">
<BusIcon
Expand All @@ -96,7 +101,6 @@ const PlanItem: React.FC<PlanItemProps> = ({ date, day }) => {
</div>
</div>
)}

<button
type="button"
onClick={handleEdit}
Expand All @@ -110,7 +114,7 @@ const PlanItem: React.FC<PlanItemProps> = ({ date, day }) => {
<PlanEditItemBox
item={tripItem?.data?.tripItems || []}
day={day}
visitDate={visitDate?.visitDate || ''}
visitDate={date || ''}
tripId={tripId || ''}
/>
) : (
Expand Down
3 changes: 2 additions & 1 deletion src/components/Plan/PlanMoveItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useContext } from 'react';
import { socketContext } from '@hooks/useSocket';
import { useState, useEffect } from 'react';
import ToastPopUp from '@components/common/toastpopup/ToastPopUp';
import { v4 as uuidv4 } from 'uuid';

interface PlanMoveItemProps {
isCheck: number | null;
Expand Down Expand Up @@ -96,7 +97,7 @@ const PlanMoveItem: React.FC<PlanMoveItemProps> = ({
{day.map((day, index) => (
<Dialog.Close asChild>
<button
key={index}
key={uuidv4()}
onClick={() => handleMoveItem(date[index])}
className="relative flex flex-shrink-0 flex-grow-0 justify-start gap-2">
<PaperIcon />
Expand Down
Loading