mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
specify certain variables as survey
This commit is contained in:
parent
d755299043
commit
c533bb3e80
3 changed files with 15 additions and 15 deletions
|
|
@ -16,7 +16,7 @@ import {
|
|||
} from "lucide-react";
|
||||
import type { PropertyDocument, DocStatus } from "./types";
|
||||
import { EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES } from "./types";
|
||||
import { splitDocumentsByType, getMissingRetrofitTypes, getUnassignedInstallDocs } from "./propertyDocuments";
|
||||
import { splitDocumentsByType, getMissingSurveyDocTypes, getUnassignedInstallDocs } from "./propertyDocuments";
|
||||
import ContractorUploadModal from "./ContractorUploadModal";
|
||||
import type { ClassifiedDeal, PortfolioCapabilityType } from "./types";
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ export default function PropertyDocumentsContent({
|
|||
});
|
||||
|
||||
const { docs: surveyDocs, coordinationDocs, designDocs, installDocs } = splitDocumentsByType(documents);
|
||||
const missingRetrofitTypes = getMissingRetrofitTypes(surveyDocs);
|
||||
const missingSurveyDocTypes = getMissingSurveyDocTypes(surveyDocs);
|
||||
const hasDocuments = documents.length > 0;
|
||||
|
||||
const isContractor = userCapability?.includes("contractor") ?? false;
|
||||
|
|
@ -235,9 +235,9 @@ export default function PropertyDocumentsContent({
|
|||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wide text-amber-500 px-0.5">
|
||||
Missing Documents ({missingRetrofitTypes.length})
|
||||
Missing Documents ({missingSurveyDocTypes.length})
|
||||
</h3>
|
||||
{missingRetrofitTypes.map((t) => (
|
||||
{missingSurveyDocTypes.map((t) => (
|
||||
<div
|
||||
key={t}
|
||||
className="flex items-center gap-2.5 p-3 rounded-lg border border-dashed border-amber-200 bg-amber-50/40"
|
||||
|
|
@ -257,7 +257,7 @@ export default function PropertyDocumentsContent({
|
|||
{!isFetching && !isError && hasDocuments && (
|
||||
<>
|
||||
{/* Retrofit Assessment */}
|
||||
<motion.div key="retrofit" initial={{ opacity: 0 }} animate={{ opacity: 1 }} className="space-y-2">
|
||||
<motion.div key="survey" initial={{ opacity: 0 }} animate={{ opacity: 1 }} className="space-y-2">
|
||||
<h3 className="text-xs font-semibold uppercase tracking-wide text-gray-400 px-0.5">
|
||||
Retrofit Assessment Documents
|
||||
</h3>
|
||||
|
|
@ -270,12 +270,12 @@ export default function PropertyDocumentsContent({
|
|||
) : (
|
||||
<p className="text-xs text-gray-400 px-0.5">None uploaded yet.</p>
|
||||
)}
|
||||
{missingRetrofitTypes.length > 0 && (
|
||||
{missingSurveyDocTypes.length > 0 && (
|
||||
<div className="space-y-1.5 pt-1">
|
||||
<h4 className="text-xs font-semibold uppercase tracking-wide text-amber-500 px-0.5">
|
||||
Missing ({missingRetrofitTypes.length})
|
||||
Missing ({missingSurveyDocTypes.length})
|
||||
</h4>
|
||||
{missingRetrofitTypes.map((t) => (
|
||||
{missingSurveyDocTypes.map((t) => (
|
||||
<div
|
||||
key={t}
|
||||
className="flex items-center gap-2.5 p-3 rounded-lg border border-dashed border-amber-200 bg-amber-50/40"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
splitDocumentsByType,
|
||||
getMissingRetrofitTypes,
|
||||
getMissingSurveyDocTypes,
|
||||
getUnassignedInstallDocs,
|
||||
} from "./propertyDocuments";
|
||||
import type { PropertyDocument, MeasureDocProgress } from "./types";
|
||||
|
|
@ -74,13 +74,13 @@ describe("splitDocumentsByType", () => {
|
|||
|
||||
describe("getMissingRetrofitTypes", () => {
|
||||
it("returns all mandatory types when no docs uploaded", () => {
|
||||
const missing = getMissingRetrofitTypes([]);
|
||||
const missing = getMissingSurveyDocTypes([]);
|
||||
expect(missing).toHaveLength(9);
|
||||
});
|
||||
|
||||
it("excludes types that have been uploaded", () => {
|
||||
const uploaded = [makeDoc({ docType: "photo_pack" })];
|
||||
const missing = getMissingRetrofitTypes(uploaded);
|
||||
const missing = getMissingSurveyDocTypes(uploaded);
|
||||
expect(missing).not.toContain("photo_pack");
|
||||
expect(missing).toHaveLength(8);
|
||||
});
|
||||
|
|
@ -91,12 +91,12 @@ describe("getMissingRetrofitTypes", () => {
|
|||
"pas_2023_condition", "pas_significance", "par_photo_pack",
|
||||
"pas_2023_property", "pas_2023_occupancy",
|
||||
].map((docType, i) => makeDoc({ id: String(i), docType }));
|
||||
expect(getMissingRetrofitTypes(uploaded)).toHaveLength(0);
|
||||
expect(getMissingSurveyDocTypes(uploaded)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("does not count ecmk types as mandatory", () => {
|
||||
const uploaded = [makeDoc({ docType: "ecmk_site_note" })];
|
||||
const missing = getMissingRetrofitTypes(uploaded);
|
||||
const missing = getMissingSurveyDocTypes(uploaded);
|
||||
expect(missing).not.toContain("ecmk_site_note");
|
||||
expect(missing).toHaveLength(9);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ export function splitDocumentsByType(docs: PropertyDocument[]): {
|
|||
};
|
||||
}
|
||||
|
||||
export function getMissingRetrofitTypes(retrofitDocs: PropertyDocument[]): string[] {
|
||||
const present = new Set(retrofitDocs.map((d) => d.docType));
|
||||
export function getMissingSurveyDocTypes(surveyDocs: PropertyDocument[]): string[] {
|
||||
const present = new Set(surveyDocs.map((d) => d.docType));
|
||||
return EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES.filter((t) => !present.has(t));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue