New Intelligence tab on the Missions collection holds a threatAssessment.likelihoods array (category + 5-level likelihood select). Renders a color-coded, dossier-styled table on the mission details page, ordered after Mission Details and above the briefing. Rows match the free-text category to a lucide glyph (helicopter, plane, armor, infantry, etc.) so the estimate scans at a glance.
330 lines
8.9 KiB
TypeScript
330 lines
8.9 KiB
TypeScript
import {
|
|
BiohazardIcon,
|
|
BinocularsIcon,
|
|
CastleIcon,
|
|
FlameIcon,
|
|
HelicopterIcon,
|
|
PackageIcon,
|
|
PlaneIcon,
|
|
PlaneTakeoffIcon,
|
|
RadarIcon,
|
|
RadioIcon,
|
|
RocketIcon,
|
|
ShieldIcon,
|
|
ShipIcon,
|
|
TruckIcon,
|
|
UsersIcon,
|
|
type LucideIcon,
|
|
} from "lucide-react";
|
|
|
|
type Likelihood = "veryUnlikely" | "unlikely" | "possible" | "likely" | "veryLikely";
|
|
|
|
interface LikelihoodEntry {
|
|
category: string;
|
|
likelihood: Likelihood;
|
|
id?: string | null;
|
|
}
|
|
|
|
interface MissionThreatAssessmentProps {
|
|
likelihoods: LikelihoodEntry[] | null;
|
|
/** Optional mission id, used to derive the deterministic REF code in the strip. */
|
|
missionId?: number;
|
|
}
|
|
|
|
/**
|
|
* Tactical dossier readout of the analyst threat estimate. Higher likelihood of
|
|
* an enemy force type reads as more dangerous, so the ramp runs cool (slate) for
|
|
* "Very Unlikely" up to red for "Very Likely". The value is always spelled out,
|
|
* so color is reinforcement only, never the sole signal.
|
|
*/
|
|
const likelihoodStyles: Record<
|
|
Likelihood,
|
|
{ label: string; className: string; dot: string }
|
|
> = {
|
|
veryUnlikely: { label: "Very Unlikely", className: "text-slate-300", dot: "bg-slate-300" },
|
|
unlikely: { label: "Unlikely", className: "text-sky-400", dot: "bg-sky-400" },
|
|
possible: { label: "Possible", className: "text-amber-400", dot: "bg-amber-400" },
|
|
likely: { label: "Likely", className: "text-orange-400", dot: "bg-orange-400" },
|
|
veryLikely: { label: "Very Likely", className: "text-red-400", dot: "bg-red-400" },
|
|
};
|
|
|
|
/**
|
|
* Heuristic force-type glyph. Categories are free text, so we match on
|
|
* substrings in priority order (first hit wins): specific platforms before
|
|
* generic domains, and air-defense before the bare "defense" catch-all. Unknown
|
|
* categories simply render without an icon. Keywords are lowercase; matching is
|
|
* case-insensitive `includes`.
|
|
*/
|
|
const CATEGORY_ICON_RULES: { Icon: LucideIcon; keywords: string[] }[] = [
|
|
{ Icon: HelicopterIcon, keywords: ["heli", "rotary", "rotor", "chopper", "dustoff"] },
|
|
{
|
|
Icon: PlaneIcon,
|
|
keywords: [
|
|
"plane",
|
|
"jet",
|
|
"aircraft",
|
|
"fighter",
|
|
"bomber",
|
|
"fixed-wing",
|
|
"fixed wing",
|
|
"air wing",
|
|
"airwing",
|
|
"air support",
|
|
],
|
|
},
|
|
{ Icon: PlaneTakeoffIcon, keywords: ["drone", "uav", "quadcopter", "fpv", "mavic", "loitering"] },
|
|
{
|
|
Icon: ShieldIcon,
|
|
keywords: [
|
|
"air defense",
|
|
"air defence",
|
|
"airdefence",
|
|
"iads",
|
|
"anti-air",
|
|
"antiair",
|
|
"surface-to-air",
|
|
"sam site",
|
|
"patriot",
|
|
"tunguska",
|
|
"pantsir",
|
|
"shilka",
|
|
"tor-m2",
|
|
"tor m2",
|
|
],
|
|
},
|
|
{
|
|
Icon: RocketIcon,
|
|
keywords: [
|
|
"rocket",
|
|
"missile",
|
|
"artillery",
|
|
"arty",
|
|
"mortar",
|
|
"howitzer",
|
|
"mlrs",
|
|
"cannon",
|
|
"gun line",
|
|
"gunline",
|
|
"field gun",
|
|
],
|
|
},
|
|
{
|
|
Icon: ShipIcon,
|
|
keywords: [
|
|
"naval",
|
|
"navy",
|
|
"ship",
|
|
"boat",
|
|
"maritime",
|
|
"amphibious",
|
|
"harbor",
|
|
"harbour",
|
|
"riverine",
|
|
"lhd",
|
|
"srf",
|
|
],
|
|
},
|
|
{
|
|
Icon: TruckIcon,
|
|
keywords: [
|
|
"armor",
|
|
"armour",
|
|
"tank",
|
|
"afv",
|
|
"apc",
|
|
"ifv",
|
|
"mbt",
|
|
"mech",
|
|
"technical",
|
|
"gun truck",
|
|
"mrap",
|
|
],
|
|
},
|
|
{
|
|
Icon: UsersIcon,
|
|
keywords: [
|
|
"infantry",
|
|
"rifle",
|
|
"foot",
|
|
"dismount",
|
|
"soldier",
|
|
"troop",
|
|
"grunt",
|
|
"para",
|
|
"ranger",
|
|
"commando",
|
|
"squad",
|
|
"insurgent",
|
|
],
|
|
},
|
|
{
|
|
Icon: CastleIcon,
|
|
keywords: [
|
|
"static",
|
|
"fortif",
|
|
"bunker",
|
|
"defense",
|
|
"defence",
|
|
"outpost",
|
|
"emplacement",
|
|
"objective",
|
|
"obstacle",
|
|
"minefield",
|
|
"landmine",
|
|
"ied",
|
|
"ambush",
|
|
],
|
|
},
|
|
{
|
|
Icon: BinocularsIcon,
|
|
keywords: [
|
|
"recon",
|
|
"scout",
|
|
"surveil",
|
|
"observation",
|
|
"spotter",
|
|
"sniper",
|
|
"designator",
|
|
"jtac",
|
|
"marc",
|
|
],
|
|
},
|
|
{
|
|
Icon: RadarIcon,
|
|
keywords: ["radar", "sensor", "counter-battery", "counter battery", "sigint", "c4isr", "c4i"],
|
|
},
|
|
{
|
|
Icon: RadioIcon,
|
|
keywords: ["comms", "communication", "radio", "electronic", "jammer", "ecm", "signal", "network"],
|
|
},
|
|
{
|
|
Icon: PackageIcon,
|
|
keywords: [
|
|
"logistic",
|
|
"supply",
|
|
"resupply",
|
|
"convoy",
|
|
"fuel",
|
|
"ammo",
|
|
"ammunition",
|
|
"transport",
|
|
"cargo",
|
|
"truck",
|
|
],
|
|
},
|
|
{ Icon: FlameIcon, keywords: ["flame", "incendiary", "thermite", "phosphorus"] },
|
|
{
|
|
Icon: BiohazardIcon,
|
|
keywords: ["chemical", "biochem", "cbrn", "nbc", "radiolog", "toxic", "nerve agent", "mustard"],
|
|
},
|
|
];
|
|
|
|
function resolveCategoryIcon(category: string): LucideIcon | null {
|
|
const value = category.toLowerCase();
|
|
for (const rule of CATEGORY_ICON_RULES) {
|
|
if (rule.keywords.some((keyword) => value.includes(keyword))) {
|
|
return rule.Icon;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function MissionThreatAssessment({
|
|
likelihoods,
|
|
missionId,
|
|
}: MissionThreatAssessmentProps) {
|
|
if (!likelihoods || likelihoods.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
const refCode = missionId != null ? String(missionId).padStart(3, "0") : null;
|
|
|
|
return (
|
|
<section
|
|
aria-label="Threat Assessment"
|
|
className="relative overflow-hidden rounded-none border border-border/70 bg-card"
|
|
>
|
|
{/* Faint grid texture: constant opacity, never brightens. */}
|
|
<div
|
|
aria-hidden="true"
|
|
className="pointer-events-none absolute inset-0 z-[1] opacity-[0.04]"
|
|
style={{
|
|
backgroundImage:
|
|
"linear-gradient(to right, white 1px, transparent 1px), linear-gradient(to bottom, white 1px, transparent 1px)",
|
|
backgroundSize: "28px 28px",
|
|
}}
|
|
/>
|
|
|
|
{/* Corner brackets. */}
|
|
<div aria-hidden="true" className="pointer-events-none absolute inset-2 z-30">
|
|
<span className="absolute left-0 top-0 size-3 border-l border-t border-white/25" />
|
|
<span className="absolute right-0 top-0 size-3 border-r border-t border-white/25" />
|
|
<span className="absolute bottom-0 left-0 size-3 border-b border-l border-white/25" />
|
|
<span className="absolute bottom-0 right-0 size-3 border-b border-r border-white/25" />
|
|
</div>
|
|
|
|
{/* Classification strip. */}
|
|
<div
|
|
aria-hidden="true"
|
|
className="relative z-20 flex items-center justify-between border-b border-white/15 bg-black/50 px-5 py-1.5 backdrop-blur-sm"
|
|
>
|
|
<span className="flex items-center gap-1.5 font-mono text-[9px] uppercase tracking-widest text-white/60">
|
|
<RadarIcon className="size-3" />
|
|
Threat Assessment // Intel
|
|
</span>
|
|
{refCode && (
|
|
<span className="font-mono text-[9px] uppercase tracking-widest text-white/60">
|
|
REF {refCode}
|
|
</span>
|
|
)}
|
|
</div>
|
|
|
|
{/* Likelihood rows. */}
|
|
<table className="relative z-10 w-full border-collapse text-sm">
|
|
<caption className="sr-only">
|
|
Likelihood of encountering each enemy force type during this operation.
|
|
</caption>
|
|
<thead>
|
|
<tr className="border-b border-white/15">
|
|
<th
|
|
scope="col"
|
|
className="px-5 pb-2 pt-3 text-left font-mono text-[9px] font-medium uppercase tracking-widest text-white/40"
|
|
>
|
|
Force Type
|
|
</th>
|
|
<th
|
|
scope="col"
|
|
className="px-5 pb-2 pt-3 text-right font-mono text-[9px] font-medium uppercase tracking-widest text-white/40"
|
|
>
|
|
Likelihood
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody className="divide-y divide-white/10">
|
|
{likelihoods.map((entry, index) => {
|
|
const style = likelihoodStyles[entry.likelihood] ?? likelihoodStyles.possible;
|
|
const Icon = resolveCategoryIcon(entry.category);
|
|
return (
|
|
<tr key={entry.id ?? `${entry.category}-${index}`}>
|
|
<th scope="row" className="px-5 py-2.5 text-left align-middle">
|
|
<span className="flex items-center gap-2 font-mono text-xs font-medium uppercase tracking-wider text-white/70">
|
|
{Icon && <Icon aria-hidden="true" className="size-3.5 shrink-0 text-white/40" />}
|
|
<span>{entry.category}</span>
|
|
</span>
|
|
</th>
|
|
<td className="px-5 py-2.5 text-right align-middle">
|
|
<span
|
|
className={`inline-flex items-center justify-end gap-2 whitespace-nowrap font-mono text-xs font-semibold uppercase tracking-wider ${style.className}`}
|
|
>
|
|
<span aria-hidden="true" className={`size-1.5 shrink-0 ${style.dot}`} />
|
|
{style.label}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
);
|
|
}
|