Last active
May 1, 2025 11:49
-
-
Save danecando/57b03230768dcbfff7b47edf44f66f43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
interface Props<T extends Promise<any>[]> { | |
promises: T; | |
children: (results: { [P in keyof T]: Awaited<T[P]> }) => React.ReactNode; | |
} | |
export function Awaiter<T extends Promise<any>[]>({ promises, children }: Props<T>) { | |
const results = React.use(Promise.all(promises)); | |
return <>{children(results)}</>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function EmailNotVerified({ children }: EmailNotVerifiedProps) { | |
return ( | |
<React.Suspense> | |
<Awaiter promises={[authClient.getAuthUser()]}> | |
{([user]) => { | |
if (!user || user?.emailVerified) { | |
return null; | |
} | |
return children; | |
}} | |
</Awaiter> | |
</React.Suspense> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment