1. QnA Page ๊ฒฝ๋ก ์ง์ ๐ข

2. QnA Page ์ ํ ๐ข
import React, { useState } from "react";
import styled from "@emotion/styled";
import ComponentWrapper from "../components/common/ComponentWrapper";
import { QnALists } from "../data/QnAList";
import { QnAListDetailData } from "../data/QnAListDetail";
const QnABoxWrapper = styled.div`
width: 100%;
`;
const QuestionBox = styled.div`
width: 100%;
height: 100px;
cursor: pointer;
border: 1px solid black;
`;
const AnswerBox = styled.div`
width: 100%;
height: 100px;
background-color: #f2f2f2;
border: 1px solid black;
border-top: none;
overflow: hidden;
transition: height 0.4s ease-in-out;
${({ isVisible }) => (isVisible ? "height: 100px;" : "height: 0;")}
`;
const CategoryButton = styled.div`
cursor: pointer;
`;
const QnAPage = () => {
const [visibleCards, setVisibleCards] = useState({});
const handleCardClick = (cardId) => {
setVisibleCards((prevVisibleCards) => ({
...prevVisibleCards,
[cardId]: !prevVisibleCards[cardId],
}));
};
const [category, setCategory] = useState("์ํ๊ด๋ จ");
const handleSetCategory = (category) => {
setCategory(category);
};
const MapData = QnAListDetailData[category];
return (
<>
{/* ์ ๋ชฉ๊ณผ ์นดํ
๊ณ ๋ฆฌ ๋ฒํผ */}
<ComponentWrapper>
<p>์์ฃผ ๋ฌป๋ ์ง๋ฌธ</p>
<>
{QnALists?.map((elem) => (
<CategoryButton
key={elem.id}
onClick={() => handleSetCategory(elem.category)}
style={{ border: "1px solid black" }}
>
{elem.title}
</CategoryButton>
))}
</>
</ComponentWrapper>
{/* ์นด๋ ์์ญ */}
<ComponentWrapper
style={{
backgroundColor: "yellow",
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
marginTop: "70px",
}}
>
{MapData?.map((elem) => (
<QnABoxWrapper key={elem?.id}>
<QuestionBox onClick={() => handleCardClick(elem?.id)}>
<p>{elem?.title}</p>
<p>{elem?.content}</p>
</QuestionBox>
<AnswerBox isVisible={visibleCards[elem?.id]}>
<p>{elem?.reply}</p>
</AnswerBox>
</QnABoxWrapper>
))}
</ComponentWrapper>
</>
);
};
export default QnAPage;
3. QnA List ์ ํ ๐ข
export const QnALists = [
{
id: "1",
title: "์ํ๊ด๋ จ",
category: "์ํ๊ด๋ จ",
},
{
id: "2",
title: "์ฃผ๋ฌธ/๊ฒฐ์ ",
category: "์ฃผ๋ฌธ/๊ฒฐ์ ",
},
{
id: "3",
title: "๋ฐฐ์ก",
category: "๋ฐฐ์ก",
},
{
id: "4",
title: "๋ณ๊ฒฝ/์ทจ์/๋ฐํ",
category: "๋ณ๊ฒฝ/์ทจ์/๋ฐํ",
},
{
id: "5",
title: "ํ์์ ๋ณด",
category: "ํ์์ ๋ณด",
},
{
id: "6",
title: "์๋น์ค์ด์ฉ",
category: "์๋น์ค์ด์ฉ",
},
];
4. QnA List Detail ์ ํ ๐ข
const productQnA = [
{
id: "1",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์1",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์1",
},
{
id: "2",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์2",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์2",
},
{
id: "3",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์3",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์3",
},
{
id: "4",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์4",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์4",
},
{
id: "5",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์5",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์5",
},
{
id: "6",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์6",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์6",
},
{
id: "7",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์7",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์7",
},
{
id: "8",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์8",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์8",
},
{
id: "9",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์9",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์9",
},
{
id: "10",
title: "์ํ๊ด๋ จ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์10",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์10",
},
];
const orderAndPayQnA = [
{
id: "1",
title: "์ฃผ๋ฌธ/๊ฒฐ์ ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์",
},
];
const deliveryQnA = [
{
id: "1",
title: "๋ฐฐ์ก",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์",
},
];
const modificationEtcQnA = [
{
id: "1",
title: "๋ณ๊ฒฝ/์ทจ์/๋ฐํ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์",
},
];
const userInfoQnA = [
{
id: "1",
title: "ํ์์ ๋ณด",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์",
},
];
const serviceUsageQnA = [
{
id: "1",
title: "์๋น์ค์ด์ฉ",
content: "์ด๊ฑฐ ๋ชจ๋ฅด๊ฒ ์ด์",
reply: "์ด๊ฒ๋ ๋ชจ๋ฅด๋ ๋ฐ๋ณด์",
},
];
export const QnAListDetailData = {
์ํ๊ด๋ จ: productQnA,
"์ฃผ๋ฌธ/๊ฒฐ์ ": orderAndPayQnA,
๋ฐฐ์ก: deliveryQnA,
"๋ณ๊ฒฝ/์ทจ์/๋ฐํ": modificationEtcQnA,
ํ์์ ๋ณด: userInfoQnA,
์๋น์ค์ด์ฉ: serviceUsageQnA,
};
5. ํ์ฌ ๋ชจ์ต ๐ข