From 5165ab431907e08181f0477ecdd25face56e9591 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Mon, 4 Mar 2024 11:40:04 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=EC=BB=A4=EC=8A=A4=ED=85=80=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=EB=AC=BC=20=EC=A0=80=EC=9E=A5=20=EB=B0=8F=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EC=A0=95=EC=9D=98=20#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/result.types.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/api/result.types.ts diff --git a/src/api/result.types.ts b/src/api/result.types.ts new file mode 100644 index 0000000..1e2ccd8 --- /dev/null +++ b/src/api/result.types.ts @@ -0,0 +1,26 @@ +import { AccessoryData } from './accessory.types'; +import { ColorData } from './color.types'; +import { FontData } from './font.types'; +import { PatternData } from './pattern.types'; +import { WheelData } from './wheel.types'; + +export interface ResultData { + patternId: number; + wheelId: number; + fontId: number; + colorId: number; + accessoryId: number; +} + +export interface PostResultBody { + id: string; +} + +export interface ResultInfo { + id: string; + pattern: PatternData; + wheel: WheelData; + font: FontData; + color: ColorData; + accessory: AccessoryData; +} From d2346ca130ecb8410999781135cb9f1abaf8dad5 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Mon, 4 Mar 2024 12:03:41 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=EA=B2=B0=EA=B3=BC=EB=AC=BC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=B0=8F=20=EC=A0=80=EC=9E=A5=20API=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/result.ts | 21 +++++++++++++++++++++ src/api/result.types.ts | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/api/result.ts diff --git a/src/api/result.ts b/src/api/result.ts new file mode 100644 index 0000000..431319b --- /dev/null +++ b/src/api/result.ts @@ -0,0 +1,21 @@ +import axios, { AxiosResponse } from 'axios'; +import { PostResultBody, ResultData, ResultInfo } from './result.types'; + +const instance = axios.create({ + baseURL: `${process.env.REACT_APP_API_URL}/api/results`, + timeout: 15000, + withCredentials: true, +}); + +const responseBody = (response: AxiosResponse) => response.data; +// const responseStatus = (response: AxiosResponse) => response.status; + +const resultRequests = { + get: (url: string) => instance.get(url).then(responseBody), + post: (url: string, body: B) => instance.post(url, body).then(responseBody), +}; + +export const Result = { + read: (id: string): Promise => resultRequests.get(id), + create: (body: PostResultBody): Promise => resultRequests.post('', body), +}; diff --git a/src/api/result.types.ts b/src/api/result.types.ts index 1e2ccd8..e097c04 100644 --- a/src/api/result.types.ts +++ b/src/api/result.types.ts @@ -4,7 +4,7 @@ import { FontData } from './font.types'; import { PatternData } from './pattern.types'; import { WheelData } from './wheel.types'; -export interface ResultData { +export interface PostResultBody { patternId: number; wheelId: number; fontId: number; @@ -12,11 +12,11 @@ export interface ResultData { accessoryId: number; } -export interface PostResultBody { +export interface ResultInfo { id: string; } -export interface ResultInfo { +export interface ResultData { id: string; pattern: PatternData; wheel: WheelData; From 288b55313bf015e9702631550564dfc43252dadd Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Mon, 4 Mar 2024 12:06:45 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=EA=B2=B0=EA=B3=BC=EB=AC=BC=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?#27?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/production/button-group/index.tsx | 27 ++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/pages/production/button-group/index.tsx b/src/pages/production/button-group/index.tsx index 737e00a..f262ac5 100644 --- a/src/pages/production/button-group/index.tsx +++ b/src/pages/production/button-group/index.tsx @@ -1,6 +1,14 @@ import Button from '@components/button'; import { Container } from './index.style'; import { useNavigate } from 'react-router'; +import { Result } from '@api/result'; +import { useRecoilState } from 'recoil'; +import { selectedPatternState } from '@context/pattern'; +import { selectedWheelState } from '@context/wheel'; +import { selectedFontState } from '@context/font'; +import { selectedColorState } from '@context/color'; +import { selectedAccessoryState } from '@context/accessory'; +import { ResultInfo } from '@api/result.types'; interface ButtonGroupProps { step: number; @@ -9,6 +17,11 @@ interface ButtonGroupProps { function ButtonGroup(props: ButtonGroupProps) { const navigate = useNavigate(); + const [selectedPattern] = useRecoilState(selectedPatternState); + const [selectedWheel] = useRecoilState(selectedWheelState); + const [selectedFont] = useRecoilState(selectedFontState); + const [selectedColor] = useRecoilState(selectedColorState); + const [selectedAccessory] = useRecoilState(selectedAccessoryState); return ( @@ -20,7 +33,19 @@ function ButtonGroup(props: ButtonGroupProps) {