File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import { ChangeEvent , FormEvent , useState } from "react" ;
2+ import { postLink } from "@/lib/api/link" ;
3+ import Image from "next/image" ;
4+ import Button from "../Button" ;
5+
6+ const AddLinkInput = ( folderId : number ) => {
7+ const [ value , setValue ] = useState ( "" ) ;
8+
9+ const handleChange = ( e : ChangeEvent < HTMLInputElement > ) => {
10+ setValue ( e . target . value ) ;
11+ } ;
12+
13+ const handleSubmit = async ( e : FormEvent < HTMLFormElement > ) => {
14+ e . preventDefault ( ) ;
15+ await postLink ( { url : value , folderId } ) ;
16+ // postLink 하고 추가된 link가 보이도록 하는 로직 구현해야 함.
17+ } ;
18+
19+ return (
20+ < form
21+ onSubmit = { handleSubmit }
22+ className = "flex gap-[12px] items-center w-[800px] h-[69px] py-[16px] px-[20px] border border-blue-500 rounded-[10px] md:w-[704px] sm:w-[325px] sm:h-[53px] transition-all"
23+ >
24+ < Image src = "/icons/link.svg" width = { 20 } height = { 20 } alt = "link icon" />
25+ < input
26+ onChange = { handleChange }
27+ value = { value }
28+ placeholder = "링크를 추가해 보세요."
29+ className = "flex-grow"
30+ />
31+ < Button color = "positive" className = "w-[80px] h-[37px]" >
32+ 추가하기
33+ </ Button >
34+ </ form >
35+ ) ;
36+ } ;
37+
38+ export default AddLinkInput ;
You can’t perform that action at this time.
0 commit comments