@react.component let make = () => { module Form = { type proto = HTTP | HTTPS; type urlStyle = VHOST | PATH; type t = { protocol: option, endpoint: option, url: option, region: option, keyId: option, secretKey: option, } type e = | UndefinedParameter let make = () => { protocol: None, endpoint: None, url: None, region: None, keyId: None, secretKey: None } let _build_unsafe = f => { open Belt.Option { S3.endpoint: Some({ protocol: switch(f.protocol -> getExn) { | HTTP => "http" | _ => "https" }, hostname: f.endpoint -> getExn, path: "/" }), credentials: Some({ accessKeyId: f.keyId -> getExn, secretAccessKey: f.secretKey -> getExn, }), tls: Some((f.protocol -> getExn) == HTTPS), forcePathStyle: Some((f.url -> getExn) == PATH), region: Some(f.region -> getExn), } } let build: t => Belt.Result.t = f => { switch(f -> _build_unsafe) { | config => Ok(config) | exception Not_found => Error(UndefinedParameter) } } } let (form, updateForm) = React.useState(_ => Form.make()); let login = _ => { Js.log(form -> Form.build) } let setProtocol = evt => { let value = switch (ReactEvent.Form.target(evt)["value"]) { | "http" => Form.HTTP | _ => Form.HTTPS } updateForm(form => {...form, protocol: Some(value)}) } let setEndpoint = evt => { let value = (ReactEvent.Form.target(evt)["value"]) updateForm(form => {...form, endpoint: Some(value) }) } let setRegion = _ => () let setUrlStyle = evt => { let value = switch (ReactEvent.Form.target(evt)["value"]) { | "path" => Form.PATH | _ => Form.VHOST } updateForm(form => {...form, url: Some(value)}) } let setKeyId = _ => () let setSecretKey = _ => ()
{ "Configuration"->React.string }
{ `Réseau` -> React.string }
{ "Authentification"->React.string }
}