Skip to content

Commit

Permalink
Merge pull request #254 from FinalDoubleTen/TripsQA/Design
Browse files Browse the repository at this point in the history
경로 시간 포맷팅 추가
  • Loading branch information
suehub authored Jan 24, 2024
2 parents 7ffcf4c + 85116a7 commit e3e520c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/Plan/PlanItemBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ const PlanItemBox = ({
}
};

const formatTime = (totalMinutes: number) => {
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes % 60;
if (hours === 0) {
return `${minutes}분`;
}
return `${hours}시간 ${minutes}분`;
};

return (
<>
<div>
Expand Down Expand Up @@ -147,9 +156,9 @@ const PlanItemBox = ({
? '경로 정보가 없습니다.'
: `${(path.pathInfo.totalDistance / 1000).toFixed(
2,
)}km, ${
path.pathInfo.totalTime
}, ${path.pathInfo.price.toLocaleString()}원`}
)}km, ${formatTime(
path.pathInfo.totalTime,
)}, ${path.pathInfo.price.toLocaleString()}원`}
</div>
</div>
</div>
Expand Down

0 comments on commit e3e520c

Please sign in to comment.