algunos refactor y ahora arregle lo que no se actualizaba la tarjeta de

perfil
This commit is contained in:
2025-12-26 01:37:10 -03:00
parent 6d2bb774d4
commit 9508b575f5
6 changed files with 91 additions and 90 deletions

View File

@@ -28,13 +28,7 @@
let showCrearPost = $state(false);
const toggleCrearPost = () => (showCrearPost = !showCrearPost);
const { subscribe } = apiBase;
let baseUrl: string = '';
let data = $state(page.data);
subscribe((value) => {
baseUrl = value;
})();
let data = $derived(page.data);
$effect(() => {
obtenerPosts();
@@ -42,7 +36,7 @@
async function obtenerPosts() {
try {
const req = await fetch(baseUrl + '/api/posts/user/' + params.perfil, {
const req = await fetch($apiBase + '/api/posts/user/' + params.perfil, {
method: 'GET',
headers: {
Authorization: `Bearer ${$sesionStore?.accessToken}`
@@ -72,10 +66,13 @@
postAModificar = null;
}
</script>
{$inspect(data)}
<!-- {$inspect(data)} -->
<div class="flex min-h-fit w-full items-center justify-center p-6 md:p-10">
<div class="w-full max-w-6xl">
{#key data}
<CardPerfil bind:data />
{/key}
<h1
class="mt-10 flex scroll-m-20 justify-between text-3xl font-extrabold tracking-tight lg:text-3xl"
>

View File

@@ -4,13 +4,14 @@ import { error } from '@sveltejs/kit';
import { obtenerSeguidosPorUsuario } from '@/hooks/obtenerSeguidosPorUsuario.js';
import { obtenerSeguidoresPorUsuario } from '@/hooks/obtenerSeguidoresPorUsuario.js';
export async function load({ params }) {
const usuario: UserResponseDto | null = await obtenerUsuarioPorUsername(params.perfil);
export async function load({ params, depends, fetch }) {
depends('perfil:general');
const usuario: UserResponseDto | null = await obtenerUsuarioPorUsername(params.perfil, fetch);
if (!usuario) error(404, 'No se encontro el usuario, ' + params.perfil);
const [seguidos, seguidores] = await Promise.all([
obtenerSeguidosPorUsuario(usuario.id, 3),
obtenerSeguidoresPorUsuario(usuario.id, 3)
obtenerSeguidosPorUsuario(usuario.id, 3, fetch),
obtenerSeguidoresPorUsuario(usuario.id, 3, fetch)
]);
return { ...usuario, seguidos, seguidores };