diff --git a/src/components/Tenanat/SubScription.jsx b/src/components/Tenanat/SubScription.jsx index d3c11ab3..9f88acf7 100644 --- a/src/components/Tenanat/SubScription.jsx +++ b/src/components/Tenanat/SubScription.jsx @@ -10,8 +10,10 @@ import { useNavigate } from "react-router-dom"; const SubScription = ({ onSubmitSubScription, onNext }) => { const [frequency, setFrequency] = useState(2); const [selectedPlanId, setSelectedPlanId] = useState(null); - const selectedTenant = useSelector((store)=>store.globalVariables.currentTenant) - const naviget = useNavigate() + const selectedTenant = useSelector( + (store) => store.globalVariables.currentTenant + ); + const naviget = useNavigate(); const { data: plans = [], isError, @@ -26,9 +28,13 @@ const SubScription = ({ onSubmitSubScription, onNext }) => { formState: { errors }, } = useFormContext(); - const {mutate:AddSubScription,isPending,error} = useAddSubscription(()=>{ - onNext() - } ) + const { + mutate: AddSubScription, + isPending, + error, + } = useAddSubscription(() => { + onNext(); + }); const handleSubscriptionSubmit = async () => { const isValid = await trigger([ "planId", @@ -42,8 +48,8 @@ const SubScription = ({ onSubmitSubScription, onNext }) => { if (isValid) { const payload = getValues(); // onSubmitSubScription(payload); - const subscriptionPayload = {...payload,tenantId:selectedTenant.id} - AddSubScription(subscriptionPayload) + const subscriptionPayload = { ...payload, tenantId: selectedTenant.id }; + AddSubScription(subscriptionPayload); } }; @@ -109,19 +115,24 @@ const SubScription = ({ onSubmitSubScription, onNext }) => { Features - {Object.entries(plan.features.modules) - .filter(([key]) => key !== "id") - .map(([key, mod]) => ( -
- - {mod.name} -
- ))} + {plan?.features && + Object.entries(plan?.features?.modules || {}) + .filter(([key]) => key !== "id") + .map(([key, mod]) => ( +
+ + {mod.name} +
+ ))}