diff --git a/public/calcforcardiac_logo.png b/public/calcforcardiac_logo.png index c94cec5..b4dbe7c 100644 Binary files a/public/calcforcardiac_logo.png and b/public/calcforcardiac_logo.png differ diff --git a/src/app/(calculators)/calculate/[section]/[id]/page.tsx b/src/app/(calculators)/calculate/[section]/[id]/page.tsx index 6a6167e..e3e5283 100644 --- a/src/app/(calculators)/calculate/[section]/[id]/page.tsx +++ b/src/app/(calculators)/calculate/[section]/[id]/page.tsx @@ -1,12 +1,29 @@ +import InputComponent from "@/app/utils/Input"; import Input from "@/app/utils/Input"; - +import { CalculatorRegistry } from "@/app/utils/calculators/registry"; export default async function Calculator({params} : {params:Promise<{section:string, id:string}>}){ const calcData : {section:string, id:string} = await params; - return( + const calculator = CalculatorRegistry[calcData.section].calculators.find(e => e.id === calcData.id); + console.log(calculator); + return calculator ? ( <> -

Section:- {calcData.section}

-

Calculator ID:- {calcData.id}

- +
+

+ {calculator?.name} +

+ +

+ {calculator?.desc} +

+

+ Unit of the value:- {calculator?.unit} +

+
+ {calculator.inputs.map(e => { + return( + + ); + })} - ) + ) : null; } \ No newline at end of file diff --git a/src/app/(calculators)/layout.tsx b/src/app/(calculators)/layout.tsx index cdb4466..ee519e3 100644 --- a/src/app/(calculators)/layout.tsx +++ b/src/app/(calculators)/layout.tsx @@ -1,5 +1,5 @@ import LayoutClient from "./layoutClient"; - +import { Roboto } from "next/font/google"; export default function CalculatorsLayout({children} : {children:React.ReactNode}){ return( <> diff --git a/src/app/(calculators)/layoutClient.tsx b/src/app/(calculators)/layoutClient.tsx index 5434e1f..b27b625 100644 --- a/src/app/(calculators)/layoutClient.tsx +++ b/src/app/(calculators)/layoutClient.tsx @@ -2,11 +2,12 @@ import { useState } from "react"; import Sidemenu from "../utils/Sidemenu"; import Navbar from "../utils/Navbar"; - +import { Roboto } from "next/font/google"; +const font = Roboto({}); export default function LayoutClient({children} : {children:React.ReactNode}){ const [navbar, setNavbar] = useState(false); return( -
+
diff --git a/src/app/utils/Input.tsx b/src/app/utils/Input.tsx index 2fc6d8a..31e3467 100644 --- a/src/app/utils/Input.tsx +++ b/src/app/utils/Input.tsx @@ -1,11 +1,64 @@ -export default function Input(){ - return( - <> +"use client" +import { useState } from "react"; +import { Input } from "./calculators/types"; + +export default function InputComponent({id, type, inputOptions, min, max, required, defaultUnit, unitOptions, name, placeholder} : Input){ + const [showError, setErrorStatus] = useState(false); + const [error, setError] = useState(); + const [option, setOption] = useState(""); + console.log(id); + if(type === "number"){ + console.log(min); + return( + <> +
+ {name} + { + if(e.target.value === ""){ + return; + } + const val = Number(e.target.value); + if(min !== undefined && val < min){ + setError(`Value must be greater than or equal to ${min}`) + setErrorStatus(true); + }else if(max !== undefined && val > max){ + setError(`Value must be smaller than or equal to ${max}`); + setErrorStatus(true); + }else{ + setError(""); + setErrorStatus(false); + } + }} + /> + {showError ?

{error}

: null} +
+ + ); + } else if(type === "select"){ + return(
- Page title - -

You can edit page title later on from settings

+ {name} + + {/* Optional */}
- - ); + ) + } } \ No newline at end of file diff --git a/src/app/utils/Navbar.tsx b/src/app/utils/Navbar.tsx index 0e23207..767b6a6 100644 --- a/src/app/utils/Navbar.tsx +++ b/src/app/utils/Navbar.tsx @@ -1,12 +1,12 @@ "use client" - +import Link from "next/link"; type Props = { navbarToggle: React.Dispatch>; }; export default function Navbar({navbarToggle}: Props){ return( -
+
-
- - - CalcForCardiac - +
+ + + + CalcForCardiac + +