diff --git a/src/app/components/portfolio/Toolbar.tsx b/src/app/components/portfolio/Toolbar.tsx
index 9dd8a3c..d09da5c 100644
--- a/src/app/components/portfolio/Toolbar.tsx
+++ b/src/app/components/portfolio/Toolbar.tsx
@@ -2,7 +2,6 @@
import {
Cog6ToothIcon,
- CalculatorIcon,
BuildingOfficeIcon,
ChartBarIcon,
} from "@heroicons/react/24/outline";
@@ -29,11 +28,7 @@ export function Toolbar({ portfolioId }: ToolbarProps) {
const router = useRouter();
function handleClickSettings() {
- console.log("Settings were clicked, implement me");
- }
-
- function handleClickPortfolioPlan() {
- router.push(`/portfolio/${portfolioId}/plan`);
+ router.push(`/portfolio/${portfolioId}/settings`);
}
function handleClickPortfolio() {
@@ -65,14 +60,6 @@ export function Toolbar({ portfolioId }: ToolbarProps) {
Summary
- {/*
-
- Portfolio Plan
- */}
-
) {
+ setPortfolioName(e.target.value);
+ }
+
+ // Last thing we'd need to do is make that update in the db
+
+ return (
+ <>
+
+ >
+ );
+}
diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/page.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/page.tsx
new file mode 100644
index 0000000..a8a61f3
--- /dev/null
+++ b/src/app/portfolio/[slug]/(portfolio)/settings/page.tsx
@@ -0,0 +1,37 @@
+import { getPortfolioSettings } from "../../utils";
+import PortfolioSettings from "./PortfolioSettings";
+
+export default async function PortfolioSettingsPage({
+ params,
+}: {
+ params: { slug: string };
+}) {
+ const portfolioId = params.slug;
+ // fetch data securely on the server
+ // Stef's page!!!!
+ // 1) Rename
+ // 2) Delete - much harder
+
+ // fetch data in the server - name, budget, goal,
+ // pass it to a client component to render and take user input
+
+ const portfolioSettingsData = await getPortfolioSettings(portfolioId);
+
+ // Get goal options and status options by importing something like this:
+ // import {
+ // PortfolioStatus,
+ // PortfolioGoal,
+ // } from "./../../db/schema/portfolio";
+ // and then pass them to the portfoliosettings component
+
+ return (
+ <>
+
+ >
+ );
+}
diff --git a/src/app/portfolio/[slug]/utils.ts b/src/app/portfolio/[slug]/utils.ts
index c50bcd2..3cc8dd5 100644
--- a/src/app/portfolio/[slug]/utils.ts
+++ b/src/app/portfolio/[slug]/utils.ts
@@ -1,3 +1,7 @@
+import type {
+ PortfolioStatus,
+ PortfolioGoal,
+} from "./../../db/schema/portfolio";
import { formatNumber } from "@/app/utils";
import { and, eq, inArray } from "drizzle-orm";
import { db } from "@/app/db/db";
@@ -15,6 +19,38 @@ import {
ScenarioSelect,
} from "@/app/db/schema/recommendations";
+export interface PortfolioSettingsType {
+ name: string;
+ budget: number | null;
+ goal: (typeof PortfolioGoal)[number];
+ status: (typeof PortfolioStatus)[number];
+}
+
+export async function getPortfolioSettings(
+ portfolioId: string
+): Promise {
+ //name, budget, goal, status
+ const data = await db
+ .select({
+ name: portfolio.name,
+ budget: portfolio.budget,
+ goal: portfolio.goal,
+ status: portfolio.status,
+ })
+ .from(portfolio)
+ .where(eq(portfolio.id, BigInt(portfolioId)));
+
+ if (data.length === 0) {
+ throw new Error("Portfolio not found");
+ }
+
+ if (data.length > 1) {
+ throw new Error("More than one portfolio found");
+ }
+
+ return data[0];
+}
+
export async function getPortfolio(portfolioId: string): Promise {
const data = await db
.select()