❗ Antd design의 Modal

Modal.error({
    title: "오류 제목",
    content: "오류 내용",
  });
import { Modal } from 'antd';
import { EXCEPTION_MODAL_TITLE } from './constants';

export const exceptionModal = (ERROR_MESSAGE: string) => {
  Modal.error({
		// EXCEPTION_MODAL_TITLE = '오류'
    title: `${EXCEPTION_MODAL_TITLE}`,
    content: `${ERROR_MESSAGE}`,
  });
};

🎯 입력값이 없을 때 예외 처리하기

// TodoCreate.tsx
const TodoCreate = ({ nextId, createTodo, incrementNextId }: TodoCreateProps) => {
	const [startDate, setStartDate] = useState('');
  const [deadline, setDeadline] = useState('');
  const [value, setValue] = useState('');

  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => 
		setValue(e.target.value);

  const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();

    if (!value) {
			// BLANK_ERROR_MESSAGE = '검색어를 입력해주세요.'
      exceptionModal(BLANK_ERROR_MESSAGE);

      return;
    }

		// 다음 예외 처리
    if (!startDate || !deadline) {
			// SELECT_NOT_ERROR_MESSAGE : '시작일, 목표 완료일을 선택해주세요.'
      exceptionModal(SELECT_NOT_ERROR_MESSAGE);

      return;
    }
  };

  return (
    <>
      <InsertFormPositioner>
        <InsertForm onSubmit={handleSubmit}>
          ...
          <RangePickerWrapper onChange={handleDateChange} />
					...
        </InsertForm>
      </InsertFormPositioner>
    </>
  );
};

🎯 시작일, 목표 완료일이 없을 때 예외 처리

    if (!startDate || !deadline) {
			// SELECT_NOT_ERROR_MESSAGE : '시작일, 목표 완료일을 선택해주세요.'
      exceptionModal(SELECT_NOT_ERROR_MESSAGE);

      return;
    }