mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
setting up db wip
This commit is contained in:
parent
50ee1db7a0
commit
2de80ee8ab
7 changed files with 1607 additions and 40 deletions
1506
package-lock.json
generated
1506
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -21,12 +21,14 @@
|
|||
"autoprefixer": "10.4.14",
|
||||
"class-variance-authority": "^0.6.0",
|
||||
"clsx": "^1.2.1",
|
||||
"drizzle-orm": "^0.27.0",
|
||||
"eslint": "8.41.0",
|
||||
"eslint-config-next": "13.4.3",
|
||||
"lucide-react": "^0.233.0",
|
||||
"next": "13.4.3",
|
||||
"next-auth": "^4.22.1",
|
||||
"next-axiom": "^0.17.0",
|
||||
"pg": "^8.11.1",
|
||||
"postcss": "8.4.23",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
|
|
@ -34,5 +36,9 @@
|
|||
"tailwindcss": "3.3.2",
|
||||
"tailwindcss-animate": "^1.0.5",
|
||||
"typescript": "5.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pg": "^8.10.2",
|
||||
"drizzle-kit": "^0.19.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ type PlanPartProps = {
|
|||
co2Reduction: number;
|
||||
workHours: number;
|
||||
parts: Part[];
|
||||
option: string | undefined;
|
||||
setParts: Dispatch<SetStateAction<Part[]>>;
|
||||
setTotalCost: Dispatch<SetStateAction<number>>;
|
||||
setWorkHours: Dispatch<SetStateAction<number>>;
|
||||
|
|
@ -24,6 +25,7 @@ export default function PlanPart({
|
|||
co2Reduction,
|
||||
workHours,
|
||||
parts,
|
||||
option,
|
||||
setParts,
|
||||
setTotalCost,
|
||||
setWorkHours,
|
||||
|
|
@ -32,38 +34,76 @@ export default function PlanPart({
|
|||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
// These are temporary options for the demo
|
||||
// const options: PartOption[] = [
|
||||
// {
|
||||
// label: option || "option 1" + ": £" + formatNumber(cost + 0.05 * cost),
|
||||
// part: option || "option 1",
|
||||
// cost: cost + 0.05 * cost,
|
||||
// co2Reduction: co2Reduction - 0.05 * co2Reduction,
|
||||
// workHours: workHours + 0.05 * workHours,
|
||||
// },
|
||||
// {
|
||||
// label: "option 2: £" + formatNumber(cost + 0.1 * cost),
|
||||
// part: "option 2",
|
||||
// cost: cost + 0.1 * cost,
|
||||
// co2Reduction: co2Reduction - 0.1 * co2Reduction,
|
||||
// workHours: workHours + 0.1 * workHours,
|
||||
// },
|
||||
// {
|
||||
// label: "option 3: £" + formatNumber(cost + 0.15 * cost),
|
||||
// part: "option 3",
|
||||
// cost: cost + 0.15 * cost,
|
||||
// co2Reduction: co2Reduction - 0.15 * co2Reduction,
|
||||
// workHours: workHours + 0.15 * workHours,
|
||||
// },
|
||||
// {
|
||||
// label: "option 4: £" + formatNumber(cost + 0.2 * cost),
|
||||
// part: "option 4",
|
||||
// cost: cost + 0.2 * cost,
|
||||
// co2Reduction: co2Reduction - 0.2 * co2Reduction,
|
||||
// workHours: workHours + 0.2 * workHours,
|
||||
// },
|
||||
// {
|
||||
// label: "option 5: £" + formatNumber(cost + 0.25 * cost),
|
||||
// part: "option 5",
|
||||
// cost: cost + 0.25 * cost,
|
||||
// co2Reduction: co2Reduction - 0.25 * co2Reduction,
|
||||
// workHours: workHours + 0.25 * workHours,
|
||||
// },
|
||||
// ];
|
||||
|
||||
const options: PartOption[] = [
|
||||
{
|
||||
label: "option 1: £" + formatNumber(cost + 0.05 * cost),
|
||||
part: "option 1",
|
||||
label: option || "option 1" + ": £" + formatNumber(cost + 0.05 * cost),
|
||||
part: option || "option 1",
|
||||
cost: cost + 0.05 * cost,
|
||||
co2Reduction: co2Reduction - 0.05 * co2Reduction,
|
||||
workHours: workHours + 0.05 * workHours,
|
||||
},
|
||||
{
|
||||
label: "option 2: £" + formatNumber(cost + 0.1 * cost),
|
||||
part: "option 2",
|
||||
label: "250mm insulation: £" + formatNumber(cost + 0.1 * cost),
|
||||
part: "250mm insulation",
|
||||
cost: cost + 0.1 * cost,
|
||||
co2Reduction: co2Reduction - 0.1 * co2Reduction,
|
||||
workHours: workHours + 0.1 * workHours,
|
||||
},
|
||||
{
|
||||
label: "option 3: £" + formatNumber(cost + 0.15 * cost),
|
||||
part: "option 3",
|
||||
label: "300mm insulation: £" + formatNumber(cost + 0.15 * cost),
|
||||
part: "300mm insulation",
|
||||
cost: cost + 0.15 * cost,
|
||||
co2Reduction: co2Reduction - 0.15 * co2Reduction,
|
||||
workHours: workHours + 0.15 * workHours,
|
||||
},
|
||||
{
|
||||
label: "option 4: £" + formatNumber(cost + 0.2 * cost),
|
||||
part: "option 4",
|
||||
label: "350mm insulation: £" + formatNumber(cost + 0.2 * cost),
|
||||
part: "350mm insulation",
|
||||
cost: cost + 0.2 * cost,
|
||||
co2Reduction: co2Reduction - 0.2 * co2Reduction,
|
||||
workHours: workHours + 0.2 * workHours,
|
||||
},
|
||||
{
|
||||
label: "option 5: £" + formatNumber(cost + 0.25 * cost),
|
||||
part: "option 5",
|
||||
label: "400mm insulation: £" + formatNumber(cost + 0.25 * cost),
|
||||
part: "400mm insulation",
|
||||
cost: cost + 0.25 * cost,
|
||||
co2Reduction: co2Reduction - 0.25 * co2Reduction,
|
||||
workHours: workHours + 0.25 * workHours,
|
||||
|
|
|
|||
14
src/app/db/db.ts
Normal file
14
src/app/db/db.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// db.ts
|
||||
import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { Pool } from "pg";
|
||||
|
||||
const pool = new Pool({
|
||||
host: "127.0.0.1",
|
||||
port: 5432,
|
||||
user: "postgres",
|
||||
password: "password",
|
||||
database: "db_name",
|
||||
});
|
||||
|
||||
const db = drizzle(pool);
|
||||
|
|
@ -5,61 +5,61 @@ const Home = async () => {
|
|||
const Portfolios = [
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0851",
|
||||
title: "Portfolio 1",
|
||||
title: "Manchester Home Col. 2023",
|
||||
budget: "£500k",
|
||||
status: "scoping" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0852",
|
||||
title: "Portfolio 2",
|
||||
title: "Birmingham 2024 Ensemble",
|
||||
budget: "£150k",
|
||||
status: "assessment" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0853",
|
||||
title: "Portfolio 3",
|
||||
title: "London Property Array 2025",
|
||||
budget: "£1m",
|
||||
status: "tendering" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0854",
|
||||
title: "Portfolio 4",
|
||||
title: "Liverpool Estate Collection 2023",
|
||||
budget: "£2m",
|
||||
status: "tendering" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0855",
|
||||
title: "Portfolio 5",
|
||||
title: "Leeds Abode Portfolio 2024",
|
||||
budget: "250000",
|
||||
status: "project underway" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0856",
|
||||
title: "Portfolio 6",
|
||||
title: "Newcastle Project 2025",
|
||||
budget: "£410k",
|
||||
status: "completion; status 'on track'" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0857",
|
||||
title: "Portfolio 7",
|
||||
title: "Sheffield Selection 2023",
|
||||
budget: "£233k",
|
||||
status: "completion; status 'delayed'" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0858",
|
||||
title: "Portfolio 8",
|
||||
title: "Bristol Hearth Assemblage 2024",
|
||||
budget: "£670k",
|
||||
status: "completion; status 'at risk'" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0859",
|
||||
title: "Portfolio 9",
|
||||
title: "Nottingham col. 2025",
|
||||
budget: "£240k",
|
||||
status: "completion; status 'completed'" as PortfolioStage,
|
||||
},
|
||||
{
|
||||
id: "d290f1ee-6c54-4b01-90e6-d701748f0860",
|
||||
title: "Portfolio 10",
|
||||
title: "Cardiff Homestead Set 2023",
|
||||
budget: "93k",
|
||||
status: "needs review" as PortfolioStage,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,91 +30,91 @@ export default function Plan({
|
|||
const partsConfig = [
|
||||
{
|
||||
part: "Roof",
|
||||
option: "option 1",
|
||||
option: "200mm insulation",
|
||||
cost: 1200,
|
||||
co2Reduction: 1.3,
|
||||
workHours: 6,
|
||||
},
|
||||
{
|
||||
part: "Walls",
|
||||
option: "option 1",
|
||||
cost: 5000,
|
||||
option: "Cavity wall insulation",
|
||||
cost: 450,
|
||||
co2Reduction: 0.75,
|
||||
workHours: 20,
|
||||
},
|
||||
{
|
||||
part: "Floors",
|
||||
option: "option 1",
|
||||
cost: 4300,
|
||||
option: "175mm insulation",
|
||||
cost: 1200,
|
||||
co2Reduction: 1.1,
|
||||
workHours: 8,
|
||||
},
|
||||
{
|
||||
part: "Window Glazing",
|
||||
option: "option 1",
|
||||
cost: 3000,
|
||||
option: "Double glazing",
|
||||
cost: 4000,
|
||||
co2Reduction: 0.18,
|
||||
workHours: 15,
|
||||
},
|
||||
{
|
||||
part: "Window Draughproofing",
|
||||
option: "option 1",
|
||||
option: "Draughtproofing strips",
|
||||
cost: 10,
|
||||
co2Reduction: 0.05,
|
||||
workHours: 1,
|
||||
},
|
||||
{
|
||||
part: "Door Insulation",
|
||||
option: "option 1",
|
||||
option: "Sealing doors",
|
||||
cost: 250,
|
||||
co2Reduction: 0.3,
|
||||
workHours: 7,
|
||||
},
|
||||
{
|
||||
part: "Door Draughproofing",
|
||||
option: "option 1",
|
||||
option: "Draughtproofing strips",
|
||||
cost: 70,
|
||||
co2Reduction: 0.1,
|
||||
workHours: 2,
|
||||
},
|
||||
{
|
||||
part: "Heating",
|
||||
option: "option 1",
|
||||
cost: 2300,
|
||||
option: "A efficiency boiler",
|
||||
cost: 1900,
|
||||
co2Reduction: 0.25,
|
||||
workHours: 15,
|
||||
},
|
||||
{
|
||||
part: "Hot Water",
|
||||
option: "option 1",
|
||||
option: "Heat pump water heater",
|
||||
cost: 5290,
|
||||
co2Reduction: 0.15,
|
||||
workHours: 12,
|
||||
},
|
||||
{
|
||||
part: "Solar Panels",
|
||||
option: "option 1",
|
||||
cost: 1300,
|
||||
option: "4 roof solar panels",
|
||||
cost: 5900,
|
||||
co2Reduction: 0.08,
|
||||
workHours: 24,
|
||||
},
|
||||
{
|
||||
part: "Solar Hot Water",
|
||||
option: "option 1",
|
||||
cost: 1000,
|
||||
option: "Solar hot water system",
|
||||
cost: 3000,
|
||||
co2Reduction: 0.2,
|
||||
workHours: 10,
|
||||
},
|
||||
{
|
||||
part: "Lighting",
|
||||
option: "option 1",
|
||||
option: "Replace bulbs with LEDs",
|
||||
cost: 20,
|
||||
co2Reduction: 0.01,
|
||||
workHours: 1,
|
||||
},
|
||||
{
|
||||
part: "Chimneys/ Open Fire Places",
|
||||
option: "option 1",
|
||||
option: "Fill open fire place",
|
||||
cost: 350,
|
||||
co2Reduction: 0.15,
|
||||
workHours: 6,
|
||||
|
|
@ -291,7 +291,6 @@ export default function Plan({
|
|||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
console.log(errorCheck);
|
||||
if (errorCheck) {
|
||||
return <div>Error fetching data: {errorCheck.message}</div>;
|
||||
}
|
||||
|
|
@ -314,6 +313,7 @@ export default function Plan({
|
|||
partIndex={index}
|
||||
title={part.part}
|
||||
cost={part.cost}
|
||||
option={part.option}
|
||||
co2Reduction={part.co2Reduction}
|
||||
workHours={part.workHours}
|
||||
parts={parts}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ type Part = {
|
|||
cost: number;
|
||||
co2Reduction: number;
|
||||
workHours: number;
|
||||
option?: string | undefined;
|
||||
};
|
||||
|
||||
type PartOption = { label: string } & Part;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue