diff --git a/src/components/header/index.tsx b/src/components/header/index.tsx
index 278c925..0e35247 100644
--- a/src/components/header/index.tsx
+++ b/src/components/header/index.tsx
@@ -1,9 +1,5 @@
import Logo from '@components/logo';
import Container from './index.style';
-import { useRecoilState } from 'recoil';
-import { selectedPatternIdState } from '@context/pattern';
-import { selectedWheelIdState } from '@context/wheel';
-import { useEffect } from 'react';
import { useNavigate } from 'react-router';
interface HeaderProps {
@@ -12,13 +8,6 @@ interface HeaderProps {
function Header(props: HeaderProps) {
const navigate = useNavigate();
- const [, setSelectedPattern] = useRecoilState(selectedPatternIdState);
- const [, setSelectedWheel] = useRecoilState(selectedWheelIdState);
-
- useEffect(() => {
- setSelectedPattern(0);
- setSelectedWheel(0);
- }, []);
return (
diff --git a/src/context/accessory.ts b/src/context/accessory.ts
new file mode 100644
index 0000000..07488fe
--- /dev/null
+++ b/src/context/accessory.ts
@@ -0,0 +1,6 @@
+import { atom } from 'recoil';
+
+export const selectedAccessoryState = atom({
+ key: 'selectedAccessoryState',
+ default: 0,
+});
diff --git a/src/context/color.ts b/src/context/color.ts
index ea1889e..f92e155 100644
--- a/src/context/color.ts
+++ b/src/context/color.ts
@@ -1,6 +1,6 @@
import { atom } from 'recoil';
-export const selectedColorIdState = atom({
+export const selectedColorState = atom({
key: 'selectedColorIdState',
default: 0,
});
diff --git a/src/context/font.ts b/src/context/font.ts
index a3268a2..8bb8e40 100644
--- a/src/context/font.ts
+++ b/src/context/font.ts
@@ -1,6 +1,6 @@
import { atom } from 'recoil';
-export const selectedFontIdState = atom({
+export const selectedFontState = atom({
key: 'selectedFontIdState',
default: 0,
});
diff --git a/src/context/pattern.ts b/src/context/pattern.ts
index 010d9d9..6acb9a4 100644
--- a/src/context/pattern.ts
+++ b/src/context/pattern.ts
@@ -1,6 +1,6 @@
import { atom } from 'recoil';
-export const selectedPatternIdState = atom({
+export const selectedPatternState = atom({
key: 'selectedPatternState',
default: 0,
});
diff --git a/src/context/wheel.ts b/src/context/wheel.ts
index 2c29169..6965894 100644
--- a/src/context/wheel.ts
+++ b/src/context/wheel.ts
@@ -1,6 +1,6 @@
import { atom } from 'recoil';
-export const selectedWheelIdState = atom({
+export const selectedWheelState = atom({
key: 'selectedWheelIdState',
default: 0,
});
diff --git a/src/pages/production/button-group/index.tsx b/src/pages/production/button-group/index.tsx
index 209ee20..737e00a 100644
--- a/src/pages/production/button-group/index.tsx
+++ b/src/pages/production/button-group/index.tsx
@@ -20,7 +20,7 @@ function ButtonGroup(props: ButtonGroupProps) {
diff --git a/src/pages/production/content/summary/index.tsx b/src/pages/production/content/summary/index.tsx
index b16f76e..143aae8 100644
--- a/src/pages/production/content/summary/index.tsx
+++ b/src/pages/production/content/summary/index.tsx
@@ -1,11 +1,12 @@
import useCustomData from '@hooks/useCustomData';
import { Container, Explanation, Name, Price } from './index.style';
import { useSearchParams } from 'react-router-dom';
-import { selectedPatternIdState } from '@context/pattern';
+import { selectedPatternState } from '@context/pattern';
import { useRecoilState } from 'recoil';
-import { selectedWheelIdState } from '@context/wheel';
-import { selectedFontIdState } from '@context/font';
-import { selectedColorIdState } from '@context/color';
+import { selectedWheelState } from '@context/wheel';
+import { selectedFontState } from '@context/font';
+import { selectedColorState } from '@context/color';
+import { selectedAccessoryState } from '@context/accessory';
function formatCurrency(price: number) {
return '+ ' + price.toLocaleString('ko-KR') + '원';
@@ -15,10 +16,11 @@ function Summary() {
const [searchParams] = useSearchParams();
const step: number = Number(searchParams.get('step'));
const { pattern, wheel, font, color, accessory } = useCustomData();
- const [selectedPattern] = useRecoilState(selectedPatternIdState);
- const [selectedWheel] = useRecoilState(selectedWheelIdState);
- const [selectedFont] = useRecoilState(selectedFontIdState);
- const [selectedColor] = useRecoilState(selectedColorIdState);
+ const [selectedPattern] = useRecoilState(selectedPatternState);
+ const [selectedWheel] = useRecoilState(selectedWheelState);
+ const [selectedFont] = useRecoilState(selectedFontState);
+ const [selectedColor] = useRecoilState(selectedColorState);
+ const [selectedAccessory] = useRecoilState(selectedAccessoryState);
if (!pattern.length || !wheel.length || !font.length || !color.length || !accessory.length) {
return
Loading...
;
@@ -69,6 +71,19 @@ function Summary() {
);
+ case 3:
+ return (
+
+
+
{accessory[selectedAccessory].name}
+
{formatCurrency(accessory[selectedAccessory].price)}
+
+
+
+ {accessory[selectedAccessory].explanation}
+
+
+ );
default:
return Error...
;
}
diff --git a/src/pages/production/option-selector/index.tsx b/src/pages/production/option-selector/index.tsx
index e15c5cc..0f857ac 100644
--- a/src/pages/production/option-selector/index.tsx
+++ b/src/pages/production/option-selector/index.tsx
@@ -1,11 +1,12 @@
import { Container, Title } from './index.style';
import Item from './item';
import { useRecoilState } from 'recoil';
-import { selectedPatternIdState } from '@context/pattern';
-import { selectedWheelIdState } from '@context/wheel';
import useCustomData from 'hooks/useCustomData';
-import { selectedFontIdState } from '@context/font';
-import { selectedColorIdState } from '@context/color';
+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';
interface OptionSelectorProps {
shape: 'square' | 'circle';
@@ -14,10 +15,11 @@ interface OptionSelectorProps {
}
function OptionSelector(props: OptionSelectorProps) {
- const [, setSelectedPattern] = useRecoilState(selectedPatternIdState);
- const [, setSelectedWheel] = useRecoilState(selectedWheelIdState);
- const [, setSelectedFont] = useRecoilState(selectedFontIdState);
- const [, setSelectedColor] = useRecoilState(selectedColorIdState);
+ const [, setSelectedPattern] = useRecoilState(selectedPatternState);
+ const [, setSelectedWheel] = useRecoilState(selectedWheelState);
+ const [, setSelectedFont] = useRecoilState(selectedFontState);
+ const [, setSelectedColor] = useRecoilState(selectedColorState);
+ const [, setSelectedAccessory] = useRecoilState(selectedAccessoryState);
const data = getData(props.data);
return (
@@ -46,6 +48,9 @@ function OptionSelector(props: OptionSelectorProps) {
{
props.data === 'color' && setSelectedColor(index);
}
+ {
+ props.data === 'accessory' && setSelectedAccessory(index);
+ }
}}
/>
))}
diff --git a/src/pages/production/option-selector/item/index.tsx b/src/pages/production/option-selector/item/index.tsx
index 8e22cd0..7a91de3 100644
--- a/src/pages/production/option-selector/item/index.tsx
+++ b/src/pages/production/option-selector/item/index.tsx
@@ -1,9 +1,10 @@
import { useRecoilState } from 'recoil';
import { Container, ItemImage, ItemName } from './index.style';
-import { selectedPatternIdState } from '@context/pattern';
-import { selectedWheelIdState } from '@context/wheel';
-import { selectedColorIdState } from '@context/color';
-import { selectedFontIdState } from '@context/font';
+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';
interface ItemProps {
id: number;
@@ -14,10 +15,11 @@ interface ItemProps {
}
function Item(props: ItemProps) {
- const [selectedPattern] = useRecoilState(selectedPatternIdState);
- const [selectedWheel] = useRecoilState(selectedWheelIdState);
- const [selectedFont] = useRecoilState(selectedFontIdState);
- const [selectedColor] = useRecoilState(selectedColorIdState);
+ const [selectedPattern] = useRecoilState(selectedPatternState);
+ const [selectedWheel] = useRecoilState(selectedWheelState);
+ const [selectedFont] = useRecoilState(selectedFontState);
+ const [selectedColor] = useRecoilState(selectedColorState);
+ const [selectedAccessory] = useRecoilState(selectedAccessoryState);
return (
@@ -37,6 +39,9 @@ function Item(props: ItemProps) {
type="circle"
/>
)}
+ {props.data === 'accessory' && (
+
+ )}
{props.name}
);