reverted portfolio page

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-04 20:16:26 +01:00
parent bfb2f600d4
commit d053273020

View file

@ -1,5 +1,3 @@
"use client";
import { PencilSquareIcon, HomeIcon } from "@heroicons/react/24/outline";
import AddNew from "../../components/portfolio/AddNew";
import { formatNumber } from "@/app/utils";
@ -9,75 +7,6 @@ import { ArrowRightCircleIcon } from "@heroicons/react/20/solid";
import { Badge } from "@/app/shadcn_components/ui/badge";
import { PortfolioStage } from "@/types/portfolio";
import StatusBadge from "@/app/components/StatusBadge";
import { useState } from "react";
import { Button } from "@/app/shadcn_components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/app/shadcn_components/ui/dialog";
// import { Input } from "@/components/ui/input";
// import { Label } from "@/components/ui/label";
export function DialogDemo({
budget,
setBudget,
}: {
budget: string | number | string[] | undefined;
setBudget: (budget: number | string | undefined | string[]) => void;
}) {
const [budgetInput, setBudgetInput] = useState<number | null>(null);
function handleSubmit() {
if (budgetInput !== null) {
setBudget(budgetInput);
}
// setIsOpen(false);
}
return (
<Dialog>
<DialogTrigger asChild>
<li className="text-gray-700 px-2 mb-2 flex items-center cursor-pointer hover:text-gray-200 hover:bg-brandblue hover:rounded-md transition-colors duration-200">
Budget: {budget || "Not Set"}
<PencilSquareIcon className="h-6 w-6 ml-2" />
</li>
</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-4 items-center gap-4">
{/* <Label htmlFor="name" className="text-right">
Name
</Label> */}
{/* <Input id="name" value="Pedro Duarte" className="col-span-3" /> */}
</div>
<div className="grid grid-cols-4 items-center gap-4">
{/* <Label htmlFor="username" className="text-right">
Username
</Label>
<Input id="username" value="@peduarte" className="col-span-3" /> */}
</div>
</div>
<DialogFooter>
<Button onClick={handleSubmit} type="submit">
Save changes
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}
function generateProperties(
value: number,
@ -183,15 +112,10 @@ export default async function Page({
searchParams,
}: {
params: { slug: string };
searchParams: { [key: string]: string[] | undefined | number };
searchParams: { [key: string]: string | string[] | undefined | number };
}) {
// This is temp until we retrieve this data from the frontend
// TODO: Update the objects to contains objective + any other required information
const [isBudgetModalOpen, setIsBudgetModalOpen] = useState(false);
const [budget, setBudget] = useState<
number | string | undefined | string[] | "Not set"
>("Not set");
const Portfolios = [
{
id: "f290f1ee-6c54-4b01-90e6-d701748f0851",
@ -332,6 +256,7 @@ export default async function Page({
let page_config;
let pageName;
let budget;
let co2Reduction: number;
let totalWorksHours: number;
let totalValueIncrease: number;
@ -343,22 +268,18 @@ export default async function Page({
...searchParams,
};
pageName = searchParams.name;
budget = searchParams.budget;
co2Reduction = 0;
totalWorksHours = 0;
totalValueIncrease = 0;
rentalYieldIncrease = 0;
totalCost = 0;
if (searchParams.budget !== budget) {
setBudget(searchParams.budget);
}
} else {
page_config = Portfolios.filter((portfolio) => {
return portfolio.id == params.slug;
})[0];
pageName = page_config.title;
if (page_config.budget !== budget) {
setBudget(page_config.budget);
}
budget = page_config.budget;
co2Reduction = page_config.co2Reduction as number;
totalWorksHours = page_config.totalWorksHours as number;
totalValueIncrease = page_config.totalValueIncrease as number;
@ -369,6 +290,10 @@ export default async function Page({
// TODO: Put this back in for demo
const properties = page_config.properties;
// TODO: Add the porfolio summary information on the left
// Add an empty state for when there are no properties
// Create populated state for when there are properties
return (
<>
<div className="flex justify-center">
@ -387,7 +312,10 @@ export default async function Page({
Portfolio Summary
</h2>
<ul>
<DialogDemo budget={budget} />
<li className="text-gray-700 px-2 mb-2 flex items-center cursor-pointer hover:text-gray-200 hover:bg-brandblue hover:rounded-md transition-colors duration-200">
Budget: {budget || "Not Set"}
<PencilSquareIcon className="h-6 w-6 ml-2" />
</li>
<li className="text-gray-700 px-2 mb-2">
Total Cost: £{totalCost}
</li>