-
Notifications
You must be signed in to change notification settings - Fork 1
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 #57 from Team-INSERT/feat/history
feat : history api 연결
- Loading branch information
Showing
9 changed files
with
127 additions
and
2 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,7 @@ | ||
import React from "react"; | ||
|
||
const History = () => { | ||
return <div>asd</div>; | ||
}; | ||
|
||
export default History; |
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,7 @@ | ||
import React from "react"; | ||
|
||
const HistoryDetail = () => { | ||
return <div>asd</div>; | ||
}; | ||
|
||
export default HistoryDetail; |
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,29 @@ | ||
import Container from "@/components/Container"; | ||
import React from "react"; | ||
import { HydrationBoundary, dehydrate } from "@tanstack/react-query"; | ||
import getQueryClient from "@/app/getQueryClient"; | ||
import { historyQuery } from "@/services/history/historyQuery"; | ||
|
||
interface PageProps { | ||
params: { | ||
title: string; | ||
}; | ||
} | ||
|
||
const Page = async ({ params: { title } }: PageProps) => { | ||
const queryClient = getQueryClient(); | ||
const history = await queryClient.fetchQuery( | ||
historyQuery.getDetail(title, 0), | ||
); | ||
|
||
return ( | ||
<Container title={title} classify={title}> | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
{/* <History docs={docs} /> */} | ||
{JSON.stringify(history)} | ||
</HydrationBoundary> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Page; |
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,39 @@ | ||
import Container from "@/components/Container"; | ||
import React from "react"; | ||
import { HydrationBoundary, dehydrate } from "@tanstack/react-query"; | ||
import getQueryClient from "@/app/getQueryClient"; | ||
import { historyQuery } from "@/services/history/historyQuery"; | ||
import Link from "next/link"; | ||
|
||
interface PageProps { | ||
params: { | ||
title: string; | ||
}; | ||
} | ||
|
||
const Page = async ({ params: { title } }: PageProps) => { | ||
const queryClient = getQueryClient(); | ||
const historyList = await queryClient.fetchQuery(historyQuery.getList(title)); | ||
|
||
return ( | ||
<Container title={title} classify={title}> | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<Link | ||
href={`/history/${title}/detail/0`} | ||
style={{ | ||
width: "fit-content", | ||
padding: "20px", | ||
color: "white", | ||
background: "green", | ||
}} | ||
> | ||
버전디텔 | ||
</Link> | ||
{/* <History docs={docs} /> */} | ||
{JSON.stringify(historyList)} | ||
</HydrationBoundary> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Page; |
Empty file.
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,13 @@ | ||
import { HttpClient } from "@/apis/httpClient"; | ||
|
||
class HistoryService extends HttpClient { | ||
getList(title: string) { | ||
return this.get(`/find/${title}/version`); | ||
} | ||
|
||
getDetail(title: string, id: number) { | ||
return this.get(`/find/version/${title}/different/${id}`); | ||
} | ||
} | ||
|
||
export default new HistoryService("api/docs"); |
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,19 @@ | ||
import HistoryService from "./HistoryService"; | ||
|
||
const queryKeys = { | ||
list: (title: string) => ["history", title] as const, | ||
detail: (title: string, id: number) => | ||
["history", "detail", title, id] as const, | ||
}; | ||
|
||
export const historyQuery = { | ||
getList: (title: string) => ({ | ||
queryKey: queryKeys.list(title), | ||
queryFn: () => HistoryService.getList(title).then((r) => r.data), | ||
}), | ||
|
||
getDetail: (title: string, id: number) => ({ | ||
queryKey: queryKeys.detail(title, id), | ||
queryFn: () => HistoryService.getDetail(title, id).then((r) => r.data), | ||
}), | ||
}; |