mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 18:18:18 +00:00
implement booking flow
This commit is contained in:
@@ -44,11 +44,19 @@ export function endpoint<TInput, TResponse>(
|
||||
service: string,
|
||||
action: string,
|
||||
execute: (input: TInput) => Promise<TResponse>,
|
||||
queryKeyBuilder?: (input: TInput) => readonly unknown[],
|
||||
) {
|
||||
const buildKey = (input?: TInput): readonly unknown[] =>
|
||||
input === undefined
|
||||
const buildKey = (input?: TInput): readonly unknown[] => {
|
||||
if (queryKeyBuilder && input !== undefined) {
|
||||
return queryKeyBuilder(input as TInput);
|
||||
}
|
||||
if (queryKeyBuilder && input === undefined) {
|
||||
return queryKeyBuilder(undefined as TInput);
|
||||
}
|
||||
return input === undefined
|
||||
? [service, action]
|
||||
: [service, action, input];
|
||||
};
|
||||
|
||||
const call = (input: TInput) => execute(input);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user