set up outline of the settings page

This commit is contained in:
Khalim Conn-Kowlessar 2024-10-10 11:54:45 +01:00
parent 9562e165f8
commit 23a6c3c8ad
2 changed files with 63 additions and 1 deletions

View file

@ -0,0 +1,52 @@
"use client";
import { useState } from "react";
import { PortfolioSettingsType } from "../../utils";
import { Button } from "@/app/shadcn_components/ui/button";
import { Input } from "@/app/shadcn_components/ui/input";
import { useRouter } from "next/navigation";
export default function PortfolioSettings({
portfolioId,
portfolioSettingsData,
}: {
portfolioId: string;
portfolioSettingsData: PortfolioSettingsType;
}) {
// Running in the client
const router = useRouter();
const [portfolioName, setPortfolioName] = useState(
portfolioSettingsData.name
);
function handleRename() {
// API call to rename the portfolio
// apiFunction(portfolioName)
// Update portfolio function with name is equal to portfolioName
router.refresh();
}
function handlePortfolioNameChange(e: React.ChangeEvent<HTMLInputElement>) {
setPortfolioName(e.target.value);
}
// Last thing we'd need to do is make that update in the db
return (
<>
<div className="flex justify-center max-w-8xl w-8xl">
<ul>
<li>
Name:{" "}
<Input value={portfolioName} onChange={handlePortfolioNameChange} />{" "}
<Button onClick={handleRename}>Rename</Button>
</li>
<li>Budget: {portfolioSettingsData.budget}</li>
<li>Goal: {portfolioSettingsData.goal}</li>
<li>Status: {portfolioSettingsData.status}</li>
</ul>
</div>
</>
);
}

View file

@ -17,10 +17,20 @@ export default async function PortfolioSettingsPage({
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 (
<>
<div className="flex justify-center max-w-8xl w-8xl">
<PortfolioSettings portfolioSettingsData={portfolioSettingsData} />
<PortfolioSettings
portfolioId={portfolioId}
portfolioSettingsData={portfolioSettingsData}
/>
</div>
</>
);