Skip to content

Commit

Permalink
feat: modify addTour action
Browse files Browse the repository at this point in the history
  • Loading branch information
cjeongmin committed Sep 29, 2024
1 parent e31f89e commit 7e10446
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/components/travel/DetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export function DetailCard({
}) {
const [time, setTime] = useState<Times>(place.time ?? '오전');

console.log(time);

const { data: tourSpot } = useTourSpotData(
place.item.contentId,
place.item.contentTypeId,
Expand Down Expand Up @@ -222,7 +220,6 @@ const styles = {

placeImg: styled.img<NoImage>`
width: 100%;
object-fit: content;
flex: 1;
border-radius: 8px;
margin-top: 0.8rem;
Expand Down
22 changes: 21 additions & 1 deletion src/features/trip/trip.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,27 @@ export const useTripStore = create<TripState & TripAction>((set, get) => ({
})),

addTour: () =>
set((prev) => ({ ...prev, activities: [...prev.activities, []] })),
set((prev) => {
const { tourInfo, activities } = prev;
if (!tourInfo.startTime || !tourInfo.endTime) return prev;

const DAY = 60 * 60 * 24 * 1000;
const days =
Math.round(tourInfo.endTime.getTime() - tourInfo.startTime.getTime()) /
DAY;

return {
...prev,
tourInfo: {
...tourInfo,
endTime:
days >= activities.length
? new Date(tourInfo.endTime.getTime() + DAY)
: tourInfo.endTime,
},
activities: [...prev.activities, []],
};
}),

removeTour: (day) =>
set((prev) => ({
Expand Down

0 comments on commit 7e10446

Please sign in to comment.