mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Updated user input to ask for housing type and fixed download bug with nextJS Link component causing subsequent downloads after the first when hovering over
This commit is contained in:
parent
d4252cff16
commit
aff31f2128
1 changed files with 28 additions and 29 deletions
|
|
@ -14,12 +14,12 @@ import Link from "next/link";
|
|||
export const SubmitPlan = ({
|
||||
buttonDisabled,
|
||||
goal,
|
||||
fundingScheme,
|
||||
housingType,
|
||||
goalValue,
|
||||
}: {
|
||||
buttonDisabled: boolean;
|
||||
goal: string;
|
||||
fundingScheme: string;
|
||||
housingType: string;
|
||||
goalValue: string;
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
|
|
@ -28,7 +28,7 @@ export const SubmitPlan = ({
|
|||
const requestBody = JSON.stringify({
|
||||
goal: goal,
|
||||
goalValue: goalValue,
|
||||
fundingScheme: fundingScheme,
|
||||
housingType: housingType,
|
||||
});
|
||||
|
||||
const response = await fetch("/api/portfolio/plan", {
|
||||
|
|
@ -77,7 +77,7 @@ export function InputFile({
|
|||
handleButtonDisabled,
|
||||
setCsvFile,
|
||||
selectedGoal,
|
||||
fundingScheme,
|
||||
housingType,
|
||||
goalValue,
|
||||
}: {
|
||||
handleButtonDisabled: (
|
||||
|
|
@ -88,7 +88,7 @@ export function InputFile({
|
|||
) => void;
|
||||
setCsvFile: (file: File) => void;
|
||||
selectedGoal: string;
|
||||
fundingScheme: string;
|
||||
housingType: string;
|
||||
goalValue: string;
|
||||
}) {
|
||||
function handleOnChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
|
|
@ -101,7 +101,7 @@ export function InputFile({
|
|||
return;
|
||||
}
|
||||
setCsvFile(file); // Assuming you have a state to keep the file
|
||||
handleButtonDisabled(selectedGoal, fundingScheme, goalValue, file);
|
||||
handleButtonDisabled(selectedGoal, housingType, goalValue, file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,23 +182,19 @@ export function SelectDropdown({
|
|||
const hiddenInputArrows =
|
||||
"[-moz-appearance:_textfield] [&::-webkit-inner-spin-button]:m-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:m-0 [&::-webkit-outer-spin-button]:appearance-none";
|
||||
|
||||
const selectFundingSchemeOptions = [
|
||||
const selecthousingTypeOptions = [
|
||||
{
|
||||
label: "None",
|
||||
value: "None",
|
||||
label: "Social",
|
||||
value: "Social",
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: "SHDF",
|
||||
value: "SHDF",
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: "ECO4",
|
||||
value: "ECO4",
|
||||
label: "Private",
|
||||
value: "Private",
|
||||
disabled: false,
|
||||
},
|
||||
];
|
||||
|
||||
const selectGoalOptions = [
|
||||
// {
|
||||
// label: "None",
|
||||
|
|
@ -245,7 +241,7 @@ export default function UploadCsvModal({
|
|||
|
||||
const [buttonDisabled, setButtonDisabled] = useState(true);
|
||||
const [selectedGoal, setSelectedGoal] = useState<string>("");
|
||||
const [fundingScheme, setFundingScheme] = useState<string>("");
|
||||
const [housingType, sethousingType] = useState<string>("");
|
||||
const [goalValue, setGoalValue] = useState<string>("");
|
||||
|
||||
const [csvFile, setCsvFile] = useState<File | null>(null);
|
||||
|
|
@ -260,7 +256,7 @@ export default function UploadCsvModal({
|
|||
|
||||
function handleButtonDisabled(
|
||||
goal?: string,
|
||||
scheme?: string,
|
||||
housetype?: string,
|
||||
value?: string,
|
||||
file?: File | null
|
||||
) {
|
||||
|
|
@ -269,7 +265,7 @@ export default function UploadCsvModal({
|
|||
// will not have updated yet, so we need to pass in the value as an argument to check if the value has been updated
|
||||
if (
|
||||
(goal || selectedGoal) &&
|
||||
(scheme || fundingScheme) &&
|
||||
(housetype || housingType) &&
|
||||
(value || goalValue) &&
|
||||
(file || csvFile)
|
||||
) {
|
||||
|
|
@ -354,14 +350,14 @@ export default function UploadCsvModal({
|
|||
htmlFor="portfolio-name"
|
||||
className="text-sm font-semibold text-gray-600 mb-1 relative leading-relaxed tracking-wider"
|
||||
>
|
||||
Funding Scheme
|
||||
Housing type
|
||||
<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<SelectDropdown
|
||||
options={selectFundingSchemeOptions}
|
||||
selectedOption={fundingScheme}
|
||||
options={selecthousingTypeOptions}
|
||||
selectedOption={housingType}
|
||||
onSelectOption={(option) => {
|
||||
setFundingScheme(option.value);
|
||||
sethousingType(option.value);
|
||||
handleButtonDisabled(
|
||||
selectedGoal,
|
||||
option.value,
|
||||
|
|
@ -384,7 +380,7 @@ export default function UploadCsvModal({
|
|||
setSelectedGoal(option.value);
|
||||
handleButtonDisabled(
|
||||
option.value,
|
||||
fundingScheme,
|
||||
housingType,
|
||||
goalValue,
|
||||
csvFile
|
||||
);
|
||||
|
|
@ -406,7 +402,7 @@ export default function UploadCsvModal({
|
|||
setGoalValue(option.value);
|
||||
handleButtonDisabled(
|
||||
selectedGoal,
|
||||
fundingScheme,
|
||||
housingType,
|
||||
option.value,
|
||||
csvFile
|
||||
);
|
||||
|
|
@ -422,9 +418,12 @@ export default function UploadCsvModal({
|
|||
properties
|
||||
</div>
|
||||
<div className="!text-blue-500 underline">
|
||||
<Link href="/example_properties.csv">
|
||||
<a
|
||||
href="/example_properties.csv"
|
||||
onChange={() => console.log("Triggered")}
|
||||
>
|
||||
Download example CSV
|
||||
</Link>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -434,7 +433,7 @@ export default function UploadCsvModal({
|
|||
handleButtonDisabled={handleButtonDisabled}
|
||||
setCsvFile={setCsvFile}
|
||||
selectedGoal={selectedGoal}
|
||||
fundingScheme={fundingScheme}
|
||||
housingType={housingType}
|
||||
goalValue={goalValue}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -451,7 +450,7 @@ export default function UploadCsvModal({
|
|||
<SubmitPlan
|
||||
buttonDisabled={buttonDisabled}
|
||||
goal={goalValue}
|
||||
fundingScheme={fundingScheme}
|
||||
housingType={housingType}
|
||||
goalValue={goalValue}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue