CoreControl/app/setup/page.tsx

31 lines
682 B
TypeScript
Raw Normal View History

2025-05-17 15:38:56 +02:00
"use client";
2025-05-17 16:17:35 +02:00
import SetupPage from "./SetupPage";
import Loading from "@/components/Loading";
import { useState, useEffect } from "react";
2025-05-17 15:38:56 +02:00
import { useRouter } from "next/navigation";
import axios from "axios";
2025-05-17 16:17:35 +02:00
export default function Setup() {
const router = useRouter();
const [loading, setLoading] = useState(true);
2025-05-17 15:38:56 +02:00
2025-05-17 16:17:35 +02:00
useEffect(() => {
const init = async () => {
const response = await axios.get("/api/user/init");
if (response.data.message !== "No users found") {
router.push("/");
} else {
setLoading(false);
}
};
init();
}, []);
2025-05-17 15:38:56 +02:00
2025-05-17 16:17:35 +02:00
if (loading) {
return <Loading />;
} else {
return <SetupPage />;
}
2025-05-17 15:38:56 +02:00
}