tachybase_todo/packages/plugins/@nocobase/plugin-auth/src/client/pages/AuthLayout.tsx
YANG QIA 06f11a2d08
refactor(auth): move auth client from core to the plugin & refactor auth client api (#3215)
* refactor(auth): auth client api

* fix: build

* fix: dependencies

* fix: fix T-2777

* fix: fix T-2776

* chore: update type

* fix: build

* fix: allowSignUp

* fix: file name

* fix: file name

* refactor: client api

* fix: build

* chore: update name

* fix: tsx must be loaded with --import instead of --loader

* fix: type

* fix: type

* fix: type

* fix: type

* fix: bug

* chore: improve wording

* fix: test

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
2023-12-21 20:19:25 +08:00

49 lines
1.1 KiB
TypeScript

import { css } from '@emotion/css';
import React from 'react';
import { Outlet } from 'react-router-dom';
import { useSystemSettings, PoweredBy, useRequest, useAPIClient } from '@nocobase/client';
import { AuthenticatorsContext } from '../authenticator';
export function AuthLayout(props: any) {
const { data } = useSystemSettings();
const api = useAPIClient();
const { data: authenticators = [], error } = useRequest(() =>
api
.resource('authenticators')
.publicList()
.then((res) => {
return res?.data?.data || [];
}),
);
if (error) {
throw error;
}
return (
<div
style={{
maxWidth: 320,
margin: '0 auto',
paddingTop: '20vh',
}}
>
<h1>{data?.data?.title}</h1>
<AuthenticatorsContext.Provider value={authenticators as any}>
<Outlet />
</AuthenticatorsContext.Provider>
<div
className={css`
position: absolute;
bottom: 24px;
width: 100%;
left: 0;
text-align: center;
`}
>
<PoweredBy />
</div>
</div>
);
}