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