mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 16:36:29 +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.
107 lines
4.1 KiB
TypeScript
107 lines
4.1 KiB
TypeScript
import * as React from "react"
|
|
import { Slot } from "@radix-ui/react-slot"
|
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
export const STATUS_LIST = [
|
|
"Not Started", "On Progress", "On Going", "Halted", "Issue",
|
|
"SIT", "UAT", "PTR", "BAST", "Warranty", "End Of Support",
|
|
"Canceled", "Active"
|
|
] as const;
|
|
|
|
const badgeVariants = cva(
|
|
"inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default:
|
|
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
secondary:
|
|
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
destructive:
|
|
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
outline:
|
|
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
his: "border-orange-500 dark:border-orange-500 text-orange-500 dark:text-orange-500 hover:opacity-80",
|
|
warn: "border-transparent bg-yellow-500 text-zinc-50 dark:bg-yellow-500 dark:text-yellow-50 hover:opacity-80",
|
|
info: "border-transparent bg-cyan-500 text-zinc-50 dark:bg-cyan-500 dark:text-cyan-50 hover:opacity-80",
|
|
violet: "border-transparent bg-violet-500 text-zinc-50 dark:bg-violet-500 dark:text-violet-50 hover:opacity-80",
|
|
|
|
// --- CUSTOM STATUS VARIANTS ---
|
|
statusNotStarted: "border-transparent bg-slate-500 text-zinc-50 hover:opacity-80", // Gray
|
|
statusActive: "border-transparent bg-teal-500 text-zinc-50 hover:opacity-80", // Blue
|
|
statusWarning: "border-transparent bg-amber-500 text-zinc-50 hover:opacity-80", // Yellow/Orange
|
|
statusDanger: "border-transparent bg-red-500 text-zinc-50 hover:opacity-80", // Red
|
|
statusTesting: "border-transparent bg-indigo-500 text-zinc-50 hover:opacity-80", // Indigo/Purple
|
|
statusSuccess: "border-transparent bg-emerald-500 text-zinc-50 hover:opacity-80", // Green
|
|
statusMaintenance: "border-transparent bg-blue-500 text-zinc-50 hover:opacity-80", // Teal
|
|
statusEnded: "border-transparent bg-stone-500 text-zinc-50 hover:opacity-80", // Dark Gray/Brown
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: "default",
|
|
},
|
|
}
|
|
)
|
|
|
|
export const STATUS_BADGE_MAP: Record<string, VariantProps<typeof badgeVariants>["variant"]> = {
|
|
"not started": "statusNotStarted",
|
|
|
|
"on progress": "statusActive",
|
|
"on going": "statusActive",
|
|
"active": "statusActive",
|
|
|
|
"halted": "statusWarning",
|
|
|
|
"issue": "statusDanger",
|
|
"canceled": "statusDanger",
|
|
|
|
// Technical progression stages
|
|
"development": "info",
|
|
|
|
"sit": "statusTesting",
|
|
"system integration testing (sit)": "statusTesting",
|
|
"system integration testing": "statusTesting",
|
|
|
|
"uat": "violet",
|
|
"user acceptance testing (uat)": "violet",
|
|
"user acceptance testing": "violet",
|
|
|
|
"ptr": "statusWarning",
|
|
"production trial run (ptr)": "statusWarning",
|
|
"production trial run": "statusWarning",
|
|
|
|
"go-live": "statusSuccess",
|
|
"go live": "statusSuccess",
|
|
"golive": "statusSuccess",
|
|
|
|
"bast": "statusActive",
|
|
"project handover & bast": "statusActive",
|
|
"project handover and bast": "statusActive",
|
|
|
|
"warranty": "statusMaintenance",
|
|
|
|
"end of support": "statusEnded",
|
|
}
|
|
|
|
function Badge({
|
|
className,
|
|
variant,
|
|
asChild = false,
|
|
...props
|
|
}: React.ComponentProps<"span"> &
|
|
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
const Comp = asChild ? Slot : "span"
|
|
|
|
return (
|
|
<Comp
|
|
data-slot="badge"
|
|
className={cn(badgeVariants({ variant }), className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export { Badge, badgeVariants }
|