-
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.
* feat: Connect vote data api * feat: Add post vote api * fix: Fix rewrite api source * fix: Add weski proxy to fix build error
- Loading branch information
1 parent
5f33f22
commit 36478d6
Showing
13 changed files
with
144 additions
and
68 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,8 @@ | ||
import { apiClient } from '@/shared/api/base'; | ||
import type { Vote } from '../model'; | ||
|
||
export const getVote = async (key: string): Promise<Vote> => { | ||
const result = await apiClient.get<Vote>(`/ski/${key}/snowmaking`); | ||
|
||
return result; | ||
}; |
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 +1,2 @@ | ||
export { discoveryQueries } from './discovery.queries'; | ||
export { postVote } from './post-vote'; |
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 { apiClient } from '@/shared/api/base'; | ||
import type { PostVoteRequest } from '../model'; | ||
|
||
export const postVote = async (key: string, body: PostVoteRequest) => { | ||
const res = await apiClient.post<PostVoteRequest>(`/ski/${key}/snowmaking`, body); | ||
return res; | ||
}; |
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 { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { discoveryApi } from '..'; | ||
|
||
export const usePostVote = (key: string) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: ({ isLike }: { isLike: boolean }) => discoveryApi.postVote(key, { isLike }), | ||
async onSettled() { | ||
await queryClient.invalidateQueries({ | ||
queryKey: discoveryApi.discoveryQueries.voteQueryKey(key), | ||
}); | ||
}, | ||
}); | ||
}; |
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,2 +1,2 @@ | ||
export { DiscoveryData } from './constants'; | ||
export type { Weather, WeeklyWeather, Discovery } from './model'; | ||
export type { Weather, WeeklyWeather, Discovery, Vote, PostVoteRequest } from './model'; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { API_URL } from '@/shared/config'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
const { path } = req.query; | ||
const url = `${API_URL}/${(path as string[]).join('/')}`; | ||
|
||
const response = await fetch(url, { | ||
method: req.method, | ||
headers: { | ||
...(req.headers as Record<string, string>), | ||
}, | ||
body: req.method !== 'GET' ? JSON.stringify(req.body) : undefined, | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
res.status(response.status).json(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