2020-02-26 09:11:06 +00:00
|
|
|
type route =
|
2020-02-26 09:30:37 +00:00
|
|
|
| Model(string)
|
2020-02-26 09:11:06 +00:00
|
|
|
| Home
|
|
|
|
| NotFound;
|
|
|
|
|
|
|
|
let routeToPath = route =>
|
|
|
|
switch (route) {
|
2020-02-26 09:30:37 +00:00
|
|
|
| Model(i) => "/m/" ++ i
|
2020-02-26 09:11:06 +00:00
|
|
|
| Home => "/"
|
|
|
|
| _ => "/"
|
|
|
|
};
|
|
|
|
|
|
|
|
module Menu = {
|
|
|
|
module Styles = {
|
|
|
|
open Css;
|
|
|
|
let menu =
|
|
|
|
style([
|
|
|
|
position(`relative),
|
|
|
|
marginTop(em(0.25)),
|
|
|
|
marginBottom(em(0.25)),
|
|
|
|
selector(
|
|
|
|
"a",
|
|
|
|
[
|
|
|
|
borderRadius(em(0.25)),
|
|
|
|
display(`inlineBlock),
|
|
|
|
backgroundColor(`hex("eee")),
|
|
|
|
padding(em(1.)),
|
|
|
|
cursor(`pointer),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
selector("a:hover", [backgroundColor(`hex("bfcad4"))]),
|
|
|
|
selector("a:hover", [backgroundColor(`hex("bfcad4"))]),
|
|
|
|
selector(
|
|
|
|
"a:not(:first-child):not(:last-child)",
|
|
|
|
[marginRight(em(0.25)), marginLeft(em(0.25))],
|
|
|
|
),
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
module Item = {
|
|
|
|
[@react.component]
|
|
|
|
let make = (~href, ~children) => {
|
|
|
|
<a
|
|
|
|
href
|
|
|
|
onClick={e => {
|
|
|
|
e->ReactEvent.Synthetic.preventDefault;
|
|
|
|
ReasonReactRouter.push(href);
|
|
|
|
}}>
|
|
|
|
children
|
|
|
|
</a>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
[@react.component]
|
|
|
|
let make = () => {
|
|
|
|
<div className=Styles.menu>
|
|
|
|
<Item href={routeToPath(Home)} key="home"> {"Home" |> E.ste} </Item>
|
2020-02-26 09:30:37 +00:00
|
|
|
<Item href={routeToPath(Model("1"))} key="ea-funds">
|
2020-02-26 09:11:06 +00:00
|
|
|
{"EA Funds" |> E.ste}
|
|
|
|
</Item>
|
2020-02-26 09:30:37 +00:00
|
|
|
<Item href={routeToPath(Model("2"))} key="gc">
|
2020-02-26 09:11:06 +00:00
|
|
|
{"Global Catastrophe" |> E.ste}
|
|
|
|
</Item>
|
|
|
|
</div>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-10 20:37:12 +00:00
|
|
|
[@react.component]
|
|
|
|
let make = () => {
|
2020-02-26 09:11:06 +00:00
|
|
|
let url = ReasonReactRouter.useUrl();
|
|
|
|
|
|
|
|
let routing =
|
|
|
|
switch (url.path) {
|
2020-02-26 09:30:37 +00:00
|
|
|
| ["m", modelId] => Model(modelId)
|
2020-02-26 09:11:06 +00:00
|
|
|
| [] => Home
|
|
|
|
| _ => NotFound
|
|
|
|
};
|
|
|
|
|
2020-02-10 20:37:12 +00:00
|
|
|
<div className="w-full max-w-screen-xl mx-auto px-6">
|
2020-02-26 09:11:06 +00:00
|
|
|
<Menu />
|
|
|
|
{switch (routing) {
|
2020-02-26 09:30:37 +00:00
|
|
|
| Model("1") => <FormBuilder.ModelForm model=EAFunds.Interface.model />
|
|
|
|
| Model("2") =>
|
2020-02-26 09:11:06 +00:00
|
|
|
<FormBuilder.ModelForm model=GlobalCatastrophe.Interface.model />
|
|
|
|
| Home => <div> {"Welcome" |> E.ste} </div>
|
|
|
|
| _ => <div> {"Page is not found" |> E.ste} </div>
|
|
|
|
}}
|
2020-02-10 20:37:12 +00:00
|
|
|
</div>;
|
|
|
|
};
|