diff --git a/apps/common/features/src/pages/(pst)/notice/ui/modify-page.tsx b/apps/common/features/src/pages/(pst)/notice/ui/modify-page.tsx
index 1bff638f8..897b72e62 100644
--- a/apps/common/features/src/pages/(pst)/notice/ui/modify-page.tsx
+++ b/apps/common/features/src/pages/(pst)/notice/ui/modify-page.tsx
@@ -1,6 +1,5 @@
"use client";
-import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { useMutation, useQuery } from "@tanstack/react-query";
@@ -11,7 +10,7 @@ import {
type PostUpdateFormData,
} from "@/entities/post";
import { ENDPOINT } from "@/shared/config";
-import { setCookie, useAlertStore, useUserStore } from "@/shared/lib";
+import { useAlertStore, useUserStore } from "@/shared/lib";
function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
const { setMessage: alert } = useAlertStore((state) => state);
@@ -39,10 +38,6 @@ function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) {
},
});
- useEffect(() => {
- setCookie("atfl-cd-key", "");
- }, []);
-
return (
diff --git a/apps/common/features/src/widgets/post/model/post-table-columns.tsx b/apps/common/features/src/widgets/post/model/post-table-columns.tsx
index 153593607..8500cf653 100644
--- a/apps/common/features/src/widgets/post/model/post-table-columns.tsx
+++ b/apps/common/features/src/widgets/post/model/post-table-columns.tsx
@@ -6,7 +6,7 @@ import type { Post } from "@/entities/post";
export const columns: ColumnDef
[] = [
{
- id: "no",
+ accessorKey: "rowNo",
header: "NO",
cell: ({ row }) => {
if (row.original.isUpndFixPost) {
@@ -19,7 +19,7 @@ export const columns: ColumnDef[] = [
);
}
- return row.index + 1;
+ return row.original.rowNo;
},
},
{
diff --git a/apps/common/features/src/widgets/post/ui/post-form.tsx b/apps/common/features/src/widgets/post/ui/post-form.tsx
index e603e91f1..84636f234 100644
--- a/apps/common/features/src/widgets/post/ui/post-form.tsx
+++ b/apps/common/features/src/widgets/post/ui/post-form.tsx
@@ -24,10 +24,10 @@ import { handleTusUpload } from "@/entities/tus";
import { BOARD_POSTING_CODE, type Board } from "@/entities/board";
import { AttachmentApi, type Attachment } from "@/entities/attachment";
import type { Post, PostFormData, PostUpdateFormData } from "@/entities/post";
-import { FormControl, FormField, FormItem } from "@/shared/ui/form";
-import { FormWrapper } from "@/shared/ui/form-wrapper";
-import { useUserStore } from "@/shared/lib";
import { ENDPOINT } from "@/shared/config";
+import { useUserStore, useAlertStore, setCookie } from "@/shared/lib";
+import { FormWrapper } from "@/shared/ui/form-wrapper";
+import { FormControl, FormField, FormItem } from "@/shared/ui/form";
type PostFormProps = {
form: UseFormReturn;
@@ -41,6 +41,7 @@ function PostForm({
const atflCd = form.getValues("atflCd" as FieldPath);
const { userInfo } = useUserStore((state) => state);
+ const { setMessage: alert } = useAlertStore((state) => state);
const [storedBbsInfo] = useLocalStorage("bbs-info", "");
const [bbsInfo, setBbsInfo] = useState(null);
@@ -80,6 +81,29 @@ function PostForm({
}
};
+ const handleUpload = (e: React.ChangeEvent) => {
+ const atflCd = form.getValues("atflCd" as FieldPath);
+ if (atflCd) setCookie("atfl-cd-key", atflCd as string);
+
+ const files = e.target.files;
+ if (!files) return;
+ if (bbsInfo?.atflMaxCnt && files.length > bbsInfo.atflMaxCnt) {
+ alert("첨부파일 최대 개수를 초과했습니다.");
+ return;
+ }
+
+ for (const file of files) {
+ const fileSize = Math.round(file.size / 1024); // Byte -> KB
+ if (bbsInfo?.atflMaxFileSz && fileSize > bbsInfo.atflMaxFileSz) {
+ alert("첨부파일 최대 크기를 초과했습니다.");
+ return;
+ }
+ handleTusUpload(file, {
+ handleResponse: handleTusResponse,
+ });
+ }
+ };
+
const saveInterceptors = async (data: T) => {
if (deleteAttachments.length > 0) {
await Promise.all(
@@ -105,6 +129,10 @@ function PostForm({
if (storedBbsInfo) setBbsInfo(JSON.parse(storedBbsInfo));
}, [storedBbsInfo]);
+ useEffect(() => {
+ setCookie("atfl-cd-key", "");
+ }, []);
+
return (
@@ -428,54 +456,48 @@ function PostForm
({
)}
-
- 첨부파일
-
- {
- const files = e.target.files;
- if (!files) return;
- for (const file of files) {
- handleTusUpload(file, {
- handleResponse: handleTusResponse,
- });
- }
- }}
- customPreview={
-
- {Object.entries(attachments).map(
- ([atflId, attachment]) => {
- if (deleteAttachments.includes(atflId)) return null;
- return (
-
-
{attachment.orgnlFileNm}
-
- }
- />
-
-
+
{attachment.orgnlFileNm}
+
+
+ );
+ },
+ )}
+
+ }
+ />
+
+
+ )}
diff --git a/apps/cs/src/pages/bbs/ui/bbs-form.tsx b/apps/cs/src/pages/bbs/ui/bbs-form.tsx
index f56f46622..8f645da1e 100644
--- a/apps/cs/src/pages/bbs/ui/bbs-form.tsx
+++ b/apps/cs/src/pages/bbs/ui/bbs-form.tsx
@@ -36,12 +36,12 @@ type BbsFormProps = {
function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
const bbsTypeCd = form.watch("bbsTypeCd");
- const formDisabled = !!bbsTypeCd && bbsTypeCd !== "BBSNORMAL";
+ const disabledForm = !!bbsTypeCd && bbsTypeCd !== "BBSNORMAL";
const { data: boardTemplate } = useQuery({
queryKey: [ENDPOINT.BOARD_SERVICE.BBS_TEMPLATES, bbsTypeCd],
queryFn: () => BoardTemplateApi.getBoardTemplate(bbsTypeCd),
- enabled: !formDisabled,
+ enabled: disabledForm,
});
return (
@@ -128,7 +128,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.rfrncUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -158,7 +158,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.atflUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -199,7 +199,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
className="w-[12rem] !text-[1.3rem]"
placeholder="최대 개수 입력"
disabled={
- form.getValues("atflUseYn") === "N" || formDisabled
+ form.getValues("atflUseYn") === "N" || disabledForm
}
/>
@@ -234,7 +234,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
className="w-[12rem] !text-[1.3rem]"
placeholder="최대 크기 입력"
disabled={
- form.getValues("atflUseYn") === "N" || formDisabled
+ form.getValues("atflUseYn") === "N" || disabledForm
}
/>
@@ -256,7 +256,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.ansUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -315,7 +315,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.cmntUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -345,7 +345,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.dgstfnEvlUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -375,7 +375,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.popupUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -405,7 +405,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.smsUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -435,7 +435,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.upndFixUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>
@@ -465,7 +465,7 @@ function BbsForm({ form, bbsId, ...props }: BbsFormProps) {
{...field}
value={boardTemplate?.pstgPrdUseYn ?? field.value}
onValueChange={field.onChange}
- disabled={formDisabled}
+ disabled={disabledForm}
>