diff --git a/src/layout/MainLayout/Header/index.js b/src/layout/MainLayout/Header/index.js index 50e80d1..f3994b0 100644 --- a/src/layout/MainLayout/Header/index.js +++ b/src/layout/MainLayout/Header/index.js @@ -143,6 +143,9 @@ function Header(props) {
  • Users Profile
  • +
  • + System Setting +
  • diff --git a/src/pages/Setting/SystemSetting/Form.js b/src/pages/Setting/SystemSetting/Form.js new file mode 100644 index 0000000..0b3921d --- /dev/null +++ b/src/pages/Setting/SystemSetting/Form.js @@ -0,0 +1,125 @@ +// material-ui +import { + FormControl, + Button, + Grid, + // InputAdornment, + Typography, FormLabel, + OutlinedInput, +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as React from "react"; + + + +// ==============================|| DASHBOARD - DEFAULT ||============================== // +const Form = ({ selectedItem, onSave }) => { + const [data, setData] = React.useState({}); + const [value, setValue] = React.useState(""); + + React.useEffect(() => { + //if user data from parent are not null + if (selectedItem !== undefined && Object.keys(selectedItem).length > 0) { + setData(selectedItem); + setValue(selectedItem.value) + } + }, [selectedItem]); + + return ( + + + + + { + data?.name ? + <> + + Update + + +
    + + + + + Name: + + + + + {data?.name} + + + + + + + + + Type: + + + + {data?.type} + + + + + + + + + Category: + + + + + {data?.category} + + + + + + + + + Value: + + + + + { + setValue(event.target.value); + }} + /> + + + + + + +
    + + : + + Please select system params. + + + } + +
    + ); +}; + +export default Form; diff --git a/src/pages/Setting/SystemSetting/Table.js b/src/pages/Setting/SystemSetting/Table.js new file mode 100644 index 0000000..395739f --- /dev/null +++ b/src/pages/Setting/SystemSetting/Table.js @@ -0,0 +1,77 @@ +// material-ui +import { + Box, + Typography +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as React from "react"; +import { FiDataGrid } from "components/FiDataGrid"; + + +// ==============================|| DASHBOARD - DEFAULT ||============================== // +const Table = ({onRowClick, dataList}) => { + const [rows, setRows] = React.useState(dataList); + + React.useEffect(() => { + setRows(dataList); + }, [dataList]); + + const columns = [ + { + field: 'name', + headerName: 'Name', + width: 300, + }, + { + id: 'type', + field: 'type', + headerName: 'Type', + width: 150, + valueGetter: (params) => { + return params.row.type + } + }, + { + id: 'category', + field: 'category', + headerName: 'Category', + width: 150, + }, + { + id: 'value', + field: 'value', + headerName: 'Value', + flex: 1 + }, + ]; + return ( + + + + System Params + + +
    + + 'auto'} + onRowClick={onRowClick} + /> + +
    +
    + ); +}; + +export default Table; diff --git a/src/pages/Setting/SystemSetting/index.js b/src/pages/Setting/SystemSetting/index.js new file mode 100644 index 0000000..016e401 --- /dev/null +++ b/src/pages/Setting/SystemSetting/index.js @@ -0,0 +1,110 @@ + +import { + Grid, + Typography, + Stack, + Box, +} from '@mui/material'; +import * as React from "react"; + +import { GET_SYS_PARAMS, } from "utils/ApiPathConst"; + +import Loadable from 'components/Loadable'; +const Table = Loadable(React.lazy(() => import('./Table'))); +const Form = Loadable(React.lazy(() => import('./Form'))); + +import { notifyActionSuccess } from 'utils/CommonFunction'; + +import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' + +import * as HttpUtils from "utils/HttpUtils"; + +const BackgroundHead = { + backgroundImage: `url(${titleBackgroundImg})`, + width: '100%', + height: '100%', + backgroundSize: 'contain', + backgroundRepeat: 'no-repeat', + backgroundColor: '#0C489E', + backgroundPosition: 'right' +} +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const SystemSetting = () => { + const [dataList, setDataList] = React.useState([]); + const [selectedItem, setSelectedItem] = React.useState({}); + + React.useEffect(() => { + loadList(); + }, []); + + const loadList=()=>{ + HttpUtils.get({ + url: GET_SYS_PARAMS, + onSuccess: (responseData)=>{ + setDataList(responseData); + } + }); + } + + const onRowClick=(param)=>{ + setSelectedItem(param.row); + } + + const onSave=(param)=>{ + HttpUtils.post({ + url: GET_SYS_PARAMS+"/update", + params:{ + name: param.name, + value: param.value + }, + onSuccess: ()=>{ + notifyActionSuccess(); + loadList(); + } + }); + } + + + return ( + + + <> + +
    + + System Setting + +
    +
    + + {/*col 1*/} + + + + + + + + + +
    +
    +
    + + + {/*col 2*/} + + + ); +}; + +export default SystemSetting; diff --git a/src/routes/GLDUserRoutes.js b/src/routes/GLDUserRoutes.js index 6c84823..475de96 100644 --- a/src/routes/GLDUserRoutes.js +++ b/src/routes/GLDUserRoutes.js @@ -19,6 +19,7 @@ const DemandNote_Search = Loadable(lazy(() => import('pages/DemandNote/Search')) const DemandNote_Details = Loadable(lazy(() => import('pages/DemandNote/Details'))); const GFMIS_Search = Loadable(lazy(() => import('pages/GFMIS'))); const UserMaintainPage = Loadable(lazy(() => import('pages/User/GLDUserProfile'))); +const SystemSetting = Loadable(lazy(() => import('pages/Setting/SystemSetting'))); // ==============================|| MAIN ROUTING ||============================== // @@ -85,6 +86,10 @@ const GLDUserRoutes = { path: '/user/profile', element: }, + { + path: '/setting/sys', + element: + }, ] }, ] diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 5b6c13d..d536d9d 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -4,6 +4,8 @@ import {apiPath} from "../auth/utils"; export const REFRESH_TOKEN = "/refresh-token" export const CHANGE_PASSWORD_PATH = "/user/change-password" +export const GET_SYS_PARAMS = apiPath+'/settings'; + //Group Config export const GET_GROUP_LIST_PATH = '/group'; export const GET_GROUP_COMBO_PATH = '/group/combo'; diff --git a/src/utils/CommonFunction.js b/src/utils/CommonFunction.js index f278c5a..b5d4627 100644 --- a/src/utils/CommonFunction.js +++ b/src/utils/CommonFunction.js @@ -177,7 +177,7 @@ export const notifyDownloadSuccess = () => { }; export const notifyActionSuccess = (actionMsg) => { - toast.success(`${actionMsg}`, { + toast.success(actionMsg??"Success", { position: "bottom-right", autoClose: 5000, hideProgressBar: false, diff --git a/src/utils/HttpUtils.js b/src/utils/HttpUtils.js index 4c87c38..8209476 100644 --- a/src/utils/HttpUtils.js +++ b/src/utils/HttpUtils.js @@ -20,6 +20,14 @@ export const put = ({url,params, onSuccess, onFail, onError}) =>{ }); }; +export const patch = ({url,params, onSuccess, onFail, onError}) =>{ + axios.patch(url,params).then( + (response)=>{onResponse(response, onSuccess, onFail);} + ).catch(error => { + return handleError(error,onError); + }); +}; + export const post = ({url, params, onSuccess, onFail, onError, headers}) =>{ headers = headers?headers:{ "Content-Type":"application/json" @@ -137,7 +145,7 @@ const onResponse= (response, onSuccess, onFail) =>{ } if(onSuccess){ - onSuccess(response.data); + onSuccess(response?.data); } }