2022-02-12 15:23:37 +01:00
|
|
|
import OptionsIcon from 'shared/components/icons/options.js'
|
|
|
|
import { Chevron } from 'shared/components/navigation/primary.js'
|
2022-09-06 15:33:38 +02:00
|
|
|
import OptionGroup from '../design-options/option-group'
|
|
|
|
import Option from './option'
|
2022-02-12 15:23:37 +01:00
|
|
|
import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-09-06 15:33:38 +02:00
|
|
|
import { optionsMenuStructure } from 'shared/utils.mjs'
|
2022-09-14 15:02:39 +02:00
|
|
|
import { adult, doll, giant } from '@freesewing/models'
|
2022-09-06 17:46:51 +02:00
|
|
|
|
|
|
|
const groups = { adult, doll, giant }
|
|
|
|
|
|
|
|
const SampleDesignOption = props => {
|
|
|
|
const { t } = useTranslation(['app'])
|
|
|
|
|
|
|
|
return <Option
|
|
|
|
updateGist={props.updateGist}
|
|
|
|
option={props.option}
|
|
|
|
design={props.design}
|
|
|
|
active={props.gist.sample?.option}
|
|
|
|
label={t(`o_${props.design.config.data.name}:${props.option}.t`)}
|
|
|
|
sampleSettings={{type: 'option', option: props.option}}
|
|
|
|
/>
|
|
|
|
}
|
2022-02-12 15:23:37 +01:00
|
|
|
|
|
|
|
const DesignOptions = props => {
|
2022-02-19 14:21:54 +01:00
|
|
|
const { t } = useTranslation(['app'])
|
2022-09-06 15:33:38 +02:00
|
|
|
const optionsMenu = optionsMenuStructure(props.design.config.options)
|
2022-02-12 15:23:37 +01:00
|
|
|
|
2022-09-06 17:46:51 +02:00
|
|
|
const measies = props.draft?.config?.measurements || []
|
|
|
|
|
2022-02-12 15:23:37 +01:00
|
|
|
return (
|
2022-09-06 17:46:51 +02:00
|
|
|
<>
|
2022-02-12 15:23:37 +01:00
|
|
|
<Details open>
|
|
|
|
<TopSummary icon={<OptionsIcon />}>
|
2022-09-06 17:46:51 +02:00
|
|
|
<TopSumTitle>{t('designOptions')}</TopSumTitle>
|
2022-02-12 15:23:37 +01:00
|
|
|
<Chevron />
|
|
|
|
</TopSummary>
|
|
|
|
<Ul className="pl-5 list-inside">
|
2022-09-06 15:33:38 +02:00
|
|
|
{Object.entries(optionsMenu).map(([group, options]) => typeof options === "string"
|
2022-09-06 17:46:51 +02:00
|
|
|
? <Option {...props} type={options} option={group} key={group} sampleSettings={{ type: 'option', option}}/>
|
|
|
|
: <OptionGroup {...props} group={group} options={options} key={group} Option={SampleDesignOption}/>
|
2022-09-06 15:33:38 +02:00
|
|
|
)}
|
2022-02-12 15:23:37 +01:00
|
|
|
</Ul>
|
|
|
|
</Details>
|
2022-09-06 17:46:51 +02:00
|
|
|
|
|
|
|
<Details open>
|
|
|
|
<TopSummary icon={<OptionsIcon />}>
|
|
|
|
<TopSumTitle>{t('measurements')}</TopSumTitle>
|
|
|
|
<Chevron />
|
|
|
|
</TopSummary>
|
|
|
|
<Ul className="pl-5 list-inside">
|
|
|
|
{measies.map(m => <Option
|
|
|
|
updateGist={props.updateGist}
|
|
|
|
option={m}
|
|
|
|
design={props.design}
|
|
|
|
active={props.gist.sample?.option}
|
|
|
|
key={m}
|
|
|
|
label={m}
|
|
|
|
sampleSettings={{ type: 'measurement', measurement: m }}
|
|
|
|
/>)}
|
|
|
|
</Ul>
|
|
|
|
</Details>
|
|
|
|
|
|
|
|
<Details open>
|
|
|
|
<TopSummary icon={<OptionsIcon />}>
|
|
|
|
<TopSumTitle>{t('models')}</TopSumTitle>
|
|
|
|
<Chevron />
|
|
|
|
</TopSummary>
|
|
|
|
<Ul className="pl-5 list-inside">
|
|
|
|
{Object.entries(groups).map(([group, modelGroups]) => (
|
|
|
|
Object.entries(modelGroups).map(([name, models]) => <Option
|
|
|
|
updateGist={props.updateGist}
|
|
|
|
label={`${group} - ${name}`}
|
|
|
|
design={props.design}
|
|
|
|
active={props.gist.sample?.option}
|
|
|
|
key={name}
|
|
|
|
sampleSettings={{ type: 'models', models }}
|
|
|
|
/>
|
|
|
|
)))}
|
|
|
|
</Ul>
|
|
|
|
</Details>
|
|
|
|
</>
|
2022-02-12 15:23:37 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DesignOptions
|