From aa853b24cd4137e02f9de0935233af79d5380e71 Mon Sep 17 00:00:00 2001 From: piouson Date: Sun, 26 Jul 2020 23:55:24 +0100 Subject: [PATCH 1/2] feat: add msadmins settings edit page - [x] add edit page - [x] implement update > NOTE: requires BE endpoint update [Bug 506](https://github.com/microapidev/comment-microapi/issues/506) Resolve #52 --- src/App.js | 2 -- src/components/settings/SettingEdit.js | 36 ++++++++++++++++------- src/components/settings/SettingShow.js | 40 +++++++++++++++++++------- src/components/settings/index.js | 2 ++ 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/src/App.js b/src/App.js index 31513fe..5f13bad 100644 --- a/src/App.js +++ b/src/App.js @@ -9,13 +9,11 @@ import applications from "./components/applications"; import plans from "./components/plans"; import settings from "./components/settings"; import profile from "./components/profile"; -import CustomLayout from "./components/layout/CustomLayout"; function App() { return ( , ]} diff --git a/src/components/settings/SettingEdit.js b/src/components/settings/SettingEdit.js index b116b73..469fb4f 100644 --- a/src/components/settings/SettingEdit.js +++ b/src/components/settings/SettingEdit.js @@ -1,17 +1,31 @@ import React from "react"; -import { Edit, SimpleForm, TextInput } from "react-admin"; +import { + Edit, + SimpleForm, + TextInput, + EditController, + EditView, + BooleanInput, +} from "react-admin"; const SettingEdit = (props) => ( - - - - - - + + + {(controllerProps) => ( + + + {controllerProps.record && + Object.keys(controllerProps.record).map((key) => + /true|false/.test(controllerProps.record[key]) ? ( + + ) : ( + + ) + )} + + + )} + ); diff --git a/src/components/settings/SettingShow.js b/src/components/settings/SettingShow.js index b218ad8..dee8fdb 100644 --- a/src/components/settings/SettingShow.js +++ b/src/components/settings/SettingShow.js @@ -1,14 +1,34 @@ import React from "react"; -import { Show, SimpleShowLayout, TextField } from "react-admin"; +import { + Show, + SimpleShowLayout, + TextField, + ShowController, + ShowView, + BooleanField, +} from "react-admin"; -const SettingShow = (props) => ( - - - - - - - -); +const SettingShow = (props) => { + return ( + + + {(controllerProps) => ( + + + {controllerProps.record && + Object.keys(controllerProps.record).map((key) => + /true|false/.test(controllerProps.record[key]) ? ( + + ) : ( + + ) + )} + + + )} + + + ); +}; export default SettingShow; diff --git a/src/components/settings/index.js b/src/components/settings/index.js index fb5cbd4..5b1f4a5 100644 --- a/src/components/settings/index.js +++ b/src/components/settings/index.js @@ -1,8 +1,10 @@ import SettingShow from "./SettingShow"; +import SettingEdit from "./SettingEdit"; import SettingIcon from "@material-ui/icons/Settings"; export default { list: SettingShow, + edit: SettingEdit, show: SettingShow, icon: SettingIcon, }; From 4cc55e2318d6f912e3ae8fae59e6fa3b27827ecf Mon Sep 17 00:00:00 2001 From: piouson Date: Mon, 27 Jul 2020 00:02:28 +0100 Subject: [PATCH 2/2] fix layout omission --- src/App.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/App.js b/src/App.js index 5f13bad..31513fe 100644 --- a/src/App.js +++ b/src/App.js @@ -9,11 +9,13 @@ import applications from "./components/applications"; import plans from "./components/plans"; import settings from "./components/settings"; import profile from "./components/profile"; +import CustomLayout from "./components/layout/CustomLayout"; function App() { return ( , ]}