로그인 처리 메인에서 처리

This commit is contained in:
yschoi
2025-07-10 14:26:35 +09:00
parent 1ec26b3de2
commit 2bf1f4ac70
3 changed files with 31 additions and 78 deletions
+25 -46
View File
@@ -1,50 +1,29 @@
import { Button } from "@common/components";
import Link from "next/link";
import { redirect } from "next/navigation";
"use client";
import { LoginApi } from "@/entities/auth";
import { useEffect } from "react";
import { getCookie } from "@/shared/lib";
import { AUTH_USER_ID } from "@/shared/config";
import { useRouter } from "next/navigation";
export default function Home() {
redirect("/map");
const router = useRouter();
const userId = "admin1gmail";
const password = "test1234!";
const checkToken = getCookie(AUTH_USER_ID);
// return (
// <div>
// <div>
// <h3 className="text-bold mx-4 gap-4 text-2xl">하수관망도</h3>
// <div className="flex flex-row gap-4 p-4">
// <Link href={"/map"}>
// <Button>하수관망도</Button>
// </Link>
// </div>
// </div>
// <div>
// <h3 className="text-bold mx-4 gap-4 text-2xl">운영정보 관리</h3>
// <div className="flex flex-row gap-4 p-4">
// <Link href={"/oper/floodPre"}>
// <Button>도시침수 예방사업</Button>
// </Link>
// <Link href={"/oper/oldPp"}>
// <Button>노후 하수관로 정비사업</Button>
// </Link>
// </div>
// </div>
// <div>
// <h3 className="text-bold mx-4 gap-4 text-2xl">
// I/I 분석(기초정보 설정)
// </h3>
// <div className="flex flex-row gap-4 p-4">
// <Link href={"/ii/irsetting"}>
// <Button>침입수 분석</Button>
// </Link>
// <Link href={"/ii/rdii"}>
// <Button>RDII 분석</Button>
// </Link>
// <Link href={"/ii/result"}>
// <Button>침입수 분석 결과</Button>
// </Link>
// <Link href={"/ii/rdiiResult"}>
// <Button>RDII 분석 결과</Button>
// </Link>
// </div>
// </div>
// </div>
// );
useEffect(() => {
if (!checkToken) {
async function doLogin() {
try {
await LoginApi.login({ userId, password });
window.location.href = "/map";
} catch (err) {
console.error("로그인 실패", err);
}
}
doLogin();
} else {
router.push("/map");
}
}, []);
}