From 2ff81fd6ec73073926372fa2032693eb6273502c Mon Sep 17 00:00:00 2001 From: ywlee Date: Sat, 30 Sep 2023 22:18:19 +0900 Subject: [PATCH 01/12] =?UTF-8?q?[feat]=20api=20=ED=98=B8=EC=B6=9C=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/api/index.ts b/api/index.ts index 110fe82..8417ddd 100644 --- a/api/index.ts +++ b/api/index.ts @@ -5,27 +5,16 @@ export const fetchData = async (url: string, options?: RequestInit): Promise< const response = await fetch(`${baseURL}${url}`, options); if (response.status === 204) { - // error is: "Type 'null' is not assignable to type 'T'." return null; } - if (!response.ok) { - throw new Error('Failed to fetch data'); - } - - // TODO:나중에 삭제 try { const data = await response.json(); return data; } catch (e) { - if (response.status === 200) { - return null; - } + throw Error('에러 응답값이 없습니다'); } - const data = await response.json(); - return data; } catch (error) { - console.error(error); - throw new Error('Failed to fetch data'); + throw new Error('Failed to fetch data', error as Error); } }; From 10562948a8f8249532fe6134f714e5e90c6462ac Mon Sep 17 00:00:00 2001 From: ywlee Date: Sat, 30 Sep 2023 23:28:10 +0900 Subject: [PATCH 02/12] =?UTF-8?q?[feat]=20=EB=A9=80=ED=8B=B0=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MultiButton/MultiButton.tsx | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 components/MultiButton/MultiButton.tsx diff --git a/components/MultiButton/MultiButton.tsx b/components/MultiButton/MultiButton.tsx new file mode 100644 index 0000000..3e8514f --- /dev/null +++ b/components/MultiButton/MultiButton.tsx @@ -0,0 +1,60 @@ +import React, { useCallback, useEffect, useMemo } from 'react'; +import { UseFormRegisterReturn } from 'react-hook-form'; +import Button from '../Button/Button'; +import { Option } from '../Radio/Radio'; + +interface MultiButtonProps { + options: Option[]; + register: UseFormRegisterReturn; + onChange?: (value: string) => void; +} + +function MultiButton({ options, register }: MultiButtonProps) { + const [selected, setSelected] = React.useState