mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
submit button disabled is working
This commit is contained in:
parent
f6befc215c
commit
7f9b7f2992
1 changed files with 21 additions and 3 deletions
|
|
@ -1,8 +1,7 @@
|
|||
"use client";
|
||||
|
||||
import { Dialog, Transition, Menu } from "@headlessui/react";
|
||||
import { useState, Fragment } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useState, Fragment, useEffect } from "react";
|
||||
import { Input } from "@/app/shadcn_components/ui/input";
|
||||
import { Button } from "@/app/shadcn_components/ui/button";
|
||||
import { Float } from "@headlessui-float/react";
|
||||
|
|
@ -130,7 +129,7 @@ export default function RemoteAssesmentModal({
|
|||
const [postcode, setPostcode] = useState<string>("");
|
||||
const [uprn, setUprn] = useState<number | string | null>("");
|
||||
const [valuation, setValuation] = useState<number | string | null>("");
|
||||
// const [buttonDisabled, setButtonDisabled] = useState(true);
|
||||
const [buttonDisabled, setButtonDisabled] = useState(true);
|
||||
|
||||
function handleScenarioChange(event: React.ChangeEvent<HTMLInputElement>) {
|
||||
setScenario(event.target.value);
|
||||
|
|
@ -152,6 +151,22 @@ export default function RemoteAssesmentModal({
|
|||
setValuation(event.target.value);
|
||||
}
|
||||
|
||||
function handleButtonDisabled(): boolean {
|
||||
return !(
|
||||
scenario &&
|
||||
selectedGoal &&
|
||||
housingType &&
|
||||
addressLineOne &&
|
||||
postcode &&
|
||||
uprn &&
|
||||
valuation
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setButtonDisabled(handleButtonDisabled());
|
||||
}, [scenario, selectedGoal, housingType, addressLineOne, postcode, uprn, valuation]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Transition appear show={isOpen} as={Fragment}>
|
||||
|
|
@ -257,7 +272,10 @@ export default function RemoteAssesmentModal({
|
|||
</div>
|
||||
<div className="flex justify-center mt-6">
|
||||
<Button
|
||||
disabled={buttonDisabled}
|
||||
|
||||
onClick={() => {
|
||||
console.log("making a submission")
|
||||
setIsOpen(false);
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue