23 lines
639 B
TypeScript
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;
|
|
}
|