Skip to content

Commit

Permalink
feat: update profile hook (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fran McDade authored and Fran McDade committed Oct 30, 2024
1 parent a3e52df commit c1669ae
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ButtonProps as MButtonProps,
IconButton as MIconButton,
IconButtonProps as MIconButtonProps,
Skeleton,
} from "@mui/material";
import Router from "next/router";
import React, { ElementType } from "react";
Expand All @@ -23,9 +22,8 @@ export const Authentication = ({
Button,
closeMenu,
}: AuthenticationProps): JSX.Element | null => {
const { isLoading, profile } = useProfile();
const { profile } = useProfile();
if (!authenticationEnabled) return null;
if (isLoading) return <Skeleton height={32} variant="circular" width={32} />;
if (profile) return <AuthenticationMenu profile={profile} />;
return (
<Button
Expand Down
1 change: 0 additions & 1 deletion src/hooks/authentication/profile/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ import {
} from "../../../providers/authentication/authentication/types";

export interface UseProfile {
isLoading: boolean;
profile: Profile<UserProfile>;
}
4 changes: 1 addition & 3 deletions src/hooks/authentication/profile/useProfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAuthentication } from "../../../providers/authentication/authentication/hook";
import { AUTHENTICATION_STATUS } from "../../../providers/authentication/authentication/types";
import { UseProfile } from "./types";

/**
Expand All @@ -8,10 +7,9 @@ import { UseProfile } from "./types";
*/
export const useProfile = (): UseProfile => {
const {
authenticationState: { profile, status },
authenticationState: { profile },
} = useAuthentication();
return {
isLoading: status === AUTHENTICATION_STATUS.PENDING,
profile,
};
};

0 comments on commit c1669ae

Please sign in to comment.