Skip to content

Commit

Permalink
Merge pull request #215 from FinalDoubleTen/FE-99--feat/Trips/Edit
Browse files Browse the repository at this point in the history
Feat: 여정 수정 및 삭제
  • Loading branch information
suehub authored Jan 21, 2024
2 parents 2743ba8 + 49a3501 commit 871fa7d
Show file tree
Hide file tree
Showing 65 changed files with 1,547 additions and 422 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-toggle-group": "^1.0.4",
"@stomp/stompjs": "^7.0.0",
"@svgr/rollup": "^8.1.0",
Expand Down
35 changes: 35 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/@types/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type subInfoRes = {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
startDate: string;
endDate: string;
numberOfPeople: number;
Expand All @@ -16,7 +16,7 @@ export type subItemRes = {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
visitDate: string;
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
tripItems: {
Expand Down Expand Up @@ -52,7 +52,7 @@ export type subPathRes = {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
visitDate: string;
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
paths: {
Expand All @@ -77,7 +77,7 @@ export type subMemberRes = {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
tripMembers: {
memberId: number;
name: string;
Expand All @@ -91,7 +91,7 @@ export type subBudgetRes = {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
budget: number;
calculatedPrice: number;
} | null;
Expand All @@ -103,6 +103,7 @@ export type SocketContextType = {
tripPath: subPathRes | null;
tripMember: subMemberRes | null;
tripBudget: subBudgetRes | null;
tripId: string;
callBackPub: (callback: () => void) => void;
};

Expand Down
12 changes: 6 additions & 6 deletions src/@types/socket.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type subInfoMessage = (message: {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
startDate: string;
endDate: string;
numberOfPeople: number;
Expand All @@ -16,7 +16,7 @@ type subItemMessage = (response: {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
visitDate: string;
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
tripItems: {
Expand All @@ -36,7 +36,7 @@ type subPathMessage = (response: {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
visitDate: string;
transportation: 'CAR' | 'PUBLIC_TRANSPORTATION';
paths: {
Expand All @@ -61,7 +61,7 @@ type subMemberMessage = (response: {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
tripMembers: {
memberId: number;
name: string;
Expand All @@ -76,7 +76,7 @@ type subBudgetMessage = (response: {
status: number;
message: string;
data: {
tripId: number;
tripId: string;
budget: number;
calculatedPrice: number;
};
Expand All @@ -98,7 +98,7 @@ interface pubAddTripItem {
}

interface pubUpdatePrice {
tripId: number;
tripId: string;
visitDate: string;
price: number;
}
Expand Down
15 changes: 15 additions & 0 deletions src/@types/tours.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ export interface TourType {
longitude?: string;
latitude?: string;
}

export interface LikedListType {
tripLikedItemId: number;
tourItemId: number;
contentTypeId: number;
title: string;
ratingAverage: number;
reviewCount: number;
smallThumbnailUrl: string;
tourAddress: string;
prefer: boolean;
notPrefer: boolean;
preferTotalCount: number;
notPreferTotalCount: number;
}
12 changes: 6 additions & 6 deletions src/@types/trips.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ interface TripRequest {
numberOfPeople: number;
startDate: string | null;
endDate: string | null;
area: string | null;
subarea: string | null;
area?: string | null;
subarea?: string | null;
}

interface MyTripType {
tripId: number;
tripId: string;
tripName: string;
startDate: string;
endDate: string;
Expand All @@ -35,18 +35,18 @@ interface ourTripType {
}

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

interface AuthorityType {
status: number;
message: string;
data: {
memberId: number;
tripAuthority: string;
TripId: number;
tripId: string;
};
}
3 changes: 0 additions & 3 deletions src/api/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ export const pubUpdateTripItem = (
destination: `/pub/trips/${tripId}/updateTripItemOrder`,
body: JSON.stringify(pubUpdateTripItem),
});

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

// 여행 날짜별 교통 수단 변경 이벤트 발생시 (01/16 업데이트)
Expand Down Expand Up @@ -136,7 +134,6 @@ export const pubDeleteItem = (
destination: `/pub/tripItems/${tripItemId}/deleteItem`,
body: JSON.stringify(pubDeleteItem),
});
console.log(pubDeleteItem);
};

// 멤버 여정 페이지로 입장 이벤트 발생시
Expand Down
55 changes: 45 additions & 10 deletions src/api/trips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,36 @@ import authClient from './authClient';
// 여정 관련 API

// 여정 상세조회
export const getTrips = async (tripId: number) => {
export const getTrips = async (tripId: string) => {
const res = await client.get(`trips/${tripId}`);
return res;
};

// 여정 기본정보 수정
export const putTrips = async (tripId: number, tripsData: TripRequest) => {
const res = await client.put(`trips/${tripId}`, tripsData);
export const putTrips = async (
tripId: string,
tripRequestData: TripRequest,
) => {
const res = await authClient.put(`trips/${tripId}`, tripRequestData);
return res;
};

// 여행 상세페이지에서 여정에 여행지 등록
export const postTripsItem = async (
tripId: string,
tourItemId: number,
visitDate: string,
) => {
const requestBody = {
tourItemId: tourItemId,
visitDate: visitDate,
};
const res = await authClient.post(`trips/${tripId}`, requestBody);
return res;
};

// 여정 탈퇴
export const deleteTrips = async (tripId: number) => {
export const deleteTrips = async (tripId: string) => {
try {
const res = await authClient.delete(`trips/${tripId}`);

Expand All @@ -34,7 +51,7 @@ export const postTrips = async (tripsData: TripRequest) => {

// 우리의 관심목록 조회
export const getTripsLike = async (
tripId: number,
tripId: string,
page: number,
size: number,
) => {
Expand All @@ -46,7 +63,7 @@ export const getTripsLike = async (
};

// 우리의 관심 목록 등록
export const postTripsLike = async (tripId: number, tourItemIds: number[]) => {
export const postTripsLike = async (tripId: string, tourItemIds: number[]) => {
const requestBody = {
tourItemIds: tourItemIds,
};
Expand All @@ -59,7 +76,7 @@ export const postTripsLike = async (tripId: number, tourItemIds: number[]) => {

// 우리의 관심 목록 좋아요/싫어요
export const postTripsLikeHate = async (
tripId: number,
tripId: string,
tourId: number,
prefer: boolean,
notPrefer: boolean,
Expand All @@ -71,17 +88,17 @@ export const postTripsLikeHate = async (
};

// 우리의 여행취향 조회
export const getTripsSurvey = async (tripId: number) => {
export const getTripsSurvey = async (tripId: string) => {
const res = await client.get(`trips/${tripId}/survey`);
return res;
};
// 우리의 여행취향 참여/미참여 회원 조회
export const getTripsSurveyMembers = async (tripId: number) => {
export const getTripsSurveyMembers = async (tripId: string) => {
const res = await client.get(`trips/${tripId}/survey/members`);
return res;
};
// 여정을 공유하고 있는 회원 조회
export const getTripsMembers = async (tripId: number) => {
export const getTripsMembers = async (tripId: string) => {
const res = await client.get(`trips/${tripId}/members`);
return res;
};
Expand All @@ -91,3 +108,21 @@ export const getTripsAuthority = async (tripId: string) => {
const res = await authClient.get(`trips/${tripId}/authority`);
return res;
};

// 나의 여정목록 조회
export const getMyTrips = async () => {
const res = await authClient.get(`trips`);
return res;
};

// 여정 참여 코드 조회
export const getTripsjoin = async (tripId: string) => {
const res = await authClient.get(`trips/${tripId}/join`);
return res;
};

// 여정 참여
export const postTripsjoin = async (tripId: string, joinCode: string) => {
const res = await authClient.post(`trips/${tripId}/join`, { joinCode });
return res;
};
10 changes: 8 additions & 2 deletions src/components/Auth/Login/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AuthRequest } from '@/@types/auth.types';
import { SubmitHandler, useForm } from 'react-hook-form';
import { postEmailLogin } from '@api/auth';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { AxiosError } from 'axios';
import { useState } from 'react';
import SubmitBtn from '@components/common/button/SubmitBtn';
Expand All @@ -26,6 +26,8 @@ const LoginForm = () => {
});

const navigate = useNavigate();
const { state } = useLocation();

// const [userInfo, setUserInfo] = useRecoilState(UserInfoState);

const onLoginSubmit: SubmitHandler<AuthRequest> = async (data) => {
Expand All @@ -38,7 +40,11 @@ const LoginForm = () => {
if (res.data.status === 200) {
setItem('accessToken', res.data.data.tokenInfo.accessToken);
// setUserInfo(res.data.data.memberDto);
navigate('/');
if (state) {
navigate(state.prevPath);
} else {
navigate('/');
}
}
} catch (err) {
if (err instanceof AxiosError) {
Expand Down
Loading

0 comments on commit 871fa7d

Please sign in to comment.