handle error if features missing
This commit is contained in:
parent
e466fd27be
commit
56b5633c51
@ -10,8 +10,10 @@ import { useNavigate } from "react-router-dom";
|
|||||||
const SubScription = ({ onSubmitSubScription, onNext }) => {
|
const SubScription = ({ onSubmitSubScription, onNext }) => {
|
||||||
const [frequency, setFrequency] = useState(2);
|
const [frequency, setFrequency] = useState(2);
|
||||||
const [selectedPlanId, setSelectedPlanId] = useState(null);
|
const [selectedPlanId, setSelectedPlanId] = useState(null);
|
||||||
const selectedTenant = useSelector((store)=>store.globalVariables.currentTenant)
|
const selectedTenant = useSelector(
|
||||||
const naviget = useNavigate()
|
(store) => store.globalVariables.currentTenant
|
||||||
|
);
|
||||||
|
const naviget = useNavigate();
|
||||||
const {
|
const {
|
||||||
data: plans = [],
|
data: plans = [],
|
||||||
isError,
|
isError,
|
||||||
@ -26,9 +28,13 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useFormContext();
|
} = useFormContext();
|
||||||
|
|
||||||
const {mutate:AddSubScription,isPending,error} = useAddSubscription(()=>{
|
const {
|
||||||
onNext()
|
mutate: AddSubScription,
|
||||||
} )
|
isPending,
|
||||||
|
error,
|
||||||
|
} = useAddSubscription(() => {
|
||||||
|
onNext();
|
||||||
|
});
|
||||||
const handleSubscriptionSubmit = async () => {
|
const handleSubscriptionSubmit = async () => {
|
||||||
const isValid = await trigger([
|
const isValid = await trigger([
|
||||||
"planId",
|
"planId",
|
||||||
@ -42,8 +48,8 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
const payload = getValues();
|
const payload = getValues();
|
||||||
// onSubmitSubScription(payload);
|
// onSubmitSubScription(payload);
|
||||||
const subscriptionPayload = {...payload,tenantId:selectedTenant.id}
|
const subscriptionPayload = { ...payload, tenantId: selectedTenant.id };
|
||||||
AddSubScription(subscriptionPayload)
|
AddSubScription(subscriptionPayload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -109,19 +115,24 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
Features
|
Features
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{Object.entries(plan.features.modules)
|
{plan?.features &&
|
||||||
.filter(([key]) => key !== "id")
|
Object.entries(plan?.features?.modules || {})
|
||||||
.map(([key, mod]) => (
|
.filter(([key]) => key !== "id")
|
||||||
<div
|
.map(([key, mod]) => (
|
||||||
key={key}
|
<div
|
||||||
className="mb-2 d-flex align-items-center"
|
key={key}
|
||||||
>
|
className="mb-2 d-flex align-items-center"
|
||||||
<i
|
>
|
||||||
className={`fa-regular ${mod.enabled ? "fa-circle-check text-success" : "fa-circle-xmark text-danger"} `}
|
<i
|
||||||
></i>
|
className={`fa-regular ${
|
||||||
<small className="ms-1">{mod.name}</small>
|
mod.enabled
|
||||||
</div>
|
? "fa-circle-check text-success"
|
||||||
))}
|
: "fa-circle-xmark text-danger"
|
||||||
|
}`}
|
||||||
|
></i>
|
||||||
|
<small className="ms-1">{mod.name}</small>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@ -141,7 +152,10 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
{/* Form Inputs */}
|
{/* Form Inputs */}
|
||||||
<div className="row g-2 mt-3">
|
<div className="row g-2 mt-3">
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<Label htmlFor="maxUsers" required> Team Size</Label>
|
<Label htmlFor="maxUsers" required>
|
||||||
|
{" "}
|
||||||
|
Team Size
|
||||||
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
@ -196,7 +210,7 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
type="button"
|
type="button"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
>
|
>
|
||||||
{isPending ? "Please Wait...":"Submit"}
|
{isPending ? "Please Wait..." : "Submit"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user