import React, { useEffect, useState } from 'react' export default function FormInputTime({ value = '10:20', onChange, label = '', error, }) { const clocks = Array.from(Array(24).keys()) const minutes = Array.from(Array(61).keys()) const [clock, setClock] = useState('') const [minute, setMinute] = useState('') const selectTime = (v, s) => { if (s === 'm') { setMinute(v) onChange(`${clock}:${v}`) } if (s === 'c') { setClock(v) onChange(`${v}:${minute}`) } } useEffect(() => { setClock(Math.abs(value.split(':')[0])) setMinute(Math.abs(value.split(':')[1])) }, [value]) return (
{label !== '' && ( )}
{error && (

{error}

)}
) }