Explorar el Código

update ui

master
Anna Ho hace 1 año
padre
commit
14563ed118
Se han modificado 2 ficheros con 33 adiciones y 26 borrados
  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 Ver fichero

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

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

// ==============================|| 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 navigate=useNavigate();

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

const formik = useFormik({
enableReinitialize:true,
@@ -72,23 +70,6 @@ const PublicNoticeApplyForm = ({loadedData}) => {
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 (
<Grid container style={{ padding: 24}} rowSpacing={16} columnSpacing={2.75}>
@@ -140,7 +121,7 @@ const PublicNoticeApplyForm = ({loadedData}) => {
defaultValue={formik.values.issueId}
>
{
getIssueSelection()
selections
}
</RadioGroup>
</Grid>


+ 26
- 0
src/pages/PublicNotice/ApplyForm/index.js Ver fichero

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

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

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

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

React.useEffect(()=>{
@@ -29,11 +36,29 @@ const ApplyForm = () => {
response["fax_countryCode"] = response?.contactFaxNo?.countryCode;
response["faxNumber"] = response?.contactFaxNo?.faxNumber;
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);
}
});
};

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


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


Cargando…
Cancelar
Guardar