All files / src/sections/PayBuilder/components/InvoicePreview InvoicePreviewView.tsx

11.11% Statements 1/9
0% Branches 0/10
0% Functions 0/1
11.11% Lines 1/9

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                      12x                                                                                      
import { Stack } from "@mui/material";
import GiveTabs from "@shared/Tabs/GiveTabs";
import { useState } from "react";
import EmailPreview from "./EmailPreview";
import { useAppTheme } from "@theme/v2/Provider";
import { useGetCurrentMerchantId } from "@hooks/common";
import { useGetMerchantById } from "@hooks/enterprise-api/account/useGetMerchants";
import InvoiceCheckoutPage from "@pages/Checkout/InvoiceCheckoutPage";
import PDFPage from "./PDFPage";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
 
const invoicePreviewTabs = [
  {
    label: "Email",
    value: "email",
  },
  {
    label: "PDF",
    value: "pdf_page",
  },
  {
    label: "Payment page",
    value: "payment_page",
  },
];
 
enum InvoicePreviewTabs {
  EMAIL = "email",
  PAYMENT_PAGE = "payment_page",
  PDF_PAGE = "pdf_page",
}
 
function InvoicePreviewView() {
  const [selectedTab, setSelectedTab] = useState(
    InvoicePreviewTabs.PAYMENT_PAGE,
  );
  const { palette } = useAppTheme();
  const isEmailTab = selectedTab === InvoicePreviewTabs.EMAIL;
  const isPDFTab = selectedTab === InvoicePreviewTabs.PDF_PAGE;
  const isPaymentPageTab = selectedTab === InvoicePreviewTabs.PAYMENT_PAGE;
 
  const { merchantId } = useGetCurrentMerchantId();
  const { data: merchant } = useGetMerchantById({ merchantId });
 
  return (
    <Stack spacing={2} sx={{ width: "100%", height: "100%" }}>
      {isEmailTab && <EmailPreview from={merchant?.name || ""} />}
      {isPDFTab && <PDFPage from={merchant} />}
      {isPaymentPageTab && <InvoiceCheckoutPage from={merchant?.name || ""} />}
    </Stack>
  );
}
 
export default InvoicePreviewView;