-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from jangmoonwon/part3-장문원-week20
[장문원] week20
- Loading branch information
Showing
13 changed files
with
194 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: #ffffff; | ||
height: 100vh; | ||
} | ||
|
||
.text { | ||
font-size: 10rem; | ||
font-weight: 700; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import styles from "./Loading.module.scss"; | ||
import classNames from "classnames/bind"; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
export default function Loading() { | ||
return ( | ||
<div className={cx("container")}> | ||
<h1 className={cx("text")}>Loading...</h1> | ||
</div> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
import "@/styles/resets.css"; | ||
import type { AppProps } from "next/app"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} />; | ||
} | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<Component {...pageProps} /> | ||
<ReactQueryDevtools initialIsOpen={false} /> | ||
</QueryClientProvider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import axios from "axios"; | ||
|
||
const axiosInstance = axios.create({ | ||
baseURL: "https://bootcamp-api.codeit.kr/api", | ||
baseURL: "https://bootcamp-api.codeit.kr/api/linkbrary/v1", | ||
}); | ||
|
||
export default axiosInstance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import axiosInstance from "./axiosInstance"; | ||
|
||
type Data = { | ||
id: number; | ||
created_at: string; | ||
favorite: boolean; | ||
name: string; | ||
link_count: number; | ||
}; | ||
|
||
export async function getFolders(): Promise<Data[]> { | ||
const response = await axiosInstance.get("/users/1/folders"); | ||
const data: Data[] = response.data; | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import axiosInstance from "./axiosInstance"; | ||
|
||
type Data = { | ||
id: number; | ||
created_at: string; | ||
favorite: boolean; | ||
url: string; | ||
title: string; | ||
image_source: string; | ||
description: string; | ||
}; | ||
|
||
export async function getLinks(): Promise<Data[]> { | ||
const response = await axiosInstance.get("/users/1/links"); | ||
const data: Data[] = response.data; | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import axiosInstance from "./axiosInstance"; | ||
|
||
type Data = { | ||
id: number; | ||
created_at: string; | ||
url: string; | ||
title: string; | ||
description: string; | ||
image_source: string; | ||
}; | ||
|
||
export async function getSampleLinks(): Promise<Data[]> { | ||
const response = await axiosInstance.get("/sample/links"); | ||
const data: Data[] = response.data; | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,37 @@ | ||
|
||
import styles from "./test.module.scss"; | ||
import classNames from "classnames/bind"; | ||
import { Button } from "./test"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getUsers } from "../api/testApi"; | ||
import { useRouter } from "next/router"; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
export default function Test() { | ||
const router = useRouter(); | ||
const { userId } = router.query; | ||
|
||
const { data, isLoading } = useQuery({ | ||
queryKey: ["users", userId], | ||
queryFn: () => getUsers(userId as string), | ||
}); | ||
|
||
console.log(data); | ||
|
||
const user = data && Array.isArray(data) ? data[0] : data; | ||
|
||
if (isLoading) return "로딩 중입니다..."; | ||
|
||
return ( | ||
<div className={cx("container")}> | ||
<Button variant="red" size="sm" className={cx("font-weight")}> | ||
<span>red</span> | ||
</Button> | ||
<Button variant="sky" size="lg"> | ||
<span>sky</span> | ||
</Button> | ||
<h1>test page</h1> | ||
{user ? ( | ||
<> | ||
<h1>{user.email}</h1> | ||
<h1>{user.name}</h1> | ||
</> | ||
) : ( | ||
<h1>데이터가 없습니다</h1> | ||
)} | ||
</div> | ||
); | ||
} |