diff --git a/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx b/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx index de28e58..c8be486 100644 --- a/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/settings/PortfolioSettings.tsx @@ -6,27 +6,47 @@ import { Button } from "@/app/shadcn_components/ui/button"; import { Input } from "@/app/shadcn_components/ui/input"; import { useRouter } from "next/navigation"; import { handleNumericKeyDown } from "@/app/utils"; -import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/app/shadcn_components/ui/select" -import { PortfolioStatus } from "@/app/db/schema/portfolio"; -import { PortfolioGoal } from "@/app/db/schema/portfolio"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "@/app/shadcn_components/ui/select"; +import { PortfolioStatus as PortfolioStatusOptions } from "@/app/db/schema/portfolio"; +import { PortfolioGoal as PortfolioGoalOptions } from "@/app/db/schema/portfolio"; + +export function SettingsDropdown({ + startingValue, + options, + setOption, +}: { + startingValue: string; + options: string[]; + setOption: (option: string) => void; +}) { + function handleValueChange(newValue: string) { + setOption(newValue); + } -export function SettingsDropdown({startingValue}:{startingValue:string;}) { return ( - handleValueChange(newValue)}> - Apple - Banana - Blueberry - Grapes - Pineapple + {options.map((option, idx) => ( + + {option} + + ))} - ) + ); } export default function PortfolioSettings({ @@ -39,20 +59,14 @@ export default function PortfolioSettings({ // Running in the client const router = useRouter(); - //Renaming functionality - + // Set up state + // Syntax const [variable, function whos only job is to update the value of variable] = useState(initial value) const [portfolioName, setPortfolioName] = useState( portfolioSettingsData.name ); - - const [portfolioBudget, setPortfolioBudget] = useState( - portfolioSettingsData.budget - ); - const [portfolioGoal, setPortfolioGoal] = useState( portfolioSettingsData.goal ); - const [portfolioStatus, setPortfolioStatus] = useState( portfolioSettingsData.status ); @@ -69,16 +83,20 @@ export default function PortfolioSettings({ } // Last thing we'd need to do is make that update in the db - + + //Change budget functionality + const [portfolioBudget, setPortfolioBudget] = useState< + number | string | null + >(portfolioSettingsData.budget); function handleBudgetUpdate() { // API call to change the budget // apiFunction(portfolioBudget) // Update portfolio function with budget is equal to portfolioBudget - console.log(portfolioBudget) + console.log(portfolioBudget); router.refresh(); } - + function handlePortfolioBudgetUpdate(e: React.ChangeEvent) { setPortfolioBudget(Number(e.target.value)); } @@ -86,62 +104,76 @@ export default function PortfolioSettings({ return ( <>
-
    +
    {/* Row 1: Name */} -
  • +
    Name: -
  • -
  • +
  • +
    - -
  • - -
  • - +
    +
    + +
    + {/* Row 2: Budget */} -
  • +
    Budget: -
  • -
  • +
+
handleNumericKeyDown(e)} /> - -
  • - -
  • - +
    +
    + +
    + {/* Row 3: Goal */} -
  • +
    Goal: -
  • -
  • - {portfolioSettingsData.goal} -
  • -
  • - -
  • - + + +
    + +
    + + {/* Row 4: Status */} -
  • +
    Status: -
  • -
  • - {portfolioSettingsData.status} -
  • -
  • - -
  • + +
    + +
    + + +
    Portfolio Name: {portfolioName}
    +
    Portfolio Budget: {portfolioBudget}
    +
    Goal value: {portfolioGoal}
    +
    Status value: {portfolioStatus}
    {/* Row 5: Delete */} -
  • -
  • +
    +
    {/* */} -
  • - + + );