Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 6x 2x 5x 5x 5x 13x 13x 13x 13x 13x 13x 13x 13x 12x 12x 12x | import Alert from "components/Alert"; import Button from "components/Button"; import ProfileIncompleteDialog from "components/ProfileIncompleteDialog/ProfileIncompleteDialog"; import { useAuthContext } from "features/auth/AuthProvider"; import useAccountInfo from "features/auth/useAccountInfo"; import FlagButton from "features/FlagButton"; import FriendActions from "features/profile/actions/FriendActions"; import MessageUserButton from "features/profile/actions/MessageUserButton"; import UserOverview from "features/profile/view/UserOverview"; import { GLOBAL, PROFILE } from "i18n/namespaces"; import Link from "next/link"; import { useTranslation } from "next-i18next"; import { HostingStatus } from "proto/api_pb"; import { useState } from "react"; import { connectionsRoute, EditUserTab, routeToEditProfile, UserTab, } from "routes"; import { theme } from "theme"; import makeStyles from "utils/makeStyles"; import { useProfileUser } from "../hooks/useProfileUser"; import AdminPanelUserButton from "./AdminPanelUserButton"; const useStyles = makeStyles((theme) => ({ modButtons: { alignSelf: "center", }, })); const getEditTab = (tab: UserTab): EditUserTab | undefined => { switch (tab) { case "about": case "home": return tab; default: return undefined; } }; function LoggedInUserActions({ tab }: { tab: UserTab }) { const { t } = useTranslation([GLOBAL, PROFILE]); return ( <> <Link href={routeToEditProfile(getEditTab(tab))} passHref legacyBehavior> <Button component="a" color="primary"> {t("global:edit")} </Button> </Link> <Link href={connectionsRoute} passHref legacyBehavior> <Button component="a" variant="outlined" sx={{ color: theme.palette.common.black, borderColor: theme.palette.grey[300], "&:hover": { borderColor: theme.palette.grey[300], backgroundColor: "#3135390A", }, }} > {t("profile:my_connections")} </Button> </Link> </> ); } function DefaultActions({ setIsRequesting, }: { setIsRequesting: (value: boolean) => void; }) { const { t } = useTranslation([GLOBAL, PROFILE]); const classes = useStyles(); const user = useProfileUser(); const disableHosting = user.hostingStatus === HostingStatus.HOSTING_STATUS_CANT_HOST; const [mutationError, setMutationError] = useState(""); const [showCantRequestDialog, setShowCantRequestDialog] = useState<boolean>(false); const { data: accountInfo, isLoading: isAccountInfoLoading } = useAccountInfo(); const requestButton = () => { if (!accountInfo?.profileComplete) { setShowCantRequestDialog(true); } else { setIsRequesting(true); } }; return ( <> <ProfileIncompleteDialog open={showCantRequestDialog} onClose={() => setShowCantRequestDialog(false)} attempted_action="send_request" /> <Button onClick={requestButton} disabled={isAccountInfoLoading || disableHosting} > {disableHosting ? t("global:hosting_status.cant_host") : t("profile:actions.request")} </Button> <MessageUserButton user={user} setMutationError={setMutationError} /> <FriendActions user={user} setMutationError={setMutationError} /> <div className={classes.modButtons}> <FlagButton contentRef={`profile/${user.userId}`} authorUser={user.userId} /> <AdminPanelUserButton username={user.username} /> </div> {mutationError && <Alert severity="error">{mutationError}</Alert>} </> ); } export interface OverviewProps { setIsRequesting: (value: boolean) => void; tab: UserTab; } export default function Overview({ setIsRequesting, tab }: OverviewProps) { const currentUserId = useAuthContext().authState.userId; const user = useProfileUser(); return ( <UserOverview showHostAndMeetAvailability actions={ user.userId === currentUserId ? ( <LoggedInUserActions tab={tab} /> ) : ( <DefaultActions setIsRequesting={setIsRequesting} /> ) } /> ); } |