Skip to content

Commit 41f46ba

Browse files
authored
Merge pull request #31 from kryptodrex/issue-fixes
Version 0.3.0 Updates and Fixes
2 parents 15b7522 + 15fbbf4 commit 41f46ba

48 files changed

Lines changed: 6372 additions & 1465 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

electron/main.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,40 @@ ipcMain.handle('save-budget', async (event, filePath: string, data: string) => {
11691169
}
11701170
});
11711171

1172+
/**
1173+
* Rename budget file
1174+
* @param oldPath - Existing file path
1175+
* @param newPath - Desired file path
1176+
*/
1177+
ipcMain.handle('rename-budget-file', async (_event, oldPath: string, newPath: string) => {
1178+
try {
1179+
if (!oldPath || !newPath) {
1180+
return { success: false, error: 'Both old and new file paths are required.' };
1181+
}
1182+
1183+
if (oldPath === newPath) {
1184+
return { success: true, filePath: oldPath };
1185+
}
1186+
1187+
// Ensure source file exists before attempting rename.
1188+
await fs.access(oldPath);
1189+
1190+
// Avoid clobbering an existing file at the target path.
1191+
try {
1192+
await fs.access(newPath);
1193+
return { success: false, error: 'A file with that name already exists.' };
1194+
} catch {
1195+
// Target does not exist - safe to continue.
1196+
}
1197+
1198+
await fs.rename(oldPath, newPath);
1199+
return { success: true, filePath: newPath };
1200+
} catch (error) {
1201+
console.error('Error renaming budget file:', error);
1202+
return { success: false, error: (error as Error).message };
1203+
}
1204+
});
1205+
11721206
/**
11731207
* Load budget data from file
11741208
* @param filePath - Where to load the file from

electron/preload.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
2222
// Returns: { success: boolean, error?: string }
2323
saveBudget: (filePath: string, data: string) =>
2424
ipcRenderer.invoke('save-budget', filePath, data),
25+
26+
// Rename an existing budget file
27+
// Takes: current path and new path
28+
// Returns: { success: boolean, filePath?: string, error?: string }
29+
renameBudgetFile: (oldPath: string, newPath: string) =>
30+
ipcRenderer.invoke('rename-budget-file', oldPath, newPath),
2531

2632
// Load budget from file
2733
// Takes: file path

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "paycheck-planner",
33
"private": true,
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"description": "Desktop paycheck planning and budget management application.",
66
"author": {
77
"name": "Paycheck Planner",

src/components/AccountsManager/AccountsManager.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ const AccountsManager: React.FC<AccountsManagerProps> = ({ onClose }) => {
3131
updateAccount(id, updates);
3232
};
3333

34+
const handleMoveAccount = (fromIndex: number, toIndex: number) => {
35+
const newAccounts = [...accounts];
36+
[newAccounts[fromIndex], newAccounts[toIndex]] = [newAccounts[toIndex], newAccounts[fromIndex]];
37+
updateBudgetData({ accounts: newAccounts });
38+
};
39+
3440
const handleDeleteAccount = (id: string) => {
3541
if (accounts.length <= 1) {
3642
return;
@@ -140,6 +146,7 @@ const AccountsManager: React.FC<AccountsManagerProps> = ({ onClose }) => {
140146
onAdd={handleAddAccount}
141147
onUpdate={handleUpdateAccount}
142148
onDelete={handleDeleteAccount}
149+
onMove={handleMoveAccount}
143150
showToggleButton={true}
144151
infoMessage="These accounts are specific to this plan. Changes will only affect this plan file."
145152
/>

0 commit comments

Comments
 (0)