@@ -51,6 +71,7 @@ function ContentsForm({ form, contsSn, ...props }: ContentsFormProps) {
value={field.value ?? ""}
className="!text-[1.3rem]"
placeholder="콘텐츠 제목을 입력하십시오."
+ disabled={disabledFields?.contsTtl}
/>
@@ -93,13 +114,33 @@ function ContentsForm({ form, contsSn, ...props }: ContentsFormProps) {
onValueChange={field.onChange}
>
-
-
-
-
-
-
+
+
+ {cclCode?.map((code) => (
+
+
+
+
+ ))}
@@ -123,13 +164,35 @@ function ContentsForm({ form, contsSn, ...props }: ContentsFormProps) {
onValueChange={field.onChange}
>
-
-
-
-
-
-
+
+
+ {koglCode?.map((code) => (
+
+ ))}
diff --git a/apps/cs/src/pages/contents/ui/modify-page.tsx b/apps/cs/src/pages/contents/ui/modify-page.tsx
new file mode 100644
index 000000000..52241a5cc
--- /dev/null
+++ b/apps/cs/src/pages/contents/ui/modify-page.tsx
@@ -0,0 +1,127 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { useForm } from "react-hook-form";
+import { useMutation, useQuery } from "@tanstack/react-query";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { ENDPOINT } from "@/shared/config";
+import { useAlertStore } from "@/shared/lib/use-alert-store";
+import {
+ CONTENTS_APPROVAL_STATUS,
+ ContentsApi,
+ contentsFormSchema,
+ type ContentsFormData,
+} from "@/entities/content";
+import { ContentsForm } from "./contents-form";
+import {
+ Select,
+ SelectTrigger,
+ SelectValue,
+ SelectContent,
+ SelectItem,
+} from "@common/components/ui";
+
+function ModifyPage({ sequential }: { sequential: string }) {
+ const { setMessage: alert } = useAlertStore((state) => state);
+
+ const [contentsVersion, setContentsVersion] = useState(0);
+ const [disabledFields, setDisabledFields] = useState<
+ Partial
>
+ >({});
+
+ const { data: contentsVersionList } = useQuery({
+ queryKey: [ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS, sequential],
+ queryFn: () =>
+ ContentsApi.getContentsVersionList({
+ contsSn: Number(sequential),
+ page: 0,
+ size: 100,
+ }),
+ });
+
+ const { data: contentsDetail } = useQuery({
+ queryKey: [ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS, contentsVersion],
+ queryFn: () =>
+ ContentsApi.getLatestContentsInfo(Number(sequential), contentsVersion),
+ enabled: !!contentsVersion,
+ });
+
+ const { mutateAsync: createContents } = useMutation({
+ mutationFn: (data: ContentsFormData) => ContentsApi.createContents(data),
+ onSuccess: () => {
+ alert("수정되었습니다.");
+ },
+ });
+
+ const { mutateAsync: updateContents } = useMutation({
+ mutationFn: (data: ContentsFormData) =>
+ ContentsApi.updateContents(
+ Number(sequential),
+ contentsDetail?.contsVer ?? 0,
+ data,
+ ),
+ onSuccess: () => {
+ alert("수정되었습니다.");
+ },
+ });
+
+ const form = useForm({
+ resolver: zodResolver(contentsFormSchema),
+ values: contentsDetail,
+ });
+
+ const isApprovedContents =
+ contentsDetail?.aprvCd === CONTENTS_APPROVAL_STATUS.APPROVED;
+
+ useEffect(() => {
+ if (!contentsVersionList?.content?.length) return;
+
+ const latestContent = contentsVersionList?.content[0];
+ if (!latestContent) return;
+
+ if (latestContent?.contsVer > 1) {
+ setDisabledFields({
+ contsTtl: true,
+ });
+ }
+ setContentsVersion(latestContent?.contsVer ?? 0);
+ }, [contentsVersionList?.content]);
+
+ return (
+
+
+
템플릿 수정
+
+
+
+
+
+
+ );
+}
+
+export { ModifyPage };
diff --git a/apps/cs/src/pages/file/model/table-columns.tsx b/apps/cs/src/pages/file/model/table-columns.tsx
index 0bc7e5c23..2606397c9 100644
--- a/apps/cs/src/pages/file/model/table-columns.tsx
+++ b/apps/cs/src/pages/file/model/table-columns.tsx
@@ -28,6 +28,10 @@ export const createColumns = (
{
accessorKey: "atflFlieSz",
header: "파일크기",
+ cell: ({ row }) => {
+ const size = row.getValue("atflFlieSz");
+ return size ? formatFileSize(Number(size)) : "0 Bytes";
+ },
},
{
@@ -60,3 +64,14 @@ export const createColumns = (
),
},
];
+
+const formatFileSize = (bytes: number): string => {
+ console.log("bytes: ", bytes);
+ if (bytes === 0) return "0 Bytes";
+
+ const k = 1024;
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
+
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
+};