WIP: 동영상 게시판 작업중

This commit is contained in:
2025-05-14 12:29:24 +09:00
parent a68b455898
commit d9a4e365ba
6 changed files with 37 additions and 8 deletions
+2 -1
View File
@@ -412,7 +412,8 @@ function PostForm<T extends PostFormData | PostUpdateFormData>({
<TableRow>
<TableHead>첨부파일</TableHead>
<TableCell className="border">
{bbsInfo?.bbsTypeCd === "BBSIMAGE" ? (
{bbsInfo?.bbsTypeCd === "BBSIMAGE" ||
bbsInfo?.bbsTypeCd === "BBSMOVIE" ? (
<WithPreviewFileUploader
form={form}
attachmentData={attachmentData}
+1 -1
View File
@@ -211,7 +211,7 @@ function PostPage({ bbsId }: { bbsId: string }) {
</div>
<div className="card !m-[1.2rem] h-full overflow-auto !p-0">
{isFetched ? (
bbsType === "BBSIMAGE" ? (
bbsType === "BBSIMAGE" || bbsType === "BBSMOVIE" ? (
<GridViewDataTable
table={gridViewTable}
onRowClick={handleRowClick}
@@ -7,6 +7,7 @@ import { handleTusUpload } from "@/entities/tus";
import { AttachmentApi, type Attachment } from "@/entities/attachment";
import type { PostFormData, PostUpdateFormData } from "@/entities/post";
import { setCookie, useAlertStore, useMenuStore } from "@/shared/lib";
import type { BbsType } from "@/shared/store/menu-store";
function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
form,
@@ -21,6 +22,17 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
const [thumbnailUrl, setThumbnailUrl] = useState("");
const [progress, setProgress] = useState(0);
const fileAccept = (bbsTypeCd: BbsType) => {
switch (bbsTypeCd) {
case "BBSIMAGE":
return ".jpeg,.jpg,.png";
case "BBSMOVIE":
return ".mp4,.mov,.avi,.wmv,.mkv";
default:
return "";
}
};
const handleTusResponse = async (res: HttpResponse) => {
const fileInfo = res.getHeader("X-File-Info");
if (
@@ -33,7 +45,13 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
if (atflCd) form.setValue("atflCd" as FieldPath<T>, atflCd);
if (atflId) {
const imageUrl = await AttachmentApi.getImageUrl(atflId);
let imageUrl = "";
if (bbsInfo?.bbsTypeCd === "BBSIMAGE") {
imageUrl = await AttachmentApi.getImageUrl(atflId);
}
if (bbsInfo?.bbsTypeCd === "BBSMOVIE") {
imageUrl = await AttachmentApi.getMovieThumbnailUrl(atflId);
}
setThumbnailUrl(imageUrl);
}
};
@@ -78,7 +96,7 @@ function WithPreviewFileUploader<T extends PostFormData | PostUpdateFormData>({
<FileUploader
id="atflCd"
className="!h-auto !max-w-none flex-col !items-start gap-4"
accept=".jpeg,.jpg,.png"
accept={fileAccept(bbsInfo?.bbsTypeCd as BbsType)}
onUpload={onUpload}
customPreview={
<Label htmlFor="atflCd">