import { dialog, ipcMain } from 'electron';

function handleDialogSelectFile(
  event: Electron.IpcMainInvokeEvent,
  config: Electron.OpenDialogOptions
) {
  return dialog.showOpenDialog(config);
}

function handleDialogSaveFile(
  event: Electron.IpcMainInvokeEvent,
  config: Electron.SaveDialogOptions
) {
  return dialog.showSaveDialog(config);
}

export default function useElectron() {
  ipcMain.handle('dialog:selectFile', handleDialogSelectFile);
  ipcMain.handle('dialog:saveFile', handleDialogSaveFile);
}
