All files / src/sections/PayBuilder/components ProductPreviewView.tsx

81.81% Statements 9/11
50% Branches 2/4
50% Functions 1/2
90% Lines 9/10

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                12x 511x 511x 511x         511x 511x   511x   511x       511x                      
import { useAppSelector } from "@redux/hooks";
import { selectAuth } from "@redux/slices/auth/auth";
import { usePayBuilderContext } from "../provider/PayBuilderContext";
import { usePayBuilderForm } from "../provider/PayBuilderFormProvider";
import { Item_Layout } from "../provider/provider.type";
import ProductPageContainer from "./products/ProductPageContainer";
import UnpublishedPage from "./products/UnpublishedPage";
 
const ProductPreviewView = () => {
  const isAuthenticated = useAppSelector(selectAuth);
  const { displayStatus } = usePayBuilderContext();
  const { methods } = usePayBuilderForm();
  const {
    Style: { itemLayout },
    Items,
    About: { heading, description, assetPosition },
  } = methods.watch();
  const header = { heading, description, assetPosition };
 
  const displayedItems = Items?.filter((item) => item?.display);
 
  Iif (displayStatus === "draft" && !isAuthenticated) {
    return <UnpublishedPage />;
  }
 
  return (
    <ProductPageContainer
      displayStatus={displayStatus}
      header={header}
      isPreview
      items={displayedItems}
      itemLayout={itemLayout as Item_Layout}
    />
  );
};
export default ProductPreviewView;