fixed itself - payeee issue ( not submitting form after checkin-uncheck check-box)
This commit is contained in:
parent
25a599e614
commit
492f483f5e
@ -18,9 +18,9 @@ import {
|
|||||||
PaymentRequestSchema,
|
PaymentRequestSchema,
|
||||||
} from "./PaymentRequestSchema";
|
} from "./PaymentRequestSchema";
|
||||||
import { INR_CURRENCY_CODE } from "../../utils/constants";
|
import { INR_CURRENCY_CODE } from "../../utils/constants";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
|
||||||
import Filelist from "../Expenses/Filelist";
|
import Filelist from "../Expenses/Filelist";
|
||||||
import InputSuggestions from "../common/InputSuggestion";
|
import InputSuggestions from "../common/InputSuggestion";
|
||||||
|
import { useProfile } from "../../hooks/useProfile";
|
||||||
|
|
||||||
function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
||||||
const {
|
const {
|
||||||
@ -30,6 +30,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
error: requestError,
|
error: requestError,
|
||||||
} = usePaymentRequestDetail(requestToEdit);
|
} = usePaymentRequestDetail(requestToEdit);
|
||||||
|
|
||||||
|
const { profile } = useProfile();
|
||||||
const {
|
const {
|
||||||
projectNames,
|
projectNames,
|
||||||
loading: projectLoading,
|
loading: projectLoading,
|
||||||
@ -49,7 +50,6 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
error: ExpenseError,
|
error: ExpenseError,
|
||||||
} = useExpenseCategory();
|
} = useExpenseCategory();
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: Payees,
|
data: Payees,
|
||||||
isLoading: isPayeeLoaing,
|
isLoading: isPayeeLoaing,
|
||||||
@ -187,13 +187,17 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
let payload = {
|
let payload = {
|
||||||
...fromdata,
|
...fromdata,
|
||||||
dueDate: localToUtc(fromdata.dueDate),
|
dueDate: localToUtc(fromdata.dueDate),
|
||||||
payee: isItself ? `${profile?.employeeInfo?.firstName} ${profile?.employeeInfo?.lastName}` : fromdata.payee,
|
payee: isItself
|
||||||
|
? `${profile?.employeeInfo?.firstName} ${profile?.employeeInfo?.lastName}`
|
||||||
|
: fromdata.payee,
|
||||||
};
|
};
|
||||||
if (requestToEdit) {
|
if (requestToEdit) {
|
||||||
const editPayload = {
|
const editPayload = {
|
||||||
...payload,
|
...payload,
|
||||||
id: data.id,
|
id: data.id,
|
||||||
payee: isItself ? `${profile?.employeeInfo?.firstName} ${profile?.employeeInfo?.lastName}` : fromdata.payee,
|
payee: isItself
|
||||||
|
? `${profile?.employeeInfo?.firstName} ${profile?.employeeInfo?.lastName}`
|
||||||
|
: fromdata.payee,
|
||||||
};
|
};
|
||||||
PaymentRequestUpdate({ id: data.id, payload: editPayload });
|
PaymentRequestUpdate({ id: data.id, payload: editPayload });
|
||||||
} else {
|
} else {
|
||||||
@ -202,14 +206,10 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
};
|
};
|
||||||
const handleSetItSelf = (e) => {
|
const handleSetItSelf = (e) => {
|
||||||
setisItself(e.target.value);
|
setisItself(e.target.value);
|
||||||
let name = `${profile?.employeeInfo.firstName} ${profile?.employeeInfo.lastName}`
|
let name = `${profile?.employeeInfo.firstName} ${profile?.employeeInfo.lastName}`;
|
||||||
|
|
||||||
setValue(
|
setValue("payee", name);
|
||||||
"payee",
|
|
||||||
name
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container p-3">
|
<div className="container p-3">
|
||||||
<h5 className="m-0">
|
<h5 className="m-0">
|
||||||
@ -309,11 +309,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
checked={field.value === true}
|
checked={field.value === true}
|
||||||
onChange={() => field.onChange(true)} // send boolean true
|
onChange={() => field.onChange(true)} // send boolean true
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label className="form-check-label">Yes</Label>
|
||||||
className="form-check-label"
|
|
||||||
>
|
|
||||||
Yes
|
|
||||||
</Label>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="form-check d-flex flex-row m-0 gap-2">
|
<div className="form-check d-flex flex-row m-0 gap-2">
|
||||||
@ -324,11 +320,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
checked={field.value === false}
|
checked={field.value === false}
|
||||||
onChange={() => field.onChange(false)} // send boolean false
|
onChange={() => field.onChange(false)} // send boolean false
|
||||||
/>
|
/>
|
||||||
<Label
|
<Label className="form-check-label">No</Label>
|
||||||
className="form-check-label"
|
|
||||||
>
|
|
||||||
No
|
|
||||||
</Label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -392,7 +384,6 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) {
|
|||||||
error={errors.payee?.message}
|
error={errors.payee?.message}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
{/* Checkbox below input */}
|
{/* Checkbox below input */}
|
||||||
<div className="form-check mt-2">
|
<div className="form-check mt-2">
|
||||||
<input
|
<input
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user