-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
551149b
commit 840de82
Showing
4 changed files
with
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useMutation } from "@tanstack/react-query"; | ||
import axios from "axios"; | ||
|
||
export const useSignupMutation = () => { | ||
const fetcher = ({ | ||
name, | ||
email, | ||
password, | ||
}: { | ||
name: string; | ||
email: string; | ||
password: string; | ||
}) => { | ||
return axios.post("/auth/register", { name, email, password }); | ||
}; | ||
|
||
return useMutation({ | ||
mutationFn: fetcher, | ||
}); | ||
}; | ||
|
||
export const useLoginMutation = () => { | ||
const fetcher = ({ email, password }: { email: string; password: string }) => { | ||
return axios.post("/auth/login", { email, password }); | ||
}; | ||
|
||
return useMutation({ | ||
mutationFn: fetcher, | ||
// TODO 성공했을 경우 accessToken 저장 (zustand? localStorage? cookie?) | ||
// accessToken: cookie (쿠기 다 때려넣기...) / localStorage / zustand (번거로움..귀찮음.. 안해봤음..) | ||
// refreshToken: cookie, | ||
// onSuccess: (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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import axios from "axios"; | ||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import "./index.css"; | ||
import App from "./App.tsx"; | ||
|
||
axios.defaults.baseURL = import.meta.env.VITE_API_URL; | ||
axios.defaults.withCredentials = true; | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
refetchOnWindowFocus: false, | ||
}, | ||
}, | ||
}); | ||
|
||
createRoot(document.getElementById("root")!).render( | ||
<StrictMode> | ||
<App /> | ||
<QueryClientProvider client={queryClient}> | ||
<App /> | ||
</QueryClientProvider> | ||
</StrictMode>, | ||
); |
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