-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] 예상 작업 완료 시간 관련 로직 수정 #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,7 @@ import { | |||||||||||||||||||||
| import { ActionButton } from "@/components/photoManage/ActionButton"; | ||||||||||||||||||||||
| import { RecipientInfoCard } from "@/components/photoManage/RecipientInfoCard"; | ||||||||||||||||||||||
| import { formatEstimatedTime, formatShippedDate } from "@/utils/dateFormat"; | ||||||||||||||||||||||
| import { getEarlyFinishedHours } from "@/utils/getEarlyFinishedHours"; | ||||||||||||||||||||||
| import { getEarlyFinishedTime } from "@/utils/getEarlyFinishedTime"; | ||||||||||||||||||||||
| import ProcessStepSubContent from "@/components/photoManage/ProcessStepSubContent"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| type BuildStepsArgs = { | ||||||||||||||||||||||
|
|
@@ -48,7 +48,7 @@ export function buildProcessSteps({ | |||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const earlyHours = workData.print | ||||||||||||||||||||||
| ? getEarlyFinishedHours( | ||||||||||||||||||||||
| ? getEarlyFinishedTime( | ||||||||||||||||||||||
| workData.print.estimatedAt, | ||||||||||||||||||||||
| workData.print.completedAt, | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
@@ -129,11 +129,14 @@ export function buildProcessSteps({ | |||||||||||||||||||||
| workData.print?.status === "COMPLETED" | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| const content = `작업 완료 시간: ${formatEstimatedTime(workData.print.completedAt)}`; | ||||||||||||||||||||||
| const subcontent = `예상 작업 시간보다 ${earlyHours}시간 빨리 완료되었어요!`; | ||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <ProcessStepSubContent | ||||||||||||||||||||||
| content={content} | ||||||||||||||||||||||
| subcontent={subcontent} | ||||||||||||||||||||||
| subcontent={ | ||||||||||||||||||||||
| earlyHours !== -1 | ||||||||||||||||||||||
| ? `예상 작업 시간보다 ${earlyHours} 빨리 완료되었어요!` | ||||||||||||||||||||||
| : undefined | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+135
to
+139
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 조건
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 완료 |
||||||||||||||||||||||
| icon={<ClockIcon className="h-3 w-3" />} | ||||||||||||||||||||||
| /> | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| export function getEarlyFinishedTime( | ||
| estimatedAt: string | null, | ||
| completedAt: string | null, | ||
| ): string { | ||
| if (!estimatedAt || !completedAt) return ""; | ||
|
|
||
| const estimated = new Date(estimatedAt).getTime(); | ||
| const completed = new Date(completedAt).getTime(); | ||
|
|
||
| const diffMs = estimated - completed; | ||
|
|
||
| // 일찍 끝나지 않았으면 | ||
| if (diffMs <= 0) return "-1"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const totalMinutes = Math.floor(diffMs / (1000 * 60)); | ||
|
|
||
| const minutesInHour = 60; | ||
| const minutesInDay = 60 * 24; | ||
|
|
||
| // 1시간 미만 → 분 | ||
| if (totalMinutes < minutesInHour) { | ||
| return `${totalMinutes}분`; | ||
| } | ||
|
|
||
| // 1일 미만 → 시간 | ||
| if (totalMinutes < minutesInDay) { | ||
| const hours = Math.floor(totalMinutes / minutesInHour); | ||
| return `${hours}시간`; | ||
| } | ||
|
|
||
| // 1일 이상 → 일 | ||
| const days = Math.floor(totalMinutes / minutesInDay); | ||
| return `${days}일`; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHOULD:함수명에 맞게 이것도 바꾸면 좋을 거 같아요!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
완료