Skip to content

Commit ebf8cc1

Browse files
authored
Merge pull request #223 from Podo-Store/feat/scriptmanage-routing
feat: 작품 관리 페이지 썸네일, 제목 routing 추가
2 parents 65be57d + 0a3ee59 commit ebf8cc1

File tree

3 files changed

+52
-12
lines changed

3 files changed

+52
-12
lines changed

src/components/myPage/ScriptContent.jsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import circleInfoBtn from "../../assets/image/button/circleInfoBtn.svg";
1313

1414
import "./ScriptContent.scss";
1515
import "./../../styles/utilities.css";
16+
import { useNavigate } from "react-router-dom";
1617

1718
/**
1819
* 구매한 작품 페이지, 작품 관리 페이지의 상품 란,
@@ -22,6 +23,7 @@ import "./../../styles/utilities.css";
2223
* @param {string} props.currentPage - 구매한 작품: "0", 작품 관리: "1"
2324
* @param {component} props.Button - 페이지에 사용할 Button component. e.g. PurchasedScriptBtn.jsx
2425
* @param {string} props.currentTogglePage - PurchasedScript의 토글 버튼. 대본: "0", 공연권: "1"
26+
* @param {boolean} [props.isRoute] - 클릭 시 detail 페이지 이동 활성화 여부, 값 넣을 시 썸네일과 제목에 추가 및 cursor-pointer 적용
2527
*/
2628
const ScriptContent = ({
2729
order,
@@ -30,6 +32,7 @@ const ScriptContent = ({
3032
Button,
3133
// currentTogglePage: PurchasedScript에서 대본, 공연권 토글 여부
3234
currentTogglePage = "0",
35+
isRoute = false,
3336
}) => {
3437
// 삭제된 작가 info 팝업
3538
const [showPopup, setShowPopup] = useState(false);
@@ -41,6 +44,8 @@ const ScriptContent = ({
4144

4245
const { widthConditions } = useWindowDimensions();
4346

47+
const navigate = useNavigate();
48+
4449
return (
4550
<div key={index} className="script-content ">
4651
<p className="date p-large-bold c-grey-8f8f8f">{formattedDate}</p>
@@ -49,7 +54,11 @@ const ScriptContent = ({
4954
<div key={script.id}>
5055
<div className="script">
5156
<div className=" aspect-square thumbnail-img-wrap">
52-
<ThumbnailImg imagePath={script.imagePath}></ThumbnailImg>
57+
<ThumbnailImg
58+
imagePath={script.imagePath}
59+
isRoute={isRoute}
60+
id={script.id}
61+
></ThumbnailImg>
5362
</div>
5463
<div className=" script-tag">
5564
<div
@@ -58,9 +67,20 @@ const ScriptContent = ({
5867
}`}
5968
id="title"
6069
>
61-
<p className="p-large-bold" id="title">
62-
{script.title || "제목 없음"}
63-
</p>
70+
<div className="relative">
71+
<p className="p-large-bold" id="title">
72+
{script.title || "제목 없음"}
73+
</p>
74+
{isRoute && (
75+
<button
76+
className="absolute top-0 size-full cursor-pointer"
77+
style={{ top: 0 }} // 왜 tailwind 안먹음..?
78+
onClick={() => {
79+
navigate(`/list/detail/${script.id}`);
80+
}}
81+
></button>
82+
)}
83+
</div>
6484
{script.delete && (
6585
<img
6686
id="title-info"

src/components/thumbnail/ThumbnailImg.jsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useNavigate } from "react-router-dom";
12
import defaultThumbnail from "./../../assets/image/defaultThumbnail.svg";
23

34
import "./ThumbnailImg.css";
@@ -6,16 +7,29 @@ import "./ThumbnailImg.css";
67
* @param {*} props
78
* @param {*} props.style - e.g. style={{ width: "24.271vw", height: "0", paddingBottom: "24.271vw" }}
89
* @param {*} props.imagePath - 이미지 경로
10+
* @param {boolean} [props.isRoute] - 클릭 시 detail 페이지 이동 활성화 여부, 값 넣을 시 썸네일과 제목에 추가 및 cursor-pointer 적용
11+
* @param {string} [props.id] - 클릭 시 detail 페이지 이동 시 사용할 id
912
* @returns
1013
*/
11-
const ThumbnailImg = ({ children, className, id, style, imagePath }) => {
14+
const ThumbnailImg = ({ className, style, imagePath, isRoute = false, id, ...props }) => {
15+
const navigate = useNavigate();
16+
1217
return (
13-
<div
14-
className={`__thumbnail-img ${className}`}
15-
id={id}
16-
style={{ ...style, backgroundImage: `url(${imagePath || defaultThumbnail})` }}
17-
>
18-
{children}
18+
<div className="relative">
19+
<div
20+
className={`__thumbnail-img ${className}`}
21+
style={{ ...style, backgroundImage: `url(${imagePath || defaultThumbnail})` }}
22+
{...props}
23+
></div>
24+
{isRoute && (
25+
<button
26+
className="absolute top-0 size-full cursor-pointer"
27+
style={{ top: 0 }} // 그러니까 왜 tailwind 안먹음..?
28+
onClick={() => {
29+
navigate(`/list/detail/${id}`);
30+
}}
31+
></button>
32+
)}
1933
</div>
2034
);
2135
};

src/pages/myPage/ScriptManage.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ const ScriptManage = () => {
6060
<PartialLoading />
6161
) : !isNull ? (
6262
productList.map((order, index) => (
63-
<ScriptContent order={order} index={index} currentPage="1" Button={ScriptManageBtn} />
63+
<ScriptContent
64+
order={order}
65+
index={index}
66+
currentPage="1"
67+
Button={ScriptManageBtn}
68+
isRoute={true}
69+
/>
6470
))
6571
) : (
6672
<NullScriptContent currentPage={1} />

0 commit comments

Comments
 (0)