mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Merge pull request #140 from Hestia-Homes/new-reporting
fixed scenario re-creationg every time bug
This commit is contained in:
commit
ed26dfa781
6 changed files with 24 additions and 23 deletions
|
|
@ -252,11 +252,12 @@ export const AuthOptions: NextAuthOptions = {
|
|||
*/
|
||||
async redirect({ url, baseUrl }) {
|
||||
// If the user has not onboarded, send them to onboarding
|
||||
console.log("Redirect triggered:", {
|
||||
from: url,
|
||||
to: `${baseUrl}/home`,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
// This logging is too noisy
|
||||
// console.log("Redirect triggered:", {
|
||||
// from: url,
|
||||
// to: `${baseUrl}/home`,
|
||||
// timestamp: new Date().toISOString(),
|
||||
// });
|
||||
return `${baseUrl}/home`;
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ const s3 = new S3Client({
|
|||
export async function POST(req: Request) {
|
||||
try {
|
||||
const { key } = await req.json(); // key = "path/to/photo.jpg"
|
||||
if (!key) return NextResponse.json({ error: "Missing key" }, { status: 400 });
|
||||
if (!key)
|
||||
return NextResponse.json({ error: "Missing key" }, { status: 400 });
|
||||
|
||||
const command = new GetObjectCommand({
|
||||
Bucket: process.env.RETROFIT_DATA_DEV_S3_BUCKET_NAME!,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
import { useState } from "react";
|
||||
import { formatNumber } from "@/app/utils";
|
||||
|
||||
|
||||
interface SummaryBoxProps {
|
||||
scenarios: Array<{
|
||||
id: bigint;
|
||||
|
|
@ -36,11 +35,11 @@ function SummaryBox({ scenarios, numProperties }: SummaryBoxProps) {
|
|||
const [totalCostFormatted, setTotalCostFormatted] = useState(
|
||||
formatMoney(defaultScenario.totalCost)
|
||||
);
|
||||
const [funding, setFunding] = useState(
|
||||
formatMoney(defaultScenario.funding)
|
||||
);
|
||||
const [funding, setFunding] = useState(formatMoney(defaultScenario.funding));
|
||||
const [netCost, setNetCost] = useState(
|
||||
formatMoney((defaultScenario.totalCost || 0) - (defaultScenario.funding || 0))
|
||||
formatMoney(
|
||||
(defaultScenario.totalCost || 0) - (defaultScenario.funding || 0)
|
||||
)
|
||||
);
|
||||
const [contingency, setContingency] = useState(
|
||||
formatMoney(defaultScenario.contingency)
|
||||
|
|
@ -149,21 +148,15 @@ function SummaryBox({ scenarios, numProperties }: SummaryBoxProps) {
|
|||
</tr>
|
||||
<tr>
|
||||
<td className="text-brandblue">Funding</td>
|
||||
<td className="text-brandblue text-end">
|
||||
{funding}
|
||||
</td>
|
||||
<td className="text-brandblue text-end">{funding}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="text-brandblue ">Cost after funding</td>
|
||||
<td className="text-brandblue text-end">
|
||||
{netCost}
|
||||
</td>
|
||||
<td className="text-brandblue text-end">{netCost}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="text-brandblue">Contingency</td>
|
||||
<td className="text-brandblue text-end">
|
||||
{contingency}
|
||||
</td>
|
||||
<td className="text-brandblue text-end">{contingency}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="text-brandblue">Total properties</td>
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@ import { getPortfolio, getPortfolioPerformance, getProperties } from "../utils";
|
|||
import DataTable from "@/app/portfolio/[slug]/components/propertyTable";
|
||||
import { columns } from "@/app/portfolio/[slug]/components/propertyTableColumns";
|
||||
import { PropertyWithRelations } from "@/app/db/schema/property";
|
||||
import { formatNumber, convertDaysToWorkingWeeks } from "@/app/utils";
|
||||
import SummaryBox from "@/app/components/portfolio/SummaryBox";
|
||||
import { is } from "cypress/types/bluebird";
|
||||
|
||||
// We enfore caching of data for 60 seconds
|
||||
export const revalidate = 60;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export default function RemoteAssessmentClient({
|
|||
builtForm?: string;
|
||||
} | null>(null);
|
||||
const [selectedPostcode, setSelectedPostcode] = useState<string>("");
|
||||
const [selectedScenario, setSelectedScenario] = useState<string | null>(null);
|
||||
|
||||
const { handleSubmit: submitAssessment, isUploading } =
|
||||
useCreateRemoteAssessment({
|
||||
|
|
@ -37,6 +38,7 @@ export default function RemoteAssessmentClient({
|
|||
propertyType: selectedAddress?.propertyType || null,
|
||||
builtForm: selectedAddress?.builtForm || null,
|
||||
measures: measuresList,
|
||||
scenarioId: selectedScenario,
|
||||
});
|
||||
|
||||
async function onSubmitRemoteAssessment(values: RemoteAssessmentFormValues) {
|
||||
|
|
@ -150,6 +152,8 @@ export default function RemoteAssessmentClient({
|
|||
selectedBuiltForm={selectedAddress?.builtForm ?? null}
|
||||
isSubmitting={isUploading}
|
||||
onSubmitRemoteAssessment={onSubmitRemoteAssessment}
|
||||
setSelectedScenario={setSelectedScenario}
|
||||
selectedScenario={selectedScenario}
|
||||
/>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ export default function ScenarioSetup({
|
|||
selectedBuiltForm,
|
||||
isSubmitting,
|
||||
onSubmitRemoteAssessment,
|
||||
setSelectedScenario,
|
||||
selectedScenario,
|
||||
}: {
|
||||
portfolioId: string;
|
||||
scenarios: ScenarioSelect[];
|
||||
|
|
@ -59,9 +61,11 @@ export default function ScenarioSetup({
|
|||
selectedBuiltForm: string | null;
|
||||
isSubmitting: boolean;
|
||||
onSubmitRemoteAssessment: (values: RemoteAssessmentFormValues) => void;
|
||||
setSelectedScenario: (scenarioId: string | null) => void;
|
||||
selectedScenario: string | null;
|
||||
}) {
|
||||
const NEW_SENTINEL = "__new__";
|
||||
const [selectedScenario, setSelectedScenario] = useState<string | null>(null);
|
||||
|
||||
const [showMeasures, setShowMeasures] = useState(false);
|
||||
|
||||
const form = useForm<RemoteAssessmentFormValues>({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue