Skip to content

Commit

Permalink
[MDS-6148] Fixed invalid date / missing create_user in spatial file b…
Browse files Browse the repository at this point in the history
…undle upload table (#3231)

MDS-6148 Fixed invalid date / missing create_user in spatial file bundle upload table
  • Loading branch information
simensma-fresh authored Aug 29, 2024
1 parent cf3e847 commit 5114e6d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const AddSpatialDocumentsModal: FC<AddSpatialDocumentsModalProps> = ({
onRemoveFile={handleRemoveFile}
component={RenderFileUpload}
maxFileSize="400MB"
label="Upload shapefiles"
label="Upload Spatial File"
abbrevLabel
listedFileTypes={["spatial"]}
required
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { GenericDocTableProps } from "@mds/common/interfaces/document/documentTableProps.interface";
import CoreTable from "../../common/CoreTable";
import { uploadDateColumn, uploadedByColumn } from "../DocumentColumns";
Expand All @@ -16,6 +16,8 @@ import { groupSpatialBundles } from "@mds/common/redux/slices/spatialDataSlice";
import { downloadFileFromDocumentManager } from "@mds/common/redux/utils/actionlessNetworkCalls";
import { ISpatialBundle } from "@mds/common/interfaces/document/spatialBundle.interface";
import { IMineDocument } from "@mds/common/interfaces";
import { getFormattedUserName } from "@mds/common/redux/selectors/authenticationSelectors";
import moment from "moment";

interface SpatialDocumentTableProps extends GenericDocTableProps<ISpatialBundle> {
documents: IMineDocument[];
Expand All @@ -26,9 +28,24 @@ const SpatialDocumentTable: FC<SpatialDocumentTableProps> = ({ documents, catego
const dispatch = useDispatch();
const [isCompressionModalVisible, setIsCompressionModalVisible] = useState(false);
const [spatialBundles, setSpatialBundles] = useState([]);
const username = useSelector(getFormattedUserName);

const handleGetSpatialBundles = async () => {
const newSpatialBundles = groupSpatialBundles(documents);
// Provide default upload_date / create_user for new documents so they don't show
// up as emtpy columns in the table
const docs = documents.map((doc) => {
if (doc.mine_document_guid) {
return doc;
}

return {
...doc,
upload_date: doc.upload_date ?? moment().toISOString(),
create_user: doc.create_user ?? username,
};
});

const newSpatialBundles = groupSpatialBundles(docs);
setSpatialBundles(newSpatialBundles);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ exports[`AddSpatialDocumentsModal renders properly 1`] = `
title=""
>
<span>
Upload shapefiles
Upload Spatial File
<span>
<span
Expand Down

0 comments on commit 5114e6d

Please sign in to comment.