import {isOfType} from '@myparcel/ts-utils'; import {type ActionContextWithResponse} from '../executors'; import {generateLabelFilename} from '../../utils'; import {type PdfDataResponse, type PrintAction} from '../../types'; import {downloadFile, openPdfInNewWindow} from '../../services'; export const openOrPrintPdf = async ({ response, parameters, }: ActionContextWithResponse): Promise => { if (isOfType(response, 'data')) { return openPdfInNewWindow(response.data); } await downloadFile(response.url, generateLabelFilename(parameters)); };