Skip to content

Commit

Permalink
fix(individual-project): download orhophoto
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujit committed Oct 4, 2024
1 parent ce96f10 commit 55c86d2
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import DataTable from '@Components/common/DataTable';
import Icon from '@Components/common/Icon';
import { useTypedSelector } from '@Store/hooks';
import { useMemo } from 'react';
import { toast } from 'react-toastify';

const contributionsDataColumns = [
{
Expand All @@ -15,6 +17,41 @@ const contributionsDataColumns = [
header: 'Task Status',
accessorKey: 'task_state',
},
{ header: 'Image count', accessorKey: 'image_count' },

{
header: 'Orthophoto',
accessorKey: 'assets_url',
cell: ({ row }: any) => {
const handleDownloadResult = () => {
const { original: rowData } = row;
if (!rowData?.assets_url) return;
try {
const link = document.createElement('a');
link.href = rowData?.assets_url;
link.download = 'assets.zip';
document.body.appendChild(link);
link.click();
link.remove();
} catch (error) {
toast.error(`There wan an error while downloading file ${error}`);
}
};

return (
<div
className="naxatw-group naxatw-flex naxatw-cursor-pointer naxatw-items-center naxatw-gap-1 naxatw-text-center naxatw-font-semibold naxatw-text-red"
tabIndex={0}
role="button"
onKeyDown={() => {}}
onClick={() => handleDownloadResult()}
>
<div className="group-hover:naxatw-underline">Download</div>
<Icon className="!naxatw-text-icon-sm" name="download" />
</div>
);
},
},
];

export default function TableSection() {
Expand All @@ -30,6 +67,8 @@ export default function TableSection() {
user: curr?.name || '-',
task_mapped: `Task# ${curr?.project_task_index}`,
task_state: curr?.state,
assets_url: curr?.assets_url,
image_count: curr?.image_count,
},
];
}, []);
Expand Down

0 comments on commit 55c86d2

Please sign in to comment.