1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
import { useState, useMemo } from "react";
import type { Order, OrderStatus, OrderPriority, OrderType } from "../../lib/api";
const STATUS_BADGE: Record<OrderStatus, { color: string; label: string }> = {
open: { color: "text-[#75aafc] border-[rgba(117,170,252,0.4)]", label: "OPEN" },
in_progress: { color: "text-yellow-400 border-yellow-800", label: "IN PROGRESS" },
under_review: { color: "text-purple-400 border-purple-800", label: "REVIEW" },
done: { color: "text-emerald-400 border-emerald-800", label: "DONE" },
archived: { color: "text-[#556677] border-[#2a3a5a]", label: "ARCHIVED" },
};
const PRIORITY_COLOR: Record<OrderPriority, string> = {
critical: "bg-red-400",
high: "bg-orange-400",
medium: "bg-yellow-400",
low: "bg-[#75aafc]",
none: "bg-[#556677]",
};
const TYPE_BADGE: Record<OrderType, { color: string; label: string }> = {
feature: { color: "text-[#75aafc] border-[rgba(117,170,252,0.3)]", label: "FEAT" },
bug: { color: "text-red-400 border-red-800", label: "BUG" },
spike: { color: "text-yellow-400 border-yellow-800", label: "SPIKE" },
chore: { color: "text-[#7788aa] border-[#2a3a5a]", label: "CHORE" },
improvement: { color: "text-emerald-400 border-emerald-800", label: "IMPROVE" },
};
interface OrderListProps {
orders: Order[];
selectedId: string | null;
onSelect: (id: string) => void;
onCreate: () => void;
statusFilter: OrderStatus | undefined;
onStatusFilter: (s: OrderStatus | undefined) => void;
typeFilter: OrderType | undefined;
onTypeFilter: (t: OrderType | undefined) => void;
}
const STATUS_OPTIONS: (OrderStatus | "all")[] = ["all", "open", "in_progress", "under_review", "done", "archived"];
const TYPE_OPTIONS: (OrderType | "all")[] = ["all", "feature", "bug", "spike", "chore", "improvement"];
export function OrderList({
orders,
selectedId,
onSelect,
onCreate,
statusFilter,
onStatusFilter,
typeFilter,
onTypeFilter,
}: OrderListProps) {
const [search, setSearch] = useState("");
const filtered = useMemo(() => {
if (!search.trim()) return orders;
const q = search.toLowerCase();
return orders.filter(
(o) =>
o.title.toLowerCase().includes(q) ||
(o.description && o.description.toLowerCase().includes(q)) ||
o.labels.some((l) => l.toLowerCase().includes(q)) ||
(o.directiveName && o.directiveName.toLowerCase().includes(q)),
);
}, [orders, search]);
return (
<div className="flex flex-col h-full">
{/* Header */}
<div className="flex items-center justify-between px-3 py-2 border-b border-dashed border-[rgba(117,170,252,0.2)]">
<span className="text-[11px] font-mono text-[#9bc3ff] uppercase tracking-wide">
Orders
</span>
<button
type="button"
onClick={onCreate}
className="text-[11px] font-mono text-[#75aafc] hover:text-white bg-transparent border border-[rgba(117,170,252,0.3)] rounded px-2 py-0.5 hover:border-[rgba(117,170,252,0.6)] transition-colors"
>
+ New
</button>
</div>
{/* Search */}
<div className="px-3 py-1.5 border-b border-[rgba(117,170,252,0.1)]">
<input
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search orders..."
className="w-full bg-transparent border-none outline-none text-[11px] font-mono text-white placeholder:text-[#556677]"
/>
</div>
{/* Filters */}
<div className="px-3 py-1.5 border-b border-[rgba(117,170,252,0.1)] flex flex-col gap-1">
<div className="flex items-center gap-1 flex-wrap">
<span className="text-[9px] font-mono text-[#556677] uppercase w-[38px] shrink-0">
Status
</span>
{STATUS_OPTIONS.map((s) => (
<button
key={s}
type="button"
onClick={() => onStatusFilter(s === "all" ? undefined : s)}
className={`text-[9px] font-mono px-1.5 py-0.5 rounded transition-colors ${
(s === "all" && !statusFilter) || s === statusFilter
? "text-white bg-[rgba(117,170,252,0.15)] border border-[rgba(117,170,252,0.4)]"
: "text-[#556677] hover:text-[#7788aa] border border-transparent"
}`}
>
{s === "all" ? "ALL" : s === "in_progress" ? "WIP" : s === "under_review" ? "REVIEW" : s.toUpperCase()}
</button>
))}
</div>
<div className="flex items-center gap-1 flex-wrap">
<span className="text-[9px] font-mono text-[#556677] uppercase w-[38px] shrink-0">
Type
</span>
{TYPE_OPTIONS.map((t) => (
<button
key={t}
type="button"
onClick={() => onTypeFilter(t === "all" ? undefined : t)}
className={`text-[9px] font-mono px-1.5 py-0.5 rounded transition-colors ${
(t === "all" && !typeFilter) || t === typeFilter
? "text-white bg-[rgba(117,170,252,0.15)] border border-[rgba(117,170,252,0.4)]"
: "text-[#556677] hover:text-[#7788aa] border border-transparent"
}`}
>
{t === "all" ? "ALL" : t.toUpperCase()}
</button>
))}
</div>
</div>
{/* List */}
<div className="flex-1 overflow-y-auto">
{filtered.length === 0 ? (
<div className="px-3 py-6 text-center text-[#556677] font-mono text-[11px]">
No orders found
</div>
) : (
filtered.map((o) => {
const statusBadge = STATUS_BADGE[o.status] || STATUS_BADGE.open;
const typeBadge = TYPE_BADGE[o.orderType] || TYPE_BADGE.feature;
const priorityColor = PRIORITY_COLOR[o.priority] || PRIORITY_COLOR.none;
return (
<button
key={o.id}
type="button"
onClick={() => onSelect(o.id)}
className={`w-full text-left px-3 py-2.5 border-b border-[rgba(117,170,252,0.1)] hover:bg-[rgba(117,170,252,0.05)] transition-colors ${
selectedId === o.id ? "bg-[rgba(117,170,252,0.1)]" : ""
}`}
>
<div className="flex items-start gap-2 mb-1">
{/* Priority dot */}
<span
className={`w-2 h-2 rounded-full ${priorityColor} shrink-0 mt-[3px]`}
title={o.priority}
/>
<span className="text-[12px] font-mono text-white truncate flex-1">
{o.title}
{o.directiveName && (
<span className="text-[9px] font-mono text-[#556677] truncate block">
{o.directiveName}
</span>
)}
</span>
</div>
<div className="flex items-center gap-1.5 pl-4">
<span
className={`text-[9px] font-mono ${statusBadge.color} border rounded px-1.5 py-0.5`}
>
{statusBadge.label}
</span>
<span
className={`text-[9px] font-mono ${typeBadge.color} border rounded px-1.5 py-0.5`}
>
{typeBadge.label}
</span>
{o.labels.length > 0 && (
<span className="text-[9px] font-mono text-[#556677] truncate">
{o.labels.slice(0, 2).join(", ")}
{o.labels.length > 2 && ` +${o.labels.length - 2}`}
</span>
)}
</div>
</button>
);
})
)}
</div>
</div>
);
}
|