fixed missing fieldd noOfEmployee inside employee

This commit is contained in:
pramod.mahajan 2025-11-06 18:08:19 +05:30
parent 72e5cf0bbe
commit 161f14d247
2 changed files with 55 additions and 51 deletions

View File

@ -10,7 +10,7 @@ const ALLOWED_TYPES = [
"image/jpeg",
];
export const ExpenseSchema = (expenseTypes) => {
export const ExpenseSchema = (ExpenseCategories) => {
return z
.object({
projectId: z.string().min(1, { message: "Project is required" }),
@ -70,11 +70,11 @@ export const ExpenseSchema = (expenseTypes) => {
}
)
.superRefine((data, ctx) => {
const expenseType = expenseTypes.find(
(et) => et.id === data.expensesCategoryId
const ExpenseCategory = ExpenseCategories.find(
(et) => et.id === data.expenseCategoryId
);
if (
expenseType?.noOfPersonsRequired &&
ExpenseCategory?.noOfPersonsRequired &&
(!data.noOfPersons || data.noOfPersons < 1)
) {
ctx.addIssue({
@ -177,7 +177,7 @@ export const SearchSchema = z.object({
statusIds: z.array(z.string()).optional(),
createdByIds: z.array(z.string()).optional(),
paidById: z.array(z.string()).optional(),
ExpenseTypeIds: z.array(z.string()).optional(),
ExpenseCategoryIds: z.array(z.string()).optional(),
startDate: z.string().optional(),
endDate: z.string().optional(),
isTransactionDate: z.boolean().default(true),
@ -188,7 +188,7 @@ export const defaultFilter = {
statusIds: [],
createdByIds: [],
paidById: [],
ExpenseTypeIds: [],
ExpenseCategoryIds: [],
isTransactionDate: true,
startDate: null,
endDate: null,

View File

@ -153,7 +153,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
if (expenseToEdit && data) {
reset({
projectId: data.project.id || "",
expenseCategoryId: data.expenseType.id || "",
expenseCategoryId: data?.expenseCategory?.id || "",
paymentModeId: data.paymentMode.id || "",
paidById: data.paidBy.id || "",
transactionDate: data.transactionDate?.slice(0, 10) || "",
@ -200,7 +200,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
CreateExpense(payload);
}
};
const ExpenseTypeId = watch("expensesCategoryId");
const ExpenseTypeId = watch("expenseCategoryId");
useEffect(() => {
setExpenseType(
@ -306,7 +306,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
)}
</div>
<div className="col-12 col-md-6 text-start">
<Label className="form-label" required>Paid By </Label>
<Label className="form-label" required>
Paid By{" "}
</Label>
<EmployeeSearchInput
control={control}
name="paidById"
@ -421,24 +423,8 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
)}
</div>
{ExpenseType?.noOfPersonsRequired && (
<div className="col-md-6 mt-2 text-start">
<label className="form-label ">No. of Persons</label>
<input
type="number"
id="noOfPersons"
className="form-control form-control-sm"
{...register("noOfPersons")}
inputMode="numeric"
/>
{errors.noOfPersons && (
<small className="danger-text">
{errors.noOfPersons.message}
</small>
)}
</div>
)}
</div>
<div className="row">
<div className="col-md-6 text-start ">
<Label htmlFor="currencyId" className="form-label" required>
Select Currency
@ -465,6 +451,24 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
<small className="danger-text">{errors.currencyId.message}</small>
)}
</div>
{ExpenseType?.noOfPersonsRequired && (
<div className="col-md-6 text-start">
<Label className="form-label" required>No. of Persons</Label>
<input
type="number"
id="noOfPersons"
className="form-control form-control-sm"
{...register("noOfPersons")}
inputMode="numeric"
/>
{errors.noOfPersons && (
<small className="danger-text">
{errors.noOfPersons.message}
</small>
)}
</div>
)}
</div>
<div className="row my-2 text-start">
<div className="col-md-12">