mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Merge pull request #157 from Hestia-Homes/new-reporting
added enforce fabric first
This commit is contained in:
commit
ec20126d1e
3 changed files with 39 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import DataTable from "@/app/portfolio/[slug]/components/propertyTable";
|
|||
import { columns } from "@/app/portfolio/[slug]/components/propertyTableColumns";
|
||||
import { PropertyWithRelations } from "@/app/db/schema/property";
|
||||
import SummaryBox from "@/app/components/portfolio/SummaryBox";
|
||||
import { Component } from "lucide-react";
|
||||
|
||||
// We enfore caching of data for 60 seconds
|
||||
export const revalidate = 60;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export const uploadCsvSchema = baseFormSchema.extend({
|
|||
},
|
||||
z.union([z.number(), z.null()]).optional()
|
||||
),
|
||||
enforce_fabric_first: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export type UploadCsvFormValues = z.infer<typeof uploadCsvSchema>;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {
|
|||
Transition,
|
||||
TransitionChild,
|
||||
} from "@headlessui/react";
|
||||
import { Checkbox } from "@/app/shadcn_components/ui/checkbox";
|
||||
|
||||
import { Fragment, useMemo, useState } from "react";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
|
@ -250,6 +251,7 @@ export function useUploadCsvPlan({
|
|||
onSuccessRedirect,
|
||||
fileType,
|
||||
fileFormat,
|
||||
enforceFabricFirst,
|
||||
}: {
|
||||
file: File;
|
||||
portfolioId: string;
|
||||
|
|
@ -266,6 +268,7 @@ export function useUploadCsvPlan({
|
|||
onSuccessRedirect: (path: string) => void;
|
||||
fileType: "csv" | "xlsx";
|
||||
fileFormat: "domna_asset_list" | null;
|
||||
enforceFabricFirst: boolean;
|
||||
}) {
|
||||
const session = useSession();
|
||||
const userId = String(session.data?.user.dbId);
|
||||
|
|
@ -308,6 +311,7 @@ export function useUploadCsvPlan({
|
|||
ashp_cop: Number(ashpCop),
|
||||
file_type: fileType, // Pass the file type for backend processing
|
||||
file_format: fileFormat,
|
||||
enforce_fabric_first: enforceFabricFirst,
|
||||
};
|
||||
|
||||
const triggerRes = await fetch("/api/plan/trigger", {
|
||||
|
|
@ -421,6 +425,7 @@ export default function UploadCsvModal({
|
|||
selectedSheet,
|
||||
sheetCount: sheetCounts[selectedSheet] || 0,
|
||||
onSuccessRedirect: (path) => router.push(path),
|
||||
enforceFabricFirst: form.watch("enforce_fabric_first"),
|
||||
});
|
||||
|
||||
const onSubmit = form.handleSubmit(async () => {
|
||||
|
|
@ -733,6 +738,38 @@ export default function UploadCsvModal({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/*enforceFabricFirst checkbox */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="enforce_fabric_first"
|
||||
render={({ field }) => (
|
||||
<FormItem className="mt-6">
|
||||
<div className="rounded-lg border border-gray-200 p-4">
|
||||
<FormControl>
|
||||
<label className="flex items-start gap-3 cursor-pointer">
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
// disabled={selectedScenario !== NEW_SENTINEL} // Always editable
|
||||
className="mt-1"
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium text-gray-900">
|
||||
Enforce Fabric First
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
Require insulation and fabric upgrades before
|
||||
heating measures are recommended.
|
||||
</span>
|
||||
</div>
|
||||
</label>
|
||||
</FormControl>
|
||||
<FormMessage className="text-brandbrown mt-2" />
|
||||
</div>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="mt-auto pt-4 flex justify-end gap-4">
|
||||
<Button
|
||||
type="button"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue