mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-19 06:17:04 -04:00
Use WithPrivateUser
This commit is contained in:
@@ -8,15 +8,14 @@ import {useCallback} from "react";
|
||||
import {debounce} from "lodash";
|
||||
import {api} from "web/lib/api";
|
||||
import {MultiSelectAnswers} from "web/components/answers/answer-compatibility-question-content";
|
||||
import {usePrivateUser} from "web/hooks/use-user";
|
||||
import {PrivateUser} from "common/user";
|
||||
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator";
|
||||
import {WithPrivateUser} from "web/components/user/with-user";
|
||||
|
||||
export const NotificationSettings = () => {
|
||||
const privateUser = usePrivateUser()
|
||||
if (!privateUser) return <CompassLoadingIndicator/>
|
||||
return <LoadedNotificationSettings privateUser={privateUser}/>
|
||||
}
|
||||
export const NotificationSettings = () => (
|
||||
<WithPrivateUser>
|
||||
{user => <LoadedNotificationSettings privateUser={user}/>}
|
||||
</WithPrivateUser>
|
||||
)
|
||||
|
||||
function LoadedNotificationSettings(props: {
|
||||
privateUser: PrivateUser,
|
||||
|
||||
10
web/components/user/with-user.tsx
Normal file
10
web/components/user/with-user.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import {usePrivateUser} from "web/hooks/use-user";
|
||||
import {PrivateUser} from "common/user";
|
||||
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator";
|
||||
|
||||
|
||||
export function WithPrivateUser({children}: { children: (user: PrivateUser) => JSX.Element }) {
|
||||
const privateUser = usePrivateUser()
|
||||
if (!privateUser) return <CompassLoadingIndicator/>
|
||||
return children(privateUser)
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import {NoSEO} from 'web/components/NoSEO'
|
||||
import {UncontrolledTabs} from 'web/components/layout/tabs'
|
||||
import {PageBase} from 'web/components/page-base'
|
||||
import {Title} from 'web/components/widgets/title'
|
||||
import {usePrivateUser} from 'web/hooks/use-user'
|
||||
import {useRedirectIfSignedOut} from "web/hooks/use-redirect-if-signed-out";
|
||||
import toast from "react-hot-toast";
|
||||
import {deleteAccount} from "web/lib/util/delete";
|
||||
@@ -13,7 +12,7 @@ import {getAuth, sendEmailVerification, sendPasswordResetEmail} from 'firebase/a
|
||||
import {auth} from "web/lib/firebase/users";
|
||||
import {NotificationSettings} from "web/components/notifications";
|
||||
import ThemeIcon from "web/components/theme-icon";
|
||||
import {CompassLoadingIndicator} from "web/components/widgets/loading-indicator";
|
||||
import {WithPrivateUser} from "web/components/user/with-user";
|
||||
|
||||
export default function NotificationsPage() {
|
||||
useRedirectIfSignedOut()
|
||||
@@ -32,11 +31,11 @@ export default function NotificationsPage() {
|
||||
)
|
||||
}
|
||||
|
||||
export const GeneralSettings = () => {
|
||||
const privateUser = usePrivateUser()
|
||||
if (!privateUser) return <CompassLoadingIndicator/>
|
||||
return <LoadedGeneralSettings privateUser={privateUser}/>
|
||||
}
|
||||
export const GeneralSettings = () => (
|
||||
<WithPrivateUser>
|
||||
{user => <LoadedGeneralSettings privateUser={user}/>}
|
||||
</WithPrivateUser>
|
||||
)
|
||||
|
||||
const LoadedGeneralSettings = (props: {
|
||||
privateUser: PrivateUser,
|
||||
|
||||
Reference in New Issue
Block a user