All files / app/features/messages/requests HostRequestGuideLinks.tsx

0% Statements 0/14
0% Branches 0/9
0% Functions 0/2
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 51 52 53 54 55 56 57 58 59 60 61 62                                                                                                                           
import { styled, Typography } from "@mui/material";
import StyledLink from "components/StyledLink";
import { Trans } from "i18n";
import { HostRequestStatus } from "proto/conversations_pb";
import React from "react";
import { howToRespondRequestGuideUrl, howToWriteRequestGuideUrl } from "routes";
 
const StyledHelpTextContainer = styled("div")(({ theme }) => ({
  display: "flex",
  flexWrap: "wrap",
  justifyContent: "center",
  marginBottom: theme.spacing(2),
}));
 
export default function HostRequestGuideLinks({
  isPast,
  isHost,
  status,
}: {
  isPast: boolean;
  isHost: boolean;
  status: HostRequestStatus;
}) {
  const isHostPending =
    !isPast &&
    isHost &&
    status === HostRequestStatus.HOST_REQUEST_STATUS_PENDING;
 
  const isSurferRejected =
    !isHost && status === HostRequestStatus.HOST_REQUEST_STATUS_REJECTED;
 
  if (isHostPending) {
    return (
      <StyledHelpTextContainer>
        <Typography variant="body1">
          <Trans i18nKey="messages:host_pending_request_help_text">
            <StyledLink variant="body1" href={howToRespondRequestGuideUrl}>
              Things to consider
            </StyledLink>{" "}
            before responding.
          </Trans>
        </Typography>
      </StyledHelpTextContainer>
    );
  } else if (isSurferRejected) {
    return (
      <StyledHelpTextContainer>
        <Typography variant="body1">
          <Trans i18nKey="messages:surfer_declined_request_help_text">
            <StyledLink variant="body1" href={howToWriteRequestGuideUrl}>
              Read our guide
            </StyledLink>{" "}
            on how to write a request that will get accepted.
          </Trans>
        </Typography>
      </StyledHelpTextContainer>
    );
  } else {
    return null;
  }
}