build error fixed
This commit was merged in pull request #69.
This commit is contained in:
@@ -7,6 +7,18 @@ import { RouteHandler } from '../../../router/routes';
|
||||
import { getLoanDetail } from '../../../core/apiRequest';
|
||||
import CustomSpinner from '../../CustomSpinner';
|
||||
|
||||
interface LoanDetail {
|
||||
loan_amount: string;
|
||||
payment_month: string;
|
||||
sales_agent: string;
|
||||
[key: string]: any; // to accommodate any additional properties
|
||||
}
|
||||
|
||||
// interface InitialValues {
|
||||
// loan_amount: string;
|
||||
// payment_month: string;
|
||||
// sales_agent: string;
|
||||
// }
|
||||
|
||||
const initialValues = {
|
||||
loan_amount: "",
|
||||
@@ -29,36 +41,43 @@ const validationSchema = Yup.object().shape({
|
||||
sales_agent: Yup.string()
|
||||
});
|
||||
|
||||
type LocationState = {
|
||||
application_uid: string
|
||||
}
|
||||
|
||||
export default function ReferenceDetails() {
|
||||
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const applicationUID = location?.state?.application_uid
|
||||
// const applicationUID = location?.state?.application_uid
|
||||
const stateExist = location?.state as LocationState
|
||||
|
||||
//FUNCTION TO HANDLE SUBMIT
|
||||
const handleSubmit = (values:{}) => {
|
||||
// handleNextStep(values)
|
||||
console.log(values)
|
||||
};
|
||||
|
||||
const [loanDetail, setLoanDetail] = useState<any>({
|
||||
const [loanDetail, setLoanDetail] = useState<{loading:Boolean, data:any}>({
|
||||
loading: true,
|
||||
data: {}
|
||||
data: {},
|
||||
})
|
||||
|
||||
useEffect(()=>{
|
||||
if(!applicationUID){
|
||||
navigate(RouteHandler.dashboardHome)
|
||||
if(!stateExist){
|
||||
navigate(RouteHandler.dashboardHome)
|
||||
return
|
||||
}
|
||||
getLoanDetail({application_uid:applicationUID}).then(res => {
|
||||
setLoanDetail({loading:false, data:res?.data?.loan})
|
||||
getLoanDetail({application_uid:stateExist.application_uid}).then(res => {
|
||||
setLoanDetail({loading:false, data:res?.data?.loan})
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
setLoanDetail({loading:false, data:{}})
|
||||
})
|
||||
},[])
|
||||
|
||||
const formInitialValue = (loanDetail.loading || Object.keys(loanDetail?.data)?.length < 1) ? initialValues : loanDetail?.data
|
||||
const formInitialValue:LoanDetail = (loanDetail.loading) ? initialValues : loanDetail?.data
|
||||
|
||||
return (
|
||||
<>
|
||||
{loanDetail.loading ?
|
||||
@@ -86,8 +105,9 @@ export default function ReferenceDetails() {
|
||||
inputClass="w-full h-[3.625rem] bg-[#EFEFEF] px-4 rounded-[.375rem] text-right"
|
||||
placeholder="350,000"
|
||||
value={props.values.loan_amount}
|
||||
disabled={true}
|
||||
onChange={props.handleChange}
|
||||
error={(props.errors.loan_amount && props.touched.loan_amount) ? props.errors.loan_amount : ''}
|
||||
// error={(props.errors.loan_amount && props.touched.loan_amount) ? props.errors.loan_amount : ''}
|
||||
/>
|
||||
<InputCompOne
|
||||
parentClass="w-full sm:max-w-[10rem] flex flex-col gap-4"
|
||||
@@ -95,11 +115,12 @@ export default function ReferenceDetails() {
|
||||
label="Months?"
|
||||
labelClass="font-bold text-[1.125rem]"
|
||||
select={true}
|
||||
disabled={true}
|
||||
selectClass="w-full h-[3.625rem] bg-[#EFEFEF] px-4 rounded-[.375rem]"
|
||||
selectOptions={paymentMonth}
|
||||
selectOptions={props.values.payment_month}
|
||||
selectValue={props.values.payment_month}
|
||||
onChange={props.handleChange}
|
||||
error={(props.errors.payment_month && props.touched.payment_month) ? props.errors.payment_month : ''}
|
||||
// error={(props.errors.payment_month && props.touched.payment_month) ? props.errors.payment_month : ''}
|
||||
/>
|
||||
<InputCompOne
|
||||
parentClass="w-full sm:max-w-[10rem] flex flex-col gap-4"
|
||||
@@ -108,11 +129,12 @@ export default function ReferenceDetails() {
|
||||
labelClass="font-bold text-[1.125rem]"
|
||||
floatLabel='Enter agent ID'
|
||||
input
|
||||
disabled={true}
|
||||
inputClass="w-full h-[3.625rem] bg-[#EFEFEF] px-4 rounded-[.375rem]"
|
||||
placeholder="Agent ID"
|
||||
value={props.values.sales_agent}
|
||||
onChange={props.handleChange}
|
||||
error={(props.errors.sales_agent && props.touched.sales_agent) ? props.errors.sales_agent : ''}
|
||||
// error={(props.errors.sales_agent && props.touched.sales_agent) ? props.errors.sales_agent : ''}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
@@ -130,20 +152,20 @@ export default function ReferenceDetails() {
|
||||
);
|
||||
}
|
||||
|
||||
interface SelectOption {
|
||||
loading: boolean;
|
||||
data: {value: string;
|
||||
label: string}[]
|
||||
}
|
||||
// interface SelectOption {
|
||||
// loading: boolean;
|
||||
// data: {value: string;
|
||||
// label: string}[]
|
||||
// }
|
||||
|
||||
|
||||
const paymentMonth: SelectOption = {
|
||||
loading: false,
|
||||
data: [
|
||||
{ value: "", label: "Please Select" },
|
||||
{ value: "6", label: "6 Months" },
|
||||
{ value: "12", label: "12 Months" },
|
||||
{ value: "18", label: "18 Months" },
|
||||
{ value: "24", label: "24 Months" },
|
||||
]
|
||||
}
|
||||
// const paymentMonth: SelectOption = {
|
||||
// loading: false,
|
||||
// data: [
|
||||
// { value: "", label: "Please Select" },
|
||||
// { value: "6", label: "6 Months" },
|
||||
// { value: "12", label: "12 Months" },
|
||||
// { value: "18", label: "18 Months" },
|
||||
// { value: "24", label: "24 Months" },
|
||||
// ]
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user