mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-21 16:27:32 -03:00
algunos refactor y ahora arregle lo que no se actualizaba la tarjeta de
perfil
This commit is contained in:
@@ -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"
|
||||
>
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user