|
- // material-ui
- import {
- FormControl,
- Button,
- Grid,
- // InputAdornment,
- Typography, FormLabel,
- OutlinedInput,
- Stack,
- Dialog, DialogTitle, DialogContent, DialogActions
- } from '@mui/material';
- // import MainCard from "../../components/MainCard";
- const MainCard = Loadable(lazy(() => import('components/MainCard')));
- import { useForm } from "react-hook-form";
- import { useNavigate } from "react-router-dom";
- import {
- useEffect,
- useState
- } from "react";
- // import Checkbox from "@mui/material/Checkbox";
- import Loadable from 'components/Loadable';
-
- import { lazy } from 'react';
- const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
- // import {useParams} from "react-router-dom";
- import * as HttpUtils from "utils/HttpUtils"
- import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
- import * as DateUtils from "utils/DateUtils";
- import * as FormatUtils from "utils/FormatUtils";
-
- // import BorderColorOutlinedIcon from '@mui/icons-material/BorderColorOutlined';
- // import DoneIcon from '@mui/icons-material/Done';
- import CloseIcon from '@mui/icons-material/Close';
- import EditNoteIcon from '@mui/icons-material/EditNote';
- import DownloadIcon from '@mui/icons-material/Download';
- // ==============================|| DASHBOARD - DEFAULT ||============================== //
- const ApplicationDetailCard = (
- { applicationDetailData,
- setStatus,
- // updateUserObject,
- // isNewRecord
- }
- ) => {
- const [isPopUp, setIsPopUp] = useState(false);
- // const params = useParams();
- const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({});
- const [fee, setFee] = useState(0);
- const [companyName, setCompanyName] = useState({});
- const [fileDetail, setfileDetail] = useState({});
- const [onReady, setOnReady] = useState(false);
- const [issueNum, setIssueNum] = useState("");
- const [issueDate, setIssueDate] = useState("");
- const { register,
- // getValues
- } = useForm();
- const navigate = useNavigate();
-
- useEffect(() => {
- //if user data from parent are not null
- // console.log(applicationDetailData)
- if (Object.keys(applicationDetailData).length > 0 && applicationDetailData.data !== null) {
- setCurrentApplicationDetailData(applicationDetailData.data);
- setCompanyName(applicationDetailData.companyName);
- setfileDetail(applicationDetailData.fileDetail);
- setIssueNum(applicationDetailData.gazetteIssueDetail.volume + "/" + applicationDetailData.gazetteIssueDetail.year
- + " No. " + applicationDetailData.gazetteIssueDetail.issueNo);
- setIssueDate(DateUtils.dateFormat(applicationDetailData.gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)"));
-
- for (let i = 0; i < applicationDetailData.proofList.length; i++) {
- if (applicationDetailData.proofList[i].action == true) {
- setFee(applicationDetailData.proofList[i].fee);
- }
- }
- }
- }, [applicationDetailData]);
-
- useEffect(() => {
- //if state data are ready and assign to different field
- // console.log(currentApplicationDetailData)
- if (Object.keys(currentApplicationDetailData).length > 0) {
- setOnReady(true);
- }
- }, [currentApplicationDetailData]);
-
- const onDownloadClick = () => () => {
- HttpUtils.fileDownload({
- fileId: fileDetail.id,
- skey: fileDetail.skey,
- filename: fileDetail.filename,
- });
- };
-
- const cancelledClick = () => () => {
- setStatus("cancel")
- };
-
- function doPayment() {
- setIsPopUp(false);
- navigate('/paymentPage', { state: { amount: fee, appIdList: [currentApplicationDetailData.id] } });
- }
-
- return (
- !onReady ?
- <LoadingComponent />
- :
- <MainCard elevation={0}
- border={false}
- content={false}
- >
- <Grid container spacing={1} direction="row">
- <Grid item xs={12}>
- <Stack
- direction="row"
- justifyContent="space-between"
- alignItems="center"
- spacing={2}
- mb={2}
- >
- {
- currentApplicationDetailData.status == "confirmed" ?
- <Button
- // size="large"
- variant="contained"
- onClick={() => { setIsPopUp(true) }}
- disabled={currentApplicationDetailData.status == "rejected" || currentApplicationDetailData.status == "cancelled" || currentApplicationDetailData.status == "paid"}
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}>
- <EditNoteIcon />
- <Typography ml={1} variant="h5"> 支付</Typography>
- </Button>
- : null
- }
- <Button
- // size="large"
- variant="contained"
- onClick={cancelledClick()}
- disabled={currentApplicationDetailData.status !== "submitted"}
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end',
- backgroundColor: '#ffa733'
- }}>
- <CloseIcon />
- <Typography ml={1} variant="h5"> 取消</Typography>
- </Button>
- </Stack>
- </Grid>
- </Grid>
- <Typography variant="h4" sx={{ mb: 2, borderBottom: "1px solid black" }}>
- 公共啟事申請資料
- </Typography>
- <form>
- <Grid container direction="column">
- <Grid item xs={12} md={12}>
- <Grid container direction="row" justifyContent="space-between"
- alignItems="center">
- <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">申請編號:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <FormControl variant="outlined" fullWidth disabled>
- <OutlinedInput
- fullWidth
- size="small"
- {...register("appNo",
- {
- value: currentApplicationDetailData.appNo,
- })}
- id='appNo'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">申請狀態:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={4} lg={4}>
- <FormControl variant="outlined">
- {StatusUtils.getStatusByText(currentApplicationDetailData.status)}
- </FormControl>
- </Grid>
- {
- currentApplicationDetailData.reason ?
- <Grid item xs={12} md={5} lg={5}>
- <Grid container alignItems={"center"}>
- <Stack direction="row" justifyContent="flex-start" alignItems="center">
- <Grid item xs={12} md={7} lg={7}>
- <FormLabel><Typography variant="h5">原因:</Typography></FormLabel>
- </Grid>
- <Grid item xs={12} md={5} lg={5}>
- <FormControl variant="outlined" fullWidth disabled>
- <Typography id='reason' variant="h5">
- {currentApplicationDetailData.reason}
- </Typography>
- </FormControl>
- </Grid>
- </Stack>
- </Grid>
- </Grid>
- : ""
- }
- </Grid>
- </Grid>
- </Grid>
- <Grid container direction="row" justifyContent="space-between"
- alignItems="center">
- <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">申請人:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <FormControl variant="outlined" fullWidth disabled >
- {currentApplicationDetailData.orgId === null ?
- <OutlinedInput
- fullWidth
- size="small"
- {...register("contactPerson",
- {
- value: currentApplicationDetailData.contactPerson,
- })}
- id='contactPerson'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- /> :
- <OutlinedInput
- fullWidth
- size="small"
- {...register("companyName",
- {
- value: companyName.enCompanyName,
- })}
- id='companyName'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- }
- </FormControl>
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">憲報期數:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <Stack direction="row">
- <FormControl variant="outlined" fullWidth disabled>
- <OutlinedInput
- size="small"
- {...register("issueNum",
- {
- value: issueNum,
- })}
- id='issueNum'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- </Stack>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- <Grid container direction="row" justifyContent="space-between"
- alignItems="center">
- <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">聯絡人:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <FormControl variant="outlined" fullWidth disabled>
- <OutlinedInput
- fullWidth
- size="small"
- {...register("contactPerson",
- {
- value: currentApplicationDetailData.contactPerson,
- })}
- id='contactPerson'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">發布日期:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <Stack direction="row">
- <FormControl variant="outlined" fullWidth disabled>
- <OutlinedInput
- size="small"
- {...register("issueDate",
- {
- value: issueDate,
- })}
- id='issueDate'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- </Stack>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
-
- <Grid container direction="row" justifyContent="space-between"
- alignItems="center">
- <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">聯絡電話:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <Stack direction="row">
- <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
- <OutlinedInput
- size="small"
- {...register("countryCode",
- {
- value: currentApplicationDetailData.contactTelNo.countryCode,
- })}
- id='countryCode'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
- <OutlinedInput
- size="small"
- {...register("phoneNumber",
- {
- value: currentApplicationDetailData.contactTelNo.phoneNumber,
- })}
- id='phoneNumber'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- </Stack>
- </Grid>
- </Grid>
- </Grid>
- {
- fee > 0 ?
- <Grid item xs={12} md={5} lg={5} sx={{ mb: 1, ml: 1 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">價錢:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <FormLabel><Typography variant="h5">{FormatUtils.currencyFormat(fee)}</Typography></FormLabel>
- </Grid>
- </Grid>
- </Grid>
- :
- <></>
- }
-
- </Grid>
- <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">傳真號碼:</Typography></FormLabel>
- </Grid>
-
- <Grid item xs={12} md={9} lg={9}>
- <Stack direction="row">
- <FormControl variant="outlined" sx={{ width: '25%' }} disabled>
- <OutlinedInput
- size="small"
- {...register("countryCode",
- {
- value: currentApplicationDetailData.contactFaxNo.countryCode,
- })}
- id='countryCode'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- <FormControl variant="outlined" sx={{ width: '100%' }} disabled>
- <OutlinedInput
- size="small"
- {...register("faxNumber",
- {
- value: currentApplicationDetailData.contactFaxNo.faxNumber,
- })}
- id='faxNumber'
- sx={{
- "& .MuiInputBase-input.Mui-disabled": {
- WebkitTextFillColor: "#000000",
- background: "#f8f8f8",
- },
- }}
- />
- </FormControl>
- </Stack>
- </Grid>
- </Grid>
- </Grid>
- <Grid container direction="row" justifyContent="space-between"
- alignItems="center">
- <Grid item xs={12} md={12} lg={12} mt={1}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={6} lg={6}>
- <Grid container direction="row">
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">稿件檔案:</Typography></FormLabel>
- </Grid>
- <Grid item xs={12} md={9} lg={9} sx={{ display: 'flex', alignItems: 'center' }}>
- <Grid container direction="row" justifyContent="flex-start">
- <Grid item xs={12} md={8} lg={8} sx={{ display: 'flex', alignItems: 'center' }}>
- <FormControl variant="outlined" fullWidth >
- <Typography
- fullWidth
- id='fileName'
- variant="h5"
- >
- {fileDetail.filename}
- </Typography>
- </FormControl>
- </Grid>
- <Grid item md={4} lg={4}>
- <Button
- size="small"
- variant="contained"
- onClick={onDownloadClick()}
- title="下載"
- style={{display:"flex-right"}}
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end',
- }}>
- <DownloadIcon />
- </Button>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- <Grid item xs={12} md={6} lg={6} sx={{ mb: 1, paddingTop: 2 }}>
- <Grid container alignItems={"center"}>
- <Grid item xs={12} md={3} lg={3}
- sx={{ display: 'flex', alignItems: 'center' }}>
- <FormLabel><Typography variant="h5">備註:</Typography></FormLabel>
- </Grid>
- <Grid item xs={12} md={9} lg={9}>
- <Typography variant="h5">{currentApplicationDetailData.remarks}</Typography>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- <div>
- <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
- <DialogTitle></DialogTitle>
- <Typography variant="h3" style={{ padding: '16px' }}>確認付款</Typography>
- <DialogContent style={{ display: 'flex', }}>
- <Stack direction="column" justifyContent="space-between">
- <Typography variant="h4">總計金額: {FormatUtils.currencyFormat(fee)}</Typography>
- </Stack>
- </DialogContent>
- <DialogActions>
- <Button onClick={() => setIsPopUp(false)}><Typography variant="h5">Close</Typography></Button>
- <Button onClick={() => doPayment()}><Typography variant="h5">確認</Typography></Button>
- </DialogActions>
- </Dialog>
- </div>
- </form>
- </MainCard >
- );
- };
-
- export default ApplicationDetailCard;
|