import { useUpdateUser } from '@/hooks/data/useUpdateUser';
import { useOtherUserInfo } from '@/hooks/data/useUserInfo';
import { utf8ToBase64 } from '@/lib/utils';
import { ProfileView } from './profile.view';

export function ProfileContainer({ userId }: { userId: string }) {
  const { data } = useOtherUserInfo(userId);
  const { mutateAsync } = useUpdateUser();
  return (
    <ProfileView
      user={data.data!}
      onSaveBio={async (bio) => {
        await mutateAsync({ body: { bio: utf8ToBase64(bio) } });
      }}
    />
  );
}
