added valiadtion for Team Size whenever going to upgrade or purchase plan
This commit is contained in:
parent
84837bbe45
commit
fe87ebc859
@ -185,13 +185,10 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
</Label>
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
min={1}
|
|
||||||
step={1}
|
step={1}
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("maxUsers", {
|
{...register("maxUsers", {
|
||||||
valueAsNumber: true,
|
valueAsNumber: true,
|
||||||
required: "Team size is required",
|
|
||||||
min: { value: 1, message: "Team size must be at least 1" },
|
|
||||||
})}
|
})}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (["e", "E", "+", "-", "."].includes(e.key)) {
|
if (["e", "E", "+", "-", "."].includes(e.key)) {
|
||||||
@ -203,9 +200,7 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
|
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<div className="d-flex justify-content-start align-items-center gap-2">
|
<div className="d-flex justify-content-start align-items-center gap-2">
|
||||||
<label className="form-label d-block">
|
<label className="form-label d-block">Enable auto renew</label>
|
||||||
Enable auto renew
|
|
||||||
</label>
|
|
||||||
<label className="switch switch-square switch-sm">
|
<label className="switch switch-square switch-sm">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
@ -7,14 +7,15 @@ import { useForm, FormProvider } from "react-hook-form";
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import {
|
import {
|
||||||
getStepFields,
|
getStepFields,
|
||||||
|
getSubscriptionSchema,
|
||||||
newTenantSchema,
|
newTenantSchema,
|
||||||
subscriptionDefaultValues,
|
subscriptionDefaultValues,
|
||||||
subscriptionSchema,
|
|
||||||
tenantDefaultValues,
|
tenantDefaultValues,
|
||||||
} from "./TenantSchema";
|
} from "./TenantSchema";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
const TenantForm = () => {
|
const TenantForm = () => {
|
||||||
|
|
||||||
const HasSelectedCurrentTenant = useSelector(
|
const HasSelectedCurrentTenant = useSelector(
|
||||||
(store) => store.globalVariables.currentTenant
|
(store) => store.globalVariables.currentTenant
|
||||||
);
|
);
|
||||||
@ -45,7 +46,7 @@ const TenantForm = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const subscriptionForm = useForm({
|
const subscriptionForm = useForm({
|
||||||
resolver: zodResolver(subscriptionSchema),
|
resolver: zodResolver(getSubscriptionSchema(HasSelectedCurrentTenant?.data?.activeEmployees)),
|
||||||
defaultValues: subscriptionDefaultValues,
|
defaultValues: subscriptionDefaultValues,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ export const newTenantSchema = z.object({
|
|||||||
.string().trim()
|
.string().trim()
|
||||||
.min(1, { message: "First Name is required!" })
|
.min(1, { message: "First Name is required!" })
|
||||||
.regex(/^[A-Za-z]+$/, { message: "First Name should contain only letters!" }),
|
.regex(/^[A-Za-z]+$/, { message: "First Name should contain only letters!" }),
|
||||||
lastName: z
|
lastName: z
|
||||||
.string().trim()
|
.string().trim()
|
||||||
.min(1, { message: "Last Name is required!" })
|
.min(1, { message: "Last Name is required!" })
|
||||||
.regex(/^[A-Za-z]+$/, { message: "Last Name should contain only letters!" }),
|
.regex(/^[A-Za-z]+$/, { message: "Last Name should contain only letters!" }),
|
||||||
@ -54,19 +54,20 @@ export const tenantDefaultValues = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const subscriptionSchema = z.object({
|
|
||||||
// tenantId: z.string().uuid("Invalid tenant ID"),
|
export const getSubscriptionSchema = (minUsers) =>
|
||||||
planId: z.string().min(1,{message:"Please select Plan"}),
|
z.object({
|
||||||
currencyId: z.string().uuid("Invalid currency"),
|
planId: z.string().min(1, { message: "Please select Plan" }),
|
||||||
maxUsers: z
|
currencyId: z.string().uuid("Invalid currency"),
|
||||||
.number({ invalid_type_error: " Must be a number" })
|
maxUsers: z
|
||||||
.min(1, "Team size is required and must be greater than zero"),
|
.number({ invalid_type_error: "Must be a number" })
|
||||||
frequency: z
|
.min(minUsers, { message: `Team size must be greater than or equal to ${minUsers}` }),
|
||||||
.number({ invalid_type_error: "Frequency must be a number" })
|
frequency: z
|
||||||
.min(0, "Frequency must be at least 1"),
|
.number({ invalid_type_error: "Frequency must be a number" })
|
||||||
isTrial: z.boolean(),
|
.min(1, "Frequency must be at least 1"),
|
||||||
autoRenew: z.boolean(),
|
isTrial: z.boolean(),
|
||||||
});
|
autoRenew: z.boolean(),
|
||||||
|
});
|
||||||
|
|
||||||
export const subscriptionDefaultValues = {
|
export const subscriptionDefaultValues = {
|
||||||
// tenantId: "",
|
// tenantId: "",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user