Use simple model Ids

This commit is contained in:
Ozzie Gooen 2020-02-26 09:30:37 +00:00
parent 1d85c21e91
commit 60e33f985a

View File

@ -1,13 +1,11 @@
type route = type route =
| EAFunds | Model(string)
| GlobalCatastrophe
| Home | Home
| NotFound; | NotFound;
let routeToPath = route => let routeToPath = route =>
switch (route) { switch (route) {
| EAFunds => "/ea-funds" | Model(i) => "/m/" ++ i
| GlobalCatastrophe => "/global-catastrophe"
| Home => "/" | Home => "/"
| _ => "/" | _ => "/"
}; };
@ -57,10 +55,10 @@ module Menu = {
let make = () => { let make = () => {
<div className=Styles.menu> <div className=Styles.menu>
<Item href={routeToPath(Home)} key="home"> {"Home" |> E.ste} </Item> <Item href={routeToPath(Home)} key="home"> {"Home" |> E.ste} </Item>
<Item href={routeToPath(EAFunds)} key="ea-funds"> <Item href={routeToPath(Model("1"))} key="ea-funds">
{"EA Funds" |> E.ste} {"EA Funds" |> E.ste}
</Item> </Item>
<Item href={routeToPath(GlobalCatastrophe)} key="gc"> <Item href={routeToPath(Model("2"))} key="gc">
{"Global Catastrophe" |> E.ste} {"Global Catastrophe" |> E.ste}
</Item> </Item>
</div>; </div>;
@ -73,8 +71,7 @@ let make = () => {
let routing = let routing =
switch (url.path) { switch (url.path) {
| ["ea-funds"] => EAFunds | ["m", modelId] => Model(modelId)
| ["global-catastrophe"] => GlobalCatastrophe
| [] => Home | [] => Home
| _ => NotFound | _ => NotFound
}; };
@ -82,8 +79,8 @@ let make = () => {
<div className="w-full max-w-screen-xl mx-auto px-6"> <div className="w-full max-w-screen-xl mx-auto px-6">
<Menu /> <Menu />
{switch (routing) { {switch (routing) {
| EAFunds => <FormBuilder.ModelForm model=EAFunds.Interface.model /> | Model("1") => <FormBuilder.ModelForm model=EAFunds.Interface.model />
| GlobalCatastrophe => | Model("2") =>
<FormBuilder.ModelForm model=GlobalCatastrophe.Interface.model /> <FormBuilder.ModelForm model=GlobalCatastrophe.Interface.model />
| Home => <div> {"Welcome" |> E.ste} </div> | Home => <div> {"Welcome" |> E.ste} </div>
| _ => <div> {"Page is not found" |> E.ste} </div> | _ => <div> {"Page is not found" |> E.ste} </div>