update name on telegram first login
This commit is contained in:
parent
c2ca2f9df5
commit
3fb25cd667
@ -1,5 +1,5 @@
|
||||
'use client';
|
||||
import { updateProfile } from '@/actions/profile';
|
||||
import { getProfile, updateProfile } from '@/actions/profile';
|
||||
import { LoadingSpinner } from '@repo/ui/components/ui/spinner';
|
||||
import { initData, isMiniAppDark, useSignal } from '@telegram-apps/sdk-react';
|
||||
import { signIn, useSession } from 'next-auth/react';
|
||||
@ -22,13 +22,27 @@ export default function Auth() {
|
||||
await updateProfile({ photoUrl: initDataUser.photoUrl });
|
||||
}
|
||||
|
||||
await updateProfile({ active: true });
|
||||
const customer = await getProfile({ telegramId: initDataUser?.id });
|
||||
|
||||
if (!customer?.active) {
|
||||
await updateProfile({
|
||||
active: true,
|
||||
name: `${initDataUser?.firstName || ''} + ' ' + ${initDataUser?.lastName}`.trim(),
|
||||
});
|
||||
}
|
||||
|
||||
setIsUpdating(false);
|
||||
};
|
||||
|
||||
update();
|
||||
}, [initDataUser?.photoUrl, isDark, setTheme]);
|
||||
}, [
|
||||
initDataUser?.firstName,
|
||||
initDataUser?.id,
|
||||
initDataUser?.lastName,
|
||||
initDataUser?.photoUrl,
|
||||
isDark,
|
||||
setTheme,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isUpdating) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user