2025-02-08 20:38:21 +03:00

39 lines
1.1 KiB
TypeScript

'use server';
// eslint-disable-next-line sonarjs/no-internal-api-use
import type * as ApolloTypes from '../../../packages/graphql/node_modules/@apollo/client/core';
import { getProfile } from './profile';
import * as api from '@repo/graphql/api';
import type * as GQL from '@repo/graphql/types';
type AddSlotInput = Omit<GQL.CreateSlotMutationVariables['input'], 'master'>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type FixTypescriptCringe = ApolloTypes.FetchResult;
export async function addSlot(input: AddSlotInput) {
const customer = await getProfile();
return api.createSlot({ ...input, master: customer?.documentId });
}
export async function getSlots(input: GQL.GetSlotsQueryVariables) {
const customer = await getProfile();
if (!customer?.documentId) throw new Error('Customer not found');
return api.getSlots({
filters: {
...input.filters,
master: {
documentId: {
eq: customer.documentId,
},
},
},
});
}
export const getSlot = api.getSlot;
export const updateSlot = api.updateSlot;
export const deleteSlot = api.deleteSlot;