Skip to content

Commit 378c317

Browse files
committed
Feat: AddLinkInput UI 컴포넌트 구현, postLink 했을때 추가된 link가 보이도록 하는 로직 구현해야 함
1 parent d3fb45c commit 378c317

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

components/Link/AddLinkInput.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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;

0 commit comments

Comments
 (0)