diff --git a/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js b/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js index 703f776..60b4ede 100644 --- a/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js +++ b/src/pages/PublicNotice/ListPanel/PublicNoteStatusUtils.js @@ -15,9 +15,11 @@ export function getStatus(params) { case "paid": return getStatusTag({ color: "#22a13f", text: "待發布" }) case "published": - return getStatusTag({ color: "#f5a83d", text: "已發布" }) + 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 }) } @@ -38,9 +40,11 @@ export function getStatusByText(status) { case "paid": return getStatusTag({ color: "#22a13f", text: "待發布" }) case "published": - return getStatusTag({ color: "#f5a83d", text: "已發布" }) + 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 }) } @@ -61,9 +65,11 @@ export function getStatusEng(params) { case "paid": return getStatusTag({ color: "#22a13f", text: "To be published" }) case "published": - return getStatusTag({ color: "#f5a83d", text: "Published" }) + return getStatusTag({ color: "#f5a83d", text: "Pending Payment" }) case "withdrawn": return getStatusTag({ color: "#8a8784", text: "Withdrawn" }) + case "completed": + return getStatusTag({ color: "#8a8784", text: "Completed" }) default: return getStatusTag({ text: params.row.status }) } @@ -83,9 +89,11 @@ export function getStatusByTextEng(status) { case "paid": return getStatusTag({ color: "#22a13f", text: "To Be Published" }) case "published": - return getStatusTag({ color: "#f5a83d", text: "Published" }) + return getStatusTag({ color: "#f5a83d", text: "Pending Payment" }) case "withdrawn": return getStatusTag({ color: "#8a8784", text: "Withdrawn" }) + case "completed": + return getStatusTag({ color: "#8a8784", text: "Completed" }) default: return getStatusTag({ text: params.row.status }) } diff --git a/src/pages/PublicNoticeDetail_GLD/ApplicationDetailCard.js b/src/pages/PublicNoticeDetail_GLD/ApplicationDetailCard.js index 42ddc30..312c6d6 100644 --- a/src/pages/PublicNoticeDetail_GLD/ApplicationDetailCard.js +++ b/src/pages/PublicNoticeDetail_GLD/ApplicationDetailCard.js @@ -22,6 +22,7 @@ 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 ApiPathConst from "utils/ApiPathConst" import * as StatusUtils from "../PublicNotice/ListPanel/PublicNoteStatusUtils"; import BorderColorOutlinedIcon from '@mui/icons-material/BorderColorOutlined'; @@ -29,9 +30,15 @@ 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'; +// import { Params } from '../../../node_modules/react-router-dom/dist/index'; +// import {useNavigate} from "react-router-dom"; +// import axios from "axios"; + + // ==============================|| DASHBOARD - DEFAULT ||============================== // const ApplicationDetailCard = ( { applicationDetailData, + setStatus, // isCollectData, // updateUserObject, // isNewRecord @@ -43,6 +50,9 @@ const ApplicationDetailCard = ( const [verified, setVerified] = useState(null); const [fileDetail, setfileDetail] = useState({}); const [onReady,setOnReady] = useState(false); + // const navigate = useNavigate() + // const params = useParams(); + const {register, // getValues } = useForm() @@ -74,21 +84,21 @@ const ApplicationDetailCard = ( }); }; - // const onStatusClick = () => () => { - // if(params.id > 0 ){ - // axios.post(`${GET_PUBLIC_NOTICE_APPLY_DETAIL}/${params.id}`) - // .then((response) => { - // if (response.status === 200) { - // navigate(`/application/${params.id}`); - // } - // }) - // .catch(error => { - // console.log(error); - // return false; - // }); - // } - // }; + const acceptedClick = () => () =>{ + setStatus("accepted") + }; + + const rejectedClick = () => () =>{ + setStatus("reject") + }; + + const complatedClick = () => () =>{ + setStatus("complete") + }; + const withdrawnClick = () => () =>{ + setStatus("withdraw") + }; return ( !onReady ? @@ -100,7 +110,7 @@ const ApplicationDetailCard = ( > {verified? - + - + :null } - + Application Details
diff --git a/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js b/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js new file mode 100644 index 0000000..e9b4263 --- /dev/null +++ b/src/pages/PublicNoticeDetail_GLD/StatusChangeDialog.js @@ -0,0 +1,148 @@ +import { + useEffect, + // useState + } from "react"; + +// material-ui +import { + Button, + // Link, + Stack, + Typography, + Dialog, + DialogActions, + DialogContent, + DialogContentText, + DialogTitle, + FormLabel, + Autocomplete, + TextField +} from '@mui/material'; +import { Grid } from "../../../node_modules/@mui/material/index"; +import * as ComboData from "utils/ComboData"; +import { useFormik,FormikProvider } from 'formik'; +import * as yup from 'yup'; + + +const StatusChangeDialog = (props) => { + // const [selectedGazetteGroup, setSelectedGazetteGroup] = useState({}); + // const [selectedGazetteGroupInputType, setSelectedGazetteGroupInputType] = useState(""); + const groupTitleComboList = ComboData.groupTitle; + + useEffect(() => { + if(props.getStatus == "accepted"){ + onAcceptedClick() + }else if (props.getStatus == "reject"){ + onRejectedClick() + }else if (props.getStatus == "complete"){ + onComplatedClick() + }else if (props.getStatus == "withdraw"){ + onWithdrawnClick() + } + }, [props.getStatus]); + + const acceptedHandle = () => () =>{ + // console.log(selectedGazetteGroup) + props.setStatusWindowAccepted(true) + }; + + + const formik = useFormik({ + initialValues:({ + username:'', + }), + validationSchema:yup.object().shape({ + }), + }); + + // const handleReset = () => { + // setSelectedGazetteGroupInputType("") + // selectedGazetteGroup({}); + // }; + + return ( + + + + + + + Accept Application + + + + + + + + + + + + + + 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("checkDigit","") + }else{ + props.setSelectedGazetteGroupInputType(""); + } + }} + // sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} + renderInput={(params) => } + /> + + + + + + + + + + + + + + + + +
+ ); +}; + +export default StatusChangeDialog; diff --git a/src/pages/PublicNoticeDetail_GLD/index.js b/src/pages/PublicNoticeDetail_GLD/index.js index f847946..3568d31 100644 --- a/src/pages/PublicNoticeDetail_GLD/index.js +++ b/src/pages/PublicNoticeDetail_GLD/index.js @@ -25,20 +25,31 @@ const ClientDetailCard = Loadable(lazy(() => import('./ClientDetailCard'))); const TabTableDetail = Loadable(lazy(() => import('./tabTableDetail/TabTable'))); import { GET_PUBLIC_NOTICE_APPLY_DETAIL, + SET_PUBLIC_NOTICE_STATUS_ACCEPTED } from "utils/ApiPathConst"; +const StatusChangeDialog = Loadable(lazy(() => import('./StatusChangeDialog'))); +import * as DateUtils from "utils/DateUtils"; // ==============================|| Body - DEFAULT ||============================== // -const DashboardDefault = () => { +const PublicNoticeDetail_GLD = () => { const params = useParams(); + // const navigate = useNavigate() const [applicationDetailData, setApplicationDetailData] = useState({}); // const [refApplicationDetailData, setRefApplicationDetailData] = React.useState({}); const [appNo, setAapNo] = useState(""); const [gazetteIssue, setGazetteIssue] = useState(""); + const [issueDate,setIssueDate] = useState(""); + const [issueNum,setIssueNum] = useState(""); const [groupNo, setGroupNo] = useState(""); const [groupTitle, setGroupTitle] = useState(""); - + const [open, setOpen] = useState(false); + const [getStatus, setStatus] = useState(""); + const [statusWindowAccepted, setStatusWindowAccepted] = useState(false); + const [selectedGazetteGroup, setSelectedGazetteGroup] = useState({}); + const [selectedGazetteGroupInputType, setSelectedGazetteGroupInputType] = useState(""); + const BackgroundHead = { backgroundImage: `url(${titleBackgroundImg})`, width: '100%', @@ -49,29 +60,142 @@ const DashboardDefault = () => { const title = groupNo!=""?("Application / "+appNo+", "+gazetteIssue+", "+groupNo+" , "+groupTitle):("Application / "+appNo+", "+gazetteIssue) useEffect(() => { + loadApplicationDetail() + }, []); + + const loadApplicationDetail = () => { 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; - // setRefApplicationDetailData(response.data); - setAapNo(response.data.data.appNo); - setGazetteIssue(gazetteIssueDetail.year +" Vol "+gazetteIssueDetail.volume); + 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)")); + if (gazetteIssueDetail.data!==null&&gazetteIssueDetail.data!==undefined){ setGroupNo("No. "+gazetteIssueDetail.data.groupNo); setGroupTitle("No. "+gazetteIssueDetail.data.groupTitle); - } - }) - .catch(error => { - console.log(error); - return false; - }); + } + }) + .catch(error => { + console.log(error); + return false; + }); } - }, []); + } + + useEffect(() => { + // console.log(getStatus) + if(getStatus!==""){ + setOpen(true) + } + }, [getStatus]); + + const handleClose = () => { + handleReset() + setOpen(false); + setStatus("") + setStatusWindowAccepted(false) + }; + + const handleReset = () => { + setSelectedGazetteGroupInputType("") + setSelectedGazetteGroup({}); + }; + + useEffect(() => { + if(statusWindowAccepted){ + console.log(selectedGazetteGroup) + if(getStatus == "accepted"){ + onAcceptedClick() + }else if (getStatus== "reject"){ + onRejectedClick() + }else if (getStatus == "complete"){ + onComplatedClick() + }else if (getStatus == "withdraw"){ + onWithdrawnClick() + } + } + }, [statusWindowAccepted]); + + const onAcceptedClick = () => { + if(params.id > 0 ){ + axios.get(`${SET_PUBLIC_NOTICE_STATUS_ACCEPTED}/${params.id}`) + .then((response) => { + if (response.status === 204) { + setOpen(false); + handleClose(); + loadApplicationDetail() + } + }) + .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(); + loadApplicationDetail() + } + }) + .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(); + loadApplicationDetail() + } + }) + .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(); + loadApplicationDetail() + } + }) + .catch(error => { + console.log(error); + return false; + }); + } + }; return ( +
@@ -88,17 +212,18 @@ const DashboardDefault = () => { - + - + { /> - + @@ -117,8 +242,8 @@ const DashboardDefault = () => { - - + + { - - + ); }; -export default DashboardDefault; +export default PublicNoticeDetail_GLD; diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 304337d..c53edbd 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -58,6 +58,11 @@ export const POST_PUBLIC_NOTICE_APPLY = apiPath+'/application/apply'; 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_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'; //User Group export const POST_AND_UPDATE_USER_GROUP = apiPath+'/group/save'; \ No newline at end of file