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 | 3x 3x 3x 3x 3x 3x 3x 3x 3x 10x 48x 48x 48x 3x | import Alert from "components/Alert";
import Button from "components/Button";
import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner";
import TextBody from "components/TextBody";
import { useLiteUsers } from "features/userQueries/useLiteUsers";
import { RpcError } from "grpc-web";
import { useTranslation } from "i18n";
import { GLOBAL, PROFILE } from "i18n/namespaces";
import { ListReferencesRes } from "proto/references_pb";
import { UseInfiniteQueryResult } from "react-query";
import hasAtLeastOnePage from "utils/hasAtLeastOnePage";
import makeStyles from "utils/makeStyles";
import ReferenceList from "./ReferenceList";
interface ReferencesViewProps {
isReceived?: boolean;
isReferenceUsersLoading: boolean;
referencesQuery: UseInfiniteQueryResult<ListReferencesRes.AsObject, RpcError>;
referenceUsers: ReturnType<typeof useLiteUsers>["data"];
}
export const useReferencesViewStyles = makeStyles((theme) => ({
noReferencesText: {
marginBlockStart: theme.spacing(1),
},
seeMoreReferencesButtonContainer: {
display: "flex",
justifyContent: "center",
width: "100%",
},
}));
export default function ReferencesView({
isReceived,
isReferenceUsersLoading,
referencesQuery: {
data: referencesRes,
error: referencesError,
fetchNextPage,
hasNextPage,
isFetchingNextPage,
isLoading: isReferencesLoading,
},
referenceUsers,
}: ReferencesViewProps) {
const { t } = useTranslation([GLOBAL, PROFILE]);
const classes = useReferencesViewStyles();
return (
<>
{referencesError && (
<Alert severity="error">{referencesError.message}</Alert>
)}
{isReferenceUsersLoading || isReferencesLoading ? (
<CenteredSpinner />
) : hasAtLeastOnePage(referencesRes, "referencesList") ? (
<>
<ReferenceList
isReceived={isReceived}
referencePages={referencesRes.pages}
referenceUsers={referenceUsers}
/>
{hasNextPage && (
<div className={classes.seeMoreReferencesButtonContainer}>
<Button
loading={isFetchingNextPage}
onClick={() => fetchNextPage()}
>
{t("profile:see_more_references")}
</Button>
</div>
)}
</>
) : (
<TextBody className={classes.noReferencesText}>
{t("profile:no_references")}
</TextBody>
)}
</>
);
}
|