選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.js 7.1 KiB

2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. // material-ui
  2. import { FiDataGrid } from "components/FiDataGrid";
  3. import {
  4. Typography, Button, Grid, Stack, useMediaQuery
  5. } from '@mui/material';
  6. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  7. import Checkbox from '@mui/material/Checkbox';
  8. import * as React from "react";
  9. import * as HttpUtils from "utils/HttpUtils";
  10. import * as UrlUtils from "utils/ApiPathConst";
  11. import * as DateUtils from "utils/DateUtils";
  12. import {FormattedMessage, useIntl} from "react-intl";
  13. import {useTheme} from "@emotion/react";
  14. const BackgroundHead = {
  15. backgroundImage: `url(${titleBackgroundImg})`,
  16. width: '100%',
  17. height: '100%',
  18. backgroundSize: 'contain',
  19. backgroundRepeat: 'no-repeat',
  20. backgroundColor: '#0C489E',
  21. backgroundPosition: 'right'
  22. }
  23. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  24. const ManageOrgUserPage = () => {
  25. const [rows, setRows] = React.useState([]);
  26. const intl = useIntl();
  27. const theme = useTheme();
  28. const isMdOrLg = useMediaQuery(theme.breakpoints.up('md'));
  29. const _sx = {
  30. padding: "4 2 4 2",
  31. boxShadow: 1,
  32. border: 1,
  33. borderColor: '#DDD',
  34. '& .MuiDataGrid-cell': {
  35. borderTop: 1,
  36. borderBottom: 1,
  37. borderColor: "#EEE"
  38. },
  39. '& .MuiDataGrid-footerContainer': {
  40. border: 1,
  41. borderColor: "#EEE"
  42. }
  43. }
  44. React.useEffect(() => {
  45. loadData();
  46. }, []);
  47. function loadData() {
  48. HttpUtils.get(
  49. {
  50. url: UrlUtils.GET_PUBLIC_ORG_USER_LIST,
  51. onSuccess: function (responseData) {
  52. setRows(responseData);
  53. }
  54. }
  55. );
  56. }
  57. function onActiveClick(params) {
  58. HttpUtils.get({
  59. url: UrlUtils.GET_USER_UNLOCK + "/" + params.row.id,
  60. onSuccess: () => {
  61. loadData();
  62. }
  63. });
  64. }
  65. function getHeader(headerStr) {
  66. return <Typography variant="h5" >{headerStr}</Typography>;
  67. }
  68. function getStatus(params) {
  69. if (params.row.locked) {
  70. return (
  71. <>
  72. {getStatusTag({ color: "#525150", text: intl.formatMessage({id: 'locked'}) })}
  73. <Button variant="outlined" onClick={() => onActiveClick(params)}>
  74. <FormattedMessage id="unlock" />
  75. </Button>
  76. </>
  77. )
  78. } else if (!params.row.verifiedBy) {
  79. return getStatusTag({ color: "#fca503", text: intl.formatMessage({id: 'pendingFor'}) })
  80. } else if (params.row.status === "active") {
  81. return getStatusTag({ color: "#73AD21", text: intl.formatMessage({id: 'active'}) })
  82. }
  83. return getStatusTag({ text: params.row.status })
  84. }
  85. function getStatusTag({ color = "#000", textColor = "#FFF", text = "" }) {
  86. return (
  87. <div style={{ borderRadius: "25px", "background": color, "color": textColor, "padding": "5px 10px 5px 10px" }}><b>{text}</b></div>
  88. )
  89. }
  90. const setPrimaryUser = (params) => {
  91. HttpUtils.get(
  92. {
  93. url: (!params.row.primaryUser ? UrlUtils.GET_SET_PRIMARY_USER : UrlUtils.GET_SET_UN_PRIMARY_USER) + "/" + params.row.id,
  94. onSuccess: function () {
  95. loadData();
  96. }
  97. }
  98. );
  99. }
  100. const columns = [
  101. {
  102. id: 'username',
  103. field: 'username',
  104. headerName: getHeader(intl.formatMessage({id: 'loginName'})),
  105. width: isMdOrLg ? 'auto' : 160,
  106. flex: isMdOrLg ? 1 : undefined,
  107. },
  108. {
  109. id: 'contactPerson',
  110. field: 'contactPerson',
  111. headerName: getHeader(intl.formatMessage({id: 'userName'})),
  112. width: isMdOrLg ? 'auto' : 160,
  113. flex: isMdOrLg ? 1 : undefined,
  114. },
  115. {
  116. id: 'contactTel',
  117. field: 'contactTel',
  118. headerName: getHeader(intl.formatMessage({id: 'userContactNumber'})),
  119. width: isMdOrLg ? 'auto' : 160,
  120. flex: isMdOrLg ? 1 : undefined,
  121. valueGetter: (params) => {
  122. let contactTel = JSON.parse(params.value)
  123. return contactTel?.countryCode + " " + contactTel?.phoneNumber;
  124. }
  125. },
  126. {
  127. id: 'emailBus',
  128. field: 'emailBus',
  129. headerName: getHeader(intl.formatMessage({id: 'userContactEmail'})),
  130. width: isMdOrLg ? 'auto' : 160,
  131. flex: isMdOrLg ? 1 : undefined,
  132. },
  133. {
  134. id: 'lastLogin',
  135. field: 'lastLogin',
  136. headerName: getHeader(intl.formatMessage({id: 'lastLoginDate'})),
  137. width: isMdOrLg ? 'auto' : 160,
  138. flex: isMdOrLg ? 1 : undefined,
  139. valueGetter: (params) => {
  140. return DateUtils.datetimeStr(params.value);
  141. }
  142. },
  143. {
  144. id: 'lastApply',
  145. field: 'lastApply',
  146. headerName: getHeader(intl.formatMessage({id: 'lastSubmissionDate'})),
  147. width: isMdOrLg ? 'auto' : 160,
  148. flex: isMdOrLg ? 1 : undefined,
  149. valueGetter: () => {
  150. return "--";
  151. }
  152. },
  153. {
  154. field: 'actions',
  155. type: 'actions',
  156. headerName: getHeader(intl.formatMessage({id: 'status'})),
  157. width: isMdOrLg ? 'auto' : 160,
  158. flex: isMdOrLg ? 1 : undefined,
  159. cellClassName: 'actions',
  160. getActions: (params) => {
  161. return [getStatus(params)]
  162. },
  163. },
  164. {
  165. id: 'primaryUser',
  166. field: 'primaryUser',
  167. type: 'bool',
  168. headerName: getHeader(intl.formatMessage({id: 'primary'})),
  169. width: isMdOrLg ? 'auto' : 160,
  170. flex: isMdOrLg ? 1 : undefined,
  171. renderCell: (params) => {
  172. console.log(params);
  173. return (
  174. <Checkbox
  175. onClick={() => { setPrimaryUser(params) }}
  176. checked={params.row.primaryUser}
  177. />
  178. );
  179. },
  180. }
  181. ];
  182. return (
  183. <Grid container>
  184. <Grid item xs={12}>
  185. <div style={BackgroundHead}>
  186. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  187. <Typography ml={15} color='#FFF' variant="h4">
  188. <FormattedMessage id="companyOrUserRecord"/>
  189. </Typography>
  190. </Stack>
  191. </div>
  192. </Grid>
  193. <Grid item lg={12} sx={{ padding: 2 }}>
  194. <FiDataGrid
  195. sx={_sx}
  196. rows={rows}
  197. columns={columns}
  198. initialState={{
  199. pagination: {
  200. paginationModel: { page: 0, pageSize: 10 },
  201. },
  202. }}
  203. />
  204. </Grid>
  205. </Grid>
  206. );
  207. };
  208. export default ManageOrgUserPage;