Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove actor
  • Loading branch information
BrunoQuaresma committed Oct 10, 2023
commit fd84833db8a655f143570230215d2a3c4e4190ba
13 changes: 3 additions & 10 deletions site/src/components/AuthProvider/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useActor, useInterpret } from "@xstate/react";
import { useMachine } from "@xstate/react";
import {
AuthMethods,
UpdateUserProfileRequest,
Expand All @@ -16,7 +16,6 @@ import {
authMachine,
isAuthenticated,
} from "xServices/auth/authXService";
import { ActorRefFrom } from "xstate";

type AuthContextValue = {
isSignedOut: boolean;
Expand All @@ -34,14 +33,12 @@ type AuthContextValue = {
signOut: () => void;
signIn: (email: string, password: string) => void;
updateProfile: (data: UpdateUserProfileRequest) => void;
authService: ActorRefFrom<typeof authMachine>;
};

const AuthContext = createContext<AuthContextValue | undefined>(undefined);

export const AuthProvider: FC<PropsWithChildren> = ({ children }) => {
const authService = useInterpret(authMachine);
const [authState, authSend] = useActor(authService);
const [authState, authSend] = useMachine(authMachine);

const isSignedOut = authState.matches("signedOut");
const isSigningOut = authState.matches("signingOut");
Expand Down Expand Up @@ -83,7 +80,6 @@ export const AuthProvider: FC<PropsWithChildren> = ({ children }) => {
isSignedIn,
isSigningIn,
isUpdatingProfile,
authService,
signOut,
signIn,
updateProfile,
Expand Down Expand Up @@ -112,8 +108,5 @@ export const useAuth = () => {
throw new Error("useAuth should be used inside of <AuthProvider />");
}

return {
...context,
actor: useActor(context.authService),
};
return context;
};