Simple model Ids
This commit is contained in:
parent
60e33f985a
commit
7e8fa21ab7
28
src/App.re
28
src/App.re
|
@ -10,6 +10,15 @@ let routeToPath = route =>
|
|||
| _ => "/"
|
||||
};
|
||||
|
||||
module Models = {
|
||||
let all = [|
|
||||
EAFunds.Interface.model,
|
||||
GlobalCatastrophe.Interface.model,
|
||||
Human.Interface.model,
|
||||
|];
|
||||
let getById = id => E.A.getBy(all, r => r.id == id);
|
||||
};
|
||||
|
||||
module Menu = {
|
||||
module Styles = {
|
||||
open Css;
|
||||
|
@ -55,12 +64,13 @@ module Menu = {
|
|||
let make = () => {
|
||||
<div className=Styles.menu>
|
||||
<Item href={routeToPath(Home)} key="home"> {"Home" |> E.ste} </Item>
|
||||
<Item href={routeToPath(Model("1"))} key="ea-funds">
|
||||
{"EA Funds" |> E.ste}
|
||||
</Item>
|
||||
<Item href={routeToPath(Model("2"))} key="gc">
|
||||
{"Global Catastrophe" |> E.ste}
|
||||
{Models.all
|
||||
|> E.A.fmap((model: Prop.Model.t) => {
|
||||
<Item href={routeToPath(Model(model.id))} key="ea-funds">
|
||||
{model.name |> E.ste}
|
||||
</Item>
|
||||
})
|
||||
|> ReasonReact.array}
|
||||
</div>;
|
||||
};
|
||||
};
|
||||
|
@ -79,9 +89,11 @@ let make = () => {
|
|||
<div className="w-full max-w-screen-xl mx-auto px-6">
|
||||
<Menu />
|
||||
{switch (routing) {
|
||||
| Model("1") => <FormBuilder.ModelForm model=EAFunds.Interface.model />
|
||||
| Model("2") =>
|
||||
<FormBuilder.ModelForm model=GlobalCatastrophe.Interface.model />
|
||||
| Model(n) =>
|
||||
switch (Models.getById(n)) {
|
||||
| Some(model) => <FormBuilder.ModelForm model />
|
||||
| None => <div> {"Page is not found" |> E.ste} </div>
|
||||
}
|
||||
| Home => <div> {"Welcome" |> E.ste} </div>
|
||||
| _ => <div> {"Page is not found" |> E.ste} </div>
|
||||
}}
|
||||
|
|
|
@ -241,6 +241,7 @@ module TypeWithMetadata = {
|
|||
module Model = {
|
||||
type t = {
|
||||
name: string,
|
||||
id: string,
|
||||
description: string,
|
||||
author: string,
|
||||
version: string,
|
||||
|
|
|
@ -216,7 +216,8 @@ module Interface = {
|
|||
|
||||
let model: Prop.Model.t =
|
||||
Prop.{
|
||||
name: "CEA Funds: Donations & Payouts",
|
||||
id: "ea-funds",
|
||||
name: "EA Funds: Donations & Payouts",
|
||||
description: "Calculate the payments and payouts of CEA Funds based on existing data.",
|
||||
version: "1.0.0",
|
||||
author: "Ozzie Gooen",
|
||||
|
|
|
@ -27,6 +27,7 @@ module Interface = {
|
|||
let model: Prop.Model.t =
|
||||
Prop.{
|
||||
name: "Global Catastrophe",
|
||||
id: "global-catastrophe",
|
||||
description: "The chances of having at least one catastrophe per year in the future, assuming no other catastrophe until then.",
|
||||
version: "1.0.0",
|
||||
author: "Ozzie Gooen",
|
||||
|
|
|
@ -28,6 +28,7 @@ module Interface = {
|
|||
let model: Prop.Model.t =
|
||||
Prop.{
|
||||
name: "Death Time",
|
||||
id: "human-lifespan",
|
||||
description: "When will you die?",
|
||||
version: "1.0.0",
|
||||
author: "Ozzie Gooen",
|
||||
|
|
Loading…
Reference in New Issue
Block a user