From 19da0fe52aa9ea68275ada541326c21af586e460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 4 Aug 2021 22:34:53 +0200 Subject: [PATCH] Use `loggedInUserData` for `Avatar` props --- src/Login.tsx | 29 +++++++++++------------------ src/authMachine.ts | 2 +- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/Login.tsx b/src/Login.tsx index 032b12f2..bcf1023b 100644 --- a/src/Login.tsx +++ b/src/Login.tsx @@ -17,13 +17,13 @@ import { } from '@chakra-ui/react'; import { useActor } from '@xstate/react'; import React from 'react'; -import { useAuth } from './authContext'; +import { useAuth, useLoggedInUserData } from './authContext'; import { registryLinks } from './registryLinks'; export const Login: React.FC = () => { const authService = useAuth(); + const loggedInUserData = useLoggedInUserData(); const [state] = useActor(authService); - const session = state.context!.client.auth.session(); return ( @@ -41,31 +41,24 @@ export const Login: React.FC = () => { )} - {state.hasTag('authorized') && ( + {state.hasTag('authorized') && loggedInUserData && ( - {state.context.loggedInUserData && ( - - View Machines - - )} + + View Machines + { authService.send('SIGN_OUT'); diff --git a/src/authMachine.ts b/src/authMachine.ts index e7001347..6c09848d 100644 --- a/src/authMachine.ts +++ b/src/authMachine.ts @@ -34,7 +34,7 @@ const authModel = createModel( client: null! as SupabaseClient, notifRef: null! as ActorRefFrom, sourceRef: null as SourceMachineActorRef | null, - loggedInUserData: null as null | LoggedInUserFragment, + loggedInUserData: null as LoggedInUserFragment | null, }, { events: {