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. íěŹ ëŞ¨ěľ đ˘