Commit b4f9dc5b authored by Emmanuel Raviart's avatar Emmanuel Raviart

refmt

parent 7790bc89
......@@ -11,26 +11,27 @@ let make = (~sor: option(ameliSor), _children) => {
style=(
ReactDOMRe.Style.make(
~backgroundColor=
switch sor {
switch (sor) {
| None => "grey"
| Some(sor) => Js.String.startsWith(sor.cod, "A") ? "#4caf50" : "#d0021b"
| Some(sor) =>
Js.String.startsWith(sor.cod, "A") ? "#4caf50" : "#d0021b"
},
~color="white",
~flex="1 1 auto",
~fontSize="16px",
~marginLeft="10px",
~padding="5px 5px 5px 5px",
()
(),
)
)>
(
(
switch sor {
switch (sor) {
| None => {js|À discuter|js}
| Some(sor) => sor.lib
}
)
|> ste
)
</mark>
};
\ No newline at end of file
</mark>,
};
......@@ -35,5 +35,5 @@ let make = _children => {
/>
<div> <MaterialUIIcons.Delete /> </div>
</MaterialUI.Typography>
</div>
};
\ No newline at end of file
</div>,
};
[%%bs.raw
{|
%bs.raw
{|
var ApolloCacheInmemory = require("apollo-cache-inmemory");
var InMemoryCache = ApolloCacheInmemory.InMemoryCache;
var IntrospectionFragmentMatcher = ApolloCacheInmemory.IntrospectionFragmentMatcher;
......@@ -9,13 +9,12 @@ var HttpLink = require("apollo-link-http").HttpLink;
var WebSocketLink = require("apollo-link-ws").WebSocketLink;
var getOperationAST = require("graphql").getOperationAST;
/* var gql = require("graphql-tag"); */
|}
];
|};
[@bs.module] external gql : ReasonApolloTypes.gql = "graphql-tag";
[%%bs.raw
{|
%bs.raw
{|
// Cf https://www.apollographql.com/docs/react/recipes/fragment-matching.html
var introspectionQueryResultData = {
"__schema": {
......@@ -44,8 +43,7 @@ var introspectionQueryResultData = {
]
}
};
|}
];
|};
let ameliAmdFragment = {js|
fragment AmeliAmdFragment on AmeliAmd {
......@@ -401,8 +399,7 @@ let referenceOrganeFragment = {js|
type graphqlClient = ApolloClient.generatedApolloClient;
let amendementUpsertedSubscriptionQuery =
[@bs]
gql(
gql(.
{j|
subscription onAmendementUpserted {
amendementUpserted {
......@@ -412,7 +409,7 @@ let amendementUpsertedSubscriptionQuery =
$(amendementFragment)
$(auteurFragment)
$(cosignatairesMentionLibreFragment)
|j}
|j},
);
let createAmendementUpsertedSubscriptionQuery: unit => ApolloClient.queryObj = [%bs.raw
......@@ -428,8 +425,7 @@ function () {
];
let assembleeDiscussionQuery =
[@bs]
gql(
gql(.
{js|
query Discussion($bibard: String!, $bibardSuffixe: String, $legislature: Int!, $organe: String!) {
discussion(bibard: $bibard, bibardSuffixe: $bibardSuffixe, legislature: $legislature, organe: $organe) {
......@@ -443,7 +439,7 @@ let assembleeDiscussionQuery =
++ discussionFragment
++ divisionFragment
++ enveloppeAmendementFragment
++ pageFragment
++ pageFragment,
);
let createAssembleeDiscussionQuery:
......@@ -465,8 +461,7 @@ function (bibard, bibardSuffixe, legislature, organe) {
];
let ordreDuJourQuery =
[@bs]
gql(
gql(.
{js|
query OrdreDuJour($legislature: Int!, $organe: String!) {
ordreDuJour(legislature: $legislature, organe: $organe) {
......@@ -474,7 +469,7 @@ let ordreDuJourQuery =
}
}
|js}
++ elementOrdreDuJourFragment
++ elementOrdreDuJourFragment,
);
let createOrdreDuJourQuery: (string, string) => ApolloClient.queryObj = [%bs.raw
......@@ -493,8 +488,7 @@ function (legislature, organe) {
];
let referencesOrganesQuery =
[@bs]
gql(
gql(.
{js|
query ReferencesOrganes($legislature: Int!) {
referencesOrganes(legislature: $legislature) {
......@@ -502,7 +496,7 @@ let referencesOrganesQuery =
}
}
|js}
++ referenceOrganeFragment
++ referenceOrganeFragment,
);
let createReferencesOrganesQuery: string => ApolloClient.queryObj = [%bs.raw
......@@ -520,8 +514,7 @@ function (legislature) {
];
let prochainADiscuterUpsertedSubscriptionQuery =
[@bs]
gql(
gql(.
{js|
subscription onProchainADiscuterUpserted {
prochainADiscuterUpserted {
......@@ -529,7 +522,7 @@ let prochainADiscuterUpsertedSubscriptionQuery =
}
}
|js}
++ prochainADiscuterFragment
++ prochainADiscuterFragment,
);
let createProchainADiscuterUpsertedSubscriptionQuery:
......@@ -578,8 +571,7 @@ function (httpUrl, wsUrl) {
];
let senatDiscussionQuery =
[@bs]
gql(
gql(.
{js|
query SenatDiscussion($num: String!, $sesinsLil: String!, $txttyp: String!) {
senatDiscussion(num: $num, sesinsLil: $sesinsLil, txttyp: $txttyp) {
......@@ -601,7 +593,7 @@ let senatDiscussionQuery =
++ ameliSorFragment
++ ameliSubFragment
++ ameliTxtFragment
++ ameliTypSubFragment
++ ameliTypSubFragment,
);
let createSenatDiscussionQuery:
......@@ -626,4 +618,4 @@ function (graphqlClient) {
// TODO: Is there something to do?
}
|}
];
\ No newline at end of file
];
......@@ -7,13 +7,13 @@ type action =
type state = {
page,
todo: int
todo: int,
};
let component = ReasonReact.reducerComponent("App");
let urlToPage = (url: ReasonReact.Router.url) : page =>
switch url.path {
switch (url.path) {
| ["a-propos"] => AboutPage
| _ => GraphqlPage(url.path, url.hash)
};
......@@ -22,7 +22,7 @@ let make = (~message as _message, _children) => {
...component,
initialState: () => {
page: urlToPage(ReasonReact.Router.dangerouslyGetInitialUrl()),
todo: 0
todo: 0,
},
subscriptions: self => [
Sub(
......@@ -30,16 +30,16 @@ let make = (~message as _message, _children) => {
ReasonReact.Router.watchUrl(url =>
self.send(Navigate(urlToPage(url)))
),
ReasonReact.Router.unwatchUrl
)
ReasonReact.Router.unwatchUrl,
),
],
reducer: (action, state) =>
switch action {
switch (action) {
| Navigate(page) => ReasonReact.Update({...state, page})
},
render: self =>
switch self.state.page {
switch (self.state.page) {
| AboutPage => <About />
| GraphqlPage(path, hash) => <GraphqlClientQuery hash path />
}
};
\ No newline at end of file
},
};
open Jest;
test("addition", (_) => Expect.(expect(3 + 4) |> toBe(7)));
test("addition", (_) =>
Expect.(expect(3 + 4) |> toBe(7))
);
......@@ -13,11 +13,11 @@ let make =
~amendementWrapper: amendementWrapper,
~discussion: discussion,
~onOpenLinkedContent,
_children
_children,
) => {
...component,
render: _self =>
switch amendementWrapper.amendement {
switch (amendementWrapper.amendement) {
| None =>
<article id=(Slugify.slugify(amendementWrapper.numero))>
<MaterialUI.Typography
......@@ -33,7 +33,7 @@ let make =
variant=MaterialUI.Typography.Variant.Display1>
("Amendement " ++ amendementWrapper.numero |> ste)
(
switch discussion.numeroProchainADiscuter {
switch (discussion.numeroProchainADiscuter) {
| None => ReasonReact.nullElement
| Some(numeroProchainADiscuter) =>
if (numeroProchainADiscuter == amendementWrapper.numero) {
......@@ -56,7 +56,7 @@ let make =
ReactDOMRe.Style.make(
~justifyContent="space-between",
~display="flex",
()
(),
)
)>
<div>
......@@ -73,7 +73,7 @@ let make =
variant=MaterialUI.Typography.Variant.Display1>
("Amendement " ++ amendement.numeroLong |> ste)
(
switch discussion.numeroProchainADiscuter {
switch (discussion.numeroProchainADiscuter) {
| None => ReasonReact.nullElement
| Some(numeroProchainADiscuter) =>
if (numeroProchainADiscuter == amendementWrapper.numero) {
......@@ -97,9 +97,10 @@ let make =
|> (
fun
| None => None
| Some(result) => Js.Nullable.toOption(Js.Re.captures(result)[0])
| Some(result) =>
Js.Nullable.toOption(Js.Re.captures(result)[0])
);
switch placeMatch {
switch (placeMatch) {
| None => ReasonReact.nullElement
| Some(place) =>
let placeSlug = Slugify.slugifySectionNumber(place);
......@@ -117,7 +118,7 @@ let make =
}
</div>
(
switch amendement.dispositif {
switch (amendement.dispositif) {
| None => ReasonReact.nullElement
| Some(dispositif) =>
<div>
......@@ -133,7 +134,7 @@ let make =
}
)
(
switch amendement.exposeSommaire {
switch (amendement.exposeSommaire) {
| None => ReasonReact.nullElement
| Some(exposeSommaire) =>
<div
......@@ -142,7 +143,7 @@ let make =
~backgroundColor="#ebebeb",
~borderBottom="3px solid #979797",
~padding="10px",
()
(),
)
)>
<h4
......@@ -165,7 +166,7 @@ let make =
~alignItems="center",
~display="inline-flex",
~margin="0px auto",
()
(),
)
)>
<img
......@@ -176,7 +177,7 @@ let make =
~flex="1",
~height="100px",
~width="auto",
()
(),
)
)
title="Le Gouvernement"
......@@ -195,7 +196,7 @@ let make =
~alignItems="center",
~display="inline-flex",
~margin="0px auto",
()
(),
)
)>
<img
......@@ -213,7 +214,7 @@ let make =
~flex="1",
~height="100px",
~width="auto",
()
(),
)
)
title=(auteur.prenom ++ " " ++ auteur.nom)
......@@ -230,13 +231,13 @@ let make =
++ " "
++ auteur.nom
++ (
switch auteur.qualite {
switch (auteur.qualite) {
| None => ""
| Some(qualite) => qualite
}
)
++ (
switch amendement.cosignatairesMentionLibre {
switch (amendement.cosignatairesMentionLibre) {
| None => ""
| Some(cosignatairesMentionLibre) =>
" " ++ cosignatairesMentionLibre.titre
......@@ -249,7 +250,7 @@ let make =
(
groupeTitleFromAuteurGroupe(
auteur,
amendementWrapper.auteurGroupe
amendementWrapper.auteurGroupe,
)
|> ste
)
......@@ -258,7 +259,7 @@ let make =
};
}
(
switch amendement.cosignataires {
switch (amendement.cosignataires) {
| [||] => ReasonReact.nullElement
| cosignataires =>
<div>
......@@ -281,13 +282,13 @@ let make =
++ " "
++ cosignataire.nom
++ (
switch cosignataire.qualite {
switch (cosignataire.qualite) {
| None => ""
| Some(qualite) => qualite
}
)
++ (
switch amendement.cosignatairesMentionLibre {
switch (amendement.cosignatairesMentionLibre) {
| None => ""
| Some(cosignatairesMentionLibre) =>
" " ++ cosignatairesMentionLibre.titre
......@@ -304,5 +305,5 @@ let make =
}
)
</article>
}
};
\ No newline at end of file
},
};
......@@ -21,13 +21,13 @@ type state = {
hash: string,
openSnackbar: bool,
page,
path: list(string)
path: list(string),
};
let component = ReasonReact.reducerComponent("AssembleeDiscussion");
let pathToPage = path : page =>
switch path {
switch (path) {
| [] => IndexPage
| ["groupes"] => ByGroupePage
| ["tout"] => FullPage
......@@ -41,7 +41,7 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
hash,
openSnackbar: false,
page: pathToPage(path),
path
path,
},
subscriptions: self => [
Sub(
......@@ -52,7 +52,7 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
~receiver=data =>
self.send(GotAmendement(data))
),
GraphqlSubscription.unsubscribe
GraphqlSubscription.unsubscribe,
),
Sub(
() =>
......@@ -62,8 +62,8 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
~receiver=data =>
self.send(GotProchainADiscuter(data))
),
GraphqlSubscription.unsubscribe
)
GraphqlSubscription.unsubscribe,
),
],
didMount: ({send}) => {
send(ScrollToHash);
......@@ -79,7 +79,7 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
{...state, hash, page, path};
},
reducer: (action, state) =>
switch action {
switch (action) {
| CloseSnackbar => ReasonReact.Update({...state, openSnackbar: false})
| GotAmendement(data) =>
/* Js.log2("GotAmendement", data); */
......@@ -96,7 +96,7 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
{
...amendementWrapper,
amendement: Some(amendement),
sort: amendement.sortEnSeance
sort: amendement.sortEnSeance,
};
} else {
amendementWrapper;
......@@ -106,8 +106,8 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
...state,
discussion: {
...discussion,
amendements: amendementsWrappers
}
amendements: amendementsWrappers,
},
});
} else {
ReasonReact.NoUpdate;
......@@ -124,9 +124,9 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
...state,
discussion: {
...discussion,
numeroProchainADiscuter: Some(prochainADiscuter.numAmdt)
numeroProchainADiscuter: Some(prochainADiscuter.numAmdt),
},
openSnackbar: true
openSnackbar: true,
});
} else {
ReasonReact.NoUpdate;
......@@ -139,7 +139,7 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
render: self =>
<div>
(
switch self.state.page {
switch (self.state.page) {
| ByGroupePage =>
<AssembleeDiscussionByGroupe
discussion=self.state.discussion
......@@ -243,5 +243,5 @@ let make = (~discussion, ~graphqlClient, ~hash, ~path, _children) => {
| (_numeroProchainADiscuter, _openSnackbar) => ReasonReact.nullElement
};
}
</div>
};
\ No newline at end of file
</div>,
};
......@@ -51,7 +51,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
auteurs :=
StringsSet.add(
amendementWrapper.auteurLabel,
auteurs^
auteurs^,
);
}
);
......@@ -77,7 +77,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
Slugify.slugify(amendementWrapper.numero);
<article key=amendementWrapper.numero>
(
switch amendementWrapper.amendement {
switch (amendementWrapper.amendement) {
| None =>
<MaterialUI.Typography
color=MaterialUI.Typography.Color.Inherit
......@@ -95,13 +95,13 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
onClick=(
event => {
ReactEventRe.Mouse.preventDefault(
event
event,
);
ReactEventRe.Mouse.stopPropagation(
event
event,
);
onNavigateToAmendement(
amendement.numeroReference
amendement.numeroReference,
);
}
)>
......@@ -119,7 +119,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
}
)
(
switch discussion.numeroProchainADiscuter {
switch (discussion.numeroProchainADiscuter) {
| None => ReasonReact.nullElement
| Some(numeroProchainADiscuter) =>
if (numeroProchainADiscuter
......@@ -128,7 +128,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
style=(
ReactDOMRe.Style.make(
~color="orange",
()
(),
)
)>
<MaterialUIIcons.Whatshot />
......@@ -157,5 +157,5 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
|> ReasonReact.arrayToElement;
}
</AssembleeDiscussionLayout>;
}
};
\ No newline at end of file
},
};
......@@ -8,12 +8,12 @@ type action =
type linkedContentDialog = {
amendement,
billPage
billPage,
};
type state = {
linkedContentDialog: option(linkedContentDialog),
todo: int
todo: int,
};
let component = ReasonReact.reducerComponent("AssembleeDiscussionFull");
......@@ -22,19 +22,19 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
...component,
initialState: () => {linkedContentDialog: None, todo: 0},
reducer: (action, state) =>
switch action {
switch (action) {
| CloseLinkedContent =>
ReasonReact.Update({...state, linkedContentDialog: None})
| OpenLinkedContent(amendement, billPage) =>
ReasonReact.Update({
...state,
linkedContentDialog: Some({amendement, billPage})
linkedContentDialog: Some({amendement, billPage}),
})
},
render: self =>
<div>
(
switch self.state.linkedContentDialog {
switch (self.state.linkedContentDialog) {
| None => ReasonReact.nullElement
| Some({billPage}) =>
<MaterialUI.Dialog
......@@ -47,7 +47,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
ReactDOMRe.Style.make(
~justifyContent="space-between",
~display="flex",
()
(),
)
)>
<MaterialUI.IconButton
......@@ -64,7 +64,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
(billPage.numero |> ste)
</MaterialUI.Typography>
(
switch billPage.titre {
switch (billPage.titre) {
| None => ReasonReact.nullElement
| Some(titre) =>
<MaterialUI.Typography
......@@ -90,7 +90,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
~backgroundColor="#f0f0f0",
~display="flex",
~flexDirection="column",
()
(),
)
)>
<MaterialUI.Typography
......@@ -106,7 +106,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
~display="flex",
~flexDirection="column",
~maxWidth="800px",
()
(),
)
)>
(
......@@ -137,7 +137,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
ReactDOMRe.Style.make(
~marginTop="24px",
~padding="16px",
()
(),
)
)>
<AssembleeAmendement
......@@ -148,8 +148,8 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
self.send(
OpenLinkedContent(
amendement,
linkedContentPage
)
linkedContentPage,
),
)
)
/>
......@@ -164,5 +164,5 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
</div>
</div>
</AssembleeDiscussionLayout>
</div>
};
\ No newline at end of file
</div>,
};
......@@ -43,7 +43,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
let hash = Slugify.slugify(amendementWrapper.numero);
<article key=amendementWrapper.numero>
(
switch amendementWrapper.amendement {
switch (amendementWrapper.amendement) {
| None =>
<MaterialUI.Typography
color=MaterialUI.Typography.Color.Inherit
......@@ -61,7 +61,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
ReactEventRe.Mouse.preventDefault(event);
ReactEventRe.Mouse.stopPropagation(event);
onNavigateToAmendement(
amendement.numeroReference
amendement.numeroReference,
);
}
)>
......@@ -75,7 +75,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
}
)
(
switch discussion.numeroProchainADiscuter {
switch (discussion.numeroProchainADiscuter) {
| None => ReasonReact.nullElement
| Some(numeroProchainADiscuter) =>
if (numeroProchainADiscuter
......@@ -91,7 +91,9 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
}
}
)
<AssembleeSortEnSeance sortEnSeance=amendementWrapper.sort />
<AssembleeSortEnSeance
sortEnSeance=amendementWrapper.sort
/>
</article>;
})
|> ReasonReact.arrayToElement
......@@ -100,5 +102,5 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, _children) => {
)
|> ReasonReact.arrayToElement
)
</AssembleeDiscussionLayout>
};
\ No newline at end of file
</AssembleeDiscussionLayout>,
};
......@@ -11,7 +11,7 @@ type action =
type state = {
showMobileDrawer: bool,
todo: int
todo: int,
};
let drawer = (discussion: discussion) => {
......@@ -84,20 +84,23 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, children) => {
...component,
initialState: () => {showMobileDrawer: false, todo: 0},
reducer: (action, state) =>
switch action {
switch (action) {
| ToggleShowMobileDrawer =>
ReasonReact.Update({
...state,
showMobileDrawer: ! state.showMobileDrawer
showMobileDrawer: ! state.showMobileDrawer,
})
},
render: self =>
<div
style=(
ReactDOMRe.Style.make
ReactDOMRe.Style.make(
/* ~display="flex", */
/* ~height="100%", */
(~position="relative", ~width="100%", ())
~position="relative",
~width="100%",
(),
)
)>
<MaterialUI.AppBar className="app-bar" position="static">
<MaterialUI.Toolbar
......@@ -105,7 +108,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, children) => {
ReactDOMRe.Style.make(
~justifyContent="space-between",
~display="flex",
()
(),
)
)>
<div
......@@ -126,7 +129,7 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, children) => {
</div>
<div>
(
switch discussion.numeroProchainADiscuter {
switch (discussion.numeroProchainADiscuter) {
| None => ReasonReact.nullElement
| Some(numeroProchainADiscuter) =>
let amendementUrlPath =
......@@ -190,8 +193,8 @@ let make = (~discussion: discussion, ~onNavigateToAmendement, children) => {
ReasonReact.createDomElement(
"main",
~props={"className": "content"},
children
children,
)
)
</div>
};
\ No newline at end of file
</div>,
};
......@@ -13,7 +13,7 @@ let make =
~legislature,
~organe,
~path,
_children
_children,
) => {
...component,
render: _self =>
......@@ -24,12 +24,12 @@ let make =
bibard,
bibardSuffixe,
legislature,
organe
organe,