"use client"; import React, { useEffect } from "react"; import { Product } from "@/types"; import PriceCard from "@/components/PriceCard"; import { useState } from "react"; import PriceToggle from "@/components/PriceToggle"; import { apiPrices } from "../app/(public)/pricing/actions"; const Payment = ({ type = "one_time", }: { type?: "one_time" | "reoccuring"; }) => { const [isAnnual, setIsAnnual] = useState(false); const [products, setProducts] = useState([]); const [isLoading, setIsLoading] = useState(true); const handleToggle = () => { setIsAnnual((prev) => !prev); }; useEffect(() => { setIsLoading(true); (async () => { const resposeProducts: Product[] = await apiPrices(); setProducts(resposeProducts); setIsLoading(false); })(); }, []); return ( <> {!(type == "one_time") && (
)}
{isLoading ? ( <> ) : ( (products ?? []) .filter((x) => type == "one_time" ? x.type == "one_time" : x.type != "one_time" ) .map((x, i) => ( )) )}
); }; export default Payment;