Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[이현승] week 15 #469

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
/WeeklyMissionPart1
/.next
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 왜인지 .next 폴더도 업로드 되었네요
처리 후 의도대로 제거 됐는지 확인해주시면 좋을 것 같아요~

.pnp.js

# testing
Expand Down
14 changes: 2 additions & 12 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,15 +22,10 @@
"static/chunks/main.js",
"static/chunks/pages/_error.js"
],
"/folder": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/folder.js"
],
"/shared": [
"/folder/[[...folderid]]": [
"static/chunks/webpack.js",
"static/chunks/main.js",
"static/chunks/pages/shared.js"
"static/chunks/pages/folder/[[...folderid]].js"
]
},
"ampFirstPages": []
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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/14.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.

4 changes: 1 addition & 3 deletions .next/server/pages-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
"/_app": "pages/_app.js",
"/_error": "pages/_error.js",
"/_document": "pages/_document.js",
"/": "pages/index.js",
"/folder": "pages/folder.js",
"/shared": "pages/shared.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.

456 changes: 0 additions & 456 deletions .next/server/pages/folder.js

This file was deleted.

34 changes: 32 additions & 2 deletions .next/server/pages/index.js

Large diffs are not rendered by default.

336 changes: 0 additions & 336 deletions .next/server/pages/shared.js

This file was deleted.

403 changes: 403 additions & 0 deletions .next/server/vendor-chunks/next.js

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions .next/server/vendor-chunks/react-toastify.js

This file was deleted.

35 changes: 34 additions & 1 deletion .next/static/chunks/pages/_app.js

Large diffs are not rendered by default.

637 changes: 0 additions & 637 deletions .next/static/chunks/pages/folder.js

This file was deleted.

2 changes: 1 addition & 1 deletion .next/static/chunks/pages/index.js

Large diffs are not rendered by default.

451 changes: 0 additions & 451 deletions .next/static/chunks/pages/shared.js

This file was deleted.

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 "c45f4f379cb7f03f"; }
/******/ __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.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions .next/static/webpack/webpack.0e40387e97b26598.hot-update.js

This file was deleted.

18 changes: 0 additions & 18 deletions .next/static/webpack/webpack.fdb78ce2c21e7ffd.hot-update.js

This file was deleted.

20 changes: 12 additions & 8 deletions .next/trace

Large diffs are not rendered by default.

34 changes: 22 additions & 12 deletions components/Api/Api.ts → Api/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ 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() {
const response = await fetch(`${BASE_URL}/sample/folder`, {
export async function getFolderData(folderId?: string | number) {
const response = await fetch(`${BASE_URL}/folders/${folderId}`, {
method: "GET",
headers: { accept: `*/*` },
});
Expand All @@ -38,18 +36,30 @@ export async function getUsersData(userId?: string | number) {
return response.json();
}

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

export async function getLinksData(folderId?: string | number) {
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
) {
const response = await fetch(
`${BASE_URL}/users/1/links?folderId=${folderId}`,
`${BASE_URL}/users/${userId}/links?folderId=${folderId}`,
{
method: "GET",
headers: { accept: `*/*` },
Expand Down
15 changes: 6 additions & 9 deletions Hooks/useData.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useCallback, useState } from "react";

export function useData(
asyncFunction: (pram?: string | number) => Promise<any>
) {
type Pram = (number | string | undefined | null)[];

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

const getData = useCallback(
async (value?: string | number) => {
async (...value: Pram) => {
try {
const result = await asyncFunction(value);
const result = await asyncFunction(...value);
setData(result);
} catch (err) {
setData(null);
Expand All @@ -17,10 +17,7 @@ export function useData(
[asyncFunction]
);

const returnArray: [any, (value?: string | number) => Promise<void>] = [
data,
getData,
];
const returnArray: [any, (...value: Pram) => Promise<void>] = [data, getData];

return returnArray;
}
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그는 지워주세요~

};

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: 2 additions & 0 deletions components/CardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export interface LinkItem {
id: number;
createdAt?: string;
created_at?: string;
updated_at?: string | null;
url: string;
title: string;
description: string;
imageSource?: string;
image_source?: string;
folder_id?: number;
}

export type FolderObject = {
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";
import { FolderType } from "../../pages/folder/[[...folderid]]";
import { MouseEvent, useRef, useState } from "react";

interface Props {
Expand Down
Loading
Loading