zapishis-client/apps/web/components/auth/update-profile.tsx
2025-02-20 19:18:56 +03:00

23 lines
639 B
TypeScript

'use client';
import { useProfileMutation } from '@/hooks/profile';
import { initData, useSignal } from '@telegram-apps/sdk-react';
import { useEffect, useState } from 'react';
export function UpdateProfile() {
const initDataUser = useSignal(initData.user);
const { mutate: updateProfile } = useProfileMutation({});
const [hasUpdated, setHasUpdated] = useState(false);
useEffect(() => {
if (!hasUpdated) {
updateProfile({
active: true,
photoUrl: initDataUser?.photoUrl || undefined,
});
setHasUpdated(true);
}
}, [hasUpdated, initDataUser?.photoUrl, updateProfile]);
return null;
}