diff --git a/apps/common/features/app/(with-base-layout)/pst/bbsimage/[bbsId]/[pstNo]/modify/page.tsx b/apps/common/features/app/(with-base-layout)/pst/bbsimage/[bbsId]/[pstNo]/modify/page.tsx new file mode 100644 index 000000000..d7601ffd1 --- /dev/null +++ b/apps/common/features/app/(with-base-layout)/pst/bbsimage/[bbsId]/[pstNo]/modify/page.tsx @@ -0,0 +1,10 @@ +import { ModifyPage } from "@/pages/(pst)/image"; + +export default async function PstBbsImagePostModifyPage({ + params, +}: { + params: Promise<{ bbsId: string; pstNo: string }>; +}) { + const { bbsId, pstNo } = await params; + return ; +} diff --git a/apps/common/features/package.json b/apps/common/features/package.json index 88a5a66a1..8ec6639bf 100644 --- a/apps/common/features/package.json +++ b/apps/common/features/package.json @@ -13,6 +13,7 @@ "@common/components": "workspace:*", "@common/config": "workspace:*", "@common/network": "workspace:*", + "@fontsource-variable/noto-sans-kr": "^5.2.5", "@frontend-opensource/use-react-hooks": "^1.1.4", "@hookform/resolvers": "^4.1.3", "@minoru/react-dnd-treeview": "^3.5.0", diff --git a/apps/common/features/src/app/index.tsx b/apps/common/features/src/app/index.tsx index 5a73f2fdd..692b55ef0 100644 --- a/apps/common/features/src/app/index.tsx +++ b/apps/common/features/src/app/index.tsx @@ -1,5 +1,7 @@ import "./styles/base.css"; import "./styles/components.css"; +import "@fontsource-variable/noto-sans-kr"; + import { AppProvider } from "./providers"; import { cookies } from "next/headers"; diff --git a/apps/common/features/src/app/styles/base.css b/apps/common/features/src/app/styles/base.css index a4f54680f..6cbb623bb 100644 --- a/apps/common/features/src/app/styles/base.css +++ b/apps/common/features/src/app/styles/base.css @@ -5,8 +5,10 @@ @tailwind base; @tailwind utilities; -html, -body { - font-family: "Noto Sans KR", sans-serif; - font-size: 10px; +@layer base { + html, + body { + font-family: "Noto Sans KR", sans-serif; + font-size: 10px; + } } diff --git a/apps/common/features/src/pages/(pst)/image/index.ts b/apps/common/features/src/pages/(pst)/image/index.ts index b3a860dfe..0bc16c1ad 100644 --- a/apps/common/features/src/pages/(pst)/image/index.ts +++ b/apps/common/features/src/pages/(pst)/image/index.ts @@ -1,3 +1,4 @@ export { CreatePage } from "./ui/create-page"; +export { ModifyPage } from "./ui/modify-page"; export { ImagePage } from "./ui/image-page"; export { ImagePost } from "./ui/image-post"; diff --git a/apps/common/features/src/pages/(pst)/image/ui/modify-page.tsx b/apps/common/features/src/pages/(pst)/image/ui/modify-page.tsx new file mode 100644 index 000000000..c721286e4 --- /dev/null +++ b/apps/common/features/src/pages/(pst)/image/ui/modify-page.tsx @@ -0,0 +1,53 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useMutation, useQuery } from "@tanstack/react-query"; +import { PostForm } from "@/widgets/post"; +import { + PostApi, + postUpdateFormSchema, + type PostUpdateFormData, +} from "@/entities/post"; +import { ENDPOINT } from "@/shared/config"; +import { useAlertStore, useUserStore } from "@/shared/lib"; + +function ModifyPage({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { + const router = useRouter(); + const { setMessage: alert } = useAlertStore((state) => state); + const { userInfo } = useUserStore((state) => state); + + const { data: postInfo } = useQuery({ + queryKey: [ENDPOINT.BOARD_SERVICE.POSTS_USER, bbsId, pstNo], + queryFn: () => PostApi.getPostInfo(bbsId, pstNo), + }); + + const { mutateAsync: updatePost } = useMutation({ + mutationFn: (data: PostUpdateFormData) => + PostApi.updatePost(bbsId, pstNo, data), + onSuccess: () => { + alert("수정되었습니다.", router.back); + }, + }); + + const form = useForm({ + resolver: zodResolver(postUpdateFormSchema), + values: { + ...postInfo, + pstTtl: postInfo?.pstTtl ?? "", + pstPswd: userInfo?.userUnqId ?? "", + }, + }); + + return ( + + + 이미지 게시글 수정 + + + + ); +} + +export { ModifyPage }; diff --git a/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx b/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx index 66c144053..4969d2c77 100644 --- a/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx +++ b/apps/common/features/src/widgets/post/model/grid-view-table-columns.tsx @@ -38,9 +38,9 @@ export const createColumns = ( NEW )} - - {pstTtl} - + + {pstTtl} + ); }, @@ -49,7 +49,6 @@ export const createColumns = ( id: "atflCd", cell: ({ row }) => { const atflCd = row.original.atflCd; - if (!atflCd) return null; return ( { const { rgtrNm } = row.original; - return {rgtrNm}; + return ( + {rgtrNm} + ); }, }, { id: "regDt", cell: ({ row }) => ( - + {dayjs(row.original.regDt).format("YYYY-MM-DD")} ), @@ -102,16 +103,21 @@ const ThumbImage = ({ atflCd, pstNo, thumbRefs }: ThumbImageProps) => { ); - if (!imageUrl) return null; + if (imageUrl) + return ( + + + + ); return ( - - + + ); }; diff --git a/apps/common/features/src/widgets/post/ui/post-comment.tsx b/apps/common/features/src/widgets/post/ui/post-comment.tsx index 0bddc1e81..983865935 100644 --- a/apps/common/features/src/widgets/post/ui/post-comment.tsx +++ b/apps/common/features/src/widgets/post/ui/post-comment.tsx @@ -125,7 +125,7 @@ function PostComment({ bbsId, pstNo }: { bbsId: number; pstNo: number }) { @@ -145,7 +145,7 @@ function PostComment({ bbsId, pstNo }: { bbsId: number; pstNo: number }) { @@ -164,7 +164,7 @@ function PostComment({ bbsId, pstNo }: { bbsId: number; pstNo: number }) { {...field} type="password" value={field.value ?? ""} - className="w-[12rem] bg-background !text-[1.3rem]" + className="w-[12rem] bg-background !text-[1.3rem] text-foreground" placeholder="비밀번호" /> @@ -187,10 +187,10 @@ function PostComment({ bbsId, pstNo }: { bbsId: number; pstNo: number }) { > - + {comment.wrtrNm} - + {dayjs(comment.regDt).format("YYYY.MM.DD")} @@ -200,7 +200,7 @@ function PostComment({ bbsId, pstNo }: { bbsId: number; pstNo: number }) { value={editValue} onChange={(e) => setEditValue(e.target.value)} maxLength={1000} - className="h-[10rem] bg-background p-4 !text-[1.3rem] !leading-6" + className="h-[10rem] bg-background p-4 !text-[1.3rem] !leading-6 text-foreground" /> ) : ( - {comment.cmntCn} + + {comment.cmntCn} + )} 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 d84cb179a..928aef922 100644 --- a/apps/common/features/src/widgets/post/ui/post-form.tsx +++ b/apps/common/features/src/widgets/post/ui/post-form.tsx @@ -155,7 +155,7 @@ function PostForm({ {...field} value={(field.value as string) ?? ""} onChange={field.onChange} - className="h-[20rem] w-full !text-[1.3rem]" + className="h-[20rem] w-full bg-form !text-[1.3rem] !leading-6" placeholder="내용을 입력해주세요" /> diff --git a/apps/common/features/src/widgets/post/ui/post.tsx b/apps/common/features/src/widgets/post/ui/post.tsx index f000c52ae..60044d2b2 100644 --- a/apps/common/features/src/widgets/post/ui/post.tsx +++ b/apps/common/features/src/widgets/post/ui/post.tsx @@ -106,7 +106,9 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { <> - {postData?.pstTtl} + + {postData?.pstTtl} + @@ -134,10 +136,9 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { )} )} - + + {postData?.pstCn ?? ""} + {isFetching ? ( @@ -147,7 +148,7 @@ function Post({ bbsId, pstNo }: { bbsId: string; pstNo: string }) { <> - 첨부파일 + 첨부파일 ({ form, + attachmentData, }: { form: UseFormReturn; attachmentData?: Attachment[]; @@ -32,7 +33,8 @@ function WithPreviewFileUploader({ const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; if (atflCd) form.setValue("atflCd" as FieldPath, atflCd); if (atflId) { - setThumbnailUrl(await AttachmentApi.getImageUrl(atflId)); + const imageUrl = await AttachmentApi.getImageUrl(atflId); + setThumbnailUrl(imageUrl); } }; @@ -41,9 +43,6 @@ function WithPreviewFileUploader({ }; const onUpload = (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) { @@ -57,6 +56,7 @@ function WithPreviewFileUploader({ alert("첨부파일 최대 크기를 초과했습니다."); return; } + setCookie("atfl-cd-key", ""); handleTusUpload(file, { handleResponse: handleTusResponse, handleProgress, @@ -64,6 +64,16 @@ function WithPreviewFileUploader({ } }; + useEffect(() => { + if (!attachmentData || attachmentData.length === 0) return; + (async () => { + const imageUrl = await AttachmentApi.getImageUrl( + attachmentData[0]?.atflId as string, + ); + setThumbnailUrl(imageUrl); + })(); + }, [attachmentData]); + return (
{comment.cmntCn}
+ {comment.cmntCn} +
+ {postData?.pstCn ?? ""} +