From 85caf828ea835d916745b04dfe845101139b0f0f Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 3 Aug 2022 13:27:45 -0700 Subject: [PATCH] IO-2008 Split local media into images and other as per cloudinary for better other support. --- ...jobs-documents-local-gallery.container.jsx | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx b/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx index f58c8025c..5b8722d3d 100644 --- a/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx +++ b/client/src/components/jobs-documents-local-gallery/jobs-documents-local-gallery.container.jsx @@ -1,4 +1,4 @@ -import { SyncOutlined } from "@ant-design/icons"; +import { SyncOutlined, FileExcelFilled } from "@ant-design/icons"; import { Button, Card, Space } from "antd"; import React, { useEffect } from "react"; import Gallery from "react-grid-gallery"; @@ -58,6 +58,24 @@ export function JobsDocumentsLocalGallery({ } }, [job, invoice_number, getJobMedia, getBillMedia]); + const jobMedia = + allMedia && allMedia[job.id] + ? allMedia[job.id].reduce( + (acc, val) => { + if ( + val.type && + val.type.mime && + val.type.mime.startsWith("image") + ) { + acc.images.push(val); + } else { + acc.other.push(val); + } + return acc; + }, + { images: [], other: [] } + ) + : { images: [], other: [] }; return (