All files / app/features/connections ConnectionsPage.tsx

0% Statements 0/14
100% Branches 0/0
0% Functions 0/1
0% Lines 0/13

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                                                                                                   
import { Box, Stack } from "@mui/material";
import HtmlMeta from "components/HtmlMeta";
import PageTitle from "components/PageTitle";
import { CONNECTIONS } from "i18n/namespaces";
import { useTranslation } from "next-i18next";
 
import BlockedUsersList from "./friends/BlockedUsersList";
import FriendList from "./friends/FriendList";
import FriendRequestsReceived from "./friends/FriendRequestsReceived";
import FriendRequestsSent from "./friends/FriendRequestsSent";
import useFriendList from "./friends/useFriendList";
 
function ConnectionsPage() {
  const { t } = useTranslation([CONNECTIONS]);
  const { errors, isLoading, data: friends, refetchFriends } = useFriendList();
 
  return (
    <>
      <HtmlMeta title={t("connections:my_connections")} />
      <PageTitle>{t("connections:my_connections")}</PageTitle>
      {/* Your friends is the main content, so it gets the larger share and the
          rest stack beside it. On mobile, requests to answer come first. */}
      <Box
        sx={{
          display: "grid",
          gap: 2,
          alignItems: "start",
          gridTemplateAreas: { xs: `"received" "friends" "others"`, md: `"friends received" "friends others"` },
          gridTemplateColumns: { xs: "minmax(0, 1fr)", md: "minmax(0, 7fr) minmax(0, 5fr)" },
          // the second row takes any extra height, so no gap opens under requests
          gridTemplateRows: { md: "auto 1fr" },
        }}
      >
        <Box sx={{ gridArea: "friends" }}>
          <FriendList errors={errors} friends={friends} isLoading={isLoading} />
        </Box>
        <Box sx={{ gridArea: "received" }}>
          <FriendRequestsReceived isContentAboveLoaded={!isLoading} />
        </Box>
        <Stack spacing={2} sx={{ gridArea: "others" }}>
          <FriendRequestsSent />
          <BlockedUsersList refetchFriends={refetchFriends} />
        </Stack>
      </Box>
    </>
  );
}
 
export default ConnectionsPage;