Skip to content

Commit 08a516c

Browse files
authored
Add kitchen preset control to configurator (#14)
1 parent 10bbc35 commit 08a516c

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

frontend/src/app/components/configurator-panel.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ import { Box, Button, Flex, NumberInput, NumberInputField, Text, Select } from '
55
import { useConfiguratorStore } from '../stores/configurator-store';
66

77
export default function ConfiguratorPanel() {
8-
const { loadCatalog, modules, selectedModuleId, setSelectedModule, quantity, setQuantity, quote, generateQuote } = useConfiguratorStore();
8+
const {
9+
loadCatalog,
10+
modules,
11+
selectedModuleId,
12+
setSelectedModule,
13+
quantity,
14+
setQuantity,
15+
quote,
16+
generateQuote,
17+
applyKitchenPreset,
18+
} = useConfiguratorStore();
919

1020
useEffect(() => {
1121
loadCatalog();
@@ -31,7 +41,17 @@ export default function ConfiguratorPanel() {
3141
</NumberInput>
3242
</Flex>
3343

34-
<Button colorScheme="teal" onClick={generateQuote}>Generate Quote</Button>
44+
<Flex gap={2} mt={2} direction={{ base: 'column', sm: 'row' }} align={{ base: 'stretch', sm: 'center' }}>
45+
<Button
46+
variant="outline"
47+
data-test="preset-kitchen"
48+
onClick={applyKitchenPreset}
49+
isDisabled={modules.length === 0}
50+
>
51+
Kitchen Preset
52+
</Button>
53+
<Button colorScheme="teal" onClick={generateQuote}>Generate Quote</Button>
54+
</Flex>
3555

3656
{quote && (
3757
<Box mt={4}>

frontend/src/app/stores/configurator-store.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ConfiguratorState {
1414
setSelectedModule: (id: string | null) => void;
1515
setQuantity: (qty: number) => void;
1616
generateQuote: () => Promise<void>;
17+
applyKitchenPreset: () => void;
1718
}
1819

1920
export const useConfiguratorStore = create<ConfiguratorState>((set, get) => ({
@@ -55,6 +56,24 @@ export const useConfiguratorStore = create<ConfiguratorState>((set, get) => ({
5556
set({ isLoading: false });
5657
}
5758
},
59+
60+
applyKitchenPreset: () => {
61+
const { modules } = get();
62+
if (modules.length === 0) {
63+
return;
64+
}
65+
66+
const preferredModule =
67+
modules.find((m) => m.name.toLowerCase().includes('kitchen')) ??
68+
modules.find((m) => m.name.toLowerCase().includes('base')) ??
69+
modules[0];
70+
71+
set({
72+
selectedModuleId: preferredModule.id,
73+
quantity: 4,
74+
quote: null,
75+
});
76+
},
5877
}));
5978

6079

0 commit comments

Comments
 (0)