|
|
|
|
@ -1,13 +1,15 @@
|
|
|
|
|
'use client'
|
|
|
|
|
import React from 'react'
|
|
|
|
|
import React, { useEffect } from 'react'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
|
|
|
import { useContext } from 'use-context-selector'
|
|
|
|
|
import Toast from '../components/base/toast'
|
|
|
|
|
import Loading from '../components/base/loading'
|
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
|
import { setup } from '@/service/common'
|
|
|
|
|
import I18n from '@/context/i18n'
|
|
|
|
|
import { fetchSetupStatus, setup } from '@/service/common'
|
|
|
|
|
import type { SetupStatusResponse } from '@/models/common'
|
|
|
|
|
|
|
|
|
|
const validEmailReg = /^[\w\.-]+@([\w-]+\.)+[\w-]{2,}$/
|
|
|
|
|
const validPassword = /^(?=.*[a-zA-Z])(?=.*\d).{8,}$/
|
|
|
|
|
@ -21,6 +23,8 @@ const InstallForm = () => {
|
|
|
|
|
const [name, setName] = React.useState('')
|
|
|
|
|
const [password, setPassword] = React.useState('')
|
|
|
|
|
const [showPassword, setShowPassword] = React.useState(false)
|
|
|
|
|
const [loading, setLoading] = React.useState(true)
|
|
|
|
|
|
|
|
|
|
const showErrorMessage = (message: string) => {
|
|
|
|
|
Toast.notify({
|
|
|
|
|
type: 'error',
|
|
|
|
|
@ -61,8 +65,20 @@ const InstallForm = () => {
|
|
|
|
|
})
|
|
|
|
|
router.push('/signin')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchSetupStatus().then((res: SetupStatusResponse) => {
|
|
|
|
|
if (res.step === 'finished')
|
|
|
|
|
window.location.href = '/signin'
|
|
|
|
|
else
|
|
|
|
|
setLoading(false)
|
|
|
|
|
})
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
loading
|
|
|
|
|
? <Loading />
|
|
|
|
|
: <>
|
|
|
|
|
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
|
|
|
|
<h2 className="text-[32px] font-bold text-gray-900">{t('login.setAdminAccount')}</h2>
|
|
|
|
|
<p className='
|
|
|
|
|
|