Browse Source

update ui

master
Anna Ho 1 year ago
parent
commit
14563ed118
2 changed files with 33 additions and 26 deletions
  1. +7
    -26
      src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js
  2. +26
    -0
      src/pages/PublicNotice/ApplyForm/index.js

+ 7
- 26
src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js View File

@@ -3,9 +3,7 @@ import {
Grid, Grid,
Typography, Typography,
Button, Button,
Radio,
RadioGroup, RadioGroup,
FormControlLabel
} from '@mui/material'; } from '@mui/material';
import { useFormik } from 'formik'; import { useFormik } from 'formik';
import * as yup from 'yup'; import * as yup from 'yup';
@@ -13,20 +11,20 @@ import * as React from "react";
import * as HttpUtils from "utils/HttpUtils"; import * as HttpUtils from "utils/HttpUtils";
import * as UrlUtils from "utils/ApiPathConst"; import * as UrlUtils from "utils/ApiPathConst";
import * as FieldUtils from "utils/FieldUtils"; import * as FieldUtils from "utils/FieldUtils";
import * as DateUtils from "utils/DateUtils";


import {useNavigate} from "react-router-dom"; import {useNavigate} from "react-router-dom";


// ==============================|| DASHBOARD - DEFAULT ||============================== // // ==============================|| DASHBOARD - DEFAULT ||============================== //


const PublicNoticeApplyForm = ({loadedData}) => {
const [formData, setFormData] = React.useState([]);
const PublicNoticeApplyForm = ({loadedData, selections}) => {
//const [formData, setFormData] = React.useState([]);
const [attachment, setAttachment] = React.useState({}); const [attachment, setAttachment] = React.useState({});
const navigate=useNavigate(); const navigate=useNavigate();


React.useEffect(()=>{
setFormData(loadedData);
},[]);
// React.useEffect(()=>{
// setFormData(loadedData);
// },[]);


const formik = useFormik({ const formik = useFormik({
enableReinitialize:true, enableReinitialize:true,
@@ -72,23 +70,6 @@ const PublicNoticeApplyForm = ({loadedData}) => {
setAttachment(event.target.files[0]); setAttachment(event.target.files[0]);
} }


const getIssueSelection=()=>{
var selection = [];
for (var i = 0; i < formData?.gazetteIssueList?.length; i++) {
let data = formData.gazetteIssueList[i];
let label = data.year
+" Vol. "+zeroPad(data.volume,3)
+", No. "+zeroPad(data.issueNo,2)
+", "+DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)");
selection.push(<FormControlLabel value={data.id} control={<Radio />} label={label} />);
}
return selection;
}

function zeroPad(num, places) {
var zero = places - num.toString().length + 1;
return Array(+(zero > 0 && zero)).join("0") + num;
}


return ( return (
<Grid container style={{ padding: 24}} rowSpacing={16} columnSpacing={2.75}> <Grid container style={{ padding: 24}} rowSpacing={16} columnSpacing={2.75}>
@@ -140,7 +121,7 @@ const PublicNoticeApplyForm = ({loadedData}) => {
defaultValue={formik.values.issueId} defaultValue={formik.values.issueId}
> >
{ {
getIssueSelection()
selections
} }
</RadioGroup> </RadioGroup>
</Grid> </Grid>


+ 26
- 0
src/pages/PublicNotice/ApplyForm/index.js View File

@@ -2,6 +2,12 @@
import * as React from "react"; import * as React from "react";
import * as HttpUtils from "utils/HttpUtils"; import * as HttpUtils from "utils/HttpUtils";
import * as UrlUtils from "utils/ApiPathConst"; import * as UrlUtils from "utils/ApiPathConst";
import * as DateUtils from "utils/DateUtils";

import {
Radio,
FormControlLabel
} from '@mui/material';


import Loadable from 'components/Loadable'; import Loadable from 'components/Loadable';
import { lazy } from 'react'; import { lazy } from 'react';
@@ -13,6 +19,7 @@ const PublicNoticeApplyForm = Loadable(lazy(() => import('./PublicNoticeApplyFor


const ApplyForm = () => { const ApplyForm = () => {
const [userData, setUserData] = React.useState([]); const [userData, setUserData] = React.useState([]);
const [selections, setSelection] = React.useState([]);
const [isLoading, setLoding] = React.useState(true); const [isLoading, setLoding] = React.useState(true);


React.useEffect(()=>{ React.useEffect(()=>{
@@ -29,11 +36,29 @@ const ApplyForm = () => {
response["fax_countryCode"] = response?.contactFaxNo?.countryCode; response["fax_countryCode"] = response?.contactFaxNo?.countryCode;
response["faxNumber"] = response?.contactFaxNo?.faxNumber; response["faxNumber"] = response?.contactFaxNo?.faxNumber;
response["issueId"] = response?.gazetteIssueList[0].id; response["issueId"] = response?.gazetteIssueList[0].id;

var selection = [];
for (var i = 0; i < response?.gazetteIssueList?.length; i++) {
let data = response.gazetteIssueList[i];
let label = data.year
+" Vol. "+zeroPad(data.volume,3)
+", No. "+zeroPad(data.issueNo,2)
+", "+DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)");
selection.push(<FormControlLabel value={data.id} control={<Radio />} label={label} />);
}
setSelection(selection);
setUserData(response); setUserData(response);
} }
}); });
}; };


function zeroPad(num, places) {
var zero = places - num.toString().length + 1;
return Array(+(zero > 0 && zero)).join("0") + num;
}


React.useEffect(() => { React.useEffect(() => {
setLoding(false); setLoding(false);
}, [userData]); }, [userData]);
@@ -44,6 +69,7 @@ const ApplyForm = () => {
: :
<PublicNoticeApplyForm <PublicNoticeApplyForm
loadedData={userData} loadedData={userData}
selections={selections}
/> />
); );
}; };


Loading…
Cancel
Save