25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

358 lines
18 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({});
  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. setCompanyName(applicationDetailData.companyName);
  48. }
  49. }, [applicationDetailData]);
  50. useEffect(() => {
  51. //if state data are ready and assign to different field
  52. // console.log(currentApplicationDetailData)
  53. if (Object.keys(currentApplicationDetailData).length > 0) {
  54. setOnReady(true);
  55. }
  56. }, [currentApplicationDetailData]);
  57. const handleViewClick = () => () => {
  58. console.log(currentApplicationDetailData)
  59. currentApplicationDetailData.type == "ORG"?
  60. navigate('/orgUser/'+ currentApplicationDetailData.id):
  61. navigate('/indUser/'+ currentApplicationDetailData.id);
  62. };
  63. // useEffect(() => {
  64. // //upload latest data to parent
  65. // const values = getValues();
  66. // const objectData ={
  67. // ...values,
  68. // locked: locked,
  69. // }
  70. // updateUserObject(objectData);
  71. // }, [isCollectData]);
  72. return (
  73. !onReady ?
  74. <LoadingComponent/>
  75. :
  76. <MainCard elevation={0}
  77. border={false}
  78. content={false}
  79. sx={{xs:"12", md:"7"}}>
  80. <Grid container spacing={1} direction="row">
  81. <Grid item xs={12} md={7} >
  82. <Stack
  83. direction="row"
  84. justifyContent="flex-start"
  85. alignItems="center"
  86. spacing={2}
  87. mb={2}
  88. >
  89. <Button
  90. // size="large"
  91. variant="contained"
  92. onClick={handleViewClick()}
  93. sx={{
  94. textTransform: 'capitalize',
  95. alignItems: 'end',
  96. }}>
  97. <ContentPasteSearchIcon/>
  98. <Typography ml={1} mr={1}> View</Typography>
  99. </Button>
  100. </Stack>
  101. </Grid>
  102. </Grid>
  103. <Typography variant="h5" sx={{mb: 2, borderBottom: "1px solid black"}}>
  104. Client Details
  105. </Typography>
  106. <form>
  107. <Grid container direction="column" justifyContent="flex-start"
  108. alignItems="flex-start">
  109. <Grid item xs={12} md={12} lg={12} mb={1} >
  110. {currentApplicationDetailData.verifiedBy!==null?
  111. <Stack direction="row">
  112. <Typography>
  113. Verified
  114. </Typography>
  115. <CheckCircleOutline color="success"/>
  116. </Stack>:
  117. <Stack direction="row">
  118. <Typography>
  119. Not Verified
  120. </Typography>
  121. <HighlightOff color="error"/>
  122. </Stack>
  123. }
  124. </Grid>
  125. </Grid>
  126. <Grid container direction="column" justifyContent="flex-start"
  127. alignItems="flex-start">
  128. <Grid item xs={12} md={12} lg={12} mb={1} >
  129. <FormLabel>Client Type:</FormLabel>
  130. </Grid>
  131. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  132. <FormControl variant="outlined" sx={{width:'100%'}} >
  133. <OutlinedInput
  134. size="small"
  135. {...register("type",
  136. {
  137. value: currentApplicationDetailData.type,
  138. })}
  139. id='type'
  140. />
  141. </FormControl>
  142. </Grid>
  143. </Grid>
  144. {currentApplicationDetailData.type==="ORG"?
  145. <>
  146. <Grid container direction="column" justifyContent="flex-start"
  147. alignItems="flex-start">
  148. <Grid item xs={12} md={12} lg={12} mb={1}
  149. sx={{display: 'flex', alignItems: 'center'}}>
  150. <FormLabel>Company Name (English):</FormLabel>
  151. </Grid>
  152. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  153. <FormControl variant="outlined" sx={{width:'100%'}} >
  154. <OutlinedInput
  155. size="small"
  156. {...register("enCompanyName",
  157. {
  158. value: companyName.enCompanyName ,
  159. })}
  160. id='enCompanyName'
  161. />
  162. </FormControl>
  163. </Grid>
  164. </Grid>
  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>Company Name (Chinese):</FormLabel>
  170. </Grid>
  171. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  172. <FormControl variant="outlined" sx={{width:'100%'}} >
  173. <OutlinedInput
  174. size="small"
  175. {...register("chCompanyName",
  176. {
  177. value: companyName.chCompanyName,
  178. })}
  179. id='chCompanyName'
  180. />
  181. </FormControl>
  182. </Grid>
  183. </Grid>
  184. <Grid container direction="column" justifyContent="flex-start"
  185. alignItems="flex-start">
  186. <Grid item xs={12} md={12} lg={12} mb={1}
  187. sx={{display: 'flex', alignItems: 'center'}}>
  188. <FormLabel>English Name:</FormLabel>
  189. </Grid>
  190. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  191. <FormControl variant="outlined" sx={{width:'100%'}} >
  192. <OutlinedInput
  193. size="small"
  194. {...register("contactPerson",
  195. {
  196. value: currentApplicationDetailData.contactPerson,
  197. })}
  198. id='contactPerson'
  199. />
  200. </FormControl>
  201. </Grid>
  202. </Grid>
  203. <Grid container direction="column" justifyContent="flex-start"
  204. alignItems="flex-start">
  205. <Grid item xs={12} md={12} lg={12} mb={1}
  206. sx={{display: 'flex', alignItems: 'center'}}>
  207. <FormLabel>Contact Phone:</FormLabel>
  208. </Grid>
  209. <Grid item xs={12} md={12} lg={12} mb={1} >
  210. <Stack direction="row">
  211. <FormControl variant="outlined" sx={{width:'40%'}}>
  212. <OutlinedInput
  213. size="small"
  214. {...register("countryCode",
  215. {
  216. value: currentApplicationDetailData.contactTel.countryCode,
  217. })}
  218. id='countryCode'
  219. />
  220. </FormControl>
  221. <FormControl variant="outlined" sx={{width:'100%'}}>
  222. <OutlinedInput
  223. size="small"
  224. {...register("phoneNumber",
  225. {
  226. value: currentApplicationDetailData.contactTel.phoneNumber,
  227. })}
  228. id='phoneNumber'
  229. />
  230. </FormControl>
  231. </Stack>
  232. </Grid>
  233. </Grid>
  234. <Grid container direction="column" justifyContent="flex-start"
  235. alignItems="flex-start">
  236. <Grid item xs={12} md={12} lg={12} mb={1}
  237. sx={{display: 'flex', alignItems: 'center'}}>
  238. <FormLabel>Email:</FormLabel>
  239. </Grid>
  240. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  241. <FormControl variant="outlined" sx={{width:'100%'}} >
  242. <OutlinedInput
  243. size="small"
  244. {...register("emailBus",
  245. {
  246. value: currentApplicationDetailData.emailBus,
  247. })}
  248. id='emailBus'
  249. />
  250. </FormControl>
  251. </Grid>
  252. </Grid>
  253. </>:
  254. <>
  255. <Grid container direction="column" justifyContent="flex-start"
  256. alignItems="flex-start">
  257. <Grid item xs={12} md={12} lg={12} mb={1}
  258. sx={{display: 'flex', alignItems: 'center'}}>
  259. <FormLabel>English Name:</FormLabel>
  260. </Grid>
  261. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  262. <FormControl variant="outlined" sx={{width:'100%'}} >
  263. <OutlinedInput
  264. size="small"
  265. {...register("enName",
  266. {
  267. value: currentApplicationDetailData.enName,
  268. })}
  269. id='enName'
  270. />
  271. </FormControl>
  272. </Grid>
  273. </Grid>
  274. <Grid container direction="column" justifyContent="flex-start"
  275. alignItems="flex-start">
  276. <Grid item xs={12} md={12} lg={12} mb={1}
  277. sx={{display: 'flex', alignItems: 'center'}}>
  278. <FormLabel>Chinese Name:</FormLabel>
  279. </Grid>
  280. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  281. <FormControl variant="outlined" sx={{width:'100%'}} >
  282. <OutlinedInput
  283. size="small"
  284. {...register("chName",
  285. {
  286. value: currentApplicationDetailData.chName,
  287. })}
  288. id='chName'
  289. />
  290. </FormControl>
  291. </Grid>
  292. </Grid>
  293. <Grid container direction="column" justifyContent="flex-start"
  294. alignItems="flex-start">
  295. <Grid item xs={12} md={12} lg={12} mb={1}
  296. sx={{display: 'flex', alignItems: 'center'}}>
  297. <FormLabel>Contact Phone:</FormLabel>
  298. </Grid>
  299. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  300. <Stack direction="row">
  301. <FormControl variant="outlined" sx={{width:'40%'}}>
  302. <OutlinedInput
  303. size="small"
  304. {...register("countryCode",
  305. {
  306. value: currentApplicationDetailData.mobileNumber.countryCode,
  307. })}
  308. id='countryCode'
  309. />
  310. </FormControl>
  311. <FormControl variant="outlined" sx={{width:'100%'}}>
  312. <OutlinedInput
  313. size="small"
  314. {...register("phoneNumber",
  315. {
  316. value: currentApplicationDetailData.mobileNumber.phoneNumber,
  317. })}
  318. id='phoneNumber'
  319. />
  320. </FormControl>
  321. </Stack>
  322. </Grid>
  323. </Grid>
  324. <Grid container direction="column" justifyContent="flex-start"
  325. alignItems="flex-start">
  326. <Grid item xs={12} md={12} lg={12} mb={1}
  327. sx={{display: 'flex', alignItems: 'center'}}>
  328. <FormLabel>Email:</FormLabel>
  329. </Grid>
  330. <Grid item xs={12} md={12} lg={12} mb={1} sx={{width:'100%'}} >
  331. <FormControl variant="outlined" sx={{width:'100%'}} >
  332. <OutlinedInput
  333. size="small"
  334. {...register("emailAddress",
  335. {
  336. value: currentApplicationDetailData.emailAddress,
  337. })}
  338. id='emailAddress'
  339. />
  340. </FormControl>
  341. </Grid>
  342. </Grid>
  343. </>
  344. }
  345. </form>
  346. </MainCard>
  347. );
  348. };
  349. export default ClientDetailCard;