- {links.map((item) => {
+ {links?.map((item) => {
const { url, title, description } = item;
if (
url.includes(inputValue) ||
diff --git a/components/imagelist/ImageListItem.tsx b/components/imagelist/ImageListItem.tsx
index 585abedc3..7615df4d3 100644
--- a/components/imagelist/ImageListItem.tsx
+++ b/components/imagelist/ImageListItem.tsx
@@ -3,27 +3,18 @@ import styles from "./ImageListItem.module.css";
import { getElapsedTime, parseDatestring } from "@/utils/caltime";
import Card from "../card/Card";
import Link from "next/link";
-import { LinkContents } from "@/api/share";
-import Image from "next/image";
+import { AuthShareLinks } from "@/api/share";
-export default function ImageListItem({ item }: { item: LinkContents }) {
- const { id, createdAt, url, title, description, imageSource } = item;
- const targetData = parseDatestring(createdAt);
+export default function ImageListItem({ item }: { item: AuthShareLinks }) {
+ const { id, created_at, url, title, description, image_source } = item;
+ const targetData = parseDatestring(created_at);
const { year, month, day } = targetData;
- const diffTime = getElapsedTime(createdAt);
+ const diffTime = getElapsedTime(created_at);
return (
- {/* */}
- {/* */}
-
+
{diffTime}
{description}
diff --git a/components/input/Input.tsx b/components/input/Input.tsx
index d48e1fa2c..946913b60 100644
--- a/components/input/Input.tsx
+++ b/components/input/Input.tsx
@@ -4,7 +4,7 @@ import styles from "./Input.module.css";
import { ErrorMessage } from "@hookform/error-message";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons";
-import { InputProps } from "../types/hookFormTypes";
+import { InputProps } from "@/types/hookFormTypes";
export default function Input({
type,
diff --git a/components/menubar/FolderMenuBar.tsx b/components/menubar/FolderMenuBar.tsx
index 1cf25c3c4..804805b48 100644
--- a/components/menubar/FolderMenuBar.tsx
+++ b/components/menubar/FolderMenuBar.tsx
@@ -1,28 +1,24 @@
-import React, { useContext, useState } from "react";
+import React, { useState } from "react";
import styles from "./FolderMenu.module.css";
-import LocaleContext from "../../contexts/LocaleContext";
import Modal from "@/components/modal/Modal";
import Image from "next/image";
+import { useRouter } from "next/router";
+import { FolderMenuBarData } from "@/types/folderMenuBarTypes";
type TabName = "share" | "change" | "delete" | "deleteLink";
-type FolderMenuProps = {
- folderIdKey: string | undefined;
-};
-type FolderTypeProps = {
- folderId: number | undefined;
- folderName: string;
-};
-
-export default function FolderMenu({ folderIdKey }: FolderMenuProps) {
+export default function FolderMenuBar({
+ folderIdKey,
+ data,
+}: {
+ folderIdKey: string;
+ data?: FolderMenuBarData;
+}) {
const [openModal, setOpenModal] = useState(false);
const [tabName, setTabName] = useState("share");
- const { ObjectValue } = useContext(LocaleContext);
-
- const folder: FolderTypeProps | undefined =
- typeof folderIdKey === "string" ? ObjectValue[folderIdKey] : undefined;
- const folderName = folder?.folderName || "전체";
- const isSelected = typeof folder !== "undefined";
+ const router = useRouter();
+ const { folderId } = router.query;
+ const folderName = !folderId ? "전체" : data?.[folderIdKey].folderName;
const handleModal = () => {
setOpenModal(true);
@@ -31,51 +27,42 @@ export default function FolderMenu({ folderIdKey }: FolderMenuProps) {
const handleTab = (e: React.MouseEvent) => {
const altAttribute = (e.target as HTMLImageElement).alt as TabName;
setTabName(altAttribute);
- // setTabName(e.target.alt);
};
return (
{folderName}
- {isSelected && (
-
-
{
- handleTab(e);
- handleModal();
- }}
- >
-
-
-
{
- handleTab(e);
- handleModal();
- }}
- >
-
-
-
{
- handleTab(e);
- handleModal();
- }}
- >
-
-
+
+
{
+ handleTab(e);
+ handleModal();
+ }}
+ >
+
- )}
-
+
{
+ handleTab(e);
+ handleModal();
+ }}
+ >
+
+
+
{
+ handleTab(e);
+ handleModal();
+ }}
+ >
+
+
+
{openModal && (
- {userProfile.data ?
:
}
- {userProfile.data &&
}
+ {userProfile?.data ?
:
}
+ {userProfile?.data &&
}
);
diff --git a/components/nav/ShareNav.tsx b/components/nav/ShareNav.tsx
index 87b31b6a2..d8a625fc3 100644
--- a/components/nav/ShareNav.tsx
+++ b/components/nav/ShareNav.tsx
@@ -1,6 +1,6 @@
import React from "react";
import styles from "./ShareNav.module.css";
-import { ShareUser } from "@/api/share";
+import { AuthShareUser, ShareUser } from "@/api/share";
import { UserProfile } from "@/api/folder";
import Logo from "@/public/images/logo.svg";
import Person from "@/public/images/person.svg";
@@ -10,14 +10,14 @@ import Profile from "@/components/profile/Profile";
export default function ShareNav({
data,
}: {
- data: UserProfile[] | ShareUser;
+ data: UserProfile[] | ShareUser | AuthShareUser | undefined;
}) {
return (
{data ?
:
}
- {!Array.isArray(data) ? data.email :
}
+ {!Array.isArray(data) ? data?.email :
}
);
diff --git a/contexts/LocaleContext.ts b/contexts/LocaleContext.ts
index 77e62dacb..ed9c05283 100644
--- a/contexts/LocaleContext.ts
+++ b/contexts/LocaleContext.ts
@@ -1,16 +1,13 @@
-import { MappedDataProps } from "@/components/types/mappedFolderTypes";
import { createContext } from "react";
-
+import { MappedDataProps } from "@/types/mappedFolderTypes";
export type LocaleContextProps = {
ObjectValue: { [key: string]: MappedDataProps };
LinkSDataArr: MappedDataProps[];
- folderIdKey: string;
};
const LocaleContext = createContext
({
ObjectValue: {},
LinkSDataArr: [],
- folderIdKey: "",
});
export default LocaleContext;
diff --git a/contexts/provider/LocaleProvider.tsx b/contexts/provider/LocaleProvider.tsx
index 45b57f0c9..8281d6f9c 100644
--- a/contexts/provider/LocaleProvider.tsx
+++ b/contexts/provider/LocaleProvider.tsx
@@ -2,9 +2,7 @@ import LocaleContext from "./../LocaleContext";
const LocaleProvider = ({ children }: { children: React.ReactNode }) => {
return (
-
+
{children}
);
diff --git a/hooks/useFetchLinksdata.ts b/hooks/useFetchLinksdata.ts
index 891600ab8..34c54660d 100644
--- a/hooks/useFetchLinksdata.ts
+++ b/hooks/useFetchLinksdata.ts
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { UserFolder } from "@/api/folder";
-import { MappedDataProps } from "@/components/types/mappedFolderTypes";
+import { MappedDataProps } from "@/types/mappedFolderTypes";
function useFetchLinksData(fetchFunc: Function, targetArr: UserFolder[]) {
const [data, setData] = useState([]);
diff --git a/next.config.js b/next.config.js
index 6b12b3688..0f6c174b7 100644
--- a/next.config.js
+++ b/next.config.js
@@ -33,6 +33,7 @@ const nextConfig = {
"codeit-images.codeit.com",
"testing-library.com",
"static.cdninstagram.com",
+ "ca.slack-edge.com",
],
},
};
diff --git a/package-lock.json b/package-lock.json
index 7a2b19a75..cdc7877a1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,6 +12,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@hookform/error-message": "^2.0.1",
+ "axios": "^1.6.2",
"babel-plugin-styled-components": "^2.1.4",
"clsx": "^2.0.0",
"next": "13.5.6",
@@ -3408,6 +3409,11 @@
"has-symbols": "^1.0.3"
}
},
+ "node_modules/asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+ },
"node_modules/available-typed-arrays": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz",
@@ -3429,6 +3435,16 @@
"node": ">=4"
}
},
+ "node_modules/axios": {
+ "version": "1.6.2",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
+ "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
+ "dependencies": {
+ "follow-redirects": "^1.15.0",
+ "form-data": "^4.0.0",
+ "proxy-from-env": "^1.1.0"
+ }
+ },
"node_modules/axobject-query": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz",
@@ -3723,6 +3739,17 @@
"integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
"dev": true
},
+ "node_modules/combined-stream": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+ "dependencies": {
+ "delayed-stream": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
"node_modules/commander": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
@@ -3999,6 +4026,14 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
@@ -4849,6 +4884,25 @@
"integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==",
"dev": true
},
+ "node_modules/follow-redirects": {
+ "version": "1.15.3",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
+ "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://github.com/sponsors/RubenVerborgh"
+ }
+ ],
+ "engines": {
+ "node": ">=4.0"
+ },
+ "peerDependenciesMeta": {
+ "debug": {
+ "optional": true
+ }
+ }
+ },
"node_modules/for-each": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
@@ -4858,6 +4912,19 @@
"is-callable": "^1.1.3"
}
},
+ "node_modules/form-data": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
+ "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
+ "dependencies": {
+ "asynckit": "^0.4.0",
+ "combined-stream": "^1.0.8",
+ "mime-types": "^2.1.12"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -5899,8 +5966,6 @@
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
- "dev": true,
- "peer": true,
"engines": {
"node": ">= 0.6"
}
@@ -5909,8 +5974,6 @@
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
- "dev": true,
- "peer": true,
"dependencies": {
"mime-db": "1.52.0"
},
@@ -6525,6 +6588,11 @@
"react-is": "^16.13.1"
}
},
+ "node_modules/proxy-from-env": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
+ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
+ },
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
diff --git a/package.json b/package.json
index 02d934e50..ce137322b 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@hookform/error-message": "^2.0.1",
+ "axios": "^1.6.2",
"babel-plugin-styled-components": "^2.1.4",
"clsx": "^2.0.0",
"next": "13.5.6",
diff --git a/pages/404.tsx b/pages/404.tsx
new file mode 100644
index 000000000..38e800281
--- /dev/null
+++ b/pages/404.tsx
@@ -0,0 +1,3 @@
+export default function Custom404() {
+ return 페이지가 없어~~~~~~
;
+}
diff --git a/pages/500.tsx b/pages/500.tsx
new file mode 100644
index 000000000..f5abc339a
--- /dev/null
+++ b/pages/500.tsx
@@ -0,0 +1,3 @@
+export default function Custom500() {
+ return 500 - Server-side error occurred
;
+}
diff --git a/pages/folder/[folderId].tsx b/pages/folder/[folderId].tsx
new file mode 100644
index 000000000..2db45a085
--- /dev/null
+++ b/pages/folder/[folderId].tsx
@@ -0,0 +1,74 @@
+import { useRouter } from "next/router";
+import React, { useEffect, useState } from "react";
+import DataList from "@/components/datalist/DataList";
+import SearchBar from "@/components/searchbar/SearchBar";
+import FolderNav from "@/components/nav/FolderNav";
+import Header from "@/components/header/Header";
+import FolderMenuList from "@/components/foldermenulist/FolderMenuList";
+import Footer from "@/components/footer/Footer";
+import { AuthFolderData, AuthFolderLinks } from "@/api/folder";
+import FolderPageLayout from "@/layout/FolderPageLayout";
+import { getCurrentUser } from "@/api/share";
+import { Folder, FolderMenuListProps } from "@/types/folderMenuListTypes";
+import axios from "axios";
+import FolderMenuBar from "@/components/menubar/FolderMenuBar";
+
+export default function FolderItem() {
+ const router = useRouter();
+ const { folderId } = router.query as { folderId: string };
+ const [user, setUser] = useState();
+ const [data, setData] = useState();
+ const [folderMenu, setFolderMenu] = useState();
+
+ useEffect(() => {
+ (async () => {
+ const shareUser = await getCurrentUser();
+ if (axios.isAxiosError(shareUser)) return;
+ const folderMenu = await AuthFolderData();
+ const folderLinksData = await AuthFolderLinks(folderId);
+ const folderMenuList = folderMenu.data.folder;
+ const copyfolderMenuList = folderMenuList.slice();
+ const combinedFolderMenuList = [
+ {
+ id: 0,
+ name: "전체",
+ user_id: 25,
+ links: [],
+ },
+ ...copyfolderMenuList,
+ ];
+
+ const folderLink = folderLinksData.data.folder!;
+ const filteredLinks = folderLink.filter(
+ (item: Folder) => item.folder_id === Number(folderId)
+ );
+ setUser(shareUser);
+ setData(filteredLinks);
+ setFolderMenu(combinedFolderMenuList);
+ })();
+ }, [folderId]);
+
+ const mappedObject = folderMenu?.reduce((acc, item) => {
+ return {
+ ...acc,
+ [Number(item.id)]: {
+ folderId: item.id,
+ folderName: item.name,
+ links: item.links,
+ },
+ };
+ }, {});
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+ >
+ );
+}
diff --git a/pages/folder/[id].tsx b/pages/folder/[id].tsx
deleted file mode 100644
index b523f04a4..000000000
--- a/pages/folder/[id].tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { useRouter } from "next/router";
-import React from "react";
-import { mapFolderData, mapLinksData } from "@/utils/mapdata";
-import DataList from "@/components/datalist/DataList";
-import SearchBar from "@/components/searchbar/SearchBar";
-import FolderNav from "@/components/nav/FolderNav";
-import Header from "@/components/header/Header";
-import FolderMenuList from "@/components/foldermenulist/FolderMenuList";
-import FolderMenu from "@/components/menubar/FolderMenuBar";
-import Footer from "@/components/footer/Footer";
-import useFetchLinksData from "@/hooks/useFetchLinksdata";
-import { fetchUserData, fetchUserFolderData } from "@/api/folder";
-import LocaleContext from "@/contexts/LocaleContext";
-import { UserProfile, UserFolder } from "@/api/folder";
-import FolderPageLayout from "@/layout/FolderPageLayout";
-
-type FolderItemProps = {
- userProfileData: { data: UserProfile[] };
- userFolderData: { data: UserFolder[] };
-};
-
-export default function FolderItem(props: FolderItemProps) {
- const userProfileData = props.userProfileData;
- const userFolderData = props.userFolderData;
- const router = useRouter();
- const { id } = router.query;
- const folderId = id as string;
- const result = userFolderData?.data || [];
- const obj = mapFolderData(result);
- const [mappedResult] = useFetchLinksData(mapLinksData, result);
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
- >
- );
-}
-
-export async function getServerSideProps() {
- const USER_ID = 1;
- const response = await fetchUserData({ userId: USER_ID });
- const userFolderData = await fetchUserFolderData({ userId: USER_ID });
-
- return {
- props: {
- userProfileData: response,
- userFolderData: userFolderData,
- },
- };
-}
diff --git a/pages/folder/index.tsx b/pages/folder/index.tsx
index a7a4d4f9d..198e661b4 100644
--- a/pages/folder/index.tsx
+++ b/pages/folder/index.tsx
@@ -1,69 +1,74 @@
-import { fetchUserData, fetchUserFolderData } from "@/api/folder";
+"use client";
+import { AuthFolderData, AuthFolderLinks } from "@/api/folder";
import DataList from "@/components/datalist/DataList";
import FolderMenuList from "@/components/foldermenulist/FolderMenuList";
import Footer from "@/components/footer/Footer";
import Header from "@/components/header/Header";
-import FolderMenu from "@/components/menubar/FolderMenuBar";
+import FolderMenuBar from "@/components/menubar/FolderMenuBar";
import FolderNav from "@/components/nav/FolderNav";
import SearchBar from "@/components/searchbar/SearchBar";
-import LocaleContext from "@/contexts/LocaleContext";
-import useFetchLinksData from "@/hooks/useFetchLinksdata";
-import { mapFolderData, mapLinksData } from "@/utils/mapdata";
+
import { useRouter } from "next/router";
-import React from "react";
-import { UserProfile, UserFolder } from "@/api/folder";
+import React, { useEffect, useState } from "react";
import FolderPageLayout from "@/layout/FolderPageLayout";
+import { getCurrentUser } from "@/api/share";
+import { FolderMenuListProps } from "@/types/folderMenuListTypes";
+import axios from "axios";
-type FolderPageProps = {
- userProfileData: { data: UserProfile[] };
- userFolderData: { data: UserFolder[] };
-};
-
-export default function FolderPage(props: FolderPageProps) {
- const userProfileData = props.userProfileData;
- const userFolderData = props.userFolderData;
-
+export default function FolderPages() {
const router = useRouter();
const { id } = router.query;
const folderId = id as string;
- const result = userFolderData?.data || [];
+ const [user, setUser] = useState();
+ const [data, setData] = useState();
+ const [folderMenu, setFolderMenu] = useState();
- const obj = mapFolderData(result);
+ useEffect(() => {
+ (async () => {
+ const shareUser = await getCurrentUser();
+ if (axios.isAxiosError(shareUser)) return;
+ const folderMenu = await AuthFolderData();
+ const folderLink = await AuthFolderLinks();
+ const data = folderLink.data.folder;
+ const folderMenuList = folderMenu.data?.folder;
+ const copyfolderMenuList = folderMenuList.slice();
+ const combinedFolderMenuList = [
+ {
+ id: 0,
+ name: "전체",
+ user_id: shareUser.data[0].id,
+ links: folderLink,
+ },
+ ...copyfolderMenuList,
+ ];
+ setFolderMenu(combinedFolderMenuList);
+ setData(data);
+ setUser(shareUser);
+ })();
+ }, []);
- const [mappedResult, isLoading] = useFetchLinksData(mapLinksData, result);
+ const mappedObject = folderMenu?.reduce((acc, item) => {
+ return {
+ ...acc,
+ [Number(item.id)]: {
+ folderId: item.id,
+ folderName: item.name,
+ links: item.links,
+ },
+ };
+ }, {});
return (
<>
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
>
);
}
-
-export async function getServerSideProps() {
- const USER_ID = 1;
- const userProfileData = await fetchUserData({ userId: USER_ID });
-
- const userFolderData = await fetchUserFolderData({ userId: USER_ID });
- return {
- props: {
- userProfileData: userProfileData,
- userFolderData: userFolderData,
- },
- };
-}
diff --git a/pages/shared/[folderId].tsx b/pages/shared/[folderId].tsx
new file mode 100644
index 000000000..876e181b2
--- /dev/null
+++ b/pages/shared/[folderId].tsx
@@ -0,0 +1,93 @@
+import { GetServerSidePropsContext } from "next";
+import {
+ getAuthShareUserData,
+ getAuthSharedFolderData,
+ FolderContentsProps,
+ getAuthSharedLinksData,
+ getCurrentUser,
+} from "@/api/share";
+import React, { useEffect, useState } from "react";
+import SearchProvider from "@/contexts/provider/SearchProvider";
+import ShareNav from "@/components/nav/ShareNav";
+import Header from "@/components/header/Header";
+import Custom404 from "../404";
+import SearchBar from "@/components/searchbar/SearchBar";
+import ImageList from "@/components/imagelist/ImageList";
+import Footer from "@/components/footer/Footer";
+export default function SharedFolderIdPage({
+ errorCode,
+ combinedData,
+}: {
+ errorCode: string;
+ combinedData: FolderContentsProps;
+}) {
+ const [user, setUser] = useState();
+ useEffect(() => {
+ (async () => {
+ const shareUser = await getCurrentUser();
+ setUser(shareUser.data);
+ })();
+ }, []);
+
+ if (errorCode) {
+ return ;
+ }
+
+ return (
+
+
+
+
+
+
+
+ );
+}
+
+export const getServerSideProps = async (
+ context: GetServerSidePropsContext
+) => {
+ const { folderId } = context.query;
+
+ const sharedFolderData = await getAuthSharedFolderData({
+ folderId: folderId,
+ });
+
+ if (sharedFolderData.data.length === 0) {
+ return {
+ props: {
+ errorCode: 404,
+ },
+ };
+ }
+ const folderData = sharedFolderData.data[sharedFolderData.data.length - 1];
+
+ const { user_id } = folderData;
+
+ const sharedUserData = await getAuthShareUserData({ userId: user_id });
+ const userData = sharedUserData.data[sharedUserData.data.length - 1];
+ const sharedLinksData = await getAuthSharedLinksData({
+ userId: user_id,
+ folderId: folderId,
+ });
+
+ const linksData = sharedLinksData.data;
+ const propsData = {
+ id: folderData.id,
+ name: folderData.name,
+ owner: {
+ id: userData.id,
+ name: userData.name,
+ profileImageSource: userData.image_source,
+ },
+ links: linksData,
+ };
+
+ return {
+ props: {
+ sharedFolder: folderData,
+ sharedUser: userData,
+ combinedData: { folder: propsData },
+ },
+ };
+};
diff --git a/pages/shared/index.tsx b/pages/shared/index.tsx
deleted file mode 100644
index 232aa56f0..000000000
--- a/pages/shared/index.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from "react";
-import { ShareUser, getShareFolderData, getShareUserData } from "@/api/share";
-import ShareNav from "@/components/nav/ShareNav";
-import Header from "@/components/header/Header";
-import SearchBar from "@/components/searchbar/SearchBar";
-import ImageList from "@/components/imagelist/ImageList";
-import Footer from "@/components/footer/Footer";
-import SearchProvider from "@/contexts/provider/SearchProvider";
-import { FolderContentsProps } from "@/api/share";
-
-type SharedPageProps = {
- shareFolder: FolderContentsProps;
- shareUser: ShareUser;
-};
-
-export default function SharedPage(props: SharedPageProps) {
- const shareFolder = props.shareFolder;
- const shareUser = props.shareUser;
-
- return (
-
-
-
-
-
-
-
- );
-}
-
-export async function getStaticProps() {
- const shareFolderData = await getShareFolderData();
- const shareUserData = await getShareUserData();
-
- return {
- props: {
- shareFolder: shareFolderData,
- shareUser: shareUserData,
- },
- };
-}
diff --git a/pages/signin/index.tsx b/pages/signin/index.tsx
index dbd518834..1fe50dc1a 100644
--- a/pages/signin/index.tsx
+++ b/pages/signin/index.tsx
@@ -7,9 +7,8 @@ import Input from "@/components/input/Input";
import { useForm, SubmitHandler } from "react-hook-form";
import google from "@/public/images/google.png";
import kakao from "@/public/images/kakao.png";
-
import { useRouter } from "next/router";
-import { FormValues } from "@/components/types/hookFormTypes";
+import { FormValues } from "@/types/hookFormTypes";
export default function SingInPage() {
const {
register,
@@ -53,8 +52,9 @@ export default function SingInPage() {
router.push("/folder");
} else {
const jsonData = await response.json();
+
const myToken = jsonData.data?.accessToken;
- localStorage.setItem("myToken", JSON.stringify(myToken));
+ localStorage.setItem("myToken", myToken);
router.push("/folder");
}
} else if (response.status === 400) {
@@ -109,9 +109,9 @@ export default function SingInPage() {
-
-
-
+ {/*
+
+ */}