[2] fix required problem for project fields

This commit is contained in:
maxim 2025-03-28 02:26:18 +03:00
parent 754569b41d
commit d2e243ba64
6 changed files with 29 additions and 30 deletions

View File

@ -93,7 +93,7 @@ export const CarrierCreate = () => {
<TextField <TextField
{...register('main_color', { {...register('main_color', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.main_color} error={!!(errors as any)?.main_color}
helperText={(errors as any)?.main_color?.message} helperText={(errors as any)?.main_color?.message}
@ -101,7 +101,7 @@ export const CarrierCreate = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="color" type="color"
label={'Основной цвет *'} label={'Основной цвет'}
name="main_color" name="main_color"
sx={{ sx={{
'& input': { '& input': {
@ -115,7 +115,7 @@ export const CarrierCreate = () => {
<TextField <TextField
{...register('left_color', { {...register('left_color', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.left_color} error={!!(errors as any)?.left_color}
helperText={(errors as any)?.left_color?.message} helperText={(errors as any)?.left_color?.message}
@ -123,7 +123,7 @@ export const CarrierCreate = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="color" type="color"
label={'Цвет левого виджета *'} label={'Цвет левого виджета'}
name="left_color" name="left_color"
sx={{ sx={{
'& input': { '& input': {
@ -136,7 +136,7 @@ export const CarrierCreate = () => {
/> />
<TextField <TextField
{...register('right_color', { {...register('right_color', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.right_color} error={!!(errors as any)?.right_color}
helperText={(errors as any)?.right_color?.message} helperText={(errors as any)?.right_color?.message}
@ -144,7 +144,7 @@ export const CarrierCreate = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="color" type="color"
label={'Цвет правого виджета *'} label={'Цвет правого виджета'}
name="right_color" name="right_color"
sx={{ sx={{
'& input': { '& input': {
@ -158,7 +158,7 @@ export const CarrierCreate = () => {
<TextField <TextField
{...register('slogan', { {...register('slogan', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.slogan} error={!!(errors as any)?.slogan}
helperText={(errors as any)?.slogan?.message} helperText={(errors as any)?.slogan?.message}
@ -166,14 +166,14 @@ export const CarrierCreate = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="text" type="text"
label={'Слоган *'} label={'Слоган'}
name="slogan" name="slogan"
/> />
<Controller <Controller
control={control} control={control}
name="logo" name="logo"
rules={{required: 'Это поле является обязательным'}} // rules={{required: 'Это поле является обязательным'}}
defaultValue={null} defaultValue={null}
render={({field}) => ( render={({field}) => (
<Autocomplete <Autocomplete
@ -191,7 +191,7 @@ export const CarrierCreate = () => {
filterOptions={(options, {inputValue}) => { filterOptions={(options, {inputValue}) => {
return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase())) return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase()))
}} }}
renderInput={(params) => <TextField {...params} label="Выберите логотип" margin="normal" variant="outlined" error={!!errors.logo} helperText={(errors as any)?.logo?.message} required />} renderInput={(params) => <TextField {...params} label="Выберите логотип" margin="normal" variant="outlined" error={!!errors.logo} helperText={(errors as any)?.logo?.message} />}
/> />
)} )}
/> />

View File

@ -92,7 +92,7 @@ export const CarrierEdit = () => {
<TextField <TextField
{...register('main_color', { {...register('main_color', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.main_color} error={!!(errors as any)?.main_color}
helperText={(errors as any)?.main_color?.message} helperText={(errors as any)?.main_color?.message}
@ -100,7 +100,7 @@ export const CarrierEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="color" type="color"
label={'Основной цвет *'} label={'Основной цвет'}
name="main_color" name="main_color"
sx={{ sx={{
'& input': { '& input': {
@ -114,7 +114,7 @@ export const CarrierEdit = () => {
<TextField <TextField
{...register('left_color', { {...register('left_color', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.left_color} error={!!(errors as any)?.left_color}
helperText={(errors as any)?.left_color?.message} helperText={(errors as any)?.left_color?.message}
@ -122,7 +122,7 @@ export const CarrierEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="color" type="color"
label={'Цвет левого виджета *'} label={'Цвет левого виджета'}
name="left_color" name="left_color"
sx={{ sx={{
'& input': { '& input': {
@ -135,7 +135,7 @@ export const CarrierEdit = () => {
/> />
<TextField <TextField
{...register('right_color', { {...register('right_color', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.right_color} error={!!(errors as any)?.right_color}
helperText={(errors as any)?.right_color?.message} helperText={(errors as any)?.right_color?.message}
@ -143,7 +143,7 @@ export const CarrierEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="color" type="color"
label={'Цвет правого виджета *'} label={'Цвет правого виджета'}
name="right_color" name="right_color"
sx={{ sx={{
'& input': { '& input': {
@ -157,7 +157,7 @@ export const CarrierEdit = () => {
<TextField <TextField
{...register('slogan', { {...register('slogan', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.slogan} error={!!(errors as any)?.slogan}
helperText={(errors as any)?.slogan?.message} helperText={(errors as any)?.slogan?.message}
@ -165,14 +165,14 @@ export const CarrierEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="text" type="text"
label={'Слоган *'} label={'Слоган'}
name="slogan" name="slogan"
/> />
<Controller <Controller
control={control} control={control}
name="logo" name="logo"
rules={{required: 'Это поле является обязательным'}} // rules={{required: 'Это поле является обязательным'}}
defaultValue={null} defaultValue={null}
render={({field}) => ( render={({field}) => (
<Autocomplete <Autocomplete
@ -190,7 +190,7 @@ export const CarrierEdit = () => {
filterOptions={(options, {inputValue}) => { filterOptions={(options, {inputValue}) => {
return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase())) return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase()))
}} }}
renderInput={(params) => <TextField {...params} label="Выберите логотип" margin="normal" variant="outlined" error={!!errors.logo} helperText={(errors as any)?.logo?.message} required />} renderInput={(params) => <TextField {...params} label="Выберите логотип" margin="normal" variant="outlined" error={!!errors.logo} helperText={(errors as any)?.logo?.message} />}
/> />
)} )}
/> />

View File

@ -70,7 +70,6 @@ export const CityCreate = () => {
<Controller <Controller
control={control} control={control}
name="arms" name="arms"
rules={{required: 'Это поле является обязательным'}}
defaultValue={null} defaultValue={null}
render={({field}) => ( render={({field}) => (
<Autocomplete <Autocomplete
@ -88,7 +87,7 @@ export const CityCreate = () => {
filterOptions={(options, {inputValue}) => { filterOptions={(options, {inputValue}) => {
return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase())) return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase()))
}} }}
renderInput={(params) => <TextField {...params} label="Выберите герб" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />} renderInput={(params) => <TextField {...params} label="Выберите герб" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} />}
/> />
)} )}
/> />

View File

@ -69,7 +69,7 @@ export const CityEdit = () => {
<Controller <Controller
control={control} control={control}
name="arms" name="arms"
rules={{required: 'Это поле является обязательным'}} // rules={{required: 'Это поле является обязательным'}}
defaultValue={null} defaultValue={null}
render={({field}) => ( render={({field}) => (
<Autocomplete <Autocomplete
@ -87,7 +87,7 @@ export const CityEdit = () => {
filterOptions={(options, {inputValue}) => { filterOptions={(options, {inputValue}) => {
return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase())) return options.filter((option) => option.filename.toLowerCase().includes(inputValue.toLowerCase()))
}} }}
renderInput={(params) => <TextField {...params} label="Выберите герб" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} required />} renderInput={(params) => <TextField {...params} label="Выберите герб" margin="normal" variant="outlined" error={!!errors.arms} helperText={(errors as any)?.arms?.message} />}
/> />
)} )}
/> />

View File

@ -32,7 +32,7 @@ export const StationCreate = () => {
/> />
<TextField <TextField
{...register('description', { {...register('description', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.description} error={!!(errors as any)?.description}
helperText={(errors as any)?.description?.message} helperText={(errors as any)?.description?.message}
@ -40,7 +40,7 @@ export const StationCreate = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="text" type="text"
label={'Описание *'} label={'Описание'}
name="description" name="description"
/> />
<TextField <TextField

View File

@ -27,12 +27,12 @@ export const StationEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="text" type="text"
label={'Название'} label={'Название *'}
name="name" name="name"
/> />
<TextField <TextField
{...register('description', { {...register('description', {
required: 'Это поле является обязательным', // required: 'Это поле является обязательным',
})} })}
error={!!(errors as any)?.description} error={!!(errors as any)?.description}
helperText={(errors as any)?.description?.message} helperText={(errors as any)?.description?.message}
@ -54,7 +54,7 @@ export const StationEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="number" type="number"
label={'Широта'} label={'Широта *'}
name="latitude" name="latitude"
/> />
<TextField <TextField
@ -68,7 +68,7 @@ export const StationEdit = () => {
fullWidth fullWidth
InputLabelProps={{shrink: true}} InputLabelProps={{shrink: true}}
type="number" type="number"
label={'Долгота'} label={'Долгота *'}
name="longitude" name="longitude"
/> />
</Box> </Box>