Skip to content

Commit

Permalink
Fix alert background colors
Browse files Browse the repository at this point in the history
  • Loading branch information
domhhv committed Feb 8, 2024
1 parent e594f82 commit d7c8d07
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/components/user/useAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ export const useAccount = () => {
return;
}

setForbidden(false);

setLoading(true);
setForbidden(false);

const loadUserProfile = async () => {
const [data] = await getUserAccount();
Expand Down
10 changes: 4 additions & 6 deletions src/context/Auth/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useSnackbar, AuthContext } from '@context';
import { signIn, signOut, signUp } from '@services';
import React from 'react';

type UserProviderProps = {
type AuthProviderProps = {
children: React.ReactNode;
};

const AuthProvider = ({ children }: UserProviderProps) => {
const AuthProvider = ({ children }: AuthProviderProps) => {
const { showSnackbar } = useSnackbar();
const [authenticating, setAuthenticating] = React.useState(false);

Expand Down Expand Up @@ -50,13 +50,11 @@ const AuthProvider = ({ children }: UserProviderProps) => {
try {
const { error } = await signIn(email, password);

console.log('error:', error);

if (error) {
throw error;
}

showSnackbar(`Welcome, ${email}!`, {
showSnackbar('Welcome back!', {
variant: 'solid',
color: 'success',
});
Expand All @@ -80,7 +78,7 @@ const AuthProvider = ({ children }: UserProviderProps) => {
const logout = React.useCallback(async () => {
await signOut();
showSnackbar('Logged out', {
variant: 'solid',
variant: 'soft',
color: 'neutral',
dismissible: true,
});
Expand Down
21 changes: 21 additions & 0 deletions src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import { extendTheme } from '@mui/joy/styles';

export const theme = extendTheme({
components: {
JoyAlert: {
styleOverrides: {
root: ({ ownerState, theme }) => {
if (ownerState.color !== 'neutral' && ownerState.variant !== 'soft') {
return null;
}

return theme.palette.mode === 'light'
? {
backgroundColor: theme.palette.neutral[50],
color: theme.palette.neutral[800],
}
: {
backgroundColor: theme.palette.neutral[900],
color: theme.palette.neutral[100],
};
},
},
},
},
colorSchemes: {
light: {
palette: {
Expand Down

0 comments on commit d7c8d07

Please sign in to comment.