Update user data fallback and theme handling
This commit adds a fallback mechanism to handle `null` user values in the site header account section. Previously, if `user.data` was `null`, the code could fail. Now, it checks for valid `user.data` before proceeding. For the layout section, it now includes a separate condition for 'light' theme, providing a clear distinction between 'dark'
This commit is contained in:
@@ -39,13 +39,14 @@ export function SiteHeaderAccountSection({
|
|||||||
function SuspendedPersonalAccountDropdown(props: { user: User | null }) {
|
function SuspendedPersonalAccountDropdown(props: { user: User | null }) {
|
||||||
const signOut = useSignOut();
|
const signOut = useSignOut();
|
||||||
const user = useUser(props.user);
|
const user = useUser(props.user);
|
||||||
|
const userData = user.data ?? props.user ?? null;
|
||||||
|
|
||||||
if (user.data) {
|
if (userData) {
|
||||||
return (
|
return (
|
||||||
<PersonalAccountDropdown
|
<PersonalAccountDropdown
|
||||||
paths={paths}
|
paths={paths}
|
||||||
features={features}
|
features={features}
|
||||||
user={user.data}
|
user={userData}
|
||||||
signOutRequested={() => signOut.mutateAsync()}
|
signOutRequested={() => signOut.mutateAsync()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,14 +51,16 @@ export default async function RootLayout({
|
|||||||
|
|
||||||
function getClassName(theme?: string) {
|
function getClassName(theme?: string) {
|
||||||
const dark = theme === 'dark';
|
const dark = theme === 'dark';
|
||||||
|
const light = theme === 'light';
|
||||||
|
|
||||||
return cn(
|
return cn(
|
||||||
'min-h-screen bg-background antialiased',
|
'min-h-screen bg-background antialiased',
|
||||||
{
|
|
||||||
dark,
|
|
||||||
},
|
|
||||||
sans.variable,
|
sans.variable,
|
||||||
heading.variable,
|
heading.variable,
|
||||||
|
{
|
||||||
|
dark,
|
||||||
|
light,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user