-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
330 lines (281 loc) · 6.72 KB
/
types.ts
File metadata and controls
330 lines (281 loc) · 6.72 KB
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
import React from 'react';
// Theme Types
export type Theme = 'light' | 'dark';
export interface ThemeContextType {
theme: Theme;
toggleTheme: () => void;
}
// -- Data Structures for Logic --
export interface MaterialData {
material: string;
quantity: number;
}
export interface FabricData {
stacks: number;
dimensions: {
width: number;
length: number;
};
material?: string;
totalFabricUsed?: number;
}
export interface PatternData {
totalPatterns: number;
patternsPerStack: number;
wastePercentage: number;
stacksUsed: number;
estimatedTimePerPattern: number | null;
}
export interface CuttingData {
cutPieces: number;
totalPatternsUsed: number;
cuttingEfficiency: number;
estimatedTimePerPiece: number | null;
}
export interface AssemblyData {
assembledGarments: number;
piecesPerGarment: number;
cutPiecesUsed: number;
}
export interface SewingData {
finalProducts: number;
garmentsPerProduct: number;
assembledGarmentsUsed: number;
}
export interface QCData {
passedUnits: number;
rejectedUnits: number;
inputUnits: number;
passRate: number;
}
// -- Financial & Accessory Types --
export interface CostConfig {
materialCostPerUnit?: number;
laborCostPerHour?: number;
machineCostPerHour?: number;
energyCostPerUnit?: number;
overheadPercentage?: number;
fixedCost?: number;
sellingPrice?: number;
}
export interface CapacityConfig {
// Universal
workers?: number;
machines?: number;
lines?: number;
inspectors?: number;
// Socks Specific
kgPerWorkerPerHour?: number;
bobbinsPerMachinePerHour?: number;
setupMinutesPerMachine?: number;
pairsPerInspectorPerHour?: number;
pairsPerWorkerPerHour?: number;
boxesPerLinePerHour?: number;
socksPerMachinePerHour?: number;
batchesPerMachinePerHour?: number;
stations?: number;
socksPerStationPerHour?: number;
// Uniforms Specific
metersPerWorkerPerHour?: number;
tables?: number;
workersPerTable?: number;
metersPerTablePerHour?: number;
cadOperators?: number;
patternsPerOperatorPerHour?: number;
autoCutters?: number;
piecesPerCutterPerHour?: number;
workersPerLine?: number;
shirtsPerLinePerHour?: number;
shirtsPerInspectorPerHour?: number;
// Logo/Heat Press/Ironing/Folding
headsPerMachine?: number;
logosPerHeadPerHour?: number;
stampsPerMachinePerHour?: number;
shirtsPerIronerPerHour?: number;
shirtsPerFolderPerHour?: number;
}
export interface TimelineData {
totalMinutes: number;
totalHours: number;
totalDays: number;
isBottleneck: boolean;
throughputPerHour: number;
}
export interface CostBreakdown {
materialTotal: number;
laborTotal: number;
machineTotal: number; // New
energyTotal: number; // New
wasteTotal: number;
overheadTotal: number;
accessoryTotal: number;
totalNodeCost: number;
costPerUnit: number;
cumulativeCostPerUnit: number; // New: Value carried forward
profit?: number; // New
margin?: number; // New
}
export interface AccessoryItem {
id: string;
name: string;
enabled: boolean;
timePerUnit: number; // minutes
costPerUnit: number; // USD
}
export interface AccessoryData {
accessories: AccessoryItem[];
garmentsWithAccessories: number;
totalAccessoryTime: number;
totalAccessoryCost: number;
}
// -- Order Frame Types --
export interface OrderStats {
id: string;
label: string;
totalCost: number;
totalRevenue: number;
profit: number;
margin: number;
totalProducts: number;
totalTime: number;
completion: number; // 0-100 based on nodes done vs total
nodeCount: number;
}
export interface OrderFrameData {
label: string;
color: string; // Hex color for header
width?: number;
height?: number;
stats?: OrderStats; // Live calculated stats injected into the frame
}
// Generic Node Data used by React Flow
export interface NodeData {
label: string;
timer: number; // Time in minutes
// User-entered values (Form State)
inputs: Record<string, any>;
// Cost Configuration
costConfig?: CostConfig;
// Data flowing from upstream nodes
incoming: Record<string, any>;
// Calculated result
output: Record<string, any>;
// Financial Output
costs?: CostBreakdown;
// Capacity & Timeline Configuration (NEW)
capacityConfig?: CapacityConfig;
timeline?: TimelineData;
// CallbacksFor Order Frames
orderData?: OrderFrameData;
// Template Locking
locked?: boolean;
// Callback
onUpdate?: (id: string, data: Partial<NodeData>) => void;
}
export interface ViewportState {
x: number;
y: number;
scale: number;
}
export interface Coordinate {
x: number;
y: number;
}
// -- Analytics Types --
export interface GraphStats {
totalTime: number;
totalProducts: number;
totalCost: number;
costPerGarment: number;
breakdown: {
material: number;
labor: number;
waste: number;
overhead: number;
accessories: number;
}
}
export interface CriticalPathNode {
id: string;
label: string;
duration: number;
cumulativeTime: number;
}
export interface GraphAnalytics {
criticalPath: string[];
stats: GraphStats;
bottleneckNodeId?: string;
}
// -- Gemini Chat Types --
export type ChatRole = 'user' | 'model';
export interface ChatMessage {
id: string;
role: ChatRole;
text: string;
timestamp: number;
isStreaming?: boolean;
}
export interface GraphContext {
summary: string;
stats: GraphStats;
nodes: {
id: string;
type: string;
label: string;
inputs: any;
outputs: any;
timer: number;
costs?: CostBreakdown;
incoming: any;
}[];
connections: {
from: string;
to: string;
}[];
}
// -- Template & Order System Types --
export interface TemplateFilters {
category: 'Sock' | 'Uniform';
gender?: 'Men' | 'Women' | 'Child';
warmth?: 'Warm' | 'Normal';
length?: 'Long' | 'Normal' | 'Ankle';
}
export interface SavedTemplate {
id: string;
name: string;
filters: TemplateFilters;
nodes: any[]; // Using any to avoid circular dependency issues in types, mostly strict Node<NodeData>
edges: any[];
createdAt: string;
updatedAt: string;
}
export interface ActiveOrder {
id: string;
orderNumber: string;
name: string;
client: string;
quantity: number;
deliveryDate: string;
templateId: string;
status: 'Draft' | 'Production' | 'Completed';
nodes: any[];
edges: any[];
progress: number;
createdAt: string;
// Multi-variant support
isMultiVariant?: boolean;
variants?: OrderVariant[];
category?: 'Sock' | 'Uniform' | string; // Ensure category is explicit
color?: string; // Visual color for calendar lanes
}
export interface OrderVariant {
id: string;
name: string; // e.g., "Men's 168 Needle"
quantity: number;
templateId: string;
nodes: any[];
edges: any[];
machineType?: string;
sockType?: string;
color?: string;
}