Browse Source

disable 15:00 Scheduled, add send mail Button

CR003
Anna Ho 1 year ago
parent
commit
4dca798a3a
2 changed files with 61 additions and 37 deletions
  1. +60
    -37
      src/pages/Organization/DetailPage/OrganizationCard.js
  2. +1
    -0
      src/utils/ApiPathConst.js

+ 60
- 37
src/pages/Organization/DetailPage/OrganizationCard.js View File

@@ -24,11 +24,11 @@ import { PNSPS_BUTTON_THEME } from "themes/buttonConst";
import { ThemeProvider } from "@emotion/react"; import { ThemeProvider } from "@emotion/react";
import { isGrantedAny } from "auth/utils"; import { isGrantedAny } from "auth/utils";


import {DatePicker} from "@mui/x-date-pickers/DatePicker";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import dayjs from "dayjs"; import dayjs from "dayjs";
import {DemoItem} from "@mui/x-date-pickers/internals/demo";
import {LocalizationProvider} from "@mui/x-date-pickers/LocalizationProvider";
import {AdapterDayjs} from "@mui/x-date-pickers/AdapterDayjs";
import { DemoItem } from "@mui/x-date-pickers/internals/demo";
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
// ==============================|| DASHBOARD - DEFAULT ||============================== // // ==============================|| DASHBOARD - DEFAULT ||============================== //
const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => { const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
const intl = useIntl(); const intl = useIntl();
@@ -44,7 +44,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
const [fromDate, setFromDate] = React.useState(null); const [fromDate, setFromDate] = React.useState(null);
const [currentFromDate, setCurrentFromDate] = React.useState(null); const [currentFromDate, setCurrentFromDate] = React.useState(null);
const [fromDateValue, setFromDateValue] = React.useState(null); const [fromDateValue, setFromDateValue] = React.useState(null);
const {register, handleSubmit, reset} = useForm()
const { register, handleSubmit, reset } = useForm()


React.useEffect(() => { React.useEffect(() => {
setFromDateValue(fromDate); setFromDateValue(fromDate);
@@ -55,13 +55,13 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
// console.log(currentApplicationDetailData) // console.log(currentApplicationDetailData)
if (Object.keys(currentUserData).length > 0) { if (Object.keys(currentUserData).length > 0) {
console.log(currentUserData) console.log(currentUserData)
if(DateUtils.dateValue(currentUserData.brExpiryDate)>DateUtils.dateValue(minDate)){
if (DateUtils.dateValue(currentUserData.brExpiryDate) > DateUtils.dateValue(minDate)) {
setFromDate(currentUserData.brExpiryDate); setFromDate(currentUserData.brExpiryDate);
}else{
} else {
setCurrentFromDate(currentUserData.brExpiryDate); setCurrentFromDate(currentUserData.brExpiryDate);
// setErrorMsg("Please select a date after today.") // setErrorMsg("Please select a date after today.")
} }
setOnReady(true); setOnReady(true);
} }
}, [currentUserData]); }, [currentUserData]);
@@ -115,7 +115,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
let sentDateFrom = ""; let sentDateFrom = "";
if (fromDateValue == null) { if (fromDateValue == null) {
setErrorMsg(intl.formatMessage({ id: 'pleaseFillInBusinessRegCertValidityDate' })) setErrorMsg(intl.formatMessage({ id: 'pleaseFillInBusinessRegCertValidityDate' }))
}else{
} else {
sentDateFrom = DateUtils.dateValue(fromDateValue) sentDateFrom = DateUtils.dateValue(fromDateValue)
HttpUtils.post({ HttpUtils.post({
url: UrlUtils.POST_ORG_SAVE_PATH, url: UrlUtils.POST_ORG_SAVE_PATH,
@@ -123,7 +123,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
id: id > 0 ? id : null, id: id > 0 ? id : null,
enCompanyName: values.enCompanyName, enCompanyName: values.enCompanyName,
chCompanyName: values.chCompanyName, chCompanyName: values.chCompanyName,
orgShortName: values.orgShortName==="N/A"?"":values.orgShortName,
orgShortName: values.orgShortName === "N/A" ? "" : values.orgShortName,
brNo: values.brNo, brNo: values.brNo,
// brExpiryDate: values.brExpiryDate, // brExpiryDate: values.brExpiryDate,
brExpiryDate: sentDateFrom, brExpiryDate: sentDateFrom,
@@ -188,9 +188,9 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {


const onSubmit = (data) => { const onSubmit = (data) => {
let sentOrgShortName = ""; let sentOrgShortName = "";
if(data.orgShortName!=null && data.orgShortName!="" && data.orgShortName!="N/A"){
sentOrgShortName = data.orgShortName
if (sentOrgShortName.length <=24){
if (data.orgShortName != null && data.orgShortName != "" && data.orgShortName != "N/A") {
sentOrgShortName = data.orgShortName
if (sentOrgShortName.length <= 24) {
const temp = { const temp = {
orgShortName: sentOrgShortName, orgShortName: sentOrgShortName,
}; };
@@ -230,6 +230,16 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
}); });
} }


const sendDn_terminationOfCredit = () => {
setNonCreditorConfirmPopUp(false);
HttpUtils.get({
url: UrlUtils.GET_SEND_TERMINATION_OF_CREDIT + "/" + id,
onSuccess: () => {
loadDataFun();
}
});
}

return ( return (
<MainCard elevation={0} <MainCard elevation={0}
border={false} border={false}
@@ -311,17 +321,30 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
</ThemeProvider> </ThemeProvider>
</Grid> </Grid>
: :
<Grid item sx={{ ml: 3, mr: 3 }}>
<ThemeProvider theme={PNSPS_BUTTON_THEME}>
<Button
variant="contained"
color="orange"
onClick={() => setCreditorConfirmPopUp(true)}
>
Mark as Credit Client
</Button>
</ThemeProvider>
</Grid>
<>
<Grid item sx={{ ml: 3, mr: 3 }}>
<ThemeProvider theme={PNSPS_BUTTON_THEME}>
<Button
variant="contained"
color="orange"
onClick={() => setCreditorConfirmPopUp(true)}
>
Mark as Credit Client
</Button>
</ThemeProvider>
</Grid>
<Grid item sx={{ ml: 3, mr: 3 }}>
<ThemeProvider theme={PNSPS_BUTTON_THEME}>
<Button
variant="contained"
color="primary"
onClick={() => sendDn_terminationOfCredit(true)}
>
Send &quot;Termination of Credit&quot; Email
</Button>
</ThemeProvider>
</Grid>
</>
} }
</> </>
} }
@@ -396,18 +419,18 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
<Typography variant="pnspsFormParagraphBold">{FieldUtils.notNullFieldLabel("Expiry Date:")}</Typography> <Typography variant="pnspsFormParagraphBold">{FieldUtils.notNullFieldLabel("Expiry Date:")}</Typography>
</Grid> </Grid>
<Grid item xs={12} md={6} lg={6}> <Grid item xs={12} md={6} lg={6}>
{(!editMode && !createMode)?
{(!editMode && !createMode) ?
<TextField <TextField
fullWidth fullWidth
id="currentExDate" id="currentExDate"
// error={(fromDate===null)} // error={(fromDate===null)}
// type="date" // type="date"
name="currentExDate" name="currentExDate"
value={fromDate!=null?DateUtils.dateStr(fromDate):DateUtils.dateStr(currentFromDate)}
value={fromDate != null ? DateUtils.dateStr(fromDate) : DateUtils.dateStr(currentFromDate)}
disabled={true} disabled={true}
/>:
/> :
<LocalizationProvider dateAdapter={AdapterDayjs}> <LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoItem components={['DatePicker']}>
<DemoItem components={['DatePicker']}>
<DatePicker <DatePicker
id="brExpiryDate" id="brExpiryDate"
name="brExpiryDate" name="brExpiryDate"
@@ -426,9 +449,9 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
onChange={(newValue) => { onChange={(newValue) => {
// console.log(newValue) // console.log(newValue)
// setErrorMsg("") // setErrorMsg("")
if(DateUtils.dateValue(newValue)>DateUtils.dateValue(new Date())){
if (DateUtils.dateValue(newValue) > DateUtils.dateValue(new Date())) {
setFromDate(newValue); setFromDate(newValue);
}else{
} else {
// setErrorMsg("Please select a date after today.") // setErrorMsg("Please select a date after today.")
} }
}} }}
@@ -438,19 +461,19 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
} }
</Grid> </Grid>
{ {
fromDate==null?
(!editMode && !createMode)?
fromDate == null ?
(!editMode && !createMode) ?
<FormHelperText error id="helper-text-date"> <FormHelperText error id="helper-text-date">
Please select a date after today. Please select a date after today.
</FormHelperText> </FormHelperText>
:
:
<FormHelperText error id="helper-text-date"> <FormHelperText error id="helper-text-date">
{intl.formatMessage({ id: 'pleaseFillInBusinessRegCertValidityDate' })} {intl.formatMessage({ id: 'pleaseFillInBusinessRegCertValidityDate' })}
</FormHelperText> </FormHelperText>
:
:
null null
}
}
</Grid> </Grid>


</Grid> </Grid>
@@ -566,7 +589,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
{...register("orgShortName")} {...register("orgShortName")}
id='orgShortName' id='orgShortName'
label="Organisation Short Name" label="Organisation Short Name"
defaultValue={currentUserData.orgShortName!="N/A"?currentUserData.orgShortName:""}
defaultValue={currentUserData.orgShortName != "N/A" ? currentUserData.orgShortName : ""}
InputLabelProps={{ InputLabelProps={{
shrink: true shrink: true
}} }}


+ 1
- 0
src/utils/ApiPathConst.js View File

@@ -42,6 +42,7 @@ export const GET_ORG_COMBO = apiPath+'/org/combo';
export const GET_ORG_CHECK_CREDITOR = apiPath+'/org/check-creditor'; export const GET_ORG_CHECK_CREDITOR = apiPath+'/org/check-creditor';
export const GET_ORG_MARK_AS_CREDITOR = apiPath+'/org/mark-as-creditor'; export const GET_ORG_MARK_AS_CREDITOR = apiPath+'/org/mark-as-creditor';
export const GET_ORG_MARK_AS_NON_CREDITOR = apiPath+'/org/mark-as-non-creditor'; export const GET_ORG_MARK_AS_NON_CREDITOR = apiPath+'/org/mark-as-non-creditor';
export const GET_SEND_TERMINATION_OF_CREDIT = apiPath+'/org/sendDn_terminationOfCredit';
export const GET_ORG_EXPORT = apiPath+'/org/export'; export const GET_ORG_EXPORT = apiPath+'/org/export';


//public //public


Loading…
Cancel
Save