import PageLoading from '@components/Objects/Loaders/PageLoading'; import { getAPIUrl } from '@services/config/config'; import { swrFetcher } from '@services/utils/ts/requests'; import { useRouter } from 'next/navigation'; import React, { use, useEffect } from 'react' import useSWR, { mutate } from "swr"; function GetStarted() { const { data: install, error: error, isLoading } = useSWR(`${getAPIUrl()}install/latest`, swrFetcher); const router = useRouter() async function startInstallation() { let res = await fetch(`${getAPIUrl()}install/start`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) }) if (res.status == 200) { mutate(`${getAPIUrl()}install/latest`) router.refresh(); router.push(`/install?step=1`) } } function redirectToStep() { const step = install.step router.push(`/install?step=${step}`) } useEffect(() => { if (install) { redirectToStep() } }, [install]) if (error) return

Start a new installation

Start
if (isLoading) return if (install) { return (

You already started an installation

Continue
Start
) } } export default GetStarted