// material-ui import { FiDataGrid } from "components/FiDataGrid"; import { <<<<<<< HEAD Typography, Button, Grid, Stack, useMediaQuery ======= Typography, Button, Grid, Stack, Dialog, DialogTitle, DialogContent, DialogActions, >>>>>>> 92d5fde (update primary user setting UI) } from '@mui/material'; import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import Checkbox from '@mui/material/Checkbox'; import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst"; import * as DateUtils from "utils/DateUtils"; <<<<<<< HEAD import {FormattedMessage, useIntl} from "react-intl"; import {useTheme} from "@emotion/react"; ======= import { FormattedMessage, useIntl } from "react-intl"; >>>>>>> 92d5fde (update primary user setting UI) const BackgroundHead = { backgroundImage: `url(${titleBackgroundImg})`, width: '100%', height: '100%', backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundColor: '#0C489E', backgroundPosition: 'right' } // ==============================|| DASHBOARD - DEFAULT ||============================== // const ManageOrgUserPage = () => { const [rows, setRows] = React.useState([]); const intl = useIntl(); <<<<<<< HEAD const theme = useTheme(); const isMdOrLg = useMediaQuery(theme.breakpoints.up('md')); ======= const [userId, setUserId] = React.useState(""); const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); const [warningText, setWarningText] = React.useState(""); const [selectUser, setSelectUser] = React.useState({}); >>>>>>> 92d5fde (update primary user setting UI) const _sx = { padding: "4 2 4 2", boxShadow: 1, border: 1, borderColor: '#DDD', '& .MuiDataGrid-cell': { borderTop: 1, borderBottom: 1, borderColor: "#EEE" }, '& .MuiDataGrid-footerContainer': { border: 1, borderColor: "#EEE" } } React.useEffect(() => { setUserId(JSON.parse(localStorage.getItem("userData")).id); loadData(); }, []); function loadData() { HttpUtils.get( { url: UrlUtils.GET_PUBLIC_ORG_USER_LIST, onSuccess: function (responseData) { setRows(responseData); } } ); } function onActiveClick(params) { HttpUtils.get({ url: UrlUtils.GET_USER_UNLOCK + "/" + params.row.id, onSuccess: () => { loadData(); } }); } function getHeader(headerStr) { return {headerStr}; } function getStatus(params) { if (params.row.locked) { return ( <> {getStatusTag({ color: "#525150", text: intl.formatMessage({id: 'locked'}) })} ) } else if (!params.row.verifiedBy) { return getStatusTag({ color: "#fca503", text: intl.formatMessage({id: 'pendingFor'}) }) } else if (params.row.status === "active") { return getStatusTag({ color: "#73AD21", text: intl.formatMessage({id: 'active'}) }) } return getStatusTag({ text: params.row.status }) } function getStatusTag({ color = "#000", textColor = "#FFF", text = "" }) { return (
{text}
) } const setPrimaryUser = () => { setIsWarningPopUp(false) HttpUtils.get( { url: (!selectUser.row.primaryUser ? UrlUtils.GET_SET_PRIMARY_USER : UrlUtils.GET_SET_UN_PRIMARY_USER) + "/" + selectUser.row.id, onSuccess: function () { loadData(); } } ); } const columns = [ { id: 'username', field: 'username', headerName: getHeader(intl.formatMessage({id: 'loginName'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, }, { id: 'contactPerson', field: 'contactPerson', headerName: getHeader(intl.formatMessage({id: 'userName'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, }, { id: 'contactTel', field: 'contactTel', headerName: getHeader(intl.formatMessage({id: 'userContactNumber'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, valueGetter: (params) => { let contactTel = JSON.parse(params.value) return contactTel?.countryCode + " " + contactTel?.phoneNumber; } }, { id: 'emailBus', field: 'emailBus', headerName: getHeader(intl.formatMessage({id: 'userContactEmail'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, }, { id: 'lastLogin', field: 'lastLogin', headerName: getHeader(intl.formatMessage({id: 'lastLoginDate'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, valueGetter: (params) => { return DateUtils.datetimeStr(params.value); } }, { id: 'lastApply', field: 'lastApply', headerName: getHeader(intl.formatMessage({id: 'lastSubmissionDate'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, valueGetter: () => { return "--"; } }, { field: 'actions', type: 'actions', <<<<<<< HEAD headerName: getHeader(intl.formatMessage({id: 'status'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, ======= headerName: getHeader(intl.formatMessage({ id: 'status' })), flex: 1, >>>>>>> 92d5fde (update primary user setting UI) cellClassName: 'actions', getActions: (params) => { return [getStatus(params)] }, }, { id: 'primaryUser', field: 'primaryUser', type: 'bool', headerName: getHeader(intl.formatMessage({id: 'primary'})), width: isMdOrLg ? 'auto' : 160, flex: isMdOrLg ? 1 : undefined, renderCell: (params) => { console.log(params); return ( <> {params.row.id == userId ? <> : { setSelectUser(params); let str = params.row.primaryUser ? "Are you sure to mark " + params.row.username + " as un-primary user?" : "Are you sure to mark " + params.row.username + " as primary user?" setWarningText(str); setIsWarningPopUp(true); }} checked={params.row.primaryUser} /> } ); }, } ]; return (
setIsWarningPopUp(false)} > {warningText}
); }; export default ManageOrgUserPage;