diff --git a/public/sitemap.xml b/public/sitemap.xml index 536c613e..e33919b1 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -1,19 +1,19 @@ -https://www.workroot.life/login2024-12-23T05:31:01.038Zdaily0.7 -https://www.workroot.life/signup/owner2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/signup/applicant2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/signup2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/my-workform/applicant2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/my-workform/owner2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/my-workform2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/mypage2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/addform2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/work-list2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/work-talk/add2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/work-talk2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/auth/callback2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/stories/design-system/pages/albaList2024-12-23T05:31:01.040Zdaily0.7 -https://www.workroot.life/privacy2024-12-23T05:31:01.040Zdaily0.7 +https://www.workroot.life/signup/applicant2024-12-24T02:01:26.330Zdaily0.7 +https://www.workroot.life/signup/owner2024-12-24T02:01:26.331Zdaily0.7 +https://www.workroot.life/login2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/addform2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/signup2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/my-workform/applicant2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/my-workform2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/my-workform/owner2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/mypage2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/work-list2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/auth/callback2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/work-talk2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/work-talk/add2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/stories/design-system/pages/albaList2024-12-24T02:01:26.332Zdaily0.7 +https://www.workroot.life/privacy2024-12-24T02:01:26.332Zdaily0.7 \ No newline at end of file diff --git a/src/app/components/input/file/ImageInput/ImageInput.tsx b/src/app/components/input/file/ImageInput/ImageInput.tsx new file mode 100644 index 00000000..aa45e1a2 --- /dev/null +++ b/src/app/components/input/file/ImageInput/ImageInput.tsx @@ -0,0 +1,131 @@ +"use client"; +import { HiUpload } from "react-icons/hi"; +import { forwardRef, useState, useEffect } from "react"; +import { toast } from "react-hot-toast"; +import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd"; +import PreviewItem from "./PreviewItem"; +import { cn } from "@/lib/tailwindUtil"; +import { ImageInputType } from "@/types/addform"; +import React from "react"; + +interface ImageInputProps { + name: string; + onChange?: (files: File[] | string[]) => void; + onDelete?: (id: string) => void; + initialImageList: ImageInputType[]; +} + +const ImageInput = forwardRef((props, ref) => { + const [imageList, setImageList] = useState(props.initialImageList || []); + + useEffect(() => { + if (props.initialImageList?.length > 0) { + setImageList(props.initialImageList); + } + }, [props.initialImageList]); + + const handleFileChange = (selectedFiles: FileList | null) => { + if (selectedFiles) { + const filesArray = Array.from(selectedFiles); // FileList를 배열로 변환 + const validFiles = filesArray.filter((file) => file.type.startsWith("image/")); + + if (validFiles.length + imageList.length > 3) { + toast.error("이미지는 최대 3개까지 업로드할 수 있습니다."); + return; + } + + if (validFiles.length === 0) { + toast.error("이미지 파일만 업로드할 수 있습니다."); + return; + } + + // 선택된 파일을 상위 컴포넌트로 전달 + props.onChange?.(validFiles); + } + }; + + const handleDeleteImage = (targetUrl: string) => { + const newImageList = imageList.filter((image) => image.url !== targetUrl); + setImageList(newImageList); + props.onDelete?.(targetUrl); + }; + + const handleOpenFileSelector = () => { + if (typeof ref === "function") { + const fileInput = document.querySelector(`input[name="${props.name}"]`); + if (fileInput) { + (fileInput as HTMLInputElement).click(); + } + } else if (ref && "current" in ref) { + ref.current?.click(); + } + }; + + const colorStyle = { + bgColor: "bg-background-200", + borderColor: "border-[0.5px] border-transparent", + hoverColor: "hover:border-grayscale-200 hover:bg-background-300", + innerHoverColor: "hover:bg-background-300", + }; + + const handleDragEnd = (result: DropResult) => { + if (!result.destination) return; + + const items = Array.from(imageList); + const [reorderedItem] = items.splice(result.source.index, 1); + items.splice(result.destination.index, 0, reorderedItem); + + setImageList(items); + // 상위 컴포넌트에 변경된 이미지 URL 배열 전달 + props.onChange?.(items.map((item) => item.url)); + }; + + return ( + +
+
+ handleFileChange(e.target.files)} + className="hidden" + multiple + /> +
+ +
+
+ + {(provided) => ( +
+ {imageList.map((image, index) => ( + + {(provided) => ( +
+ +
+ )} +
+ ))} + {provided.placeholder} +
+ )} +
+
+
+ ); +}); + +ImageInput.displayName = "ImageInput"; + +export default ImageInput;