-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat] 어드민 - API 연동
- Loading branch information
Showing
29 changed files
with
724 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
interface FileInputProps { | ||
selectedFile: File | string | null; | ||
setSelectedFile: (file: File) => void; | ||
} | ||
|
||
export default function FileInput({ selectedFile, setSelectedFile }: FileInputProps) { | ||
const [previewUrl, setPreviewUrl] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
if (!selectedFile) { | ||
setPreviewUrl(null); | ||
return; | ||
} | ||
if (typeof selectedFile === "string") { | ||
setPreviewUrl(selectedFile); | ||
return; | ||
} | ||
|
||
const objectUrl = URL.createObjectURL(selectedFile); | ||
setPreviewUrl(objectUrl); | ||
|
||
return () => URL.revokeObjectURL(objectUrl); | ||
}, [selectedFile]); | ||
|
||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const file = event.target.files?.[0]; | ||
if (file) { | ||
setSelectedFile(file); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
{previewUrl && ( | ||
<img src={previewUrl} alt="Preview" style={{ width: "auto", maxHeight: "100px" }} /> | ||
)} | ||
<input type="file" accept="image/*" onChange={handleFileChange} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
interface ToastProps { | ||
message: string; | ||
isVisible: boolean; | ||
} | ||
|
||
export default function Toast({ message, isVisible }: ToastProps) { | ||
return ( | ||
<div | ||
className={`fixed top-[88px] left-[50%] translate-x-[-50%] h-heading-4-bold bg-neutral-400 text-white px-6 py-4 rounded-lg transition-opacity ${ | ||
isVisible ? "opacity-100" : "opacity-0" | ||
}`} | ||
> | ||
{message} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.