table fixes, download template, delete points See merge request spatial/postamates_frontend!37dev
commit
67e214c772
@ -0,0 +1,72 @@
|
|||||||
|
import { useMode } from "../../../stores/useMode.js";
|
||||||
|
import React, { useMemo } from "react";
|
||||||
|
import { Button } from "antd";
|
||||||
|
import { BiTrash } from "react-icons/all.js";
|
||||||
|
import { deletePoint } from "../../../api.js";
|
||||||
|
|
||||||
|
const MATCHING_STATUS = {
|
||||||
|
New: {
|
||||||
|
name: 'Новая',
|
||||||
|
color: 'import_status_new'
|
||||||
|
},
|
||||||
|
Error: {
|
||||||
|
name: 'Ошибка',
|
||||||
|
color: 'import_status_error'
|
||||||
|
},
|
||||||
|
Matched: {
|
||||||
|
name: 'Совпадение',
|
||||||
|
color: 'import_status_matched'
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export const usePendingTableFields = () => {
|
||||||
|
const { isImportMode } = useMode();
|
||||||
|
const deleteRow = async (e, id) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
try {
|
||||||
|
await deletePoint(id);
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fields = useMemo(() => {
|
||||||
|
return isImportMode ? [
|
||||||
|
{
|
||||||
|
title: "Статус импорта",
|
||||||
|
dataIndex: "matching_status",
|
||||||
|
key: "matching_status",
|
||||||
|
width: "120px",
|
||||||
|
ellipsis: true,
|
||||||
|
sorter: true,
|
||||||
|
showSorterTooltip: false,
|
||||||
|
render: (_, record) => {
|
||||||
|
if (!record.matching_status) return;
|
||||||
|
const name = MATCHING_STATUS[record.matching_status].name;
|
||||||
|
const color = MATCHING_STATUS[record.matching_status].color;
|
||||||
|
return (
|
||||||
|
<div className={`bg-opacity-25 rounded-md px-2 py-1 text-center border-solid border-[2px] ${color}`}>
|
||||||
|
{name}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Удалить",
|
||||||
|
key: "del",
|
||||||
|
width: "60px",
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
if (!record.id) return;
|
||||||
|
return (
|
||||||
|
<Button type="text" onClick={(event) => deleteRow(event, record.id)}>
|
||||||
|
<BiTrash />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
] : [];
|
||||||
|
}, [isImportMode]);
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
Loading…
Reference in new issue