1
0
Fork 0

wip(fs.lab): Work on workbench components

This commit is contained in:
Joost De Cock 2022-01-25 08:31:06 +01:00
parent 8703983f2f
commit 22b25c0c5d
5 changed files with 242 additions and 63 deletions

View file

@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
/*
* This is a single input for a measurements
@ -11,7 +11,6 @@ import React, { useState } from 'react'
const MeasurementInput = ({ m, gist, app, updateMeasurements }) => {
const prefix = (app.site === 'org') ? '' : 'https://freesewing.org'
const title = app.t(`measurements.${m}`)
console.log('render', m)
const isValid = input => {
if (input === null || input === '') return null
return !isNaN(input)
@ -23,7 +22,7 @@ const MeasurementInput = ({ m, gist, app, updateMeasurements }) => {
console.log({ok})
if (ok) {
setValid(true)
updateMeasurements(evt.target.value, m)
updateMeasurements(evt.target.value*10, m)
} else setValid(false)
}
@ -33,6 +32,11 @@ const MeasurementInput = ({ m, gist, app, updateMeasurements }) => {
isValid(gist.measurements[m])
)
useEffect(() => {
console.log(gist.measurements)
if (gist?.measurements?.[m]) setVal(gist.measurements[m]/10)
}, [gist])
if (!m) return null
return (