import { SyncOutlined } from "@ant-design/icons"; import { Button, Card, Form, Input, Table } from "antd"; import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; import { pageLimit } from "../../utils/config"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop }); const mapDispatchToProps = (dispatch) => ({ //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect(mapStateToProps, mapDispatchToProps)(DmsAllocationsSummaryAp); export function DmsAllocationsSummaryAp({ socket, bodyshop, billids, title }) { const { t } = useTranslation(); const [allocationsSummary, setAllocationsSummary] = useState([]); useEffect(() => { socket.on("ap-export-success", (billid) => { setAllocationsSummary((allocationsSummary) => allocationsSummary.map((a) => { if (a.billid !== billid) return a; return { ...a, status: "Successful" }; }) ); }); socket.on("ap-export-failure", ({ billid, error }) => { allocationsSummary.map((a) => { if (a.billid !== billid) return a; return { ...a, status: error }; }); }); if (socket.disconnected) socket.connect(); return () => { socket.removeListener("ap-export-success"); socket.removeListener("ap-export-failure"); //socket.disconnect(); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { if (socket.connected) { socket.emit("pbs-calculate-allocations-ap", billids, (ack) => { setAllocationsSummary(ack); socket.allocationsSummary = ack; }); } }, [socket, socket.connected, billids]); console.log(allocationsSummary); const columns = [ { title: t("general.labels.status"), dataIndex: "status", key: "status" }, { title: t("bills.fields.invoice_number"), dataIndex: ["Posting", "Reference"], key: "reference" }, { title: t("jobs.fields.dms.lines"), dataIndex: "Lines", key: "Lines", render: (text, record) => ( {record.Posting.Lines.map((l, idx) => ( ))}
{t("bills.fields.invoice_number")} {t("bodyshop.fields.dms.dms_acctnumber")} {t("jobs.fields.dms.amount")}
{l.InvoiceNumber} {l.Account} {l.Amount}
) } ]; const handleFinish = async (values) => { socket.emit(`pbs-export-ap`, { billids, txEnvelope: values }); }; return ( { socket.emit("pbs-calculate-allocations-ap", billids, (ack) => setAllocationsSummary(ack)); }} > } > `${record.InvoiceNumber}${record.Account}`} dataSource={allocationsSummary} locale={{ emptyText: t("dms.labels.refreshallocations") }} /> ); }