@@ -1,126 +0,0 @@ | |||||
// material-ui | |||||
import { | |||||
Grid, | |||||
Dialog, DialogTitle, DialogContent, DialogActions, | |||||
Typography, | |||||
Button, | |||||
Stack, | |||||
TextField | |||||
} from '@mui/material'; | |||||
import { useFormik } from 'formik'; | |||||
import * as React from "react"; | |||||
import * as yup from 'yup'; | |||||
import * as HttpUtils from "utils/HttpUtils"; | |||||
import {apiPath} from "auth/utils"; | |||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | |||||
const Mail = () => { | |||||
const [isResponsPopUp, setIsResponsPopUp] = React.useState(false); | |||||
const [responsText, setResponsText] = React.useState(""); | |||||
function getMaxErrStr(num, fieldname){ | |||||
return intl.formatMessage({ id: 'noMoreThenNWords' },{num:num, fieldname:fieldname?intl.formatMessage({ id: fieldname})+": ":""}); | |||||
} | |||||
const formik = useFormik({ | |||||
enableReinitialize:true, | |||||
initialValues:{email:""}, | |||||
validationSchema:yup.object().shape({ | |||||
email: yup.string().max(128, getMaxErrStr(128)).required(intl.formatMessage({id: 'require'}) + 'e-Mail') | |||||
}), | |||||
onSubmit:values=>{ | |||||
console.log(values); | |||||
HttpUtils.post({ | |||||
url: apiPath+"/test/send-mail", | |||||
params: { | |||||
email: values.email, | |||||
}, | |||||
onSuccess: function(){ | |||||
setResponsText("Success"); | |||||
setIsResponsPopUp(true); | |||||
}, | |||||
onFail:(response)=>{ | |||||
setResponsText("Fail: "+response); | |||||
setIsResponsPopUp(true); | |||||
}, | |||||
onError:(error)=>{ | |||||
setResponsText("Error: "+error); | |||||
setIsResponsPopUp(true); | |||||
} | |||||
}); | |||||
} | |||||
}); | |||||
return ( | |||||
!JSON.parse(localStorage.getItem('userData')).fullenName=="2fi" ? | |||||
<Grid container > | |||||
<Typography variant="h1">Ooops! Seem go wrong page...</Typography> | |||||
</Grid> | |||||
: | |||||
<Grid container spacing={1}> | |||||
<Grid item xs={12}> | |||||
<Typography variant="h3" style={{ padding: 8}}>Test Send e-Mail</Typography> | |||||
</Grid> | |||||
{/*col 2*/} | |||||
<form onSubmit={formik.handleSubmit} style={{width:'100%', padding: 64}}> | |||||
<Grid item xs={12} mt={1} > | |||||
<Stack direction="row" justifyContent="flex-end" alignItems="center"> | |||||
<TextField | |||||
fullWidth | |||||
id="email" | |||||
name="email" | |||||
type="email" | |||||
placeholder="email" | |||||
label="eMail" | |||||
onChange={formik.handleChange} | |||||
/> | |||||
</Stack> | |||||
</Grid> | |||||
<Button | |||||
variant="contained" | |||||
type="submit" | |||||
sx={{ | |||||
textTransform: 'capitalize', | |||||
alignItems: 'end', | |||||
width: 200 | |||||
}}> | |||||
Test Send e-Mail | |||||
</Button> | |||||
</form> | |||||
<div> | |||||
<Dialog | |||||
open={isResponsPopUp} | |||||
onClose={() => setIsResponsPopUp(false)} | |||||
PaperProps={{ | |||||
sx: { | |||||
minWidth: '40vw', | |||||
maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, | |||||
maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } | |||||
} | |||||
}} | |||||
> | |||||
<DialogTitle>Respons</DialogTitle> | |||||
<DialogContent style={{ display: 'flex', }}> | |||||
<Typography variant="h3" style={{ padding: '16px' }}>{responsText}</Typography> | |||||
</DialogContent> | |||||
<DialogActions> | |||||
<Button onClick={() => setIsResponsPopUp(false)}>OK</Button> | |||||
</DialogActions> | |||||
</Dialog> | |||||
</div> | |||||
</Grid> | |||||
); | |||||
}; | |||||
export default Mail; |
@@ -0,0 +1,162 @@ | |||||
// material-ui | |||||
import { | |||||
Grid, | |||||
Dialog, DialogTitle, DialogContent, DialogActions, | |||||
Typography, | |||||
Button, | |||||
Stack, | |||||
TextField | |||||
} from '@mui/material'; | |||||
import { useFormik } from 'formik'; | |||||
import * as React from "react"; | |||||
import * as yup from 'yup'; | |||||
import * as HttpUtils from "utils/HttpUtils"; | |||||
import { apiPath } from "auth/utils"; | |||||
import { useIntl } from "react-intl"; | |||||
// ==============================|| DASHBOARD - DEFAULT ||============================== // | |||||
const Mail = () => { | |||||
const [isResponsPopUp, setIsResponsPopUp] = React.useState(false); | |||||
const [responsText, setResponsText] = React.useState(""); | |||||
const intl = useIntl(); | |||||
function getMaxErrStr(num, fieldname) { | |||||
return intl.formatMessage({ id: 'noMoreThenNWords' }, { num: num, fieldname: fieldname ? intl.formatMessage({ id: fieldname }) + ": " : "" }); | |||||
} | |||||
const formik = useFormik({ | |||||
enableReinitialize: true, | |||||
initialValues: { email: "" }, | |||||
validationSchema: yup.object().shape({ | |||||
email: yup.string().max(128, getMaxErrStr(128)).required(intl.formatMessage({ id: 'require' }) + 'e-Mail') | |||||
}), | |||||
onSubmit: values => { | |||||
console.log(values); | |||||
HttpUtils.post({ | |||||
url: apiPath + "/test/send-mail", | |||||
params: { | |||||
email: values.email, | |||||
}, | |||||
onSuccess: function () { | |||||
setResponsText("Success"); | |||||
setIsResponsPopUp(true); | |||||
}, | |||||
onFail: (response) => { | |||||
setResponsText("Fail: " + response); | |||||
setIsResponsPopUp(true); | |||||
}, | |||||
onError: (error) => { | |||||
setResponsText("Error: " + error); | |||||
setIsResponsPopUp(true); | |||||
} | |||||
}); | |||||
} | |||||
}); | |||||
const setReminderDate=()=>{ | |||||
HttpUtils.get({ | |||||
url: apiPath + "/demandNote/set-expect-reminder", | |||||
onSuccess: function () { | |||||
setResponsText("Success"); | |||||
setIsResponsPopUp(true); | |||||
}, | |||||
onFail: (response) => { | |||||
setResponsText("Fail: " + response); | |||||
setIsResponsPopUp(true); | |||||
}, | |||||
onError: (error) => { | |||||
setResponsText("Error: " + error); | |||||
setIsResponsPopUp(true); | |||||
} | |||||
}); | |||||
} | |||||
return ( | |||||
!JSON.parse(localStorage.getItem('userData')).fullenName == "2fi" ? | |||||
<Grid container > | |||||
<Typography variant="h1">Ooops! Seem go wrong page...</Typography> | |||||
</Grid> | |||||
: | |||||
<Grid container spacing={1} > | |||||
<Grid item xs={12}> | |||||
<Typography variant="h3" style={{ padding: 8 }}>Test View</Typography> | |||||
</Grid> | |||||
{/*col 2*/} | |||||
<form onSubmit={formik.handleSubmit} style={{ width: '100%', paddingLeft: 64 , paddingBottom: 60}}> | |||||
<Grid item xs={12} mt={1} > | |||||
<Typography variant="h4" style={{ padding: 8 }}>Test Send Mail</Typography> | |||||
<Stack direction="row" justifyContent="flex-end" alignItems="center"> | |||||
<TextField | |||||
fullWidth | |||||
id="email" | |||||
name="email" | |||||
type="email" | |||||
placeholder="email" | |||||
label="eMail" | |||||
onChange={formik.handleChange} | |||||
/> | |||||
</Stack> | |||||
</Grid> | |||||
<Button | |||||
variant="contained" | |||||
type="submit" | |||||
sx={{ | |||||
textTransform: 'capitalize', | |||||
alignItems: 'end', | |||||
width: 200 | |||||
}}> | |||||
Send | |||||
</Button> | |||||
</form> | |||||
<Grid item xs={12} mt={1} style={{ width: '100%', paddingLeft: 64, paddingBottom: 60 }}> | |||||
<Typography variant="h4" style={{ padding: 8 }}>Set DN Reminder Expect send Date</Typography> | |||||
<Button | |||||
variant="contained" | |||||
onClick={()=>{ | |||||
setReminderDate(); | |||||
}} | |||||
sx={{ | |||||
textTransform: 'capitalize', | |||||
alignItems: 'end', | |||||
width: 200 | |||||
}}> | |||||
Set Expect Date | |||||
</Button> | |||||
</Grid> | |||||
<div> | |||||
<Dialog | |||||
open={isResponsPopUp} | |||||
onClose={() => setIsResponsPopUp(false)} | |||||
PaperProps={{ | |||||
sx: { | |||||
minWidth: '40vw', | |||||
maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' }, | |||||
maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' } | |||||
} | |||||
}} | |||||
> | |||||
<DialogTitle>Respons</DialogTitle> | |||||
<DialogContent style={{ display: 'flex', }}> | |||||
<Typography variant="h3" style={{ padding: '16px' }}>{responsText}</Typography> | |||||
</DialogContent> | |||||
<DialogActions> | |||||
<Button onClick={() => setIsResponsPopUp(false)}>OK</Button> | |||||
</DialogActions> | |||||
</Dialog> | |||||
</div> | |||||
</Grid> | |||||
); | |||||
}; | |||||
export default Mail; |
@@ -3,7 +3,7 @@ import Loadable from 'components/Loadable'; | |||||
const MainLayout = Loadable(lazy(() => import('layout/MainLayout'))); | const MainLayout = Loadable(lazy(() => import('layout/MainLayout'))); | ||||
// render - dashboard | // render - dashboard | ||||
const TestMail = Loadable(lazy(() => import('pages/_Test/Mail'))); | |||||
const TestView = Loadable(lazy(() => import('pages/_Test'))); | |||||
// ==============================|| MAIN ROUTING ||============================== // | // ==============================|| MAIN ROUTING ||============================== // | ||||
const TestRoutes = { | const TestRoutes = { | ||||
@@ -11,8 +11,8 @@ const TestRoutes = { | |||||
element: <MainLayout />, | element: <MainLayout />, | ||||
children: [ | children: [ | ||||
{ | { | ||||
path: 'test/sendMail', | |||||
element: <TestMail/> | |||||
path: 'test', | |||||
element: <TestView/> | |||||
}, | }, | ||||
] | ] | ||||
}; | }; | ||||