Created
December 4, 2023 15:38
-
-
Save vschep/cd1d2ad89763b8a931f561688ce07f49 to your computer and use it in GitHub Desktop.
EmbeddedSystemUiReceiveOnly.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [<ReactComponent>] | |
| static member RadioInputReceiveOnly | |
| (inputValue: ChargingPermission) | |
| (chargingPermission: ReceiveValue<ChargingPermission>) | |
| = | |
| let inputValueStr = $"%A{inputValue}" | |
| Html.div [ | |
| prop.classes [ "flex"; "gap-2" ] | |
| prop.children [ | |
| Html.input [ | |
| prop.type'.radio | |
| prop.name "charging-permission" | |
| prop.value inputValueStr | |
| prop.isChecked ( | |
| match chargingPermission with | |
| | Available permission when permission = inputValue -> true | |
| | Available _ | |
| | Unavailable | |
| | ReceiveFailed _ -> false | |
| ) | |
| prop.disabled ( | |
| match chargingPermission with | |
| | Available _ -> false | |
| | Unavailable | |
| | ReceiveFailed _ -> true | |
| ) | |
| ] | |
| Html.label [ prop.for' inputValueStr; prop.text inputValueStr ] | |
| ] | |
| ] | |
| [<ReactComponent>] | |
| static member ChargingPermissionComponent() = | |
| let receivedChargingPermission, setReceivedChargingPermission = | |
| React.useState Unavailable | |
| React.useEffectOnce (fun () -> RestApi.getChargingPermission setReceivedChargingPermission) | |
| Html.div [ | |
| prop.children [ | |
| Html.div [ prop.classes [ "text-xl"; "my-4" ]; prop.text "Charging Permission" ] | |
| ChargingPermissionComponent.RadioInputReceiveOnly Allow receivedChargingPermission | |
| ChargingPermissionComponent.RadioInputReceiveOnly Disallow receivedChargingPermission | |
| ] | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment