Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

Bump jspdf to 4.0.0 ([#13248](https://github.com/linode/manager/pull/13248))
3 changes: 1 addition & 2 deletions packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"he": "^1.2.0",
"immer": "^9.0.6",
"ipaddr.js": "^1.9.1",
"jspdf": "^3.0.2",
"jspdf": "^4.0.0",
"jspdf-autotable": "^5.0.2",
"launchdarkly-react-client-sdk": "3.0.10",
"libphonenumber-js": "^1.10.6",
Expand Down Expand Up @@ -140,7 +140,6 @@
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
"@types/he": "^1.1.0",
"@types/history": "4",
"@types/jspdf": "^1.3.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I hate it when packages don't provide their own type-definitions!

"@types/luxon": "3.4.2",
"@types/markdown-it": "^14.1.2",
"@types/md5": "^2.1.32",
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/dev-tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export const saveSeedsCountMap = (countMap: { [key: string]: number }) => {
/**
* Retrieves the presets map from local storage.
*/
export const getExtraPresetsMap = (): {
export const getExtraPresetsMap = (): Partial<{
[K in MockPresetExtraId]: number;
} => {
}> => {
const encodedPresetsMap = localStorage.getItem(LOCAL_STORAGE_PRESETS_MAP_KEY);

return encodedPresetsMap ? JSON.parse(encodedPresetsMap) : {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export const BillingActivityPanel = React.memo((props: Props) => {
);

const downloadPaymentPDF = React.useCallback(
(paymentId: number) => {
async (paymentId: number) => {
const payment = payments?.find(
(thisPayment) => thisPayment.id === paymentId
);
Expand All @@ -305,7 +305,7 @@ export const BillingActivityPanel = React.memo((props: Props) => {
taxes?.date,
taxes?.country_tax
);
const result = printPayment(account, payment, countryTax);
const result = await printPayment(account, payment, countryTax);

if (result.status === 'error') {
pdfErrors.add(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,12 @@ describe('PdfGenerator', () => {
});

// Call the printPayment function
const pdfResult = printPayment(account, payment, countryTax, timezone);
const pdfResult = await printPayment(
account,
payment,
countryTax,
timezone
);

// Expect the PDF generation to be successful
expect(pdfResult.status).toEqual('success');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ const addTitle = (doc: jsPDF, y: number, ...textStrings: Title[]) => {
};

// M3-6177 only make one request to get the logo
const getAkamaiLogo = () => {
return axios
.get(AkamaiLogo, { responseType: 'blob' })
.then((res) => {
return URL.createObjectURL(res.data);
})
.catch(() => {
return AkamaiLogo;
});
const getAkamaiLogo = async () => {
const response = await axios.get(AkamaiLogo, { responseType: 'blob' });

return new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result as string);
reader.onerror = reject;
reader.readAsDataURL(response.data);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests were failing - this method is valid for both node (tests) and the browser

};

interface PrintInvoiceOptions {
Expand Down Expand Up @@ -324,12 +324,12 @@ export const printInvoice = async (
}
};

export const printPayment = (
export const printPayment = async (
account: Account,
payment: Payment,
countryTax?: TaxDetail,
timezone?: string
): PdfResult => {
): Promise<PdfResult> => {
try {
const date = formatDate(payment.date, {
displayTime: true,
Expand All @@ -340,7 +340,8 @@ export const printPayment = (
});
doc.setFontSize(10);

doc.addImage(AkamaiLogo, 'JPEG', 160, 10, 120, 40, undefined, 'MEDIUM');
const AkamaiLogoURL = await getAkamaiLogo();
doc.addImage(AkamaiLogoURL, 'JPEG', 160, 10, 120, 40, undefined, 'MEDIUM');

const leftHeaderYPosition = addLeftHeader(
doc,
Expand Down
26 changes: 9 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.