mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 20:16:30 +00:00
f07990a3fb
Replace the legacy timeline status modal with a technical-status editor that supports multiple date intervals and descriptive notes. Update task views to use the new Update Technical Status action, normalize status-history parsing for array-based date records, and improve badge formatting for technical stages like SIT, UAT, PTR, Go-Live, and BAST.
59 lines
2.1 KiB
TypeScript
59 lines
2.1 KiB
TypeScript
import { Badge, STATUS_BADGE_MAP } from "@/components/ui/badge"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
function extractStatusString(status?: any): string {
|
|
if (!status) return "";
|
|
if (typeof status === "string") return status;
|
|
if (typeof status === "object") {
|
|
return status.name || status.status || status.title || "";
|
|
}
|
|
return String(status);
|
|
}
|
|
|
|
export function formatStatusText(status?: any): string {
|
|
const raw = extractStatusString(status);
|
|
const trimmed = raw.trim();
|
|
if (!trimmed) return "";
|
|
|
|
// Tetap UPPERCASE jika seluruh teks status hanya 3 huruf (SIT, UAT, PTR, dll) atau akronim BAST
|
|
const upperAcronyms = new Set([
|
|
"SIT", "UAT", "PTR", "BAST", "POC", "WIP", "WO", "IM",
|
|
"(SIT)", "(UAT)", "(PTR)", "(BAST)"
|
|
]);
|
|
if (trimmed.length === 3 || upperAcronyms.has(trimmed.toUpperCase())) {
|
|
return trimmed.toUpperCase();
|
|
}
|
|
|
|
// Capitalize setiap kata untuk teks status lainnya dengan memperhatikan akronim teknis
|
|
return trimmed
|
|
.split(/\s+/)
|
|
.map(word => {
|
|
if (!word) return "";
|
|
if (word.toUpperCase() === "GO-LIVE" || word.toLowerCase() === "go-live") return "Go-Live";
|
|
if (word === "&") return "&";
|
|
const stripped = word.replace(/[^a-zA-Z]/g, '').toUpperCase();
|
|
if (upperAcronyms.has(stripped) || upperAcronyms.has(word.toUpperCase())) {
|
|
return word.toUpperCase();
|
|
}
|
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
})
|
|
.join(" ");
|
|
}
|
|
|
|
export default function BadgeStatus({ status, className }: { status: any, className?: string }) { // e.g. status = "UAT"
|
|
const raw = extractStatusString(status);
|
|
const formatted = formatStatusText(raw);
|
|
if (!formatted) return null;
|
|
|
|
const lookupKey = raw.toLowerCase().trim();
|
|
|
|
return (
|
|
<Badge
|
|
variant={STATUS_BADGE_MAP[lookupKey] || "default"}
|
|
className={cn("text-[10px] font-semibold tracking-wide px-2 py-0.5", className)}
|
|
>
|
|
{formatted}
|
|
</Badge>
|
|
);
|
|
}
|