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 20 #1073

Open
wants to merge 19 commits into
base: part3-강영훈
Choose a base branch
from
Open
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
59 changes: 55 additions & 4 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
"lint": "next lint"
},
"dependencies": {
"@tanstack/react-query": "^5.35.1",
"@tanstack/react-query-devtools": "^5.35.1",
"@types/react-copy-to-clipboard": "^5.0.7",
"axios": "^1.6.8",
"date-fns": "^3.6.0",
"next": "^13.5.6",
"react": "^18",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18",
"react-hook-form": "^7.51.2"
"react-hook-form": "^7.51.4"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
13 changes: 12 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import "@/styles/global.css";
import type { AppProps } from "next/app";

const queryClient = new QueryClient();

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
return (
<QueryClientProvider client={queryClient}>
<Component {...pageProps} />
<div style={{ fontSize: "24px" }}>
<ReactQueryDevtools initialIsOpen={false} />
</div>
</QueryClientProvider>
);
}
17 changes: 17 additions & 0 deletions pages/api/NavBarApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { DEFAULT_PROFILE } from "@/src/util/constant";
import instance from "@/pages/api/instance";

export const getUser = async () => {
const response = await instance.get("users");
const data = response?.data[0];
const userData = data
? {
id: data.id,
name: data.name,
email: data.email,
profileImageSource: data.image_source || DEFAULT_PROFILE,
}
: null;

return userData;
};
15 changes: 15 additions & 0 deletions pages/api/folderPageApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import instance from "@/pages/api/instance";
import { mapFolderFromLink } from "@/src/util/mapFolderFromLink";

export const getFolderData = async () => {
const response = await instance.get("folders");
return response;
};

export const getLinks = async (folderId: number = 0) => {
const folderQuery = folderId === 0 ? "" : `folders/${folderId}/`;
const response = await instance.get(`${folderQuery}links`);
const data = mapFolderFromLink(response.data);

return data;
};
10 changes: 0 additions & 10 deletions pages/api/hello.ts

This file was deleted.

20 changes: 20 additions & 0 deletions pages/api/instance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import axios, { AxiosInstance } from "axios";

const instance: AxiosInstance = axios.create({
baseURL: "https://bootcamp-api.codeit.kr/api/linkbrary/v1/",
});

const getToken = () => {
if (typeof window !== undefined) {
const token = window.localStorage.getItem("accessToken");
return token;
}
return "";
};

instance.interceptors.request.use((config) => {
config.headers.Authorization = `Bearer ${getToken()}`;
return config;
});

export default instance;
17 changes: 17 additions & 0 deletions pages/api/sharedPageApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import instance from "@/pages/api/instance";
import { mapFolderFromLink } from "@/src/util/mapFolderFromLink";

export const getFolder = async (id: number) => {
const response = await instance.get(`folders/${id}`);
return response;
};
export const getFolderOwner = async (id: number) => {
const response = await instance.get(`users/${id}`);
return response.data;
};

export const getLinksByFolderId = async (folderId: number) => {
const response = await instance.get(`folders/${folderId}/links`);
const data = mapFolderFromLink(response.data?.data);
return data;
};
24 changes: 24 additions & 0 deletions pages/api/signPageApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import instance from "@/pages/api/instance";

export interface FormValue {
email: string;
password: string;
passwordConfirm?: string;
}

export const postUserInfo = async (data: FormValue) => {
const response = await instance.post("auth/sign-in", data);
return response;
};

export const postCreateAccount = async (data: FormValue) => {
const response = await instance.post("auth/sign-up", data);
console.log(response);

return response;
};

export const postCheckEmail = async (emailData: FormValue) => {
const response = await instance.post("users/check-email", emailData);
return response;
};
Loading