28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { contextBridge, ipcRenderer } from 'electron'
|
|
import {
|
|
IPC_CHANNELS,
|
|
type AvailabilityQuery,
|
|
type CancelBookingInput,
|
|
type CreateBookingInput,
|
|
type TennisBookApi,
|
|
type UpdateCourtSettingsInput
|
|
} from '../shared/contracts'
|
|
|
|
const api: TennisBookApi = {
|
|
listCourts: () => ipcRenderer.invoke(IPC_CHANNELS.listCourts),
|
|
getAvailability: (query: AvailabilityQuery) =>
|
|
ipcRenderer.invoke(IPC_CHANNELS.getAvailability, query),
|
|
getCourtSettings: (courtId: string) =>
|
|
ipcRenderer.invoke(IPC_CHANNELS.getCourtSettings, courtId),
|
|
updateCourtSettings: (input: UpdateCourtSettingsInput) =>
|
|
ipcRenderer.invoke(IPC_CHANNELS.updateCourtSettings, input),
|
|
createBooking: (input: CreateBookingInput) =>
|
|
ipcRenderer.invoke(IPC_CHANNELS.createBooking, input),
|
|
cancelBooking: (input: CancelBookingInput) =>
|
|
ipcRenderer.invoke(IPC_CHANNELS.cancelBooking, input),
|
|
getPendingBooking: (courtId: string) =>
|
|
ipcRenderer.invoke(IPC_CHANNELS.getPendingBooking, courtId)
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('tennisBook', api)
|