Skip to content

Commit

Permalink
Merge pull request #255 from FinalDoubleTen/dev
Browse files Browse the repository at this point in the history
경로 시간 포맷팅 추가
  • Loading branch information
suehub authored Jan 24, 2024
2 parents 3ae7747 + e3e520c commit b814429
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 b814429

Please sign in to comment.