);
diff --git a/component/SignHeader.tsx b/component/SignHeader.tsx
index 51ad2a276..d1649aa56 100644
--- a/component/SignHeader.tsx
+++ b/component/SignHeader.tsx
@@ -10,10 +10,10 @@ export default function SignHeader() {
return (
<>
diff --git a/component/SigninForm.tsx b/component/SigninForm.tsx
index e68bc6578..098a4ec0f 100644
--- a/component/SigninForm.tsx
+++ b/component/SigninForm.tsx
@@ -89,11 +89,11 @@ export default function SigninForm() {
className="w-full mt-3 px-[15px] py-[18px] rounded-md"
/>
{errors.password?.message}
diff --git a/component/SigninPasswordInput.tsx b/component/SigninPasswordInput.tsx
deleted file mode 100644
index 2826f5302..000000000
--- a/component/SigninPasswordInput.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-export default function SigninPasswordInput({
- register,
- inputType,
- isClosed,
- errors,
- handleToggleImage,
-}: {
- register: any;
- inputType: any;
- isClosed: any;
- errors: any;
- handleToggleImage: any;
-}) {
- return (
-
-
-
-
-
{errors.password?.message}
-
- );
-}
diff --git a/component/SignupForm.tsx b/component/SignupForm.tsx
index 594dfe8fe..34faaeffc 100644
--- a/component/SignupForm.tsx
+++ b/component/SignupForm.tsx
@@ -109,11 +109,11 @@ export default function SignupForm() {
className="w-full mt-3 px-[15px] py-[18px] rounded-md"
/>
{errors.password?.message}
@@ -139,11 +139,11 @@ export default function SignupForm() {
className="w-full mt-3 px-[15px] py-[18px] rounded-md"
/>
diff --git a/component/SocialLogin.tsx b/component/SocialLogin.tsx
index 0729a82db..7177c7c0b 100644
--- a/component/SocialLogin.tsx
+++ b/component/SocialLogin.tsx
@@ -15,18 +15,18 @@ export default function SocialLogin() {
diff --git a/lib/folderFetcher.ts b/lib/folderFetcher.ts
new file mode 100644
index 000000000..5d11c36cc
--- /dev/null
+++ b/lib/folderFetcher.ts
@@ -0,0 +1,11 @@
+import axiosInstance from "@/axios/axiosInstance";
+
+export const fetchFolders = async () => {
+ try {
+ const response = await axiosInstance.get("/folders");
+
+ return response.data;
+ } catch (error) {
+ throw error;
+ }
+};
diff --git a/lib/linkFetcher.ts b/lib/linkFetcher.ts
new file mode 100644
index 000000000..500ba9bd2
--- /dev/null
+++ b/lib/linkFetcher.ts
@@ -0,0 +1,11 @@
+import axiosInstance from "@/axios/axiosInstance";
+
+export const fetchLinks = async () => {
+ try {
+ const response = await axiosInstance.get("/links");
+
+ return response.data;
+ } catch (error) {
+ throw error;
+ }
+};
diff --git a/lib/userFetcher.ts b/lib/userFetcher.ts
new file mode 100644
index 000000000..17f0d5cf7
--- /dev/null
+++ b/lib/userFetcher.ts
@@ -0,0 +1,11 @@
+import axiosInstance from "@/axios/axiosInstance";
+
+export const fetchUser = async () => {
+ try {
+ const response = await axiosInstance.get("/users");
+
+ return response.data;
+ } catch (error) {
+ throw error;
+ }
+};
diff --git a/next.config.mjs b/next.config.mjs
index d5456a15d..61cd5eddd 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
- reactStrictMode: true,
+ reactStrictMode: false,
};
export default nextConfig;
diff --git a/pages/folder.tsx b/pages/folder/[folderId].tsx
similarity index 60%
rename from pages/folder.tsx
rename to pages/folder/[folderId].tsx
index d852d9842..aceb7636d 100644
--- a/pages/folder.tsx
+++ b/pages/folder/[folderId].tsx
@@ -2,14 +2,23 @@ import AddLinkInput from "@/component/AddLinkInput";
import FolderMain from "@/component/FolderMain";
import Navbar from "@/component/Navbar";
import Searchbar from "@/component/Searchbar";
-import useCurrentUser from "@/hooks/useCurrentUser";
+import { fetchUser } from "@/lib/userFetcher";
import axios from "axios";
-import { useState } from "react";
+import { useRouter } from "next/router";
+import { useEffect, useState } from "react";
+
+interface UserData {
+ id: number;
+ name: string;
+ email: string;
+ profileImageSource: string;
+}
export default function Folder() {
+ const [user, setUser] = useState
();
const [inputValue, setInputValue] = useState("");
- const { data: user } = useCurrentUser();
+ const router = useRouter();
const handleChange = (e: any) => {
const value = e.target.value;
@@ -31,10 +40,29 @@ export default function Folder() {
setInputValue("");
};
+ useEffect(() => {
+ const getUsers = async () => {
+ try {
+ const { data } = await fetchUser();
+ setUser(data[0]);
+ console.log(data[0]);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ getUsers();
+ }, []);
+
if (!user) {
return Loading...
;
}
+ if (!localStorage.getItem("accessToken")) {
+ alert("로그인이 필요합니다.");
+ router.push("/signin");
+ }
+
return (
<>
diff --git a/pages/folder/index.tsx b/pages/folder/index.tsx
new file mode 100644
index 000000000..fcd54e3e8
--- /dev/null
+++ b/pages/folder/index.tsx
@@ -0,0 +1,78 @@
+import AddLinkInput from "@/component/AddLinkInput";
+import FolderMain from "@/component/FolderMain";
+import Navbar from "@/component/Navbar";
+import Searchbar from "@/component/Searchbar";
+import { fetchUser } from "@/lib/userFetcher";
+import axios from "axios";
+import { useRouter } from "next/router";
+import { useEffect, useState } from "react";
+
+interface UserData {
+ id: number;
+ name: string;
+ email: string;
+ profileImageSource: string;
+}
+
+export default function Folder() {
+ const [user, setUser] = useState();
+ const [inputValue, setInputValue] = useState("");
+
+ const router = useRouter();
+
+ const handleChange = (e: any) => {
+ const value = e.target.value;
+ setInputValue(value);
+ };
+
+ const handleSubmit = async (e: any) => {
+ e.preventDefault();
+
+ try {
+ const response = await axios.post("/api/input", { inputValue });
+ setInputValue(response.data);
+ } catch (error) {
+ console.error("Error:", error);
+ }
+ };
+
+ const handleClose = () => {
+ setInputValue("");
+ };
+
+ useEffect(() => {
+ const getUsers = async () => {
+ try {
+ const { data } = await fetchUser();
+ setUser(data[0]);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ getUsers();
+ }, []);
+
+ if (typeof window !== "undefined" && !localStorage.getItem("accessToken")) {
+ alert("로그인이 필요합니다.");
+ router.push("/signin");
+ }
+
+ if (!user) {
+ return Loading...
;
+ }
+
+ return (
+ <>
+
+
+
+
+ >
+ );
+}
diff --git a/pages/index.tsx b/pages/index.tsx
index 309006262..7a34a3ae5 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -3,10 +3,36 @@ import Hero from "@/component/Hero";
import LandingDescription from "@/component/LandingDescription";
import LandingDescriptionMobile from "@/component/LandingDescriptionMobile";
import Navbar from "@/component/Navbar";
-import useCurrentUser from "@/hooks/useCurrentUser";
+import { fetchUser } from "@/lib/userFetcher";
+import { useEffect, useState } from "react";
+
+interface UserData {
+ id: number;
+ name: string;
+ email: string;
+ profileImageSource: string;
+}
export default function Home() {
- const { data: user } = useCurrentUser();
+ const [user, setUser] = useState();
+
+ useEffect(() => {
+ const getUsers = async () => {
+ try {
+ const { data } = await fetchUser();
+ setUser(data[0]);
+ console.log(data[0]);
+ } catch (error) {
+ console.error(error);
+ }
+ };
+
+ getUsers();
+ }, []);
+
+ if (!user) {
+ Loading...
;
+ }
return (
<>
diff --git a/pages/shared/[folderId].tsx b/pages/shared/[folderId].tsx
new file mode 100644
index 000000000..753b54ac3
--- /dev/null
+++ b/pages/shared/[folderId].tsx
@@ -0,0 +1,33 @@
+import Footer from "@/component/Footer";
+import LinkCardList from "@/component/LinkCardList";
+import Navbar from "@/component/Navbar";
+import SharedSearchBar from "@/component/SharedSearchBar";
+import User from "@/component/User";
+import useCurrentUser from "@/hooks/useCurrentUser";
+import { fetcher } from "@/lib/fetcher";
+import { useParams } from "next/navigation";
+import useSWR from "swr";
+
+export default function Page() {
+ const { data: user } = useCurrentUser();
+
+ const params = useParams();
+
+ const { data: links } = useSWR(
+ () =>
+ !params.folderId
+ ? `https://bootcamp-api.codeit.kr/api/users/${user?.id}/links`
+ : `https://bootcamp-api.codeit.kr/api/users/${user?.id}/links?folderId=${params.folderId}`,
+ fetcher
+ );
+
+ return (
+ <>
+
+
+
+
+
+ >
+ );
+}
diff --git a/pages/shared.tsx b/pages/shared/index.tsx
similarity index 52%
rename from pages/shared.tsx
rename to pages/shared/index.tsx
index 24debfc9d..40cd1ce07 100644
--- a/pages/shared.tsx
+++ b/pages/shared/index.tsx
@@ -4,16 +4,29 @@ import Navbar from "@/component/Navbar";
import SharedSearchBar from "@/component/SharedSearchBar";
import User from "@/component/User";
import useCurrentUser from "@/hooks/useCurrentUser";
+import { fetcher } from "@/lib/fetcher";
+import { useParams } from "next/navigation";
+import useSWR from "swr";
export default function Shared() {
const { data: user } = useCurrentUser();
+ const params = useParams();
+
+ const { data: links } = useSWR(
+ () =>
+ !params.folderId
+ ? `https://bootcamp-api.codeit.kr/api/users/${user?.id}/links`
+ : `https://bootcamp-api.codeit.kr/api/users/${user?.id}/links?folderId=${params.folderId}`,
+ fetcher
+ );
+
return (
<>
-
+
>
);