import React, { useState, useEffect } from "react"; import axios from "axios"; import { Link } from "react-router-dom"; import PlanCardSkeleton from "./PlanCardSkeleton"; import { useSubscription } from "../../hooks/useAuth"; import { frequencyLabel } from "../../utils/appUtils"; const SubscriptionPlans = () => { const [plans, setPlans] = useState([]); const [frequency, setFrequency] = useState(1); const { data, isLoading, isError, error } = useSubscription(frequency); const [loading, setLoading] = useState(false); return (
{/* Frequency Switcher */}
{["Monthly", "Quarterly", "Half-Yearly", "Yearly"].map( (label, idx) => ( ) )}
{/* Cards */}
{isLoading ? ( // Show 3 skeletons <> ) : data.length === 0 ? (
No plans found
) : isError ? (

{error.message}

{error.name}

) : ( data.map((plan) => (
{/* Header */}

{plan.planName}

{plan.description}

{/* Price */}

{plan.currency?.symbol} {plan.price} / {frequencyLabel(frequency)}

{/* Storage & Trial */}
Storage {plan.maxStorage} MB
Trial Days {plan.trialDays}
{/* Features */}
Features
    {plan.features?.modules && Object.values(plan.features.modules).map((mod) => mod && mod.name ? (
  • {mod.enabled ? ( ) : ( )} {mod.name}
  • ) : null )}
{/* Button */}
Subscribe Request a Demo
)) )}
); }; export default SubscriptionPlans;