Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

738 B
Raw Blame
"use client";

import React from "react";
import type { PayWallPricing } from "../client";
import { usePayWallStore } from "../client";
import { PayWallDialog } from "./pay-wall-dialog";

/**
 * Single, app-wide paywall instance.
 * Open it from anywhere with `showPayWall()`.
 */
export function PayWall({ pricing }: { pricing: PayWallPricing | null }) {
  const isOpen = usePayWallStore((state) => state.isOpen);
  const hide = usePayWallStore((state) => state.hide);

  React.useEffect(() => {
    usePayWallStore.setState({ pricing });
  }, [pricing]);

  return (
    <PayWallDialog
      pricing={pricing}
      isOpen={isOpen}
      onOpenChange={(open) => {
        if (!open) {
          hide();
        }
      }}
    />
  );
}