diff --git a/apps/client/src/common/api/rundown.ts b/apps/client/src/common/api/rundown.ts index 5d6c758ec..76b2db573 100644 --- a/apps/client/src/common/api/rundown.ts +++ b/apps/client/src/common/api/rundown.ts @@ -3,6 +3,7 @@ import { EntryId, OntimeEntry, OntimeEvent, ProjectRundownsList, Rundown, Transi import { apiEntryUrl } from './constants'; +type RundownId = string; const rundownPath = `${apiEntryUrl}/rundowns`; // #region operations on project rundowns ========================= @@ -26,8 +27,8 @@ export async function fetchCurrentRundown(): Promise { /** * HTTP request to switch the currently loaded rundown */ -export async function loadRundown(id: string): Promise> { - return axios.post(`${rundownPath}/${id}/load`); +export async function loadRundown(rundownId: RundownId): Promise> { + return axios.post(`${rundownPath}/${rundownId}/load`); } /** @@ -40,8 +41,8 @@ export async function createRundown(title: string): Promise> { - return axios.delete(`${rundownPath}/${id}`); +export async function deleteRundown(rundownId: RundownId): Promise> { + return axios.delete(`${rundownPath}/${rundownId}`); } // #endregion operations on project rundowns ====================== @@ -51,7 +52,7 @@ export async function deleteRundown(id: string): Promise> { return axios.post(`${rundownPath}/${rundownId}/entry`, data); @@ -60,7 +61,7 @@ export async function postAddEntry( /** * HTTP request to edit an entry */ -export async function putEditEntry(rundownId: string, data: Partial): Promise> { +export async function putEditEntry(rundownId: RundownId, data: Partial): Promise> { return axios.put(`${rundownPath}/${rundownId}/entry`, data); } @@ -72,7 +73,7 @@ export type BatchEditEntry = { /** * HTTP request to edit multiple events */ -export async function putBatchEditEvents(rundownId: string, data: BatchEditEntry): Promise> { +export async function putBatchEditEvents(rundownId: RundownId, data: BatchEditEntry): Promise> { return axios.put(`${rundownPath}/${rundownId}/batch`, data); } @@ -85,56 +86,56 @@ export type ReorderEntry = { /** * HTTP request to reorder an entry */ -export async function patchReorderEntry(rundownId: string, data: ReorderEntry): Promise> { +export async function patchReorderEntry(rundownId: RundownId, data: ReorderEntry): Promise> { return axios.patch(`${rundownPath}/${rundownId}/reorder`, data); } /** * HTTP request to swap two events */ -export async function requestEventSwap(rundownId: string, from: EntryId, to: EntryId): Promise> { +export async function requestEventSwap(rundownId: RundownId, from: EntryId, to: EntryId): Promise> { return axios.patch(`${rundownPath}/${rundownId}/swap`, { from, to }); } /** * HTTP request to request application of delay */ -export async function requestApplyDelay(rundownId: string, delayId: EntryId): Promise> { +export async function requestApplyDelay(rundownId: RundownId, delayId: EntryId): Promise> { return axios.patch(`${rundownPath}/${rundownId}/applydelay/${delayId}`); } /** * HTTP request for cloning an entry */ -export async function postCloneEntry(rundownId: string, entryId: EntryId): Promise> { +export async function postCloneEntry(rundownId: RundownId, entryId: EntryId): Promise> { return axios.post(`${rundownPath}/${rundownId}/clone/${entryId}`); } /** * HTTP request for grouping a list of entries into a group */ -export async function requestGroupEntries(rundownId: string, entryIds: EntryId[]): Promise> { +export async function requestGroupEntries(rundownId: RundownId, entryIds: EntryId[]): Promise> { return axios.post(`${rundownPath}/${rundownId}/group`, { ids: entryIds }); } /** * HTTP request for dissolving of a group */ -export async function requestUngroup(rundownId: string, groupId: EntryId): Promise> { +export async function requestUngroup(rundownId: RundownId, groupId: EntryId): Promise> { return axios.post(`${rundownPath}/${rundownId}/ungroup/${groupId}`); } /** * HTTP request to delete entries of a given rundown */ -export async function deleteEntries(rundownId: string, entryIds: EntryId[]): Promise> { +export async function deleteEntries(rundownId: RundownId, entryIds: EntryId[]): Promise> { return axios.delete(`${rundownPath}/${rundownId}/entries`, { data: { ids: entryIds } }); } /** * HTTP request to delete all entries of a given rundown */ -export async function requestDeleteAll(rundownId: string): Promise> { +export async function requestDeleteAll(rundownId: RundownId): Promise> { return axios.delete(`${rundownPath}/${rundownId}/all`); }