Whalebird-desktop-client-ma.../renderer/pages/index.tsx

34 lines
864 B
TypeScript
Raw Normal View History

2023-11-01 17:20:27 +01:00
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { db } from '@/db'
2024-01-03 09:24:19 +01:00
import { Spinner } from 'flowbite-react'
2023-11-01 17:20:27 +01:00
export default function Index() {
const router = useRouter()
useEffect(() => {
const f = async () => {
const accounts = await db.accounts.toArray()
if (accounts.length > 0) {
if (typeof localStorage !== 'undefined') {
const lastAccount = localStorage.getItem(`lastAccount`)
if (lastAccount) {
router.push(`/accounts/${lastAccount}`)
} else {
router.push(`/accounts/${accounts[0].id}`)
}
} else {
router.push(`/accounts/${accounts[0].id}`)
}
2023-11-01 17:20:27 +01:00
}
}
f()
}, [])
return (
<div className="h-screen w-full flex justify-center items-center">
2024-01-03 09:24:19 +01:00
<Spinner color="info" />
2023-11-01 17:20:27 +01:00
</div>
)
}