Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion idurar-erp-crm/frontend/src/modules/ErpPanelModule/ReadItem.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useState, useEffect } from 'react';
import { Divider } from 'antd';
import { Divider, notification } from 'antd';

import { Button, Row, Col, Descriptions, Statistic, Tag } from 'antd';
import { PageHeader } from '@ant-design/pro-layout';
import {
CopyOutlined,
EditOutlined,
FilePdfOutlined,
CloseCircleOutlined,
Expand Down Expand Up @@ -123,6 +124,23 @@ export default function ReadItem({ config, selectedItem }) {
}
}, [currentErp]);

const publicLink = typeof config.getPublicLink === 'function' ? config.getPublicLink(currentErp) : null;

const handleCopyPublicLink = async () => {
if (!publicLink) return;

try {
await navigator.clipboard.writeText(publicLink);
notification.success({
message: config.copyPublicLinkSuccessMessage || translate('link_copied_successfully'),
});
} catch (error) {
notification.error({
message: translate('failed_to_copy_link'),
});
}
};

return (
<>
<PageHeader
Expand Down Expand Up @@ -161,6 +179,11 @@ export default function ReadItem({ config, selectedItem }) {
>
{translate('Download PDF')}
</Button>,
publicLink && (
<Button key="copy-public-link" onClick={handleCopyPublicLink} icon={<CopyOutlined />}>
{config.copyPublicLinkLabel || translate('Copy link')}
</Button>
),
<Button
key={`${uniqueId()}`}
loading={mailInProgress}
Expand Down
4 changes: 4 additions & 0 deletions idurar-erp-crm/frontend/src/pages/Invoice/InvoiceRead.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BASE_URL } from '@/config/serverApiConfig';
import useLanguage from '@/locale/useLanguage';
import ReadInvoiceModule from '@/modules/InvoiceModule/ReadInvoiceModule';

Expand All @@ -16,6 +17,9 @@ export default function InvoiceRead() {
const configPage = {
entity,
...Labels,
getPublicLink: ({ _id }) => `${BASE_URL}public/download/invoice/invoice-${_id}.pdf`,
copyPublicLinkLabel: translate('copy_invoice_url'),
copyPublicLinkSuccessMessage: translate('invoice_url_copied_successfully'),
};
return <ReadInvoiceModule config={configPage} />;
}