date fix for null dates

This commit is contained in:
2021-07-28 10:47:51 +01:00
parent a1c21fd369
commit a0f777e6cb
7 changed files with 60 additions and 34 deletions
+25 -5
View File
@@ -34,6 +34,21 @@ let BuildCheckRow = (props) => {
doc
);
function formatDate(dateObj) {
var m = new Date(dateObj);
var dateString;
dateObj != null
? (dateString =
("0" + m.getDate()).slice(-2) +
"/" +
("0" + (m.getMonth() + 1)).slice(-2) +
"/" +
m.getFullYear())
: (dateString = "");
return dateString;
}
return (
<>
{Object.keys(rowXML).map((key, index) => {
@@ -51,11 +66,16 @@ let BuildCheckRow = (props) => {
{rows[0].value}
</dt>
<dd className="govuk-summary-list__value">
{
props.props.form["appealForm"].values[
datafieldname[0].value
]
}
{fieldtype[0].value ==
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}"
? formatDate(
props.props.form["appealForm"].values[
datafieldname[0].value
]
)
: props.props.form["appealForm"].values[
datafieldname[0].value
]}
</dd>
<dd className="govuk-summary-list__actions">
<a