You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

444 lines
24 KiB

  1. // material-ui
  2. import {
  3. FormControl,
  4. Button,
  5. Grid,
  6. // InputAdornment,
  7. Typography, FormLabel,
  8. OutlinedInput,
  9. Stack
  10. } from '@mui/material';
  11. import MainCard from "../../../components/MainCard";
  12. import * as React from "react";
  13. import { useForm } from "react-hook-form";
  14. import {
  15. useEffect,
  16. useState
  17. } from "react";
  18. // import Checkbox from "@mui/material/Checkbox";
  19. import Loadable from 'components/Loadable';
  20. import { lazy } from 'react';
  21. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  22. //import {useParams} from "react-router-dom";
  23. import ContentPasteSearchIcon from '@mui/icons-material/ContentPasteSearch';
  24. import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
  25. import HighlightOff from '@mui/icons-material/HighlightOff';
  26. // import {useNavigate} from "react-router-dom";
  27. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  28. const ClientDetailCard = (
  29. { applicationDetailData,
  30. // isCollectData,
  31. // updateUserObject,
  32. // isNewRecord
  33. }
  34. ) => {
  35. // const params = useParams();
  36. const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({});
  37. const [onReady, setOnReady] = useState(false);
  38. const [companyName, setCompanyName] = useState({ enCompanyName: "", chCompanyName: "" });
  39. const { register,
  40. // getValues
  41. } = useForm()
  42. // const navigate = useNavigate()
  43. useEffect(() => {
  44. //if user data from parent are not null
  45. if (Object.keys(applicationDetailData).length > 0 && applicationDetailData !== undefined) {
  46. setCurrentApplicationDetailData(applicationDetailData.userData);
  47. if (!applicationDetailData.companyName1 == null) {
  48. setCompanyName(applicationDetailData.companyName);
  49. } else {
  50. const companyNameData = {
  51. enCompanyName: applicationDetailData.userData.enCompanyName,
  52. chCompanyName: applicationDetailData.userData.chCompanyName
  53. }
  54. setCompanyName(companyNameData)
  55. }
  56. }
  57. }, [applicationDetailData]);
  58. useEffect(() => {
  59. //if state data are ready and assign to different field
  60. // console.log(currentApplicationDetailData)
  61. if (Object.keys(currentApplicationDetailData).length > 0) {
  62. setOnReady(true);
  63. }
  64. }, [currentApplicationDetailData]);
  65. const handleViewClick = () => () => {
  66. console.log(currentApplicationDetailData)
  67. currentApplicationDetailData.type == "ORG" ?
  68. window.open('/orgUser/' + currentApplicationDetailData.id, "_blank", "noreferrer") :
  69. window.open('/indUser/' + currentApplicationDetailData.id, "_blank", "noreferrer");
  70. window.addEventListener("focus", onFocus)
  71. };
  72. const onFocus = () => {
  73. window.removeEventListener("focus", onFocus)
  74. location.reload();
  75. }
  76. // useEffect(() => {
  77. // //upload latest data to parent
  78. // const values = getValues();
  79. // const objectData ={
  80. // ...values,
  81. // locked: locked,
  82. // }
  83. // updateUserObject(objectData);
  84. // }, [isCollectData]);
  85. return (
  86. !onReady ?
  87. <LoadingComponent />
  88. :
  89. <MainCard elevation={0}
  90. border={false}
  91. content={false}
  92. sx={{ xs: "12", md: "7" }}>
  93. <Grid container spacing={1} direction="row">
  94. <Grid item xs={12} md={7} >
  95. <Stack
  96. direction="row"
  97. justifyContent="flex-start"
  98. alignItems="center"
  99. spacing={2}
  100. mb={2}
  101. >
  102. <Button
  103. // size="large"
  104. variant="contained"
  105. onClick={handleViewClick()}
  106. sx={{
  107. textTransform: 'capitalize',
  108. alignItems: 'end',
  109. }}>
  110. <ContentPasteSearchIcon />
  111. <Typography variant="h5" ml={1} mr={1}> View</Typography>
  112. </Button>
  113. </Stack>
  114. </Grid>
  115. </Grid>
  116. <Typography variant="h4" sx={{ mb: 2, borderBottom: "1px solid black" }}>
  117. Client Details
  118. </Typography>
  119. <form>
  120. <Grid container direction="column" justifyContent="flex-start"
  121. alignItems="flex-start">
  122. <Grid item xs={12} md={12} lg={12} mb={1} >
  123. {currentApplicationDetailData.verifiedBy !== null ?
  124. <Stack direction="row">
  125. <Typography variant="h5">
  126. Verified
  127. </Typography>
  128. <CheckCircleOutline sx={{ mt: 0.5, ml: 0.2 }} color="success" />
  129. </Stack> :
  130. <Stack direction="row">
  131. <Typography variant="h5">
  132. Not Verified
  133. </Typography>
  134. <HighlightOff sx={{ mt: 0.5, ml: 0.2 }} color="error" />
  135. </Stack>
  136. }
  137. </Grid>
  138. </Grid>
  139. <Grid container direction="column" justifyContent="flex-start"
  140. alignItems="flex-start">
  141. <Grid item xs={12} md={12} lg={12} mb={1} >
  142. <FormLabel><Typography variant="h5">Client Type:</Typography></FormLabel>
  143. </Grid>
  144. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  145. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  146. <OutlinedInput
  147. size="small"
  148. {...register("type",
  149. {
  150. value: currentApplicationDetailData.type == "ORG" ? "Organisation":"Individual",
  151. })}
  152. id='type'
  153. sx={{
  154. "& .MuiInputBase-input.Mui-disabled": {
  155. WebkitTextFillColor: "#000000",
  156. background: "#f8f8f8",
  157. },
  158. }}
  159. />
  160. </FormControl>
  161. </Grid>
  162. </Grid>
  163. {currentApplicationDetailData.type === "ORG" ?
  164. <>
  165. <Grid container direction="column" justifyContent="flex-start"
  166. alignItems="flex-start">
  167. <Grid item xs={12} md={12} lg={12} mb={1}
  168. sx={{ display: 'flex', alignItems: 'center' }}>
  169. <FormLabel><Typography variant="h5">Company Name (English):</Typography></FormLabel>
  170. </Grid>
  171. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  172. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  173. <OutlinedInput
  174. size="small"
  175. {...register("enCompanyName",
  176. {
  177. value: companyName.enCompanyName,
  178. })}
  179. id='enCompanyName'
  180. sx={{
  181. "& .MuiInputBase-input.Mui-disabled": {
  182. WebkitTextFillColor: "#000000",
  183. background: "#f8f8f8",
  184. },
  185. }}
  186. />
  187. </FormControl>
  188. </Grid>
  189. </Grid>
  190. <Grid container direction="column" justifyContent="flex-start"
  191. alignItems="flex-start">
  192. <Grid item xs={12} md={12} lg={12} mb={1}
  193. sx={{ display: 'flex', alignItems: 'center' }}>
  194. <FormLabel><Typography variant="h5">Company Name (Chinese):</Typography></FormLabel>
  195. </Grid>
  196. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  197. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  198. <OutlinedInput
  199. size="small"
  200. {...register("chCompanyName",
  201. {
  202. value: companyName.chCompanyName,
  203. })}
  204. id='chCompanyName'
  205. sx={{
  206. "& .MuiInputBase-input.Mui-disabled": {
  207. WebkitTextFillColor: "#000000",
  208. background: "#f8f8f8",
  209. },
  210. }}
  211. />
  212. </FormControl>
  213. </Grid>
  214. </Grid>
  215. <Grid container direction="column" justifyContent="flex-start"
  216. alignItems="flex-start">
  217. <Grid item xs={12} md={12} lg={12} mb={1}
  218. sx={{ display: 'flex', alignItems: 'center' }}>
  219. <FormLabel><Typography variant="h5">English Name:</Typography></FormLabel>
  220. </Grid>
  221. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  222. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  223. <OutlinedInput
  224. size="small"
  225. {...register("contactPerson",
  226. {
  227. value: currentApplicationDetailData.contactPerson,
  228. })}
  229. id='contactPerson'
  230. sx={{
  231. "& .MuiInputBase-input.Mui-disabled": {
  232. WebkitTextFillColor: "#000000",
  233. background: "#f8f8f8",
  234. },
  235. }}
  236. />
  237. </FormControl>
  238. </Grid>
  239. </Grid>
  240. <Grid container direction="column" justifyContent="flex-start"
  241. alignItems="flex-start">
  242. <Grid item xs={12} md={12} lg={12} mb={1}
  243. sx={{ display: 'flex', alignItems: 'center' }}>
  244. <FormLabel><Typography variant="h5">Contact Phone:</Typography></FormLabel>
  245. </Grid>
  246. <Grid item xs={12} md={12} lg={12} mb={1} >
  247. <Stack direction="row">
  248. <FormControl variant="outlined" sx={{ width: '40%' }} disabled>
  249. <OutlinedInput
  250. size="small"
  251. {...register("countryCode",
  252. {
  253. value: currentApplicationDetailData.contactTel.countryCode,
  254. })}
  255. id='countryCode'
  256. sx={{
  257. "& .MuiInputBase-input.Mui-disabled": {
  258. WebkitTextFillColor: "#000000",
  259. background: "#f8f8f8",
  260. },
  261. }}
  262. />
  263. </FormControl>
  264. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  265. <OutlinedInput
  266. size="small"
  267. {...register("phoneNumber",
  268. {
  269. value: currentApplicationDetailData.contactTel.phoneNumber,
  270. })}
  271. id='phoneNumber'
  272. sx={{
  273. "& .MuiInputBase-input.Mui-disabled": {
  274. WebkitTextFillColor: "#000000",
  275. background: "#f8f8f8",
  276. },
  277. }}
  278. />
  279. </FormControl>
  280. </Stack>
  281. </Grid>
  282. </Grid>
  283. <Grid container direction="column" justifyContent="flex-start"
  284. alignItems="flex-start">
  285. <Grid item xs={12} md={12} lg={12} mb={1}
  286. sx={{ display: 'flex', alignItems: 'center' }}>
  287. <FormLabel><Typography variant="h5">Email:</Typography></FormLabel>
  288. </Grid>
  289. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  290. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  291. <OutlinedInput
  292. size="small"
  293. {...register("emailBus",
  294. {
  295. value: currentApplicationDetailData.emailBus,
  296. })}
  297. id='emailBus'
  298. sx={{
  299. "& .MuiInputBase-input.Mui-disabled": {
  300. WebkitTextFillColor: "#000000",
  301. background: "#f8f8f8",
  302. },
  303. }}
  304. />
  305. </FormControl>
  306. </Grid>
  307. </Grid>
  308. </> :
  309. <>
  310. <Grid container direction="column" justifyContent="flex-start"
  311. alignItems="flex-start">
  312. <Grid item xs={12} md={12} lg={12} mb={1}
  313. sx={{ display: 'flex', alignItems: 'center' }}>
  314. <FormLabel><Typography variant="h5">English Name:</Typography></FormLabel>
  315. </Grid>
  316. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  317. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  318. <OutlinedInput
  319. size="small"
  320. {...register("enName",
  321. {
  322. value: currentApplicationDetailData.enName,
  323. })}
  324. id='enName'
  325. sx={{
  326. "& .MuiInputBase-input.Mui-disabled": {
  327. WebkitTextFillColor: "#000000",
  328. background: "#f8f8f8",
  329. },
  330. }}
  331. />
  332. </FormControl>
  333. </Grid>
  334. </Grid>
  335. <Grid container direction="column" justifyContent="flex-start"
  336. alignItems="flex-start">
  337. <Grid item xs={12} md={12} lg={12} mb={1}
  338. sx={{ display: 'flex', alignItems: 'center' }}>
  339. <FormLabel><Typography variant="h5">Chinese Name:</Typography></FormLabel>
  340. </Grid>
  341. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  342. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  343. <OutlinedInput
  344. size="small"
  345. {...register("chName",
  346. {
  347. value: currentApplicationDetailData.chName,
  348. })}
  349. id='chName'
  350. sx={{
  351. "& .MuiInputBase-input.Mui-disabled": {
  352. WebkitTextFillColor: "#000000",
  353. background: "#f8f8f8",
  354. },
  355. }}
  356. />
  357. </FormControl>
  358. </Grid>
  359. </Grid>
  360. <Grid container direction="column" justifyContent="flex-start"
  361. alignItems="flex-start">
  362. <Grid item xs={12} md={12} lg={12} mb={1}
  363. sx={{ display: 'flex', alignItems: 'center' }}>
  364. <FormLabel><Typography variant="h5">Contact Phone:</Typography></FormLabel>
  365. </Grid>
  366. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  367. <Stack direction="row">
  368. <FormControl variant="outlined" sx={{ width: '40%' }} disabled>
  369. <OutlinedInput
  370. size="small"
  371. {...register("countryCode",
  372. {
  373. value: currentApplicationDetailData.mobileNumber.countryCode,
  374. })}
  375. id='countryCode'
  376. sx={{
  377. "& .MuiInputBase-input.Mui-disabled": {
  378. WebkitTextFillColor: "#000000",
  379. background: "#f8f8f8",
  380. },
  381. }}
  382. />
  383. </FormControl>
  384. <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
  385. <OutlinedInput
  386. size="small"
  387. {...register("phoneNumber",
  388. {
  389. value: currentApplicationDetailData.mobileNumber.phoneNumber,
  390. })}
  391. id='phoneNumber'
  392. sx={{
  393. "& .MuiInputBase-input.Mui-disabled": {
  394. WebkitTextFillColor: "#000000",
  395. background: "#f8f8f8",
  396. },
  397. }}
  398. />
  399. </FormControl>
  400. </Stack>
  401. </Grid>
  402. </Grid>
  403. <Grid container direction="column" justifyContent="flex-start"
  404. alignItems="flex-start">
  405. <Grid item xs={12} md={12} lg={12} mb={1}
  406. sx={{ display: 'flex', alignItems: 'center' }}>
  407. <FormLabel><Typography variant="h5">Email:</Typography></FormLabel>
  408. </Grid>
  409. <Grid item xs={12} md={12} lg={12} mb={1} sx={{ width: '100%' }} >
  410. <FormControl variant="outlined" sx={{ width: '100%' }} disabled >
  411. <OutlinedInput
  412. size="small"
  413. {...register("emailAddress",
  414. {
  415. value: currentApplicationDetailData.emailAddress,
  416. })}
  417. id='emailAddress'
  418. sx={{
  419. "& .MuiInputBase-input.Mui-disabled": {
  420. WebkitTextFillColor: "#000000",
  421. background: "#f8f8f8",
  422. },
  423. }}
  424. />
  425. </FormControl>
  426. </Grid>
  427. </Grid>
  428. </>
  429. }
  430. </form>
  431. </MainCard>
  432. );
  433. };
  434. export default ClientDetailCard;