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 [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
|
||||
</div>
|
||||
</div>
|
||||
{Object.entries(plan.features.modules)
|
||||
.filter(([key]) => key !== "id")
|
||||
.map(([key, mod]) => (
|
||||
<div
|
||||
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>
|
||||
<small className="ms-1">{mod.name}</small>
|
||||
</div>
|
||||
))}
|
||||
{plan?.features &&
|
||||
Object.entries(plan?.features?.modules || {})
|
||||
.filter(([key]) => key !== "id")
|
||||
.map(([key, mod]) => (
|
||||
<div
|
||||
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>
|
||||
<small className="ms-1">{mod.name}</small>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<button
|
||||
@ -141,7 +152,10 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
||||
{/* Form Inputs */}
|
||||
<div className="row g-2 mt-3">
|
||||
<div className="col-sm-4">
|
||||
<Label htmlFor="maxUsers" required> Team Size</Label>
|
||||
<Label htmlFor="maxUsers" required>
|
||||
{" "}
|
||||
Team Size
|
||||
</Label>
|
||||
<input
|
||||
type="number"
|
||||
className="form-control form-control-sm"
|
||||
@ -196,7 +210,7 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
||||
type="button"
|
||||
disabled={isPending}
|
||||
>
|
||||
{isPending ? "Please Wait...":"Submit"}
|
||||
{isPending ? "Please Wait..." : "Submit"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user