refactor: Simplify getStepIndex and getStatusCategory logic for clarity

This commit is contained in:
barsa 2026-01-19 17:11:55 +09:00
parent dd8259e06f
commit f3b41ca6f4
2 changed files with 7 additions and 13 deletions

View File

@ -53,7 +53,7 @@ function getStepIndex(state: OrderStatusState, serviceCategory: OrderServiceCate
case "active": case "active":
return steps.length - 1; // Always the last step return steps.length - 1; // Always the last step
case "review": case "review":
return serviceCategory === "internet" ? 1 : 1; // "Under Review" for internet return 1; // "Under Review" step is always index 1
case "scheduled": case "scheduled":
return serviceCategory === "internet" ? 2 : 1; return serviceCategory === "internet" ? 2 : 1;
case "activating": case "activating":
@ -122,9 +122,9 @@ export function OrderProgressTimeline({
{!isLast && ( {!isLast && (
<div <div
className={cn( className={cn(
"absolute top-4 left-1/2 w-full h-0.5 -translate-y-1/2", "absolute top-4 w-full -translate-y-1/2",
index < currentStepIndex && "bg-success", index < currentStepIndex && "h-0.5 bg-success",
index === currentStepIndex && "bg-gradient-to-r from-primary to-muted", index === currentStepIndex && "h-0.5 bg-gradient-to-r from-primary to-muted",
index > currentStepIndex && index > currentStepIndex &&
"border-t-2 border-dashed border-muted-foreground/30" "border-t-2 border-dashed border-muted-foreground/30"
)} )}

View File

@ -60,15 +60,9 @@ function getStatusCategory(
return "cancelled"; return "cancelled";
} }
// Processing: Everything else in progress // Processing: Scheduled, Activating, or any other in-progress state
if ( // Note: status === "Activated" without activationStatus === "Activated" means
activationStatus === "Scheduled" || // the order is approved but service activation isn't complete yet
activationStatus === "Activating" ||
status === "Activated"
) {
return "processing";
}
return "processing"; return "processing";
} }