diff --git a/src/@types/socket.types.ts b/src/@types/socket.types.ts index 3634d2c4..fc46aa4d 100644 --- a/src/@types/socket.types.ts +++ b/src/@types/socket.types.ts @@ -1,46 +1,3 @@ -interface pubInfo { - startDate: string; - endDate: string; - numberOfPeople: number; - tripName: string; - tripStatus: 'BEFORE' | 'DURING' | 'AFTER'; - area: string; - subarea: string; - budget: number; -} - -interface pubAddTripItem { - visitDate: string; - newTripItems: { - tourItemId: number; - }[]; -} - -interface pubUpdateTripItem { - visitDate: string; - tripItemOrder: { - tripItemId: number; - seqNum: number; - }[]; -} - -interface pubVisitDate { - // visitDate: '2024-01-07', - visitDate: string; -} - -interface pubUpdatePrice { - price: number; -} - -interface pubUpdateTransportation { - transportation: 'CAR' | 'PUBLIC_TRANSPORTATION'; -} - -interface pubMember { - memberId: number; -} - type subInfoMessage = (message: { status: number; message: string; @@ -84,13 +41,15 @@ type subPathMessage = (response: { tripId: number; visitDate: string; paths: { + fromTripItemId: number; + toTripItemId: number; fromSeqNum: number; toSeqNum: number; fromLongitude: string; fromLatitude: string; toLongitude: string; toLatitude: string; - transportation: string; + transportation: 'CAR' | 'PUBLIC_TRANSPORTATION'; pathInfo: { price: number; totalDistance: number; @@ -128,3 +87,63 @@ type subBudgetMessage = (response: { calculatedPrice: number; }; }) => void; + +interface pubInfo { + startDate: string; + endDate: string; + numberOfPeople: number; + tripName: string; + area: string; + subarea: string; + budget: number; +} + +interface pubAddTripItem { + visitDate: string; + newTripItems: { + tourItemId: number; + }[]; +} + +interface pubUpdatePrice { + tripId: number; + visitDate: string; + price: number; +} + +interface pubUpdateTripItem { + visitDate: string; + tripItemOrder: { + tripItemId: number; + seqNum: number; + }[]; +} + +interface pubUpdateTransportation { + tripId: number; + visitDate: string; + transportation: 'CAR' | 'PUBLIC_TRANSPORTATION'; +} + +interface pubVisitDate { + tripId: number; + oldVisitDate: string; + newVisitDate: string; +} + +interface pubDeleteItem { + tripId: number; + visitDate: string; +} + +interface pubMember { + memberId: number; +} + +interface pubGetPathAndItems { + visitDate: string; +} + +interface pubUpdateBudget { + budget: number; +} diff --git a/src/api/socket.ts b/src/api/socket.ts index b24503c0..bbc41c97 100644 --- a/src/api/socket.ts +++ b/src/api/socket.ts @@ -124,9 +124,13 @@ export const pubUpdateVisitDate = ( }; // 여행 아이템 삭제 이벤트 발생시 -export const pubDeleteItem = (tripItemId: number) => { +export const pubDeleteItem = ( + pubDeleteItem: pubDeleteItem, + tripItemId: number, +) => { socketClient.publish({ destination: `/pub/tripItems/${tripItemId}/deleteItem`, + body: JSON.stringify(pubDeleteItem), }); }; @@ -156,7 +160,7 @@ export const pubEnterMember = (pubMember: pubMember, tripId: string) => { // 날짜별 여행 아이템 & 경로 조회 export const pubGetPathAndItems = ( - pubGetPathAndItems: pubVisitDate, + pubGetPathAndItems: pubGetPathAndItems, tripId: string, ) => { socketClient.publish({ @@ -164,3 +168,21 @@ export const pubGetPathAndItems = ( body: JSON.stringify(pubGetPathAndItems), }); }; + +// 접속중인 멤버 정보 조회 +export const pubGetConnectedMember = (tripId: string) => { + socketClient.publish({ + destination: `/pub/trips/${tripId}/getConnectedMember`, + }); +}; + +// 목표 경비(예산) 변경시 +export const pubUpdateBudget = ( + pubUpdateBudget: pubUpdateBudget, + tripId: string, +) => { + socketClient.publish({ + destination: `/pub/trips/${tripId}/updateBudget`, + body: JSON.stringify(pubUpdateBudget), + }); +}; diff --git a/src/recoil/socket.ts b/src/recoil/socket.ts index d722c733..89cd5b90 100644 --- a/src/recoil/socket.ts +++ b/src/recoil/socket.ts @@ -7,7 +7,7 @@ export const tripIdState = atom({ export const visitDateState = atom<{ visitDate: string } | null>({ key: 'visitDateState', - default: { visitDate: '2024-01-03' }, + default: { visitDate: '2024-01-05' }, }); export const memberIdState = atom<{ memberId: number } | null>({