Skip to content

Commit d57e673

Browse files
feat: add mocked custom options retrieval
1 parent d3786ce commit d57e673

2 files changed

Lines changed: 25 additions & 33 deletions

File tree

source/app.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ import React, { useState, type ReactNode } from 'react'
33
import MainTitle from './import/MainTitle.js'
44
import Step1 from './import/Step1.js'
55
import Step2 from './import/Step2.js'
6-
import Step3, { type Item } from './import/Step3.js'
7-
import Step4 from './import/Step4.js'
6+
import Step3, { type Item as SetupTypeItem } from './import/Step3.js'
7+
import Step4, { type Item as CustomOptionsItem } from './import/Step4.js'
88
import Step5 from './import/Step5.js'
99
import { canShowStep } from './import/utils.js'
1010

1111
const App = () => {
1212
const [projectName, setProjectName] = useState<string>('')
1313
const [currentStep, setCurrentStep] = useState(1)
14-
const [setupOption, setSetupOption] = useState<Item | undefined>()
14+
const [setupType, setSetupType] = useState<SetupTypeItem | undefined>()
15+
const [customOptions, setCustomOptions] = useState<Array<CustomOptionsItem> | undefined>()
1516

1617
const finishStep = () => setCurrentStep(currentStep + 1)
17-
const onSelect = (item: Item) => setSetupOption(item)
18+
const onSelectSetupType = (item: SetupTypeItem) => setSetupType(item)
19+
const onSelectCustomOptions = (selectedItems: Array<CustomOptionsItem>) =>
20+
setCustomOptions([...selectedItems])
1821

1922
const steps: Array<ReactNode> = [
2023
<Step1
@@ -30,19 +33,19 @@ const App = () => {
3033
/>,
3134
<Step3
3235
onCompletion={finishStep}
33-
onSelect={onSelect}
36+
onSelect={onSelectSetupType}
3437
key={3}
3538
/>,
3639
<Step4
3740
onCompletion={finishStep}
38-
onSubmit={() => console.log()}
39-
installation={setupOption?.value}
41+
onSubmit={onSelectCustomOptions}
42+
installation={setupType?.value}
4043
key={4}
4144
/>,
4245
<Step5
4346
onCompletion={finishStep}
4447
projectName={projectName}
45-
installation={setupOption?.value}
48+
installation={setupType?.value}
4649
key={5}
4750
/>,
4851
]
@@ -54,6 +57,11 @@ const App = () => {
5457
>
5558
<MainTitle />
5659
{steps.map((item, index) => canShowStep(currentStep, index + 1) && item)}
60+
{customOptions?.map((item, index) => (
61+
<Text key={index}>
62+
{item.label} / {item.value}
63+
</Text>
64+
))}
5765
</Box>
5866
)
5967
}

source/import/Step4.tsx

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import MultiSelect from './Multiselect/index.js'
44
import React, { useState, type FC, useEffect } from 'react'
55
import type { Installation } from './Step3.js'
66

7-
interface Item {
7+
export interface Item {
88
label: string
99
value: string
1010
}
1111

1212
interface Props {
13-
onCompletion: () => void
14-
onSubmit: (item: Item) => void
1513
installation: Installation | undefined
14+
onCompletion: () => void
15+
onSubmit: (selectedItems: Array<Item>) => void
1616
}
1717

1818
const customPackages: Array<Item> = [
@@ -40,43 +40,27 @@ const customPackages: Array<Item> = [
4040

4141
const Step4: FC<Props> = ({ onCompletion, onSubmit, installation }) => {
4242
const [isFocused, setIsFocused] = useState(true)
43-
const [showCustomOptions, setShowCustomOptions] = useState(false)
4443
const skip = installation === 'full'
4544

4645
// biome-ignore lint/correctness/useExhaustiveDependencies: Run this only once
4746
useEffect(() => {
47+
// full installation, do nothing
4848
if (skip) {
4949
onCompletion()
5050
}
5151
}, [])
5252

53-
const onHandleSubmit = (item: Array<Item>) => {
54-
// onSubmit(item)
55-
//
56-
// if (item.value === 'full') {
57-
// onCompletion()
58-
// } else {
59-
// setShowCustomOptions(true)
60-
// }
61-
// setIsFocused(false)
53+
const onHandleSubmit = (selectedItems: Array<Item>) => {
54+
onSubmit(selectedItems)
55+
setIsFocused(false)
56+
onCompletion()
6257
}
6358

6459
return skip ? null : (
6560
<>
6661
<Text color={'whiteBright'}>Choose optional packages</Text>
6762
<MultiSelect
68-
// indicatorComponent={({ isSelected }) => (
69-
// <Text color="green">{isSelected ? '> ' : ' '}</Text>
70-
// )}
71-
// itemComponent={({ label, isSelected }) => (
72-
// <Text
73-
// color={isSelected ? 'green' : 'white'}
74-
// bold={isSelected}
75-
// >
76-
// {label}
77-
// </Text>
78-
// )}
79-
// isFocused={isFocused}
63+
focus={isFocused}
8064
items={customPackages}
8165
onSubmit={onHandleSubmit}
8266
/>

0 commit comments

Comments
 (0)