mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-07 14:53:16 -04:00
* centralise auth state into context * remove accounts from feature flags * move from context to store in @sd/client
26 lines
581 B
TypeScript
26 lines
581 B
TypeScript
import { auth } from '@sd/client';
|
|
import { Button, ButtonProps } from '@sd/ui';
|
|
|
|
import { usePlatform } from '..';
|
|
|
|
export function LoginButton({ children, ...props }: { onLogin?(): void } & ButtonProps) {
|
|
const authState = auth.useStateSnapshot();
|
|
|
|
const platform = usePlatform();
|
|
|
|
return (
|
|
<Button
|
|
variant="accent"
|
|
disabled={authState.status === 'loggingIn'}
|
|
onClick={async () => {
|
|
await auth.login(platform.auth);
|
|
|
|
props.onLogin?.();
|
|
}}
|
|
{...props}
|
|
>
|
|
{authState.status !== 'loggingIn' ? children || 'Log in' : 'Logging In...'}
|
|
</Button>
|
|
);
|
|
}
|