Reviewed-on: Pozomind/pozo-retail-app#302
This commit is contained in:
commit
35543ef3d3
|
|
@ -85,6 +85,7 @@
|
||||||
"@types/react": "^18.3.3",
|
"@types/react": "^18.3.3",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@vitejs/plugin-react": "^6.0.1",
|
"@vitejs/plugin-react": "^6.0.1",
|
||||||
|
"esbuild": "^0.27.4",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-react": "^7.34.2",
|
"eslint-plugin-react": "^7.34.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.2",
|
"eslint-plugin-react-hooks": "^4.6.2",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
// InvoiceDetail.jsx
|
// InvoiceDetail.jsx
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import html2pdf from 'html2pdf.js';
|
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {
|
import {
|
||||||
|
|
@ -47,7 +46,8 @@ import PrintStyle13 from '../BookingScreen/PrintTemplates/ThermalPrinter/PrintSt
|
||||||
import PrintA5Style11 from '../BookingScreen/PrintTemplates/A4/PrintStyleA5';
|
import PrintA5Style11 from '../BookingScreen/PrintTemplates/A4/PrintStyleA5';
|
||||||
import InvoiceTemplate from '../BookingScreen/PrintTemplates/A4/A4Standard';
|
import InvoiceTemplate from '../BookingScreen/PrintTemplates/A4/A4Standard';
|
||||||
import PrintA4Style11 from '../BookingScreen/PrintTemplates/A4/PrintA4Style11';
|
import PrintA4Style11 from '../BookingScreen/PrintTemplates/A4/PrintA4Style11';
|
||||||
|
import html2canvas from "html2canvas";
|
||||||
|
import jsPDF from "jspdf";
|
||||||
const apiUrlToken = import.meta.env.ENV_API_URL_TOKEN;
|
const apiUrlToken = import.meta.env.ENV_API_URL_TOKEN;
|
||||||
|
|
||||||
const LinkUrlCreate = () => {
|
const LinkUrlCreate = () => {
|
||||||
|
|
@ -126,7 +126,7 @@ const commonModulePreference = appPreferences?.find(
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSession = async () => {
|
const addSession = async () => {
|
||||||
if (!sessionStorage.getItem('auth')) {
|
if (!getSession('auth')) {
|
||||||
try {
|
try {
|
||||||
let data = {
|
let data = {
|
||||||
username: '1000000001',
|
username: '1000000001',
|
||||||
|
|
@ -144,7 +144,7 @@ const commonModulePreference = appPreferences?.find(
|
||||||
);
|
);
|
||||||
|
|
||||||
const { token } = response?.data;
|
const { token } = response?.data;
|
||||||
sessionStorage.setItem('auth', token);
|
sessionStore('auth', token);
|
||||||
sessionStore('LoginType', 'Kiosk');
|
sessionStore('LoginType', 'Kiosk');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error adding session:', error);
|
console.error('Error adding session:', error);
|
||||||
|
|
@ -307,21 +307,38 @@ const commonModulePreference = appPreferences?.find(
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
|
||||||
const handleDownloadPDF = () => {
|
// const handleDownloadPDF = () => {
|
||||||
|
// const element = printRef.current;
|
||||||
|
// const options = {
|
||||||
|
// // margin: 0.5,
|
||||||
|
// margin: 0,
|
||||||
|
// filename: "document.pdf",
|
||||||
|
// image: { type: "jpeg", quality: 0.98 },
|
||||||
|
// html2canvas: { scale: 2, useCORS: true }, // makes CSS + images sharper
|
||||||
|
// // jsPDF: { unit: "in", format: "a4", orientation: "portrait" },
|
||||||
|
// jsPDF: { unit: "px", format: [element.offsetWidth, element.offsetHeight] },
|
||||||
|
// };
|
||||||
|
|
||||||
|
// html2pdf().set(options).from(element).save();
|
||||||
|
// };
|
||||||
|
const handleDownloadPDF = async () => {
|
||||||
const element = printRef.current;
|
const element = printRef.current;
|
||||||
const options = {
|
|
||||||
// margin: 0.5,
|
|
||||||
margin: 0,
|
|
||||||
filename: "document.pdf",
|
|
||||||
image: { type: "jpeg", quality: 0.98 },
|
|
||||||
html2canvas: { scale: 2, useCORS: true }, // makes CSS + images sharper
|
|
||||||
// jsPDF: { unit: "in", format: "a4", orientation: "portrait" },
|
|
||||||
jsPDF: { unit: "px", format: [element.offsetWidth, element.offsetHeight] },
|
|
||||||
};
|
|
||||||
|
|
||||||
html2pdf().set(options).from(element).save();
|
const canvas = await html2canvas(element, {
|
||||||
};
|
scale: 2,
|
||||||
|
useCORS: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const imgData = canvas.toDataURL("image/jpeg", 0.98);
|
||||||
|
|
||||||
|
const pdf = new jsPDF({
|
||||||
|
unit: "px",
|
||||||
|
format: [canvas.width, canvas.height],
|
||||||
|
});
|
||||||
|
|
||||||
|
pdf.addImage(imgData, "JPEG", 0, 0, canvas.width, canvas.height);
|
||||||
|
pdf.save("document.pdf");
|
||||||
|
};
|
||||||
const scrollToPage = (pageIndex) => {
|
const scrollToPage = (pageIndex) => {
|
||||||
const pages = containerRef.current?.children;
|
const pages = containerRef.current?.children;
|
||||||
if (pages && pages[pageIndex]) {
|
if (pages && pages[pageIndex]) {
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.BSC1Payment-HoldModel-delete {
|
.BSC1Payment-HoldModel-delete {
|
||||||
color: var(-ERROR_COLOR);
|
color: var(--ERROR_COLOR);
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -288,8 +288,8 @@ a {
|
||||||
|
|
||||||
.payment-error-msg {
|
.payment-error-msg {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-family: VAR(--PARA_FONT_FAMILY);
|
font-family: var(--PARA_FONT_FAMILY);
|
||||||
color: VAR(--ERROR_COLOR);
|
color: var(--ERROR_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable all Ant Design table animations and hover effects */
|
/* Disable all Ant Design table animations and hover effects */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue