diff --git a/src/components/demand/WeightingEditor.tsx b/src/components/demand/WeightingEditor.tsx index 9810eb1..5cf1362 100644 --- a/src/components/demand/WeightingEditor.tsx +++ b/src/components/demand/WeightingEditor.tsx @@ -1,10 +1,16 @@ import { useState } from 'react' -import { Box, Button, Card, Slider, Typography } from '@mui/material' +import { Box, Button, Card, Divider, Slider, Typography } from '@mui/material' import { RotateCcw } from 'lucide-react' -import { WEIGHTING_KEYS, WEIGHTING_LABELS } from '../../domain/needBuilder' +import { WEIGHTING_LABELS } from '../../domain/needBuilder' import type { WeightingKey } from '../../domain/needBuilder' import { weightingService } from '../../services/weightingService' +const HARD_KEYS: WeightingKey[] = ['area', 'location', 'budget', 'timing'] +const SOFT_KEYS: WeightingKey[] = [ + 'prestige', 'accessibility', 'expansionPotential', 'flexibility', + 'visibility', 'footfall', 'talentAccess', 'esg', 'taxEnvironment', +] + interface Props { weights: Record onChange: (weights: Record) => void @@ -28,6 +34,44 @@ function rawToWeights(raw: Record): Record } +function SliderGroup({ + label, keys, raw, onSlider, color, +}: { + label: string + keys: WeightingKey[] + raw: Record + onSlider: (key: WeightingKey, v: number) => void + color: string +}) { + return ( + + + {label} + + + {keys.map(key => { + const importance = raw[key] ?? 3 + return ( + + + {WEIGHTING_LABELS[key]} + {IMPORTANCE_LABELS[importance]} + + onSlider(key, v as number)} + size="small" + sx={{ color }} + /> + + ) + })} + + + ) +} + export function WeightingEditor({ weights, onChange, assetType }: Props) { const [raw, setRaw] = useState>(() => toRaw(weights)) @@ -65,33 +109,9 @@ export function WeightingEditor({ weights, onChange, assetType }: Props) { - - {WEIGHTING_KEYS.map(key => { - const importance = raw[key] ?? 3 - return ( - - - - {WEIGHTING_LABELS[key]} - - - {IMPORTANCE_LABELS[importance]} - - - handleSlider(key, v as number)} - size="small" - sx={{ color: '#1e3a5f' }} - /> - - ) - })} - + + + )