Skip to content

Commit

Permalink
api 설정 변경 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
waterkail committed May 25, 2024
1 parent 3c81d2b commit 0535d70
Show file tree
Hide file tree
Showing 69 changed files with 357 additions and 116 deletions.
9 changes: 2 additions & 7 deletions .next/build-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
],
"rootMainFiles": [],
"pages": {
"/": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/index.js"
],
"/_app": [
"static/chunks/webpack.js",
"static/chunks/main.js",
Expand All @@ -27,10 +22,10 @@
"static/chunks/main.js",
"static/chunks/pages/_error.js"
],
"/shared/[folderid]": [
"/folder/[[...folderid]]": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/shared/[folderid].js"
"static/chunks/pages/folder/[[...folderid]].js"
]
},
"ampFirstPages": []
Expand Down
Binary file not shown.
Binary file modified .next/cache/webpack/client-development-fallback/0.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development-fallback/1.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development-fallback/index.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development-fallback/index.pack.gz.old
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/0.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/1.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/11.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/12.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/13.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/15.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/16.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/17.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/19.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/2.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/20.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/21.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/22.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/23.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/3.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/4.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/5.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/6.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/8.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/9.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/index.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/client-development/index.pack.gz.old
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/0.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/1.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/10.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/11.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/12.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/13.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/16.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/2.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/3.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/4.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/5.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/6.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/7.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/8.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/9.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/index.pack.gz
Binary file not shown.
Binary file modified .next/cache/webpack/server-development/index.pack.gz.old
Binary file not shown.
2 changes: 1 addition & 1 deletion .next/server/middleware-build-manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .next/server/pages-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"/_app": "pages/_app.js",
"/_error": "pages/_error.js",
"/_document": "pages/_document.js",
"/": "pages/index.js",
"/shared/[folderid]": "pages/shared/[folderid].js"
"/folder/[[...folderid]]": "pages/folder/[[...folderid]].js"
}
32 changes: 31 additions & 1 deletion .next/server/pages/_app.js

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion .next/server/pages/_error.js

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion .next/server/pages/index.js

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions .next/server/webpack-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,75 @@
/******/ __webpack_require__.m = __webpack_modules__;
/******/
/************************************************************************/
/******/ /* webpack/runtime/async module */
/******/ (() => {
/******/ var webpackQueues = typeof Symbol === "function" ? Symbol("webpack queues") : "__webpack_queues__";
/******/ var webpackExports = typeof Symbol === "function" ? Symbol("webpack exports") : "__webpack_exports__";
/******/ var webpackError = typeof Symbol === "function" ? Symbol("webpack error") : "__webpack_error__";
/******/ var resolveQueue = (queue) => {
/******/ if(queue && queue.d < 1) {
/******/ queue.d = 1;
/******/ queue.forEach((fn) => (fn.r--));
/******/ queue.forEach((fn) => (fn.r-- ? fn.r++ : fn()));
/******/ }
/******/ }
/******/ var wrapDeps = (deps) => (deps.map((dep) => {
/******/ if(dep !== null && typeof dep === "object") {
/******/ if(dep[webpackQueues]) return dep;
/******/ if(dep.then) {
/******/ var queue = [];
/******/ queue.d = 0;
/******/ dep.then((r) => {
/******/ obj[webpackExports] = r;
/******/ resolveQueue(queue);
/******/ }, (e) => {
/******/ obj[webpackError] = e;
/******/ resolveQueue(queue);
/******/ });
/******/ var obj = {};
/******/ obj[webpackQueues] = (fn) => (fn(queue));
/******/ return obj;
/******/ }
/******/ }
/******/ var ret = {};
/******/ ret[webpackQueues] = x => {};
/******/ ret[webpackExports] = dep;
/******/ return ret;
/******/ }));
/******/ __webpack_require__.a = (module, body, hasAwait) => {
/******/ var queue;
/******/ hasAwait && ((queue = []).d = -1);
/******/ var depQueues = new Set();
/******/ var exports = module.exports;
/******/ var currentDeps;
/******/ var outerResolve;
/******/ var reject;
/******/ var promise = new Promise((resolve, rej) => {
/******/ reject = rej;
/******/ outerResolve = resolve;
/******/ });
/******/ promise[webpackExports] = exports;
/******/ promise[webpackQueues] = (fn) => (queue && fn(queue), depQueues.forEach(fn), promise["catch"](x => {}));
/******/ module.exports = promise;
/******/ body((deps) => {
/******/ currentDeps = wrapDeps(deps);
/******/ var fn;
/******/ var getResult = () => (currentDeps.map((d) => {
/******/ if(d[webpackError]) throw d[webpackError];
/******/ return d[webpackExports];
/******/ }))
/******/ var promise = new Promise((resolve) => {
/******/ fn = () => (resolve(getResult));
/******/ fn.r = 0;
/******/ var fnQueue = (q) => (q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn))));
/******/ currentDeps.map((dep) => (dep[webpackQueues](fnQueue)));
/******/ });
/******/ return fn.r ? promise : getResult();
/******/ }, (err) => ((err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)));
/******/ queue && queue.d < 0 && (queue.d = 0);
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
Expand Down
35 changes: 34 additions & 1 deletion .next/static/chunks/pages/_app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .next/static/chunks/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
/******/
/******/ /* webpack/runtime/getFullHash */
/******/ !function() {
/******/ __webpack_require__.h = function() { return "940920c1cf080ee2"; }
/******/ __webpack_require__.h = function() { return "ecd5d1d48da095ab"; }
/******/ }();
/******/
/******/ /* webpack/runtime/global */
Expand Down
2 changes: 1 addition & 1 deletion .next/static/development/_buildManifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 12 additions & 42 deletions .next/trace

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions Api/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ export interface AuthProps {
password: string;
}

export async function getUserData() {
const response = await fetch(`${BASE_URL}/sample/user`, {
export async function getUserData(userToken: string) {
const response = await fetch(`${BASE_URL}/users`, {
method: "GET",
headers: { accept: `*/*` },
headers: { accept: `*/*`, Authorization: userToken },
});
if (!response.ok) throw new Error(`유저데이터 ${BASE_ERROR_MESSAGE}`);
const { name, id, email, profileImageSource } = await response.json();

return { name, id, email, profileImageSource };
return response.json();
}

export async function getFolderData(folderId?: string | number) {
Expand Down Expand Up @@ -47,6 +45,15 @@ export async function getFoldersData(userId: string | number = 1) {
return response.json();
}

export async function getFolderDataByToken(userToken: string) {
const response = await fetch(`${BASE_URL}/folders`, {
method: "GET",
headers: { accept: `*/*`, Authorization: userToken },
});
if (!response.ok) throw new Error(`폴더들 ${BASE_ERROR_MESSAGE}`);
return response.json();
}

export async function getLinksData(
folderId?: string | number,
userId: string | number = 1
Expand Down
4 changes: 2 additions & 2 deletions Hooks/useData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useState } from "react";

type Pram = (number | string | undefined)[];
type Pram = (number | string | undefined | null)[];

export function useData(asyncFunction: (...pram: Pram) => Promise<any>) {
export function useData(asyncFunction: (...pram: any) => Promise<any>) {
const [data, setData] = useState<any>(null);

const getData = useCallback(
Expand Down
1 change: 1 addition & 0 deletions components/AddLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AddLink = ({ folder, footView }: { folder: any; footView: boolean }) => {
e.preventDefault();
setAdd(!add);
setUrl(AddLink.current?.value);
console.log(folder);
};

return (
Expand Down
27 changes: 2 additions & 25 deletions components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Header from "./Header";
import Footer from "./Footer";
import { ReactNode, useCallback, useEffect, useState } from "react";
import { getUsersData } from "../Api/Api";
import { useData } from "../Hooks/useData";
import { ReactNode } from "react";

function App({
children,
Expand All @@ -13,30 +11,9 @@ function App({
headerFixed: boolean;
foot?: (node?: Element | null | undefined) => void;
}) {
const [user, getUser] = useData(getUsersData);
const [isLogIn, setIsLogIn] = useState(true);

const getData = useCallback(async () => {
try {
await getUser(1);
setIsLogIn(true);
} catch (err) {
setIsLogIn(false);
}
}, [getUser]);

useEffect(() => {
getData();
}, [isLogIn, getData]);

return (
<>
<Header
isLogIn={isLogIn}
email={user?.data[0]?.email}
img={user?.data[0]?.image_source}
fixed={headerFixed}
/>
<Header fixed={headerFixed} />
{children}
<Footer observer={foot} />
</>
Expand Down
2 changes: 1 addition & 1 deletion components/FolderPage/Folder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MainContent from "../MainContent";
import SearchBar from "../SearchBar";
import FolderBar from "./FolderBar";
import CardList, { LinkItem } from "../CardList";
import { FolderType } from "../../pages/folder/[folderid]";
import { FolderType } from "../../pages/folder/[[...folderid]]";
import { MouseEvent, useRef, useState } from "react";

interface Props {
Expand Down
4 changes: 2 additions & 2 deletions components/FolderPage/FolderBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import FolderNameBar from "@/components/FolderPage/FolderNameBar";
import { MouseEvent, ReactNode, useState } from "react";
import Portal from "../../Portal/Portal";
import ModalAddFolder from "../Modal/ModalAddFolder";
import { FolderType } from "../../pages/folder/[folderid]";
import { FolderType } from "../../pages/folder/[[...folderid]]";

const FolderBlock = ({
itemId,
Expand Down Expand Up @@ -72,7 +72,7 @@ function FolderBar({
<Bar>
<FolderIndex
onClick={onClick}
items={folderInfo?.data}
items={folderInfo}
selectedId={selectedId}
/>
<AddFolder type="button" onClick={handleAddFolder}>
Expand Down
2 changes: 1 addition & 1 deletion components/FolderPage/FolderNameBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState } from "react";
import ModalDeleteFolder from "../Modal/ModalDeleteFolder";
import ModalEdit from "../Modal/ModalEdit";
import ModalShare from "../Modal/ModalShare";
import { FolderType } from "../../pages/folder/[folderid]";
import { FolderType } from "../../pages/folder/[[...folderid]]";
import { GRAY2 } from "../color";

const ICON_MARGIN = "4px";
Expand Down
29 changes: 25 additions & 4 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ import styled from "styled-components";
import { GRAY5 } from "./color";
import Link from "next/link";
import Image from "next/image";
import { useEffect, useState } from "react";
import { useUser } from "@/contexts/UserContext";

interface UserProfileProps {
email?: string;
img?: string;
}

export interface UserData {
id: number;
created_at: string;
name: string;
image_source: string;
email: string;
img: string;
auth_id: string;
}

interface HeaderProps extends UserProfileProps {
isLogIn: boolean;
interface HeaderProps {
fixed: boolean;
}

Expand All @@ -29,7 +39,18 @@ const UserProfile = ({ email, img }: UserProfileProps) => {
);
};

const Header = ({ isLogIn, email, img, fixed }: HeaderProps) => {
const Header = ({ fixed }: HeaderProps) => {
const { user: userData, isLogin: isLogIn } = useUser();
const [img, setImg] = useState<string>();
const [email, setEmail] = useState<string>();

useEffect(() => {
if (userData) {
setEmail(userData.data[0].email);
setImg(userData.data[0].image_source);
}
}, [userData]);

return (
<Heading $headerFixed={fixed}>
<HeaderContent>
Expand Down
2 changes: 1 addition & 1 deletion components/Modal/ModalAddLink/Folder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Folder = ({ item }: { item: Item }) => {
onClick={handleClick}
>
<FolderName>{item?.name}</FolderName>
<FolderLinks>{item?.link.count}개 링크</FolderLinks>
{/* <FolderLinks>{item?.link.count}개 링크</FolderLinks> */}
</Folders>
);
};
Expand Down
5 changes: 2 additions & 3 deletions components/Modal/ModalAddLink/ModalAddLink.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import ModalFrame from "../ModalFrame";
import BlueButton from "../BlueButton";
import styled from "styled-components";
import { FolderObject, LinkItem } from "../../CardList";
import Folder from "./Folder";

interface AddLinkProps {
url?: string;
onClick: (...props: any[]) => void;
folder: FolderObject;
folder: any;
}

const ModalAddLink = ({ url, onClick, folder }: AddLinkProps) => {
Expand All @@ -18,7 +17,7 @@ const ModalAddLink = ({ url, onClick, folder }: AddLinkProps) => {
<ModalFrame name="폴더에 추가" onClick={onClick}>
<Span>{url}</Span>
<Folders>
{folder?.data.map((item) => {
{folder.map((item: any) => {
if (item.id !== 14)
return <Folder item={item} key={item?.id * -17} />;
})}
Expand Down
Loading

0 comments on commit 0535d70

Please sign in to comment.