@kruschdev/pascal-plugin-furnishings 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +70 -2
- package/docs/ARCHITECTURE.md +56 -0
- package/docs/CAD-CATALOG.md +124 -0
- package/package.json +92 -4
- package/src/agent-operations.ts +851 -0
- package/src/agent-tools.ts +273 -0
- package/src/cad/catalog.ts +107 -0
- package/src/cad/electronics-geometry.ts +298 -0
- package/src/cad/furniture-geometry.ts +846 -0
- package/src/cad/index.ts +10 -0
- package/src/cad/materials.ts +274 -0
- package/src/cad/plants-geometry.ts +506 -0
- package/src/furnishings/audit.ts +711 -0
- package/src/furnishings/autopopulate.ts +1474 -0
- package/src/furnishings/catalog.ts +1848 -0
- package/src/furnishings/geometry.ts +753 -0
- package/src/furnishings/index.ts +14 -0
- package/src/furnishings/schedule.ts +503 -0
- package/src/furnishings/spatial-grounding.ts +1753 -0
- package/src/furnishings/types.ts +416 -0
- package/src/index.ts +145 -0
- package/src/nodes/assembly.ts +105 -0
- package/src/nodes/electronics.ts +187 -0
- package/src/nodes/glb-hydration.ts +269 -0
- package/src/nodes/item.ts +202 -0
- package/src/nodes/parametrics.ts +102 -0
- package/src/nodes/plant.ts +197 -0
- package/src/render.ts +55 -0
- package/src/ui/chat-card.tsx +119 -0
- package/src/ui/furnishings-panel.tsx +679 -0
- package/src/ui/inspector-card.tsx +350 -0
- package/src/ui/schedule-view.tsx +336 -0
- package/src/ui/store.ts +94 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* InspectorExtension card for `furnishings:item`, `furnishings:electronics`,
|
|
5
|
+
* `furnishings:plant`, and `furnishings:assembly`.
|
|
6
|
+
* Supports live sibling item swapping, finish/screen-size/maturity/season/pot controls,
|
|
7
|
+
* and per-node ergonomics/clearance/AV/botanical diagnostics in one undo step.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { type AnyNode, runAsSingleSceneHistoryStep } from '@pascal-app/core'
|
|
11
|
+
import { useScene } from '@pascal-app/editor'
|
|
12
|
+
import { useMemo } from 'react'
|
|
13
|
+
import { furnishingsAgentOperations } from '../agent-operations'
|
|
14
|
+
import { auditSceneFurnishings, getFurnishingSpec, getSwapCandidates } from '../furnishings'
|
|
15
|
+
import {
|
|
16
|
+
BUDGET_TIERS,
|
|
17
|
+
DOMAIN_COLORS,
|
|
18
|
+
DOMAIN_LABELS,
|
|
19
|
+
ELECTRONICS_FINISHES,
|
|
20
|
+
FABRIC_FINISHES,
|
|
21
|
+
METAL_FINISHES,
|
|
22
|
+
PLANT_MATURITIES,
|
|
23
|
+
PLANT_SEASONS,
|
|
24
|
+
POT_STYLES,
|
|
25
|
+
SCREEN_STATES,
|
|
26
|
+
STYLE_PRESET_PALETTES,
|
|
27
|
+
STYLE_PRESETS,
|
|
28
|
+
type SceneNodeLike,
|
|
29
|
+
WOOD_FINISHES,
|
|
30
|
+
} from '../furnishings/types'
|
|
31
|
+
|
|
32
|
+
const selectStyle = {
|
|
33
|
+
width: '100%',
|
|
34
|
+
padding: '5px 7px',
|
|
35
|
+
borderRadius: 6,
|
|
36
|
+
background: 'var(--bg-secondary, rgba(255,255,255,0.06))',
|
|
37
|
+
border: '1px solid var(--border, rgba(255,255,255,0.16))',
|
|
38
|
+
color: 'inherit',
|
|
39
|
+
fontSize: 11.5,
|
|
40
|
+
} as const
|
|
41
|
+
|
|
42
|
+
export default function FurnishingsInspectorCard({ node }: { node?: AnyNode }) {
|
|
43
|
+
const nodes = useScene((s) => s.nodes)
|
|
44
|
+
const updateNodes = useScene((s) => s.updateNodes)
|
|
45
|
+
|
|
46
|
+
const raw = node as unknown as SceneNodeLike | undefined
|
|
47
|
+
const nodeType = raw?.type ?? ''
|
|
48
|
+
const isAssembly = nodeType === 'furnishings:assembly'
|
|
49
|
+
const isManaged =
|
|
50
|
+
nodeType === 'furnishings:item' ||
|
|
51
|
+
nodeType === 'furnishings:electronics' ||
|
|
52
|
+
nodeType === 'furnishings:plant'
|
|
53
|
+
|
|
54
|
+
const kind = isManaged ? String(raw?.itemKind ?? raw?.plantKind ?? '') : ''
|
|
55
|
+
const spec = useMemo(() => (kind ? getFurnishingSpec(kind) : undefined), [kind])
|
|
56
|
+
const siblings = useMemo(() => (kind ? getSwapCandidates(kind, 24) : []), [kind])
|
|
57
|
+
|
|
58
|
+
const auditResult = useMemo(() => {
|
|
59
|
+
if (!raw?.id || (!isManaged && !isAssembly)) return null
|
|
60
|
+
return auditSceneFurnishings(nodes as unknown as Readonly<Record<string, SceneNodeLike>>)
|
|
61
|
+
}, [nodes, raw?.id, isManaged, isAssembly])
|
|
62
|
+
|
|
63
|
+
const nodeFindings = useMemo(() => {
|
|
64
|
+
if (!raw?.id || !isManaged || !auditResult) return []
|
|
65
|
+
return auditResult.findings.filter((f) => f.nodeId === raw.id || f.relatedNodeId === raw.id)
|
|
66
|
+
}, [auditResult, raw?.id, isManaged])
|
|
67
|
+
|
|
68
|
+
if (!raw || (!isManaged && !isAssembly)) return null
|
|
69
|
+
|
|
70
|
+
if (isAssembly) {
|
|
71
|
+
const updateAssembly = (patch: Record<string, unknown>) => {
|
|
72
|
+
runAsSingleSceneHistoryStep(useScene, () => {
|
|
73
|
+
updateNodes([{ id: raw.id as AnyNode['id'], data: patch }])
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
return (
|
|
77
|
+
<div style={{ padding: 10, display: 'flex', flexDirection: 'column', gap: 8, fontSize: 12 }}>
|
|
78
|
+
<div
|
|
79
|
+
style={{
|
|
80
|
+
padding: '6px 8px',
|
|
81
|
+
borderRadius: 6,
|
|
82
|
+
background: 'rgba(34,197,94,0.14)',
|
|
83
|
+
border: '1px solid rgba(34,197,94,0.55)',
|
|
84
|
+
display: 'flex',
|
|
85
|
+
justifyContent: 'space-between',
|
|
86
|
+
fontWeight: 700,
|
|
87
|
+
fontSize: 11,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<span>FF&E & Landscape Package</span>
|
|
91
|
+
<span>Zone {String(raw.hardinessZone ?? '7b')}</span>
|
|
92
|
+
</div>
|
|
93
|
+
<div style={{ fontWeight: 600 }}>{raw.name || 'FF&E & Landscape Staging Package'}</div>
|
|
94
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6, fontSize: 11 }}>
|
|
95
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
96
|
+
<span>Style Preset</span>
|
|
97
|
+
<select
|
|
98
|
+
value={String(raw.stylePreset ?? 'mid-century')}
|
|
99
|
+
onChange={(e) => updateAssembly({ stylePreset: e.target.value })}
|
|
100
|
+
style={selectStyle}
|
|
101
|
+
>
|
|
102
|
+
{STYLE_PRESETS.map((s) => (
|
|
103
|
+
<option key={s} value={s}>{STYLE_PRESET_PALETTES[s].label}</option>
|
|
104
|
+
))}
|
|
105
|
+
</select>
|
|
106
|
+
</label>
|
|
107
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
108
|
+
<span>Budget Tier</span>
|
|
109
|
+
<select
|
|
110
|
+
value={String(raw.budgetTier ?? 'mid-tier')}
|
|
111
|
+
onChange={(e) => updateAssembly({ budgetTier: e.target.value })}
|
|
112
|
+
style={selectStyle}
|
|
113
|
+
>
|
|
114
|
+
{BUDGET_TIERS.map((t) => (
|
|
115
|
+
<option key={t} value={t}>{t}</option>
|
|
116
|
+
))}
|
|
117
|
+
</select>
|
|
118
|
+
</label>
|
|
119
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2, gridColumn: '1 / -1' }}>
|
|
120
|
+
<span>Botanical Season</span>
|
|
121
|
+
<select
|
|
122
|
+
value={String(raw.season ?? 'summer')}
|
|
123
|
+
onChange={(e) => updateAssembly({ season: e.target.value })}
|
|
124
|
+
style={selectStyle}
|
|
125
|
+
>
|
|
126
|
+
{PLANT_SEASONS.map((s) => (
|
|
127
|
+
<option key={s} value={s}>{s}</option>
|
|
128
|
+
))}
|
|
129
|
+
</select>
|
|
130
|
+
</label>
|
|
131
|
+
</div>
|
|
132
|
+
{auditResult && (
|
|
133
|
+
<div style={{ fontSize: 11, opacity: 0.85 }}>
|
|
134
|
+
Scene Audit: <strong>{auditResult.errorCount}</strong> error(s), <strong>{auditResult.warningCount}</strong> warning(s) across {auditResult.totalItemsAudited} item(s).
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const applySwap = (patchInput: Record<string, unknown>) => {
|
|
142
|
+
try {
|
|
143
|
+
const currentNodes = useScene.getState().nodes
|
|
144
|
+
const res = furnishingsAgentOperations.furnishings_swap_item(
|
|
145
|
+
currentNodes as unknown as Parameters<typeof furnishingsAgentOperations.furnishings_swap_item>[0],
|
|
146
|
+
{ nodeId: raw.id, ...patchInput },
|
|
147
|
+
)
|
|
148
|
+
if (res.changes.update && res.changes.update.length > 0) {
|
|
149
|
+
runAsSingleSceneHistoryStep(useScene, () => {
|
|
150
|
+
updateNodes(
|
|
151
|
+
(res.changes.update ?? []).map((u) => ({
|
|
152
|
+
id: u.id as AnyNode['id'],
|
|
153
|
+
data: u.patch,
|
|
154
|
+
})),
|
|
155
|
+
)
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
// Ignore transient swap refusal if the selected node was concurrently removed
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const accent = spec ? DOMAIN_COLORS[spec.domain] : '#22c55e'
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<div style={{ padding: 10, display: 'flex', flexDirection: 'column', gap: 8, fontSize: 12 }}>
|
|
167
|
+
<div
|
|
168
|
+
style={{
|
|
169
|
+
padding: '6px 8px',
|
|
170
|
+
borderRadius: 6,
|
|
171
|
+
background: `${accent}22`,
|
|
172
|
+
border: `1px solid ${accent}88`,
|
|
173
|
+
display: 'flex',
|
|
174
|
+
justifyContent: 'space-between',
|
|
175
|
+
fontWeight: 700,
|
|
176
|
+
fontSize: 11,
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
<span>{spec ? DOMAIN_LABELS[spec.domain] : nodeType}</span>
|
|
180
|
+
<span>CSI {spec?.csiDivision ?? '12 52 00'}</span>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<div style={{ fontWeight: 600 }}>{raw.name || spec?.label || kind}</div>
|
|
184
|
+
|
|
185
|
+
{siblings.length > 1 && (
|
|
186
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 3, fontSize: 11 }}>
|
|
187
|
+
<span style={{ fontWeight: 600 }}>Swap Item / Species ({siblings.length} options):</span>
|
|
188
|
+
<select value={kind} onChange={(e) => applySwap({ newKind: e.target.value })} style={selectStyle}>
|
|
189
|
+
{siblings.map((cand) => (
|
|
190
|
+
<option key={cand.kind} value={cand.kind}>
|
|
191
|
+
{cand.label} (${cand.estUnitPriceUsd})
|
|
192
|
+
</option>
|
|
193
|
+
))}
|
|
194
|
+
</select>
|
|
195
|
+
</label>
|
|
196
|
+
)}
|
|
197
|
+
|
|
198
|
+
{nodeType === 'furnishings:item' && (
|
|
199
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6, fontSize: 11 }}>
|
|
200
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
201
|
+
<span>Wood Finish</span>
|
|
202
|
+
<select
|
|
203
|
+
value={String(raw.woodFinish ?? 'american-walnut')}
|
|
204
|
+
onChange={(e) => applySwap({ woodFinish: e.target.value })}
|
|
205
|
+
style={selectStyle}
|
|
206
|
+
>
|
|
207
|
+
{WOOD_FINISHES.map((w) => (
|
|
208
|
+
<option key={w} value={w}>{w}</option>
|
|
209
|
+
))}
|
|
210
|
+
</select>
|
|
211
|
+
</label>
|
|
212
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
213
|
+
<span>Fabric / Rug</span>
|
|
214
|
+
<select
|
|
215
|
+
value={String(raw.fabricFinish ?? 'warm-linen')}
|
|
216
|
+
onChange={(e) => applySwap({ fabricFinish: e.target.value })}
|
|
217
|
+
style={selectStyle}
|
|
218
|
+
>
|
|
219
|
+
{FABRIC_FINISHES.map((f) => (
|
|
220
|
+
<option key={f} value={f}>{f}</option>
|
|
221
|
+
))}
|
|
222
|
+
</select>
|
|
223
|
+
</label>
|
|
224
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2, gridColumn: '1 / -1' }}>
|
|
225
|
+
<span>Metal Hardware</span>
|
|
226
|
+
<select
|
|
227
|
+
value={String(
|
|
228
|
+
raw.metalFinish ?? (kind === 'vent-grate-floor-brass' ? 'brushed-brass' : 'matte-black'),
|
|
229
|
+
)}
|
|
230
|
+
onChange={(e) => applySwap({ metalFinish: e.target.value })}
|
|
231
|
+
style={selectStyle}
|
|
232
|
+
>
|
|
233
|
+
{METAL_FINISHES.map((m) => (
|
|
234
|
+
<option key={m} value={m}>{m}</option>
|
|
235
|
+
))}
|
|
236
|
+
</select>
|
|
237
|
+
</label>
|
|
238
|
+
</div>
|
|
239
|
+
)}
|
|
240
|
+
|
|
241
|
+
{nodeType === 'furnishings:electronics' && (
|
|
242
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6, fontSize: 11 }}>
|
|
243
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
244
|
+
<span>Chassis Finish</span>
|
|
245
|
+
<select
|
|
246
|
+
value={String(raw.finish ?? 'matte-black')}
|
|
247
|
+
onChange={(e) => applySwap({ electronicsFinish: e.target.value })}
|
|
248
|
+
style={selectStyle}
|
|
249
|
+
>
|
|
250
|
+
{ELECTRONICS_FINISHES.map((f) => (
|
|
251
|
+
<option key={f} value={f}>{f}</option>
|
|
252
|
+
))}
|
|
253
|
+
</select>
|
|
254
|
+
</label>
|
|
255
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
256
|
+
<span>Display Mode</span>
|
|
257
|
+
<select
|
|
258
|
+
value={String(raw.screenState ?? 'ambient')}
|
|
259
|
+
onChange={(e) => applySwap({ screenState: e.target.value })}
|
|
260
|
+
style={selectStyle}
|
|
261
|
+
>
|
|
262
|
+
{SCREEN_STATES.map((s) => (
|
|
263
|
+
<option key={s} value={s}>{s}</option>
|
|
264
|
+
))}
|
|
265
|
+
</select>
|
|
266
|
+
</label>
|
|
267
|
+
{(kind === 'tv-oled-wall' || kind === 'tv-oled-stand' || kind === 'projector-screen') && (
|
|
268
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2, gridColumn: '1 / -1' }}>
|
|
269
|
+
<span>Screen Size Preset (in)</span>
|
|
270
|
+
<select
|
|
271
|
+
value={Number(raw.screenDiagonalIn ?? 65)}
|
|
272
|
+
onChange={(e) => applySwap({ screenDiagonalIn: Number(e.target.value) })}
|
|
273
|
+
style={selectStyle}
|
|
274
|
+
>
|
|
275
|
+
{[42, 48, 55, 65, 77, 83, 98, 100, 120].map((sz) => (
|
|
276
|
+
<option key={sz} value={sz}>{sz}" Diagonal</option>
|
|
277
|
+
))}
|
|
278
|
+
</select>
|
|
279
|
+
</label>
|
|
280
|
+
)}
|
|
281
|
+
</div>
|
|
282
|
+
)}
|
|
283
|
+
|
|
284
|
+
{nodeType === 'furnishings:plant' && (
|
|
285
|
+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6, fontSize: 11 }}>
|
|
286
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
287
|
+
<span>Maturity</span>
|
|
288
|
+
<select
|
|
289
|
+
value={String(raw.maturity ?? 'mature')}
|
|
290
|
+
onChange={(e) => applySwap({ maturity: e.target.value })}
|
|
291
|
+
style={selectStyle}
|
|
292
|
+
>
|
|
293
|
+
{PLANT_MATURITIES.map((m) => (
|
|
294
|
+
<option key={m} value={m}>{m}</option>
|
|
295
|
+
))}
|
|
296
|
+
</select>
|
|
297
|
+
</label>
|
|
298
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
|
|
299
|
+
<span>Season</span>
|
|
300
|
+
<select
|
|
301
|
+
value={String(raw.season ?? 'summer')}
|
|
302
|
+
onChange={(e) => applySwap({ season: e.target.value })}
|
|
303
|
+
style={selectStyle}
|
|
304
|
+
>
|
|
305
|
+
{PLANT_SEASONS.map((s) => (
|
|
306
|
+
<option key={s} value={s}>{s}</option>
|
|
307
|
+
))}
|
|
308
|
+
</select>
|
|
309
|
+
</label>
|
|
310
|
+
<label style={{ display: 'flex', flexDirection: 'column', gap: 2, gridColumn: '1 / -1' }}>
|
|
311
|
+
<span>Pot / Planter Style</span>
|
|
312
|
+
<select
|
|
313
|
+
value={String(raw.potStyle ?? 'none')}
|
|
314
|
+
onChange={(e) => applySwap({ potStyle: e.target.value })}
|
|
315
|
+
style={selectStyle}
|
|
316
|
+
>
|
|
317
|
+
{POT_STYLES.map((p) => (
|
|
318
|
+
<option key={p} value={p}>{p}</option>
|
|
319
|
+
))}
|
|
320
|
+
</select>
|
|
321
|
+
</label>
|
|
322
|
+
</div>
|
|
323
|
+
)}
|
|
324
|
+
|
|
325
|
+
{nodeFindings.length > 0 && (
|
|
326
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
|
327
|
+
{nodeFindings.map((f, idx) => (
|
|
328
|
+
<div
|
|
329
|
+
key={`${f.code}-${idx}`}
|
|
330
|
+
style={{
|
|
331
|
+
padding: '6px 8px',
|
|
332
|
+
borderRadius: 6,
|
|
333
|
+
fontSize: 11,
|
|
334
|
+
border: `1px solid ${f.severity === 'error' ? '#f87171' : f.severity === 'warning' ? '#fbbf24' : '#38bdf8'}`,
|
|
335
|
+
background:
|
|
336
|
+
f.severity === 'error'
|
|
337
|
+
? 'rgba(248,113,113,0.12)'
|
|
338
|
+
: f.severity === 'warning'
|
|
339
|
+
? 'rgba(251,191,36,0.12)'
|
|
340
|
+
: 'rgba(56,189,248,0.12)',
|
|
341
|
+
}}
|
|
342
|
+
>
|
|
343
|
+
<strong>{f.code}</strong>: {f.message}
|
|
344
|
+
</div>
|
|
345
|
+
))}
|
|
346
|
+
</div>
|
|
347
|
+
)}
|
|
348
|
+
</div>
|
|
349
|
+
)
|
|
350
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Full-pane 5-tab EditorHostView (`krusch:furnishings:schedule`):
|
|
5
|
+
* 1. Room Staging
|
|
6
|
+
* 2. Electronics & Electrical Load Handoff
|
|
7
|
+
* 3. Landscape & Botanicals
|
|
8
|
+
* 4. Ergonomics & Clearance Audit
|
|
9
|
+
* 5. CSI Div 12 / 23 / 26 / 27 / 32 Priced BOM & CSV Export
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { useScene } from '@pascal-app/editor'
|
|
13
|
+
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
14
|
+
import {
|
|
15
|
+
auditSceneFurnishings,
|
|
16
|
+
buildFurnishingsBom,
|
|
17
|
+
buildFurnishingsSchedule,
|
|
18
|
+
formatFurnishingsBomCsv,
|
|
19
|
+
formatFurnishingsScheduleCsv,
|
|
20
|
+
} from '../furnishings'
|
|
21
|
+
import type { SceneNodeLike } from '../furnishings/types'
|
|
22
|
+
import { type FurnishingsScheduleTab, useFurnishingsUi } from './store'
|
|
23
|
+
|
|
24
|
+
function fmtUsd(v: number): string {
|
|
25
|
+
return `$${v.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const TABS: readonly { id: FurnishingsScheduleTab; label: string }[] = [
|
|
29
|
+
{ id: 'rooms', label: 'Room Staging' },
|
|
30
|
+
{ id: 'electronics', label: 'Electronics & Power' },
|
|
31
|
+
{ id: 'botanicals', label: 'Trees & Plants' },
|
|
32
|
+
{ id: 'audit', label: 'Ergonomics & Audit' },
|
|
33
|
+
{ id: 'bom', label: 'CSI BOM & CSV' },
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
export default function FurnishingsScheduleView() {
|
|
37
|
+
const nodes = useScene((s) => s.nodes)
|
|
38
|
+
const {
|
|
39
|
+
stylePreset,
|
|
40
|
+
budgetTier,
|
|
41
|
+
season,
|
|
42
|
+
scheduleTab,
|
|
43
|
+
setScheduleTab,
|
|
44
|
+
markupPct,
|
|
45
|
+
salesTaxPct,
|
|
46
|
+
setMarkupPct,
|
|
47
|
+
setSalesTaxPct,
|
|
48
|
+
} = useFurnishingsUi()
|
|
49
|
+
const [copiedMsg, setCopiedMsg] = useState('')
|
|
50
|
+
const toastTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
51
|
+
const mountedRef = useRef(true)
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
mountedRef.current = true
|
|
55
|
+
return () => {
|
|
56
|
+
mountedRef.current = false
|
|
57
|
+
if (toastTimerRef.current) clearTimeout(toastTimerRef.current)
|
|
58
|
+
}
|
|
59
|
+
}, [])
|
|
60
|
+
|
|
61
|
+
const sceneRec = nodes as unknown as Readonly<Record<string, SceneNodeLike>>
|
|
62
|
+
const schedule = useMemo(
|
|
63
|
+
() => buildFurnishingsSchedule(sceneRec, { budgetTier, stylePreset, season }),
|
|
64
|
+
[sceneRec, budgetTier, stylePreset, season],
|
|
65
|
+
)
|
|
66
|
+
const bom = useMemo(
|
|
67
|
+
() => buildFurnishingsBom(sceneRec, { markupPct, salesTaxPct, schedule }),
|
|
68
|
+
[sceneRec, markupPct, salesTaxPct, schedule],
|
|
69
|
+
)
|
|
70
|
+
const audit = useMemo(() => auditSceneFurnishings(sceneRec), [sceneRec])
|
|
71
|
+
|
|
72
|
+
const copyCsv = async (kind: 'schedule' | 'bom') => {
|
|
73
|
+
const csv = kind === 'bom' ? formatFurnishingsBomCsv(bom) : formatFurnishingsScheduleCsv(schedule)
|
|
74
|
+
if (toastTimerRef.current) {
|
|
75
|
+
clearTimeout(toastTimerRef.current)
|
|
76
|
+
toastTimerRef.current = null
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
await navigator.clipboard.writeText(csv)
|
|
80
|
+
if (!mountedRef.current) return
|
|
81
|
+
setCopiedMsg(`Copied ${kind.toUpperCase()} CSV (${csv.split('\n').length} rows)`)
|
|
82
|
+
toastTimerRef.current = setTimeout(() => {
|
|
83
|
+
setCopiedMsg('')
|
|
84
|
+
toastTimerRef.current = null
|
|
85
|
+
}, 2500)
|
|
86
|
+
} catch {
|
|
87
|
+
if (!mountedRef.current) return
|
|
88
|
+
setCopiedMsg('Clipboard unavailable in this host.')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 12, fontSize: 12.5, height: '100%', overflow: 'auto' }}>
|
|
94
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 8 }}>
|
|
95
|
+
<div>
|
|
96
|
+
<h2 style={{ margin: 0, fontSize: 16 }}>FF&E, Electronics & Landscape Botanicals Schedule</h2>
|
|
97
|
+
<div style={{ opacity: 0.72, fontSize: 11.5 }}>
|
|
98
|
+
{schedule.totalUnits} total units · {schedule.electronicsCount} AV/PC devices ({schedule.electricalDemand.totalPlugInWattageW}W / {schedule.electricalDemand.estimatedAmps120V}A) · {schedule.botanicalCount} trees & plants · Grand Total {fmtUsd(bom.grandTotalUsd)}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
<div style={{ display: 'flex', gap: 6 }}>
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
onClick={() => void copyCsv('schedule')}
|
|
105
|
+
style={{ padding: '6px 10px', borderRadius: 6, border: '1px solid rgba(255,255,255,0.2)', background: 'rgba(255,255,255,0.06)', color: 'inherit', cursor: 'pointer' }}
|
|
106
|
+
>
|
|
107
|
+
Copy Schedule CSV
|
|
108
|
+
</button>
|
|
109
|
+
<button
|
|
110
|
+
type="button"
|
|
111
|
+
onClick={() => void copyCsv('bom')}
|
|
112
|
+
style={{ padding: '6px 10px', borderRadius: 6, border: 'none', background: '#22c55e', color: '#052e16', fontWeight: 700, cursor: 'pointer' }}
|
|
113
|
+
>
|
|
114
|
+
Copy CSI BOM CSV
|
|
115
|
+
</button>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{copiedMsg && <div style={{ fontSize: 11.5, color: '#4ade80' }}>{copiedMsg}</div>}
|
|
120
|
+
|
|
121
|
+
{/* Tabs */}
|
|
122
|
+
<div style={{ display: 'flex', gap: 6, borderBottom: '1px solid rgba(255,255,255,0.12)', paddingBottom: 8, flexWrap: 'wrap' }}>
|
|
123
|
+
{TABS.map((tab) => (
|
|
124
|
+
<button
|
|
125
|
+
key={tab.id}
|
|
126
|
+
type="button"
|
|
127
|
+
onClick={() => setScheduleTab(tab.id)}
|
|
128
|
+
style={{
|
|
129
|
+
padding: '6px 12px',
|
|
130
|
+
borderRadius: 6,
|
|
131
|
+
border: '1px solid rgba(255,255,255,0.16)',
|
|
132
|
+
background: scheduleTab === tab.id ? '#38bdf8' : 'rgba(255,255,255,0.05)',
|
|
133
|
+
color: scheduleTab === tab.id ? '#0f172a' : 'inherit',
|
|
134
|
+
fontWeight: scheduleTab === tab.id ? 700 : 500,
|
|
135
|
+
cursor: 'pointer',
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
{tab.label}
|
|
139
|
+
</button>
|
|
140
|
+
))}
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
{/* Tab 1: Room Staging */}
|
|
144
|
+
{scheduleTab === 'rooms' && (
|
|
145
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
146
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(190px, 1fr))', gap: 8 }}>
|
|
147
|
+
{schedule.rooms.map((r) => (
|
|
148
|
+
<div key={r.roomName} style={{ padding: 10, borderRadius: 8, border: '1px solid rgba(255,255,255,0.12)', background: 'rgba(255,255,255,0.03)' }}>
|
|
149
|
+
<div style={{ fontWeight: 700 }}>{r.roomName}</div>
|
|
150
|
+
<div style={{ opacity: 0.78, fontSize: 11.5 }}>
|
|
151
|
+
{r.itemCount} unit(s) · {r.totalWattageW}W · <strong style={{ color: '#4ade80' }}>{fmtUsd(r.subtotalUsd)}</strong>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
))}
|
|
155
|
+
</div>
|
|
156
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 11.5 }}>
|
|
157
|
+
<thead>
|
|
158
|
+
<tr style={{ textAlign: 'left', borderBottom: '1px solid rgba(255,255,255,0.16)' }}>
|
|
159
|
+
<th style={{ padding: 6 }}>Room / Zone</th>
|
|
160
|
+
<th style={{ padding: 6 }}>Domain</th>
|
|
161
|
+
<th style={{ padding: 6 }}>Item</th>
|
|
162
|
+
<th style={{ padding: 6 }}>Spec / Finish</th>
|
|
163
|
+
<th style={{ padding: 6 }}>Qty</th>
|
|
164
|
+
<th style={{ padding: 6, textAlign: 'right' }}>Extended</th>
|
|
165
|
+
</tr>
|
|
166
|
+
</thead>
|
|
167
|
+
<tbody>
|
|
168
|
+
{schedule.rows.map((r) => (
|
|
169
|
+
<tr key={r.nodeId} style={{ borderBottom: '1px solid rgba(255,255,255,0.07)' }}>
|
|
170
|
+
<td style={{ padding: 6 }}>{r.roomName}</td>
|
|
171
|
+
<td style={{ padding: 6 }}>{r.domainLabel}</td>
|
|
172
|
+
<td style={{ padding: 6, fontWeight: 600 }}>{r.label}</td>
|
|
173
|
+
<td style={{ padding: 6, opacity: 0.8 }}>{r.finishSummary}</td>
|
|
174
|
+
<td style={{ padding: 6 }}>{r.quantity}</td>
|
|
175
|
+
<td style={{ padding: 6, textAlign: 'right' }}>{fmtUsd(r.extendedPriceUsd)}</td>
|
|
176
|
+
</tr>
|
|
177
|
+
))}
|
|
178
|
+
</tbody>
|
|
179
|
+
</table>
|
|
180
|
+
</div>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
{/* Tab 2: Electronics & Electrical Load */}
|
|
184
|
+
{scheduleTab === 'electronics' && (
|
|
185
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
186
|
+
<div style={{ padding: 10, borderRadius: 8, border: '1px solid rgba(56,189,248,0.35)', background: 'rgba(56,189,248,0.08)' }}>
|
|
187
|
+
<strong>Electrical Handoff (`krusch:electrical`)</strong>: Total Plug-In Load{' '}
|
|
188
|
+
<strong>{schedule.electricalDemand.totalPlugInWattageW} W</strong> ({schedule.electricalDemand.estimatedAmps120V} A @ 120V) — Recommended{' '}
|
|
189
|
+
<strong>{schedule.electricalDemand.recommended15ACircuits}</strong> dedicated 15A branch circuit(s).
|
|
190
|
+
</div>
|
|
191
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 11.5 }}>
|
|
192
|
+
<thead>
|
|
193
|
+
<tr style={{ textAlign: 'left', borderBottom: '1px solid rgba(255,255,255,0.16)' }}>
|
|
194
|
+
<th style={{ padding: 6 }}>Room</th>
|
|
195
|
+
<th style={{ padding: 6 }}>Device</th>
|
|
196
|
+
<th style={{ padding: 6 }}>Spec / Mount</th>
|
|
197
|
+
<th style={{ padding: 6 }}>Wattage</th>
|
|
198
|
+
<th style={{ padding: 6, textAlign: 'right' }}>Price</th>
|
|
199
|
+
</tr>
|
|
200
|
+
</thead>
|
|
201
|
+
<tbody>
|
|
202
|
+
{schedule.rows
|
|
203
|
+
.filter((r) => r.nodeType === 'furnishings:electronics' || r.wattageW > 0)
|
|
204
|
+
.map((r) => (
|
|
205
|
+
<tr key={r.nodeId} style={{ borderBottom: '1px solid rgba(255,255,255,0.07)' }}>
|
|
206
|
+
<td style={{ padding: 6 }}>{r.roomName}</td>
|
|
207
|
+
<td style={{ padding: 6, fontWeight: 600 }}>{r.label}</td>
|
|
208
|
+
<td style={{ padding: 6, opacity: 0.8 }}>{r.finishSummary}</td>
|
|
209
|
+
<td style={{ padding: 6, color: '#38bdf8', fontWeight: 600 }}>{r.wattageW} W</td>
|
|
210
|
+
<td style={{ padding: 6, textAlign: 'right' }}>{fmtUsd(r.extendedPriceUsd)}</td>
|
|
211
|
+
</tr>
|
|
212
|
+
))}
|
|
213
|
+
</tbody>
|
|
214
|
+
</table>
|
|
215
|
+
</div>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
{/* Tab 3: Landscape & Botanicals */}
|
|
219
|
+
{scheduleTab === 'botanicals' && (
|
|
220
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 11.5 }}>
|
|
221
|
+
<thead>
|
|
222
|
+
<tr style={{ textAlign: 'left', borderBottom: '1px solid rgba(255,255,255,0.16)' }}>
|
|
223
|
+
<th style={{ padding: 6 }}>Zone / Room</th>
|
|
224
|
+
<th style={{ padding: 6 }}>Plant / Tree</th>
|
|
225
|
+
<th style={{ padding: 6 }}>Species</th>
|
|
226
|
+
<th style={{ padding: 6 }}>Placement</th>
|
|
227
|
+
<th style={{ padding: 6 }}>Maturity & Pot</th>
|
|
228
|
+
<th style={{ padding: 6, textAlign: 'right' }}>Price</th>
|
|
229
|
+
</tr>
|
|
230
|
+
</thead>
|
|
231
|
+
<tbody>
|
|
232
|
+
{schedule.rows
|
|
233
|
+
.filter((r) => r.nodeType === 'furnishings:plant')
|
|
234
|
+
.map((r) => (
|
|
235
|
+
<tr key={r.nodeId} style={{ borderBottom: '1px solid rgba(255,255,255,0.07)' }}>
|
|
236
|
+
<td style={{ padding: 6 }}>{r.roomName}</td>
|
|
237
|
+
<td style={{ padding: 6, fontWeight: 600 }}>{r.label}</td>
|
|
238
|
+
<td style={{ padding: 6, fontStyle: 'italic' }}>{r.species}</td>
|
|
239
|
+
<td style={{ padding: 6 }}>{r.placement}</td>
|
|
240
|
+
<td style={{ padding: 6, opacity: 0.8 }}>{r.finishSummary}</td>
|
|
241
|
+
<td style={{ padding: 6, textAlign: 'right' }}>{fmtUsd(r.extendedPriceUsd)}</td>
|
|
242
|
+
</tr>
|
|
243
|
+
))}
|
|
244
|
+
</tbody>
|
|
245
|
+
</table>
|
|
246
|
+
)}
|
|
247
|
+
|
|
248
|
+
{/* Tab 4: Audit */}
|
|
249
|
+
{scheduleTab === 'audit' && (
|
|
250
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
|
251
|
+
<div style={{ fontWeight: 700, color: audit.passed ? '#4ade80' : '#f87171' }}>
|
|
252
|
+
{audit.passed ? 'PASSED' : 'NEEDS ATTENTION'} — {audit.errorCount} error(s), {audit.warningCount} warning(s), {audit.infoCount} info across {audit.totalItemsAudited} item(s).
|
|
253
|
+
</div>
|
|
254
|
+
{audit.findings.length === 0 ? (
|
|
255
|
+
<div style={{ opacity: 0.78 }}>All clearances, ergonomics, TV viewing geometry, speaker balance, electrical branch loads, and tree foundation setbacks passed clean.</div>
|
|
256
|
+
) : (
|
|
257
|
+
audit.findings.map((f, idx) => (
|
|
258
|
+
<div
|
|
259
|
+
key={`${f.code}-${idx}`}
|
|
260
|
+
style={{
|
|
261
|
+
padding: 8,
|
|
262
|
+
borderRadius: 6,
|
|
263
|
+
border: `1px solid ${f.severity === 'error' ? '#f87171' : f.severity === 'warning' ? '#fbbf24' : '#38bdf8'}`,
|
|
264
|
+
background: 'rgba(255,255,255,0.03)',
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
<div style={{ fontWeight: 700 }}>
|
|
268
|
+
[{f.severity.toUpperCase()}] {f.code} · {f.roomName}
|
|
269
|
+
</div>
|
|
270
|
+
<div>{f.message}</div>
|
|
271
|
+
<div style={{ opacity: 0.78, fontSize: 11 }}>Recommendation: {f.recommendation}</div>
|
|
272
|
+
</div>
|
|
273
|
+
))
|
|
274
|
+
)}
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
|
|
278
|
+
{/* Tab 5: CSI BOM */}
|
|
279
|
+
{scheduleTab === 'bom' && (
|
|
280
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
|
281
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
|
282
|
+
<label style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
|
283
|
+
<span>Markup %:</span>
|
|
284
|
+
<input
|
|
285
|
+
type="number"
|
|
286
|
+
min={0}
|
|
287
|
+
max={200}
|
|
288
|
+
value={markupPct}
|
|
289
|
+
onChange={(e) => setMarkupPct(Number(e.target.value))}
|
|
290
|
+
style={{ width: 70, padding: 4, borderRadius: 5, background: 'rgba(255,255,255,0.06)', border: '1px solid rgba(255,255,255,0.2)', color: 'inherit' }}
|
|
291
|
+
/>
|
|
292
|
+
</label>
|
|
293
|
+
<label style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
|
294
|
+
<span>Sales Tax %:</span>
|
|
295
|
+
<input
|
|
296
|
+
type="number"
|
|
297
|
+
min={0}
|
|
298
|
+
max={25}
|
|
299
|
+
value={salesTaxPct}
|
|
300
|
+
onChange={(e) => setSalesTaxPct(Number(e.target.value))}
|
|
301
|
+
style={{ width: 70, padding: 4, borderRadius: 5, background: 'rgba(255,255,255,0.06)', border: '1px solid rgba(255,255,255,0.2)', color: 'inherit' }}
|
|
302
|
+
/>
|
|
303
|
+
</label>
|
|
304
|
+
</div>
|
|
305
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 11.5 }}>
|
|
306
|
+
<thead>
|
|
307
|
+
<tr style={{ textAlign: 'left', borderBottom: '1px solid rgba(255,255,255,0.16)' }}>
|
|
308
|
+
<th style={{ padding: 6 }}>CSI Div</th>
|
|
309
|
+
<th style={{ padding: 6 }}>SKU</th>
|
|
310
|
+
<th style={{ padding: 6 }}>Description</th>
|
|
311
|
+
<th style={{ padding: 6 }}>Qty</th>
|
|
312
|
+
<th style={{ padding: 6, textAlign: 'right' }}>Unit</th>
|
|
313
|
+
<th style={{ padding: 6, textAlign: 'right' }}>Extended</th>
|
|
314
|
+
</tr>
|
|
315
|
+
</thead>
|
|
316
|
+
<tbody>
|
|
317
|
+
{bom.lines.map((line) => (
|
|
318
|
+
<tr key={`${line.csiDivision}-${line.kind}-${line.sku}-${line.brand}-${line.finishSummary}-${line.unitPriceUsd}`} style={{ borderBottom: '1px solid rgba(255,255,255,0.07)' }}>
|
|
319
|
+
<td style={{ padding: 6 }}>{line.csiDivision}</td>
|
|
320
|
+
<td style={{ padding: 6, fontFamily: 'ui-monospace, monospace' }}>{line.sku}</td>
|
|
321
|
+
<td style={{ padding: 6, fontWeight: 600 }}>{line.label}</td>
|
|
322
|
+
<td style={{ padding: 6 }}>{line.quantity}</td>
|
|
323
|
+
<td style={{ padding: 6, textAlign: 'right' }}>{fmtUsd(line.unitPriceUsd)}</td>
|
|
324
|
+
<td style={{ padding: 6, textAlign: 'right' }}>{fmtUsd(line.extendedUsd)}</td>
|
|
325
|
+
</tr>
|
|
326
|
+
))}
|
|
327
|
+
</tbody>
|
|
328
|
+
</table>
|
|
329
|
+
<div style={{ textAlign: 'right', fontWeight: 700, fontSize: 13 }}>
|
|
330
|
+
Subtotal: {fmtUsd(bom.subtotalUsd)} · Grand Total: <span style={{ color: '#4ade80' }}>{fmtUsd(bom.grandTotalUsd)}</span>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
)}
|
|
334
|
+
</div>
|
|
335
|
+
)
|
|
336
|
+
}
|