Skip to content

Commit

Permalink
Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
sayyyho authored Nov 13, 2024
2 parents 58d2796 + 82ac84a commit 9c1d189
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/apis/login.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { instance } from "./instance";
import Cookies from "js-cookie";
import { useNavigate } from "react-router-dom";
export const postLogin = async (form) => {
const navigate = useNavigate();

try {
const response = await instance.post("/login", {
...form,
Expand All @@ -17,7 +14,6 @@ export const postLogin = async (form) => {
secure: true,
sameSite: "Strict",
});
navigate("/nugu/admin");
}
} catch (err) {
throw err;
Expand Down
21 changes: 17 additions & 4 deletions src/pages/login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ export const Login = () => {
const { form, handleChange, isValid } = useForm(loginState);
const navigate = useNavigate();

const handleLogin = async () => {
await postLogin(form);
await getUUID();
navigate(`/nugu/${Cookies.get("uuid")}`);
const performAPI = async () => {
try {
await postLogin(form);
await getUUID();
const uuid = Cookies.get("uuid");
if (uuid) {
navigate(`/nugu/${uuid}`);
} else {
console.error("UUID를 찾을 수 없습니다.");
}
} catch (error) {
console.error("로그인 요청 중 에러가 발생했습니다:", error);
}
};

const handleLogin = () => {
performAPI();
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/nugu/NuguAdmin.jsx → src/pages/nugu/Nugu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Chip } from "@components/chip/Chip";
import { useParams } from "react-router-dom";
import { useNuguInfo } from "./_hooks/useNuguInfo";

export const NuguAdmin = () => {
export const Nugu = () => {
const { uuid } = useParams();
const { data, isAdmin } = useNuguInfo(uuid);
return (
Expand Down
Empty file removed src/pages/nugu/NuguGuest.jsx
Empty file.
4 changes: 2 additions & 2 deletions src/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SignUpSubmit } from "@pages/signUp/SignUpSubmit";
import { NuguIntro } from "@pages/nuguIntro/NuguIntro";
import { WriteIntro } from "@pages/nuguIntro/WriteIntro";
import { NuguCreate } from "@pages/signUp/NuguCreate";
import { NuguAdmin } from "@pages/nugu/NuguAdmin";
import { Nugu } from "@pages/nugu/Nugu";
import { NuguTestPage } from "@pages/nuguTest/NuguTest";
import { MakeNuguTest } from "@pages/nuguTest/MakeNuguTest";
import { NuguChallenge } from "@pages/nuguTest/NuguChallenge";
Expand Down Expand Up @@ -67,7 +67,7 @@ const router = createBrowserRouter([
},
{
path: "/nugu/:uuid",
element: <NuguAdmin />,
element: <Nugu />,
},
],
},
Expand Down

0 comments on commit 9c1d189

Please sign in to comment.