All files / src/components/pages/create-group/fields/detail-feild index.tsx

0% Statements 0/36
0% Branches 0/1
0% Functions 0/1
0% Lines 0/36

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                                         
'use client';

import { AnyFieldApi } from '@tanstack/react-form';

import { Hint, Label } from '@/components/ui';

interface Props {
  field: AnyFieldApi;
}

export const GroupDetailField = ({ field }: Props) => {
  const isInvalid = field.state.meta.isTouched && !field.state.meta.isValid;

  return (
    <div className='mt-3 flex w-full flex-col gap-1'>
      <Label htmlFor='create-group-Detail' required>
        모임 상세 정보
      </Label>
      <textarea
        id='create-group-Detail'
        className='bg-mono-white scrollbar-thin focus:border-mint-500 text-text-md-medium h-40 w-full resize-none rounded-2xl border border-gray-300 px-5 py-4 text-gray-800 focus:outline-none'
        maxLength={300}
        placeholder='모임에 대해 설명해주세요'
        required
        value={field.state.value}
        onChange={(e) => field.handleChange(e.target.value)}
      />
      <div className='mt-0.5 flex'>
        {isInvalid && <Hint message={field.state.meta.errors[0].message} />}
        <div className='text-text-sm-medium ml-auto text-right text-gray-500'>
          {field.state.value.length}/300
        </div>
      </div>
    </div>
  );
};