From 3b66d6bb31cb75847adcb9229ccbe02f6be601fc Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 26 May 2023 19:18:21 +0100 Subject: [PATCH] Redirect to page --- src/app/components/home/ModelSubmit.tsx | 35 +++++++++++++++++++ src/app/components/home/NewPortfolioModal.tsx | 26 +++++--------- 2 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 src/app/components/home/ModelSubmit.tsx diff --git a/src/app/components/home/ModelSubmit.tsx b/src/app/components/home/ModelSubmit.tsx new file mode 100644 index 0000000..12ac583 --- /dev/null +++ b/src/app/components/home/ModelSubmit.tsx @@ -0,0 +1,35 @@ +import { useRouter } from "next/navigation"; + +const ModalSubmit = ({ + buttonDisabled, + budget, + objective, +}: { + buttonDisabled: boolean; + budget: string; + objective: string; +}) => { + const router = useRouter(); + function createPortfolio() { + // TODO: This will be a server action that will create a new portfolio in the database + // That endpoint will return a uuid which will be the new portfolio's id + const id = "f290f1ee-6c54-4b01-90e6-d701748f0851"; + + router.push( + `/portfolio/${id}?name=${name}&budget=${budget}&objective=${objective}` + ); + } + + return ( + + ); +}; + +export default ModalSubmit; diff --git a/src/app/components/home/NewPortfolioModal.tsx b/src/app/components/home/NewPortfolioModal.tsx index ed47d5f..3186df7 100644 --- a/src/app/components/home/NewPortfolioModal.tsx +++ b/src/app/components/home/NewPortfolioModal.tsx @@ -5,6 +5,7 @@ import LightBulbSvg from "./LightBulbSvg"; import CarbonIcon from "./CarbonIcon"; import QuestionMarkIcon from "./QuestionMarkIcon"; import EnvironmentIcon from "./EnvironmentIconSvg"; +import ModalSubmit from "./ModelSubmit"; const outcomes = [ "Valuation Improvement", @@ -66,20 +67,14 @@ export default function NewPortfolioModal({ }) { const [portfolioName, setPortfolioName] = useState(""); const [budget, setBudget] = useState(""); - const [selectedOutcome, setSelectedOutcome] = useState( - "Nothing Specific" - ); + const [selectedOutcome, setSelectedOutcome] = + useState("Nothing Specific"); const [buttonDisabled, setButtonDisabled] = useState(true); function closeModal() { setIsOpen(false); } - function createPortfolio() { - // TODO: This will be a server action that will create a new portfolio in the database - console.log("redirect"); - } - function handlePortfolioNameChange(e: React.ChangeEvent) { if (e.target.value.length > 0) { setButtonDisabled(false); @@ -123,7 +118,7 @@ export default function NewPortfolioModal({ > Create a new portfolio -
+