27 lines
784 B
TypeScript
27 lines
784 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 response = await getCustomerClients({ telegramId: user?.telegramId });
|
|
|
|
return response.data?.customers?.at(0);
|
|
}
|
|
|
|
export async function getMasters() {
|
|
const session = await getServerSession(authOptions);
|
|
if (!session) throw new Error('Missing session');
|
|
|
|
const { user } = session;
|
|
|
|
const response = await getCustomerMasters({ telegramId: user?.telegramId });
|
|
|
|
return response.data?.customers?.at(0);
|
|
}
|