2020-04-25 19:09:02 +02:00
|
|
|
import React from 'react'
|
|
|
|
import Button from '@material-ui/core/Button'
|
2021-05-23 11:32:10 +02:00
|
|
|
import { FormattedMessage } from 'react-intl'
|
2020-04-25 19:09:02 +02:00
|
|
|
import FormFieldMeasurement from '../../.form/FormFieldMeasurement'
|
|
|
|
import { withBreasts, withoutBreasts } from '@freesewing/models'
|
2020-10-31 16:53:39 +01:00
|
|
|
import Icon from '../../Icon'
|
2019-05-05 17:06:22 +02:00
|
|
|
|
2020-04-25 19:09:02 +02:00
|
|
|
const Measurements = (props) => {
|
2019-05-05 17:06:22 +02:00
|
|
|
const styles = {
|
|
|
|
container: {
|
2020-04-25 19:09:02 +02:00
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'row',
|
|
|
|
width: '100%',
|
|
|
|
minHeight: '70vh'
|
2019-05-05 17:06:22 +02:00
|
|
|
},
|
|
|
|
chooser: {
|
2020-04-25 19:09:02 +02:00
|
|
|
width: '100%',
|
|
|
|
maxWidth: '500px',
|
2020-10-31 16:53:39 +01:00
|
|
|
alignSelf: 'top'
|
|
|
|
},
|
|
|
|
ul: {
|
|
|
|
listStyleType: 'none',
|
|
|
|
margin: '0',
|
|
|
|
padding: '0'
|
|
|
|
},
|
|
|
|
li: {
|
|
|
|
display: 'inline',
|
|
|
|
padding: '0 5px 5px 0'
|
2019-05-05 17:06:22 +02:00
|
|
|
}
|
2020-04-25 19:09:02 +02:00
|
|
|
}
|
2019-05-05 17:06:22 +02:00
|
|
|
|
2020-04-25 19:09:02 +02:00
|
|
|
const getValue = (m) => {
|
|
|
|
if (props.measurements === null) return ''
|
|
|
|
if (typeof props.measurements[m] === 'undefined') return ''
|
|
|
|
return props.measurements[m]
|
|
|
|
}
|
2019-05-05 17:06:22 +02:00
|
|
|
|
2019-05-07 16:57:41 +02:00
|
|
|
if (props.required.length < 1)
|
|
|
|
return (
|
|
|
|
<div style={styles.container}>
|
|
|
|
<div style={styles.chooser}>
|
|
|
|
<h3>
|
|
|
|
<FormattedMessage id="cfp.noRequiredMeasurements" />
|
|
|
|
</h3>
|
|
|
|
<p>
|
2021-05-23 11:32:10 +02:00
|
|
|
<FormattedMessage id="cfp.howtoAddMeasurements" />
|
2019-05-07 16:57:41 +02:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<FormattedMessage id="cfp.seeDocsAt" />
|
|
|
|
|
2020-10-31 16:53:39 +01:00
|
|
|
<a href={'https://freesewing.dev/core/config'}>
|
2019-06-16 16:47:20 +02:00
|
|
|
{props.language}
|
|
|
|
.freesewing.dev/core/config
|
2019-05-07 16:57:41 +02:00
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-04-25 19:09:02 +02:00
|
|
|
)
|
2019-05-05 17:06:22 +02:00
|
|
|
return (
|
|
|
|
<div style={styles.container}>
|
|
|
|
<div style={styles.chooser}>
|
2020-10-31 16:53:39 +01:00
|
|
|
<h4 id="preload">
|
2019-05-05 17:06:22 +02:00
|
|
|
<FormattedMessage id="cfp.preloadMeasurements" />
|
|
|
|
</h4>
|
2020-10-31 16:53:39 +01:00
|
|
|
<ul style={styles.ul}>
|
2020-04-25 19:09:02 +02:00
|
|
|
{Object.keys(withoutBreasts).map((m) => (
|
2020-10-31 16:53:39 +01:00
|
|
|
<li key={`${m}-without`} style={styles.li}>
|
2020-04-25 19:09:02 +02:00
|
|
|
<Button onClick={() => props.preloadMeasurements(withoutBreasts[m])}>
|
2020-10-31 16:53:39 +01:00
|
|
|
<Icon icon="withoutBreasts" />
|
2019-05-05 17:06:22 +02:00
|
|
|
<FormattedMessage id="cfp.size" />
|
|
|
|
|
|
|
|
{m.slice(-2)}
|
|
|
|
</Button>
|
|
|
|
</li>
|
|
|
|
))}
|
2020-04-25 19:09:02 +02:00
|
|
|
{Object.keys(withBreasts).map((m) => (
|
2020-10-31 16:53:39 +01:00
|
|
|
<li key={`${m}-with`} style={styles.li}>
|
2019-09-06 10:28:29 +02:00
|
|
|
<Button onClick={() => props.preloadMeasurements(withBreasts[m])}>
|
2020-10-31 16:53:39 +01:00
|
|
|
<Icon icon="withBreasts" />
|
2019-09-06 10:28:29 +02:00
|
|
|
<FormattedMessage id="cfp.size" />
|
|
|
|
|
|
|
|
{m.slice(-2)}
|
|
|
|
</Button>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
2019-05-05 17:06:22 +02:00
|
|
|
</div>
|
2020-10-31 16:53:39 +01:00
|
|
|
<div style={styles.chooser}>
|
|
|
|
<h4 id="manual">
|
|
|
|
<FormattedMessage id="cfp.enterMeasurements" />
|
|
|
|
</h4>
|
|
|
|
{props.required.map((m) => (
|
|
|
|
<FormFieldMeasurement
|
|
|
|
key={m}
|
|
|
|
name={m}
|
|
|
|
units={props.units}
|
|
|
|
value={getValue(m)}
|
|
|
|
label={'measurements.' + m}
|
|
|
|
updateValue={props.updateMeasurement}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
2019-05-05 17:06:22 +02:00
|
|
|
</div>
|
2020-04-25 19:09:02 +02:00
|
|
|
)
|
|
|
|
}
|
2019-05-05 17:06:22 +02:00
|
|
|
|
2020-04-25 19:09:02 +02:00
|
|
|
export default Measurements
|