フォームのバリデーションとニコ連携の画面変更 (#090) #355
@@ -31,6 +31,7 @@ const PostOriginalCreatedTimeField: FC<Props> = (
|
|||||||
className="mr-2"
|
className="mr-2"
|
||||||
disabled={disabled ?? false}
|
disabled={disabled ?? false}
|
||||||
aria-invalid={errors && errors.length > 0}
|
aria-invalid={errors && errors.length > 0}
|
||||||
|
invalid={errors && errors.length > 0}
|
||||||
value={originalCreatedFrom ?? undefined}
|
value={originalCreatedFrom ?? undefined}
|
||||||
onChange={setOriginalCreatedFrom}
|
onChange={setOriginalCreatedFrom}
|
||||||
onBlur={ev => {
|
onBlur={ev => {
|
||||||
@@ -65,6 +66,7 @@ const PostOriginalCreatedTimeField: FC<Props> = (
|
|||||||
className="mr-2"
|
className="mr-2"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
aria-invalid={errors && errors.length > 0}
|
aria-invalid={errors && errors.length > 0}
|
||||||
|
invalid={errors && errors.length > 0}
|
||||||
value={originalCreatedBefore ?? undefined}
|
value={originalCreatedBefore ?? undefined}
|
||||||
onChange={setOriginalCreatedBefore}/>
|
onChange={setOriginalCreatedBefore}/>
|
||||||
より前
|
より前
|
||||||
|
|||||||
@@ -22,10 +22,11 @@ type Props = Omit<ComponentPropsWithoutRef<'input'>, 'onChange'> & {
|
|||||||
value?: string
|
value?: string
|
||||||
onChange?: (isoUTC: string | null) => void
|
onChange?: (isoUTC: string | null) => void
|
||||||
className?: string
|
className?: string
|
||||||
onBlur?: (ev: FocusEvent<HTMLInputElement>) => void }
|
onBlur?: (ev: FocusEvent<HTMLInputElement>) => void
|
||||||
|
invalid?: boolean }
|
||||||
|
|
||||||
|
|
||||||
const DateTimeField: FC<Props> = ({ value, onChange, className, onBlur, ...rest }) => {
|
const DateTimeField: FC<Props> = ({ value, onChange, className, onBlur, invalid, ...rest }) => {
|
||||||
const [local, setLocal] = useState ('')
|
const [local, setLocal] = useState ('')
|
||||||
|
|
||||||
useEffect (() => {
|
useEffect (() => {
|
||||||
@@ -35,9 +36,19 @@ const DateTimeField: FC<Props> = ({ value, onChange, className, onBlur, ...rest
|
|||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
{...rest}
|
{...rest}
|
||||||
className={cn ('border rounded p-2', className)}
|
className={cn ('border rounded p-2',
|
||||||
|
(invalid
|
||||||
|
? ['border-red-500 bg-red-50 text-red-900',
|
||||||
|
'focus:border-red-500 focus:outline-none',
|
||||||
|
'focus:ring-2 focus:ring-red-200',
|
||||||
|
'dark:border-red-500 dark:bg-red-950/30 dark:text-red-100']
|
||||||
|
: ['border-gray-300',
|
||||||
|
'focus:border-blue-500 focus:outline-none',
|
||||||
|
'focus:ring-2 focus:ring-blue-200']),
|
||||||
|
className)}
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
value={local}
|
value={local}
|
||||||
|
aria-invalid={invalid}
|
||||||
onChange={ev => {
|
onChange={ev => {
|
||||||
const v = ev.target.value
|
const v = ev.target.value
|
||||||
setLocal (v)
|
setLocal (v)
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする