added notes to better understand state management and marked where the functions for updating the DB need to be created

This commit is contained in:
StefanWout 2024-10-17 17:18:54 +01:00
parent cb89ab2358
commit dba36b850c

View file

@ -64,43 +64,45 @@ export default function PortfolioSettings({
const [portfolioName, setPortfolioName] = useState(
portfolioSettingsData.name
);
const [portfolioBudget, setPortfolioBudget] = useState<
number | string | null
>(portfolioSettingsData.budget);
const [portfolioGoal, setPortfolioGoal] = useState(
portfolioSettingsData.goal
);
const [portfolioStatus, setPortfolioStatus] = useState(
portfolioSettingsData.status
);
function handleRename() {
// API call to rename the portfolio
// apiFunction(portfolioName)
// Update portfolio function with name is equal to portfolioName
router.refresh();
}
// Renaming functionality
function handlePortfolioNameChange(e: React.ChangeEvent<HTMLInputElement>) {
setPortfolioName(e.target.value);
}
// Last thing we'd need to do is make that update in the db
function handleRename() {
// API call to rename the portfolio
// apiFunction(portfolioName)
// Update portfolioName
router.refresh();
}
//Change budget functionality
const [portfolioBudget, setPortfolioBudget] = useState<
number | string | null
>(portfolioSettingsData.budget);
function handlePortfolioBudgetUpdate(e: React.ChangeEvent<HTMLInputElement>) {
setPortfolioBudget(Number(e.target.value));
}
function handleBudgetUpdate() {
// API call to change the budget
// apiFunction(portfolioBudget)
// Update portfolio function with budget is equal to portfolioBudget
console.log(portfolioBudget);
// Update portfolioBudget
router.refresh();
}
function handlePortfolioBudgetUpdate(e: React.ChangeEvent<HTMLInputElement>) {
setPortfolioBudget(Number(e.target.value));
}
return (
<>
<div className="p-4 mt-5 flex justify-center max-w-8xl w-8xl pt-5 bg-gray-50 rounded-lg text-brandblue">