Vlad Chikalkin 9314cdd1cb
merge branch 'refactor-api' (#23)
* refactor customer api

* refactor slots api

* hooks/customers: use invalidateQueries

* refactor services api

* optimize hooks queryKey

* refactor orders api

* typo refactor hooks

* fix telegramId type (number)

* fix bot with new api

* rename customers masters & clients query

* fix useClientsQuery & useMastersQuery query

* new line after 'use client' & 'use server' directives
2025-05-20 14:27:51 +03:00

33 lines
863 B
TypeScript

/* eslint-disable promise/prefer-await-to-then */
'use client';
import { getTelegramUser } from '@/mocks/get-telegram-user';
import { LoadingSpinner } from '@repo/ui/components/ui/spinner';
import { signIn, useSession } from 'next-auth/react';
import { useTheme } from 'next-themes';
import { redirect } from 'next/navigation';
import { useEffect } from 'react';
export default function Auth() {
const { status } = useSession();
useTheme();
useEffect(() => {
if (status === 'authenticated') {
redirect('/profile');
}
if (status === 'unauthenticated' && process.env.NODE_ENV === 'development') {
getTelegramUser().then((user) => {
signIn('telegram', {
callbackUrl: '/profile',
redirect: false,
telegramId: user?.id,
});
});
}
}, [status]);
return <LoadingSpinner />;
}