diff --git a/package-lock.json b/package-lock.json index e6858aa..4b53140 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bodyshop-desktop", - "version": "1.0.5-alpha.2", + "version": "1.0.6-alpha.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bodyshop-desktop", - "version": "1.0.5-alpha.2", + "version": "1.0.6-alpha.1", "hasInstallScript": true, "dependencies": { "@apollo/client": "^3.13.6", diff --git a/package.json b/package.json index 8ae8525..2be1f31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bodyshop-desktop", - "version": "1.0.5", + "version": "1.0.6", "description": "Shop Management System Partner", "main": "./out/main/index.js", "author": "Convenient Brands, LLC", diff --git a/src/main/ppc/ppc-handler.ts b/src/main/ppc/ppc-handler.ts index 51874ef..78d8f9d 100644 --- a/src/main/ppc/ppc-handler.ts +++ b/src/main/ppc/ppc-handler.ts @@ -14,7 +14,7 @@ const handlePartsPriceChangeRequest = async ( ): Promise => { //Route handler here only. - const { job } = req.body as { job: PpcJob }; + const job = req.body as PpcJob; try { await generatePartsPriceChange(job); res.status(200).json({ success: true }); diff --git a/src/main/util/checkForAppUpdates.ts b/src/main/util/checkForAppUpdates.ts index 1cb9754..06cc343 100644 --- a/src/main/util/checkForAppUpdates.ts +++ b/src/main/util/checkForAppUpdates.ts @@ -12,10 +12,7 @@ async function checkForAppUpdatesContinuously(): Promise { } async function checkForAppUpdates(): Promise { await setReleaseChannel(); - autoUpdater.checkForUpdatesAndNotify({ - title: "Shop Partner Update", - body: "A new version of Shop Partner is available. Click to update.", - }); + autoUpdater.checkForUpdates(); } export { checkForAppUpdates, checkForAppUpdatesContinuously }; diff --git a/src/renderer/src/components/Settings/PaintScale/usePaintScaleConfig.ts b/src/renderer/src/components/Settings/PaintScale/usePaintScaleConfig.ts index f87be8f..1289514 100644 --- a/src/renderer/src/components/Settings/PaintScale/usePaintScaleConfig.ts +++ b/src/renderer/src/components/Settings/PaintScale/usePaintScaleConfig.ts @@ -1,71 +1,98 @@ -import { useState, useEffect } from 'react'; -import ipcTypes from '../../../../../util/ipcTypes.json'; -import { PaintScaleConfig, PaintScaleType } from '../../../../../util/types/paintScale'; +import { useState, useEffect } from "react"; +import ipcTypes from "../../../../../util/ipcTypes.json"; +import { + PaintScaleConfig, + PaintScaleType, +} from "../../../../../util/types/paintScale"; import { message } from "antd"; -import {useTranslation} from "react-i18next"; +import { useTranslation } from "react-i18next"; -type ConfigType = 'input' | 'output'; +type ConfigType = "input" | "output"; export const usePaintScaleConfig = (configType: ConfigType) => { - const [paintScaleConfigs, setPaintScaleConfigs] = useState([]); + const [paintScaleConfigs, setPaintScaleConfigs] = useState< + PaintScaleConfig[] + >([]); const { t } = useTranslation(); // Get the appropriate IPC methods based on config type - const getConfigsMethod = configType === 'input' + const getConfigsMethod = + configType === "input" ? ipcTypes.toMain.settings.paintScale.getInputConfigs : ipcTypes.toMain.settings.paintScale.getOutputConfigs; - const setConfigsMethod = configType === 'input' + const setConfigsMethod = + configType === "input" ? ipcTypes.toMain.settings.paintScale.setInputConfigs : ipcTypes.toMain.settings.paintScale.setOutputConfigs; - const setPathMethod = configType === 'input' + const setPathMethod = + configType === "input" ? ipcTypes.toMain.settings.paintScale.setInputPath : ipcTypes.toMain.settings.paintScale.setOutputPath; // Load paint scale configs on mount useEffect(() => { window.electron.ipcRenderer - .invoke(getConfigsMethod) - .then((configs: PaintScaleConfig[]) => { - // Ensure all configs have a pollingInterval and type (for backward compatibility) - const updatedConfigs = configs.map(config => ({ - ...config, - pollingInterval: config.pollingInterval || 1440, // Default to 1440 seconds - type: config.type || PaintScaleType.PPG, // Default type if missing - })); - setPaintScaleConfigs(updatedConfigs || []); - }) - .catch((error) => { - console.error(`Failed to load paint scale ${configType} configs:`, error); - }); + .invoke(getConfigsMethod) + .then((configs: PaintScaleConfig[]) => { + // Ensure all configs have a pollingInterval and type (for backward compatibility) + const defaultPolling = configType === "input" ? 1440 : 60; + const updatedConfigs = configs.map((config) => ({ + ...config, + pollingInterval: config.pollingInterval || defaultPolling, // Default to 1440 for input, 60 for output + type: config.type || PaintScaleType.PPG, // Default type if missing + })); + setPaintScaleConfigs(updatedConfigs || []); + }) + .catch((error) => { + console.error( + `Failed to load paint scale ${configType} configs:`, + error, + ); + }); }, [getConfigsMethod]); // Save configs to store and notify main process of config changes const saveConfigs = (configs: PaintScaleConfig[]) => { window.electron.ipcRenderer - .invoke(setConfigsMethod, configs) - .then(() => { - // Notify main process to update cron job - if (configType === 'input') { - window.electron.ipcRenderer.send(ipcTypes.toMain.settings.paintScale.updateInputCron, configs); - } else if (configType === 'output') { - window.electron.ipcRenderer.send(ipcTypes.toMain.settings.paintScale.updateOutputCron, configs); - } - }) - .catch((error) => { - console.error(`Failed to save paint scale ${configType} configs:`, error); - }); + .invoke(setConfigsMethod, configs) + .then(() => { + // Notify main process to update cron job + if (configType === "input") { + window.electron.ipcRenderer.send( + ipcTypes.toMain.settings.paintScale.updateInputCron, + configs, + ); + } else if (configType === "output") { + window.electron.ipcRenderer.send( + ipcTypes.toMain.settings.paintScale.updateOutputCron, + configs, + ); + } + }) + .catch((error) => { + console.error( + `Failed to save paint scale ${configType} configs:`, + error, + ); + }); }; // New helper to check if a path is unique across input and output configs const checkPathUnique = async (newPath: string): Promise => { try { - const inputConfigs: PaintScaleConfig[] = await window.electron.ipcRenderer.invoke(ipcTypes.toMain.settings.paintScale.getInputConfigs); - const outputConfigs: PaintScaleConfig[] = await window.electron.ipcRenderer.invoke(ipcTypes.toMain.settings.paintScale.getOutputConfigs); + const inputConfigs: PaintScaleConfig[] = + await window.electron.ipcRenderer.invoke( + ipcTypes.toMain.settings.paintScale.getInputConfigs, + ); + const outputConfigs: PaintScaleConfig[] = + await window.electron.ipcRenderer.invoke( + ipcTypes.toMain.settings.paintScale.getOutputConfigs, + ); const allConfigs = [...inputConfigs, ...outputConfigs]; // Allow updating the current config even if its current value equals newPath. - return !allConfigs.some(config => config.path === newPath); + return !allConfigs.some((config) => config.path === newPath); } catch (error) { console.error("Failed to check unique path:", error); return false; @@ -74,10 +101,11 @@ export const usePaintScaleConfig = (configType: ConfigType) => { // Handle adding a new paint scale config const handleAddConfig = (type: PaintScaleType) => { + const defaultPolling = configType === "input" ? 1440 : 60; const newConfig: PaintScaleConfig = { id: Date.now().toString(), type, - pollingInterval: 1440, // Default to 1440 seconds + pollingInterval: defaultPolling, // Default to 1440 for input, 60 for output }; const updatedConfigs = [...paintScaleConfigs, newConfig]; setPaintScaleConfigs(updatedConfigs); @@ -86,7 +114,9 @@ export const usePaintScaleConfig = (configType: ConfigType) => { // Handle removing a config const handleRemoveConfig = (id: string) => { - const updatedConfigs = paintScaleConfigs.filter((config) => config.id !== id); + const updatedConfigs = paintScaleConfigs.filter( + (config) => config.id !== id, + ); setPaintScaleConfigs(updatedConfigs); saveConfigs(updatedConfigs); }; @@ -94,7 +124,10 @@ export const usePaintScaleConfig = (configType: ConfigType) => { // Handle path selection (modified to check directory uniqueness) const handlePathChange = async (id: string) => { try { - const path: string | null = await window.electron.ipcRenderer.invoke(setPathMethod, id); + const path: string | null = await window.electron.ipcRenderer.invoke( + setPathMethod, + id, + ); if (path) { const isUnique = await checkPathUnique(path); if (!isUnique) { @@ -115,7 +148,7 @@ export const usePaintScaleConfig = (configType: ConfigType) => { // Handle polling interval change const handlePollingIntervalChange = (id: string, pollingInterval: number) => { const updatedConfigs = paintScaleConfigs.map((config) => - config.id === id ? { ...config, pollingInterval } : config, + config.id === id ? { ...config, pollingInterval } : config, ); setPaintScaleConfigs(updatedConfigs); saveConfigs(updatedConfigs); diff --git a/src/renderer/src/components/Settings/Settings.PaintScaleInputPaths.tsx b/src/renderer/src/components/Settings/Settings.PaintScaleInputPaths.tsx index 02118d9..edbbc03 100644 --- a/src/renderer/src/components/Settings/Settings.PaintScaleInputPaths.tsx +++ b/src/renderer/src/components/Settings/Settings.PaintScaleInputPaths.tsx @@ -35,7 +35,7 @@ const SettingsPaintScaleInputPaths = (): JSX.Element => { handleRemoveConfig, handlePathChange, handlePollingIntervalChange, - } = usePaintScaleConfig("input"); + } = usePaintScaleConfig("output"); const [isModalVisible, setIsModalVisible] = useState(false); const [selectedType, setSelectedType] = useState(null); diff --git a/src/renderer/src/components/Settings/Settings.PaintScaleOutputPaths.tsx b/src/renderer/src/components/Settings/Settings.PaintScaleOutputPaths.tsx index 56436d2..2ec6136 100644 --- a/src/renderer/src/components/Settings/Settings.PaintScaleOutputPaths.tsx +++ b/src/renderer/src/components/Settings/Settings.PaintScaleOutputPaths.tsx @@ -33,7 +33,7 @@ const SettingsPaintScaleOutputPaths = (): JSX.Element => { handleRemoveConfig, handlePathChange, handlePollingIntervalChange, - } = usePaintScaleConfig("output"); + } = usePaintScaleConfig("input"); const [isModalVisible, setIsModalVisible] = useState(false); const [selectedType, setSelectedType] = useState(null);