2025-01-15 18:03:31 +03:00

31 lines
868 B
TypeScript

'use server';
import { authOptions } from '@/config/auth';
import { getCustomerClients, getCustomerMasters } from '@repo/graphql/api';
import { getServerSession } from 'next-auth/next';
export async function getClients() {
const session = await getServerSession(authOptions);
if (!session) throw new Error('Missing session');
const { user } = session;
const getCustomerClientsResponse = await getCustomerClients({ telegramId: user?.telegramId });
return {
clients: getCustomerClientsResponse?.clients,
};
}
export async function getMasters() {
const session = await getServerSession(authOptions);
if (!session) throw new Error('Missing session');
const { user } = session;
const getCustomerMastersResponse = await getCustomerMasters({ telegramId: user?.telegramId });
return {
masters: getCustomerMastersResponse?.masters,
};
}