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:
parent
c318e81e72
commit
fda3718ab2
@ -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({
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user