ente/packages/accounts/pages/login.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-11-01 11:36:03 +00:00
import { useState, useEffect } from 'react';
2023-11-02 03:36:31 +00:00
import EnteSpinner from '@ente/shared/components/EnteSpinner';
import Login from '../components/Login';
import { VerticallyCentered } from '@ente/shared/components/Container';
2023-11-02 02:02:37 +00:00
import { getData, LS_KEYS } from '@ente/shared/storage/localStorage';
2023-11-02 03:36:31 +00:00
import { PAGES } from '../constants/pages';
import FormPaper from '@ente/shared/components/Form/FormPaper';
2023-11-02 03:45:48 +00:00
import { PageProps } from '@ente/shared/apps/types';
2023-11-01 07:45:00 +00:00
2023-11-02 05:26:51 +00:00
export default function LoginPage({ appContext, router, appName }: PageProps) {
2023-11-01 11:36:03 +00:00
const [loading, setLoading] = useState(true);
2023-11-01 07:45:00 +00:00
2023-11-01 11:36:03 +00:00
useEffect(() => {
const user = getData(LS_KEYS.USER);
if (user?.email) {
router.push(PAGES.VERIFY);
}
setLoading(false);
2023-11-09 14:23:14 +00:00
appContext.showNavBar(true);
2023-11-01 11:36:03 +00:00
}, []);
2023-11-01 07:45:00 +00:00
2023-11-02 03:36:31 +00:00
const register = () => {
router.push(PAGES.SIGNUP);
};
2023-11-01 10:01:08 +00:00
2023-11-01 11:36:03 +00:00
return loading ? (
<VerticallyCentered>
<EnteSpinner />
</VerticallyCentered>
) : (
<VerticallyCentered>
2023-11-02 03:36:31 +00:00
<FormPaper>
<Login signUp={register} appName={appName} />
</FormPaper>
2023-11-01 11:36:03 +00:00
</VerticallyCentered>
2023-11-01 10:01:08 +00:00
);
2023-11-01 07:45:00 +00:00
}