import { useState } from "react"; import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import { LocalizationProvider, TimePicker } from "@mui/x-date-pickers" function TimePickerField({ dataChange, setData, data }) { const [value, setValue] = useState('00:00'); return (
{ if (clockType === 'hours') { return dataChange.is_morgen ? !(16 > timeValue.$H && timeValue.$H > 5) : !(24 > timeValue.$H && timeValue.$H > 11) } }} views={['hours', 'minutes']} placeholder="انتخاب کنید..." onChange={e => { const hours = e.$H; const minute = e.$m; const handleTwoLength = value => String(value).length === 1 ? `0${value}` : value const newValue = `${handleTwoLength(hours)}:${handleTwoLength(minute)}`; const newData = data; const { idx, is_morning } = dataChange; newData[idx][is_morning ? 'morning_time' : 'evening_time'] = newValue setValue(newValue); }} sx={{ '& .MuiFormLabel-root': { top: '-4px !important' }, '& .MuiInputBase-input': { padding: '12.5px 14px' }, '& .MuiOutlinedInput-notchedOutline': { border: '1px solid #D7D7D7 !important' }, '& .MuiInputBase-root': { borderRadius: '8px !important' }, '.Mui-focused': { '& .MuiOutlinedInput-notchedOutline': { border: '1px solid #5559CE !important', transition: '0.5s all' } }, '& .muirtl-jv54yp-MuiList-root-MuiMultiSectionDigitalClockSection-root::after': { display: 'none !important' } }} />

{value}

) } export default TimePickerField