[common/features] feat: 콘텐츠 페이지 생성
This commit is contained in:
@@ -19,6 +19,15 @@ export class ContentsApiService implements ContentsService {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getLatestApprovedContentsInfo(
|
||||
contsSn: number,
|
||||
): Promise<ContentsDetail> {
|
||||
const response = await client.get<ContentsDetail>(
|
||||
`${ENDPOINT.CMS_SERVICE.CONTENTS}/${contsSn}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getContentsVersionList(
|
||||
params: ContentsVersionParams,
|
||||
): Promise<ContentsVersionList> {
|
||||
|
||||
@@ -81,6 +81,7 @@ export type ContentsVersionList = PageableList<ContentsVersion>;
|
||||
|
||||
export interface ContentsService {
|
||||
getContentsList(params: ContentsParams): Promise<ContentsList>;
|
||||
getLatestApprovedContentsInfo(contsSn: number): Promise<ContentsDetail>;
|
||||
getContentsVersionList(
|
||||
params: ContentsVersionParams,
|
||||
): Promise<ContentsVersionList>;
|
||||
|
||||
@@ -45,7 +45,7 @@ const MenuWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
if (pageMenuAuthority?.length)
|
||||
setPageMenuAuthority(pageMenuAuthority[0]!);
|
||||
})();
|
||||
}, []);
|
||||
}, [pathname]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pageMenuAuthority) return;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { ContentsPage } from "./ui/contents-page";
|
||||
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ContentsApi } from "@/entities/content";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
function ContentsPage({ contsSn }: { contsSn: number }) {
|
||||
const shadowRootRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const { data: contentsDetail } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS, contsSn],
|
||||
queryFn: () => ContentsApi.getLatestApprovedContentsInfo(contsSn),
|
||||
enabled: !!contsSn,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!shadowRootRef.current || !contentsDetail?.contsCn) return;
|
||||
|
||||
const shadowRoot = shadowRootRef.current.attachShadow({ mode: "open" });
|
||||
|
||||
const styleElement = document.createElement("style");
|
||||
styleElement.textContent = `div { font-size: 16px; line-height: 1.5; }`;
|
||||
shadowRoot.appendChild(styleElement);
|
||||
|
||||
const contentElement = document.createElement("div");
|
||||
contentElement.innerHTML = contentsDetail.contsCn;
|
||||
shadowRoot.appendChild(contentElement);
|
||||
}, [contentsDetail?.contsCn]);
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6 !p-6">
|
||||
<div ref={shadowRootRef} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { ContentsPage };
|
||||
Reference in New Issue
Block a user