Skip to content

Commit

Permalink
Feat: 경로 시간 포맷 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
suehub committed Jan 24, 2024
1 parent 7ffcf4c commit 85116a7
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 85116a7

Please sign in to comment.