From 3f5cc487d74965e3dcf01e2907d2df5e2a09bf52 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 3 Oct 2023 15:00:34 +0800 Subject: [PATCH 1/2] update application status --- .../ProofCreate_FromApp/ApplicationDetails.js | 277 ++++++++++++++++++ src/pages/ProofCreate_FromApp/DataGrid.js | 136 +++++++++ .../ProofCreate_FromApp/GazetteDetails.js | 166 +++++++++++ src/pages/ProofCreate_FromApp/index.js | 81 +++++ .../ListPanel/PublicNoteStatusUtils.js | 108 +++---- .../ListPanel/SearchPublicNoticeForm.js | 6 +- src/pages/PublicNotice/ListPanel/index.js | 24 +- .../ApplicationDetailCard.js | 12 +- .../PublicNoticeSearch_GLD/SearchForm.js | 2 +- src/routes/GLDUserRoutes.js | 5 + src/utils/ComboData.js | 67 ++++- 11 files changed, 777 insertions(+), 107 deletions(-) create mode 100644 src/pages/ProofCreate_FromApp/ApplicationDetails.js create mode 100644 src/pages/ProofCreate_FromApp/DataGrid.js create mode 100644 src/pages/ProofCreate_FromApp/GazetteDetails.js create mode 100644 src/pages/ProofCreate_FromApp/index.js diff --git a/src/pages/ProofCreate_FromApp/ApplicationDetails.js b/src/pages/ProofCreate_FromApp/ApplicationDetails.js new file mode 100644 index 0000000..474391c --- /dev/null +++ b/src/pages/ProofCreate_FromApp/ApplicationDetails.js @@ -0,0 +1,277 @@ +// material-ui +import { + CardContent, + Grid, + Stack, + FormControl, + OutlinedInput, + FormLabel, +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as React from "react"; +import { useFormik } from 'formik'; +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const SearchPublicNoticeForm = (formData) => { + + const formik = useFormik({ + enableReinitialize: true, + initialValues: formData, + }); + + const DisplayField = ({name}) => { + return + + ; + } + + + return ( + + +
+ {/*row 1*/} + + + Application Details + + + + {/*row 2*/} + + + + + + + Application No: + + + + + + + + + + + {/* + + + Status: + + + + + {StatusUtils.getStatusByTextEng(currentApplicationDetailData.status)} + + + + */} + + + + + + Applicant: + + + + + {formik.values.orgId === null ? + : + + } + + + + + + + + Contact Phone: + + + + + + + + + + + + + + + + + + + + Contect Person: + + + + + + + + + + + + + Contact Fax: + + + + + + + + + + + + + + + + + + + +
+
+ ); +}; + +export default SearchPublicNoticeForm; diff --git a/src/pages/ProofCreate_FromApp/DataGrid.js b/src/pages/ProofCreate_FromApp/DataGrid.js new file mode 100644 index 0000000..7f0fc11 --- /dev/null +++ b/src/pages/ProofCreate_FromApp/DataGrid.js @@ -0,0 +1,136 @@ +// material-ui +import * as React from 'react'; +import { + Button +} from '@mui/material'; +import * as DateUtils from "utils/DateUtils"; +import {useNavigate} from "react-router-dom"; +import {FiDataGrid} from "components/FiDataGrid"; +// ==============================|| EVENT TABLE ||============================== // + +export default function SearchPublicNoticeTable({ recordList }) { + const [rows, setRows] = React.useState(recordList); + const navigate = useNavigate() + + React.useEffect(() => { + setRows(recordList); + }, [recordList]); + + const handleEditClick = (params) => () => { + navigate('/application/'+ params.id); + }; + + + const columns = [ + { + field: 'actions', + headerName: 'Proof No.', + width: 150, + cellClassName: 'actions', + renderCell: (params) => { + return ; + }, + }, + { + id: 'appId', + field: 'appId', + headerName: 'Application No./ Gazette Code/ Gazette Issue', + flex: 1, + renderCell: (params) => { + let appNo = ""; + let code = ""; + let isssue = params.row.issueYear + +" Vol. "+zeroPad(params.row.issueVolume,3) + +", No. "+zeroPad(params.row.issueNo,2) + +", "+DateUtils.dateFormat(params.row.issueDate, "D MMM YYYY (ddd)"); + + return [appNo+" ("+code+")"+isssue] + }, + }, + { + id: 'created', + field: 'created', + headerName: 'Proof Date', + flex: 1, + valueGetter: (params) => { + return DateUtils.datetimeStr(params?.value); + } + }, + { + id: 'created', + field: 'created', + headerName: 'Confirmed/Return Date', + flex: 1, + valueGetter: (params) => { + return DateUtils.datetimeStr(params?.value); + } + }, + { + id: 'contactPerson', + field: 'contactPerson', + headerName: 'Contact Person', + flex: 1, + renderCell: (params) => { + let company = params.row.enCompanyName!= null ?" ("+(params.row.enCompanyName)+")":""; + + let phone = JSON.parse(params.row.contactTelNo); + let faxNo = JSON.parse(params.row.contactFaxNo); + + let contact = ""; + if (phone) { + contact = "Phone No.: " + phone?.countryCode + " " + phone?.phoneNumber + } + + if (faxNo && faxNo?.faxNumber) { + if (contact != "") + contact = contact + ", " + contact = contact + "Fax No.:" + faxNo?.countryCode + " " + faxNo?.faxNumber + } + + return (<> + {params?.value + company}
+ {contact} + ); + } + }, + { + id: 'groupNo', + field: 'groupNo', + headerName: 'Gazette Group', + flex: 1, + valueGetter: (params) => { + return (params?.value)?(params?.value):""; + } + }, + { + id: 'fee', + field: 'fee', + headerName: 'Fee', + flex: 1, + valueGetter: (params) => { + return (params?.value)?(params?.value):""; + } + }, + ]; + + function zeroPad(num, places) { + num=num?num:0; + var zero = places - num.toString().length + 1; + return Array(+(zero > 0 && zero)).join("0") + num; + } + + return ( +
+ + +
+ ); +} diff --git a/src/pages/ProofCreate_FromApp/GazetteDetails.js b/src/pages/ProofCreate_FromApp/GazetteDetails.js new file mode 100644 index 0000000..c77b148 --- /dev/null +++ b/src/pages/ProofCreate_FromApp/GazetteDetails.js @@ -0,0 +1,166 @@ +// material-ui +import { + FormControl, + Grid, + FormLabel, + OutlinedInput, +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as React from "react"; +import { useFormik } from 'formik'; +// ==============================|| DASHBOARD - DEFAULT ||============================== // + + +const GazetteDetails = ({formData}) => { + + const formik = useFormik({ + enableReinitialize: true, + initialValues: formData, + }); + + // function getIssueLabel(data) { + // if (data == {}) return ""; + // return data.year + // + " Vol. " + zeroPad(data.volume, 3) + // + ", No. " + zeroPad(data.issueNo, 2) + // + ", " + DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + // } + + // function zeroPad(num, places) { + // num = num ? num : 0; + // var zero = places - num.toString().length + 1; + // return Array(+(zero > 0 && zero)).join("0") + num; + // } + + return ( + + +
+ {/*row 1*/} + + + Gazette Details + + + + {/*row 2*/} + + + + + + + Issue Number: + + + + + + + + + + + + + Gazette Code: + + + + + + + + + + + + + + + Issue Date: + + + + + + + + + + + + + Group Title: + + + + + + + + + + + + + + +
+
+ ); +}; + +export default GazetteDetails; diff --git a/src/pages/ProofCreate_FromApp/index.js b/src/pages/ProofCreate_FromApp/index.js new file mode 100644 index 0000000..7d6cb9a --- /dev/null +++ b/src/pages/ProofCreate_FromApp/index.js @@ -0,0 +1,81 @@ +// material-ui +import { + Grid, +} from '@mui/material'; +import MainCard from "components/MainCard"; +import * as UrlUtils from "utils/ApiPathConst"; +import * as React from "react"; +import * as HttpUtils from "utils/HttpUtils"; +import { useParams } from "react-router-dom"; + +import Loadable from 'components/Loadable'; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); +const ApplicationDetails = Loadable(React.lazy(() => import('./ApplicationDetails'))); +//const GazetteDetails = Loadable(React.lazy(() => import('./GazetteDetails'))); +const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); + +// ==============================|| DASHBOARD - DEFAULT ||============================== // + +const Index = () => { + const params = useParams(); + + const [record, setRecord] = React.useState(); + const [onReady, setOnReady] = React.useState(false); + + React.useEffect(() => { + loadForm(); + }, []); + + React.useEffect(() => { + setOnReady(true); + }, [record]); + + + const loadForm = () => { + if(params.id > 0){ + + HttpUtils.get({ + url: UrlUtils.GET_PUBLIC_NOTICE_APPLY_DETAIL+"/"+params.id, + onSuccess:(responseData)=>{ + setRecord(responseData); + } + }); + } + } + + return ( + !onReady ? + + : + + {/*row 1*/} + + + + + + + + + + + {/*row 2*/} + + + + + + + ); +}; + +export default Index; diff --git a/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js b/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js index 60b4ede..b9b373f 100644 --- a/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js +++ b/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js @@ -1,101 +1,69 @@ export function getStatus(params) { - switch (params.row.status) { - case "submitted": - return getStatusTag({ color: "#f5a83d", text: "已提交" }) - case "rejected": - return getStatusTag({ color: "#d9372b", text: "已拒絕" }) - case "cancelled": - return getStatusTag({ color: "#757373", text: "已取消" }) - case "accepted": - return getStatusTag({ color: "#22a13f", text: "處理中" }) - case "confirmed": - return getStatusTag({ color: "#22a13f", text: "待付款" }) - case "paid": - return getStatusTag({ color: "#22a13f", text: "待發布" }) - case "published": - return getStatusTag({ color: "#f5a83d", text: "待付款" }) - case "withdrawn": - return getStatusTag({ color: "#8a8784", text: "已撤回" }) - case "complated": - return getStatusTag({ color: "#8a8784", text: "已完成" }) - default: - return getStatusTag({ text: params.row.status }) - } + return getStatusByText(params.row.status); } export function getStatusByText(status) { switch (status) { case "submitted": - return getStatusTag({ color: "#f5a83d", text: "已提交" }) - case "rejected": - return getStatusTag({ color: "#d9372b", text: "已拒絕" }) - case "cancelled": - return getStatusTag({ color: "#757373", text: "已取消" }) - case "accepted": - return getStatusTag({ color: "#22a13f", text: "處理中" }) + return getStatusTag({ color: "#f5a83d", text: "處理中" }) + case "reviewed": + return getStatusTag({ color: "#f5a83d", text: "處理中" }) case "confirmed": + if (localStorage.getItem('userData').creditor) + return getStatusTag({ color: "#22a13f", text: "待發布" }) + else + return getStatusTag({ color: "#22a13f", text: "待付款" }) + case "published": return getStatusTag({ color: "#22a13f", text: "待付款" }) case "paid": return getStatusTag({ color: "#22a13f", text: "待發布" }) - case "published": - return getStatusTag({ color: "#f5a83d", text: "待付款" }) - case "withdrawn": - return getStatusTag({ color: "#8a8784", text: "已撤回" }) case "complated": return getStatusTag({ color: "#8a8784", text: "已完成" }) - default: - return getStatusTag({ text: params.row.status }) - } -} - -export function getStatusEng(params) { - switch (params.row.status) { - case "submitted": - return getStatusTag({ color: "#f5a83d", text: "Submitted" }) - case "rejected": - return getStatusTag({ color: "#d9372b", text: "Rejected" }) + case "notAccepted": + return getStatusTag({ color: "#d9372b", text: "不接受" }) + case "resubmit": + return getStatusTag({ color: "#757373", text: "需重新提交" }) case "cancelled": - return getStatusTag({ color: "#757373", text: "Cancelled" }) - case "accepted": - return getStatusTag({ color: "#22a13f", text: "Processing" }) - case "confirmed": - return getStatusTag({ color: "#22a13f", text: "Pending Payment" }) - case "paid": - return getStatusTag({ color: "#22a13f", text: "To be published" }) - case "published": - return getStatusTag({ color: "#f5a83d", text: "Pending Payment" }) + return getStatusTag({ color: "#f5a83d", text: "已取消" }) case "withdrawn": - return getStatusTag({ color: "#8a8784", text: "Withdrawn" }) - case "completed": - return getStatusTag({ color: "#8a8784", text: "Completed" }) + return getStatusTag({ color: "#8a8784", text: "已撤銷" }) default: - return getStatusTag({ text: params.row.status }) + return getStatusTag({ text: status }) } } + +export function getStatusEng(params) { + return getStatusByTextEng(params.row.status); +} export function getStatusByTextEng(status) { switch (status) { case "submitted": - return getStatusTag({ color: "#f5a83d", text: "Submitted" }) - case "rejected": - return getStatusTag({ color: "#d9372b", text: "Rejected" }) - case "cancelled": - return getStatusTag({ color: "#757373", text: "Cancelled" }) - case "accepted": - return getStatusTag({ color: "#22a13f", text: "Processing" }) + return getStatusTag({ color: "#f5a83d", text: "Processing" }) + case "reviewed": + return getStatusTag({ color: "#f5a83d", text: "Processing" }) case "confirmed": + if (localStorage.getItem('userData').creditor) + return getStatusTag({ color: "#22a13f", text: "Pending Publish" }) + else + return getStatusTag({ color: "#22a13f", text: "Pending Payment" }) + case "published": return getStatusTag({ color: "#22a13f", text: "Pending Payment" }) case "paid": - return getStatusTag({ color: "#22a13f", text: "To Be Published" }) - case "published": - return getStatusTag({ color: "#f5a83d", text: "Pending Payment" }) + return getStatusTag({ color: "#22a13f", text: "Pending Publish" }) + case "complated": + return getStatusTag({ color: "#8a8784", text: "Completed" }) + case "notAccepted": + return getStatusTag({ color: "#d9372b", text: "Not accepted" }) + case "resubmit": + return getStatusTag({ color: "#757373", text: "Re-submit Required" }) + case "cancelled": + return getStatusTag({ color: "#f5a83d", text: "Cancelled" }) case "withdrawn": return getStatusTag({ color: "#8a8784", text: "Withdrawn" }) - case "completed": - return getStatusTag({ color: "#8a8784", text: "Completed" }) default: - return getStatusTag({ text: params.row.status }) + return getStatusTag({ text: status }) } } diff --git a/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js b/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js index b502f86..6a8fadc 100644 --- a/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js +++ b/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js @@ -129,7 +129,11 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { disablePortal id="status" filterOptions={(options)=>options} - options={ComboData.publicNoticeStatic} + options={ + localStorage.getItem('userData').creditor? + ComboData.publicNoticeStatic_Creditor: + ComboData.publicNoticeStatic + } values={status} inputValue={status?.label} onChange={(event, newValue) => { diff --git a/src/pages/PublicNotice/ListPanel/index.js b/src/pages/PublicNotice/ListPanel/index.js index 63a0cae..6c5cba2 100644 --- a/src/pages/PublicNotice/ListPanel/index.js +++ b/src/pages/PublicNotice/ListPanel/index.js @@ -29,7 +29,6 @@ import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' const PublicNotice = () => { const [submittedList, setSubmittedList] = useState([]); - const [inProgressList, setInProgressList] = useState([]); const [pendingPaymentList, setPendingPaymentList] = useState([]); const [pendingPublishList, setPendingPublishList] = useState([]); const [isLoading, setLoding] = useState(true); @@ -60,7 +59,6 @@ const PublicNotice = () => { url: `${UrlUtils.GET_PUBLIC_NOTICE_LIST_ListByStatus}`, onSuccess: function (response) { setSubmittedList(response["submitted"]); - setInProgressList(response["inProgress"]); setPendingPaymentList(response["pendingPayment"]); setPendingPublishList(response["pendingPublish"]); } @@ -106,9 +104,8 @@ const PublicNotice = () => { - - - + + @@ -119,12 +116,6 @@ const PublicNotice = () => { reloadFunction={reloadPage} /> - - - { - - + - + @@ -163,12 +153,6 @@ const PublicNotice = () => { reloadFunction={reloadPage} /> - - - { + window.open("/proof/create/" + currentApplicationDetailData.id, "_blank", "noreferrer"); + window.addEventListener("focus", onFocus) + } + + const onFocus = () => { + location.reload(); + window.removeEventListener("focus", onFocus) + } + return ( !onReady ? @@ -224,7 +234,7 @@ const ApplicationDetailCard = ( - - : - <>{ - currentApplicationDetailData.status=="submitted"? - - - - : - null - } - - } - {currentApplicationDetailData.status == "accepted" ? : currentApplicationDetailData.status == "paid" ? @@ -420,7 +306,7 @@ const ApplicationDetailCard = ( - + - + - + - + - + - {/* - - - - - - Remarks: - - - - - - - - - - - - - */} diff --git a/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js b/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js index db32a95..e3a837a 100644 --- a/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js +++ b/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js @@ -1,7 +1,7 @@ import { useEffect, useState - } from "react"; +} from "react"; // material-ui import { @@ -20,138 +20,190 @@ import { } from '@mui/material'; import { Grid } from "../../../node_modules/@mui/material/index"; import * as ComboData from "utils/ComboData"; -import { useFormik,FormikProvider } from 'formik'; +import { useFormik, FormikProvider } from 'formik'; import * as yup from 'yup'; const StatusChangeDialog = (props) => { - const [status, setStatus] = useState(""); + const [content, setContent] = useState(); + const [dialogTitle, setDialogTitle] = useState("Confirm"); + const [prositiveBtnText, setPrositiveBtnText] = useState("Confirm"); + const [remarks, setRemarks] = useState(""); + const [helperText, setHelperText] = useState(""); // const [selectedGazetteGroupInputType, setSelectedGazetteGroupInputType] = useState(""); const groupTitleComboList = ComboData.groupTitle; - + useEffect(() => { // console.log(Object.keys(!props.selectedGazetteGroup).length) - if(props.getStatus == "accept"){ - setStatus("Accept") - }else if (props.getStatus == "reject"){ - setStatus("Reject") - }else if (props.getStatus == "complete"){ - setStatus("Complete") - }else if (props.getStatus == "withdraw"){ - setStatus("Withdraw") + // if (props.getStatus == "resubmit") { + // setStatus("Accept") + // } else if (props.getStatus == "reject") { + // setStatus("Reject") + // } else if (props.getStatus == "complete") { + // setStatus("Complete") + // } else if (props.getStatus == "withdraw") { + // setStatus("Withdraw") + // } + + if (props.getStatus == "genGazetteCode") { + setDialogTitle("Gen Gazette Code"); + setPrositiveBtnText("Gen"); + return getGazetteCodeContent() + } else if (props.getStatus == "notAccepted") { + setDialogTitle("Not Accept Reason"); + setPrositiveBtnText("Mark Not Accept"); + return getNotAcceptedContent(); + } else { + setDialogTitle("Action Confirm"); + setPrositiveBtnText("Confirm"); + let str = "Are you sure you want to "+props.getStatus+" this application?" + return getConfirmContent(str); } + + + }, [props.getStatus]); - - const acceptedHandle = () => () =>{ + + const acceptedHandle = () => () => { // console.log(selectedGazetteGroup) - props.setStatusWindowAccepted(true) + if(props.getStatus == "notAccepted"){ + if(!remarks || remarks=="" ) + setHelperText("Please enter reason"); + } + if(!helperText){ + props.onWindowCallback(props.getStatus,{"reason": remarks}); + } + props.setStatusWindowAccepted(true); }; - + const formik = useFormik({ - initialValues:({ - username:'', - }), - validationSchema:yup.object().shape({ - }), + initialValues: ({ + username: '', + }), + validationSchema: yup.object().shape({ + }), }); - // const handleReset = () => { - // setSelectedGazetteGroupInputType("") - // selectedGazetteGroup({}); - // }; - + + const getConfirmContent = (text) => { + setContent( + + {text} + + ); + } + + const getNotAcceptedContent = () => { + setContent( + + { + setRemarks(newValues); + setHelperText(""); + }} + > + + + + ); + } + + const getGazetteCodeContent = () => { + setContent( + + + + Target Issue: + + + + {props.gazetteIssue + ", "}{props.issueNum + ", "}{props.issueDate} + + + + + + + + Grazette Group: + + + options} + inputValue={props.selectedGazetteGroupInputType} + onChange={(event, newValue) => { + if (newValue != null && newValue != {}) { + props.setSelectedGazetteGroupInputType(newValue.label); + props.setSelectedGazetteGroup(newValue); + formik.setFieldValue("gazetteGroup", "") + } else { + props.setSelectedGazetteGroupInputType(""); + } + }} + // sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + + + + + ); + } + return ( - - - - - - - {status} Application - - - + + + + + + + {dialogTitle} + + - - -
- - - {props.getStatus == "accept"? - - - - - Target Issue: - - - - {props.gazetteIssue+", "}{props.issueNum+", "}{props.issueDate} - - - - - - - - Grazette Group: - - - options} - inputValue={props.selectedGazetteGroupInputType} - onChange={(event, newValue) => { - if (newValue!=null && newValue != {}){ - props.setSelectedGazetteGroupInputType(newValue.label); - props.setSelectedGazetteGroup(newValue); - formik.setFieldValue("gazetteGroup","") - }else{ - props.setSelectedGazetteGroupInputType(""); - } - }} - // sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} - renderInput={(params) => } - /> - - - - : - - - - Are you really {status} the Application? - - - - } - - -
-
- - - - - - - - -
+
+
+ +
+ + + {content} + + +
+
+ + + + + + + + +
); }; diff --git a/src/pages/PublicNoticeDetail_GLD/index.js b/src/pages/PublicNoticeDetail_GLD/index.js index a5c4d0f..c1ae869 100644 --- a/src/pages/PublicNoticeDetail_GLD/index.js +++ b/src/pages/PublicNoticeDetail_GLD/index.js @@ -1,7 +1,7 @@ import { useEffect, useState - } from "react"; +} from "react"; // material-ui import { @@ -17,7 +17,7 @@ import { useParams } from "react-router-dom"; import axios from "axios"; - +import * as HttpUtils from "utils/HttpUtils"; import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' const ApplicationDetailCard = Loadable(lazy(() => import('./ApplicationDetailCard'))); const GazetteDetailCard = Loadable(lazy(() => import('./GazetteDetailCard'))); @@ -27,7 +27,7 @@ import { GET_PUBLIC_NOTICE_APPLY_DETAIL, UPDATE_PUBLIC_NOTICE_APPLY_DETAIL, SET_PUBLIC_NOTICE_STATUS_ACCEPTED, - SET_PUBLIC_NOTICE_STATUS_REJRCTED, + SET_PUBLIC_NOTICE_STATUS_NOT_ACCEPT, SET_PUBLIC_NOTICE_STATUS_COMPLATED, SET_PUBLIC_NOTICE_STATUS_WITHDRAW } from "utils/ApiPathConst"; @@ -42,24 +42,24 @@ const PublicNoticeDetail_GLD = () => { // const navigate = useNavigate() const [applicationDetailData, setApplicationDetailData] = useState({}); // const [refApplicationDetailData, setRefApplicationDetailData] = React.useState({}); - const [isLoading,setLoading] = useState(false); + const [isLoading, setLoading] = useState(false); const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent'))); - + //pageTitle const [appNo, setAapNo] = useState(""); const [gazetteIssue, setGazetteIssue] = useState(""); - const [issueDate,setIssueDate] = useState(""); - const [issueNum,setIssueNum] = useState(""); + const [issueDate, setIssueDate] = useState(""); + const [issueNum, setIssueNum] = useState(""); const [groupNo, setGroupNo] = useState(""); // const [groupTitle, setGroupTitle] = useState(""); - + //statusWindow const [open, setOpen] = useState(false); const [getStatus, setStatus] = useState(""); const [statusWindowAccepted, setStatusWindowAccepted] = useState(false); const [selectedGazetteGroup, setSelectedGazetteGroup] = useState({}); const [selectedGazetteGroupInputType, setSelectedGazetteGroupInputType] = useState(""); - + //editMode const [updateApplicationObject, setUpdateApplicationObject] = useState({}); const [editMode, isEditMode] = useState(false); @@ -70,78 +70,78 @@ const PublicNoticeDetail_GLD = () => { backgroundImage: `url(${titleBackgroundImg})`, width: '100%', height: '100%', - backgroundSize:'contain', + backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundColor: '#0C489E', backgroundPosition: 'right' } - const title = groupNo!=null?("Application / "+appNo+", "+gazetteIssue+", "+issueNum+" , "+groupNo):("Application / "+appNo+", "+gazetteIssue+", "+issueNum) + const title = groupNo != null ? ("Application / " + appNo + ", " + gazetteIssue + ", " + issueNum + " , " + groupNo) : ("Application / " + appNo + ", " + gazetteIssue + ", " + issueNum) useEffect(() => { - loadApplicationDetail() + loadApplicationDetail() }, []); - + // useEffect(() => { // if (reload){ // loadApplicationDetail() // } // }, [reload]); - + useEffect(() => { - if(editMode&&isSave){ - onUpdateClick(updateApplicationObject) - } + if (editMode && isSave) { + onUpdateClick(updateApplicationObject) + } }, [updateApplicationObject]); - + const loadApplicationDetail = () => { - if(params.id > 0){ + if (params.id > 0) { axios.get(`${GET_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`) - .then((response) => { - if (response.status === 200) { - setApplicationDetailData(response.data); - const gazetteIssueDetail = response.data.gazetteIssueDetail; - setAapNo(response.data.data.appNo); - setGazetteIssue(gazetteIssueDetail.year +" Vol "+gazetteIssueDetail.volume); - setIssueNum(" No. "+gazetteIssueDetail.issueNo); - setIssueDate(DateUtils.dateFormat(gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)")); - setGroupNo(response.data.data.groupNo); - setLoading(false); - } - }) - .catch(error => { - console.log(error); - return false; - }); + .then((response) => { + if (response.status === 200) { + setApplicationDetailData(response.data); + const gazetteIssueDetail = response.data.gazetteIssueDetail; + setAapNo(response.data.data.appNo); + setGazetteIssue(gazetteIssueDetail.year + " Vol " + gazetteIssueDetail.volume); + setIssueNum(" No. " + gazetteIssueDetail.issueNo); + setIssueDate(DateUtils.dateFormat(gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)")); + setGroupNo(response.data.data.groupNo); + setLoading(false); + } + }) + .catch(error => { + console.log(error); + return false; + }); } } const onUpdateClick = (updateApplicationObject) => { const data = updateApplicationObject.objectData - if(params.id > 0 ){ - setLoading(true); - axios.post(`${UPDATE_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`, - { - contactPerson:data.contactPerson, - contactFaxNo:data.contactFaxNo, - contactTelNo:data.contactTelNo, + if (params.id > 0) { + setLoading(true); + axios.post(`${UPDATE_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`, + { + contactPerson: data.contactPerson, + contactFaxNo: data.contactFaxNo, + contactTelNo: data.contactTelNo, + } + ) + .then((response) => { + if (response.status === 200) { + location.reload(); } - ) - .then((response) => { - if (response.status === 200) { - location.reload(); - } - }) - .catch(error => { - console.log(error); - return false; - }); + }) + .catch(error => { + console.log(error); + return false; + }); } }; useEffect(() => { // console.log(getStatus) - if(getStatus!==""){ + if (getStatus !== "") { setOpen(true) } }, [getStatus]); @@ -159,99 +159,128 @@ const PublicNoticeDetail_GLD = () => { }; useEffect(() => { - if(statusWindowAccepted){ - if(getStatus == "accept"){ + if (statusWindowAccepted) { + if (getStatus == "accept") { onAcceptedClick() - }else if (getStatus== "reject"){ - onRejectedClick() - }else if (getStatus == "complete"){ + } else if (getStatus == "reject") { + onNotAcceptClick() + } else if (getStatus == "complete") { onComplatedClick() - }else if (getStatus == "withdraw"){ + } else if (getStatus == "withdraw") { onWithdrawnClick() } } }, [statusWindowAccepted]); + const onWindowCallback = (status, data) => { + if (status == "genGazetteCode") { + onAcceptedClick() + } else if (getStatus == "notAccepted") { + onNotAcceptClick(data.reason); + } else if (getStatus == "complete") { + onComplatedClick() + } else if (getStatus == "withdraw") { + onWithdrawnClick() + } + } + const onAcceptedClick = () => { - if(params.id > 0 ){ - axios.post(`${SET_PUBLIC_NOTICE_STATUS_ACCEPTED}/${params.id}`, - { - "groupTitle": selectedGazetteGroup.title, - "groupNo": selectedGazetteGroup.type, + if (params.id > 0) { + axios.post(`${SET_PUBLIC_NOTICE_STATUS_ACCEPTED}/${params.id}`, + { + "groupTitle": selectedGazetteGroup.title, + "groupNo": selectedGazetteGroup.type, + } + ) + .then((response) => { + if (response.status === 204) { + setOpen(false); + handleClose(); + location.reload(); } - ) - .then((response) => { - if (response.status === 204) { - setOpen(false); - handleClose(); - location.reload(); - } - }) - .catch(error => { - console.log(error); - return false; - }); + }) + .catch(error => { + console.log(error); + return false; + }); } }; - - const onRejectedClick = () => { - if(params.id > 0 ){ - axios.get(`${SET_PUBLIC_NOTICE_STATUS_REJRCTED}/${params.id}`) - .then((response) => { - if (response.status === 204) { - setOpen(false); - handleClose(); - location.reload(); - } - }) - .catch(error => { - console.log(error); - return false; - }); - } - }; - + + const onNotAcceptClick = (reason) => { + if (params.id <= 0) return; + HttpUtils.post({ + url: `${SET_PUBLIC_NOTICE_STATUS_NOT_ACCEPT}/${params.id}`, + params: { + reason: reason + }, + onSuccess: function () { + location.reload(); + } + }); + // axios.get(`${SET_PUBLIC_NOTICE_STATUS_REJRCTED}/${params.id}`) + // .then((response) => { + // if (response.status === 204) { + // setOpen(false); + // handleClose(); + // location.reload(); + // } + // }) + // .catch(error => { + // console.log(error); + // return false; + // }); + // } + } + const onComplatedClick = () => { - if(params.id > 0 ){ - axios.get(`${SET_PUBLIC_NOTICE_STATUS_COMPLATED}/${params.id}`) - .then((response) => { - if (response.status === 204) { - setOpen(false); - handleClose(); - location.reload(); - } - }) - .catch(error => { - console.log(error); - return false; - }); + if (params.id > 0) { + axios.get(`${SET_PUBLIC_NOTICE_STATUS_COMPLATED}/${params.id}`) + .then((response) => { + if (response.status === 204) { + setOpen(false); + handleClose(); + location.reload(); + } + }) + .catch(error => { + console.log(error); + return false; + }); } }; - + const onWithdrawnClick = () => { - if(params.id > 0 ){ - axios.get(`${SET_PUBLIC_NOTICE_STATUS_WITHDRAW}/${params.id}`) - .then((response) => { - if (response.status === 204) { - setOpen(false); - handleClose(); - location.reload(); - } - }) - .catch(error => { - console.log(error); - return false; - }); + if (params.id > 0) { + axios.get(`${SET_PUBLIC_NOTICE_STATUS_WITHDRAW}/${params.id}`) + .then((response) => { + if (response.status === 204) { + setOpen(false); + handleClose(); + location.reload(); + } + }) + .catch(error => { + console.log(error); + return false; + }); } }; return ( - - + +
@@ -260,43 +289,43 @@ const PublicNoticeDetail_GLD = () => {
- - {title} - + + {title} + - - {isLoading&&editMode? - : - + {isLoading && editMode ? + : + } - - + - + @@ -304,18 +333,18 @@ const PublicNoticeDetail_GLD = () => { - - + - +
); diff --git a/src/themes/palette.js b/src/themes/palette.js index d20075f..0246acb 100644 --- a/src/themes/palette.js +++ b/src/themes/palette.js @@ -52,7 +52,31 @@ const Palette = (mode) => { background: { paper: paletteColor.grey[0], default: paletteColor.grey.A50 - } + }, + ochre: { + main: '#E3D026', + light: '#E9DB5D', + dark: '#A29415', + contrastText: '#242105', + }, + red: { + main: '#f05b5b', + light: '#ff5e5e', + dark: '#c91616', + contrastText: '#fff', + }, + pink: { + main: '#ed138a', + light: '#ff5e5e', + dark: '#ba1c73', + contrastText: '#fff', + }, + orange: { + main: '#ed9740', + light: '#ff5e5e', + dark: '#b0671e', + contrastText: '#fff', + }, } }); }; diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 01b40d2..f157ebc 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -59,7 +59,7 @@ export const POST_ADMIN_USER_REGISTER = apiPath+'/user/registry'; export const DELETE_USER = apiPath+'/user'; export const GET_PUBLIC_NOTICE_APPLY_DETAIL = apiPath+'/application/application-detail'; export const SET_PUBLIC_NOTICE_STATUS_ACCEPTED = apiPath+'/application/application-detail-status-accepted'; -export const SET_PUBLIC_NOTICE_STATUS_REJRCTED = apiPath+'/application/application-detail-status-rejected'; +export const SET_PUBLIC_NOTICE_STATUS_NOT_ACCEPT = apiPath+'/application/application-detail-status-not-accept'; export const SET_PUBLIC_NOTICE_STATUS_CANCELLED = apiPath+'/application/application-detail-status-cancelled'; export const SET_PUBLIC_NOTICE_STATUS_COMPLATED = apiPath+'/application/application-detail-status-complated'; export const SET_PUBLIC_NOTICE_STATUS_WITHDRAW = apiPath+'/application/application-detail-status-withdrawn';