2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 22:58:28 +00:00

fix: make the props posPrintWidth optional

This commit is contained in:
AbleKSaju 2025-01-03 11:44:31 +05:30
parent c318e81e72
commit fda3718ab2
3 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import fs from 'fs/promises';
import path from 'path';
import { TemplateFile } from 'utils/types';
export async function getTemplates(posTemplateWidth: number) {
export async function getTemplates(posTemplateWidth?: number) {
const paths = await getPrintTemplatePaths();
if (!paths) {
return [];
@ -14,7 +14,7 @@ export async function getTemplates(posTemplateWidth: number) {
const template = await fs.readFile(filePath, 'utf-8');
const { mtime } = await fs.stat(filePath);
const width =
file?.split('-')[1]?.split('.')[0] === 'POS' ? posTemplateWidth : 0;
file?.split('-')[1]?.split('.')[0] === 'POS' ? posTemplateWidth ?? 0 : 0;
const height = file?.split('-')[1]?.split('.')[0] === 'POS' ? 22 : 0;
templates.push({

View File

@ -75,7 +75,7 @@ const ipc = {
};
},
async getTemplates(posTemplateWidth: number): Promise<TemplateFile[]> {
async getTemplates(posTemplateWidth?: number): Promise<TemplateFile[]> {
return (await ipcRenderer.invoke(
IPC_ACTIONS.GET_TEMPLATES,
posTemplateWidth

View File

@ -207,7 +207,7 @@ export default function registerIpcMainActionListeners(main: Main) {
ipcMain.handle(
IPC_ACTIONS.GET_TEMPLATES,
async (_, posPrintWidth: number) => {
async (_, posPrintWidth?: number) => {
return getTemplates(posPrintWidth);
}
);