mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-25 16:54:28 -03:00
añadido editar y eliminar posts
This commit is contained in:
@@ -11,12 +11,18 @@ export const addPost = (post: Post) => {
|
||||
posts.update((currentPosts) => [post, ...currentPosts]);
|
||||
};
|
||||
|
||||
export const updatePost = (postId: string, updatedData: Partial<Post>) => {
|
||||
export const updatePostStore = (postId: string, updatedData: Partial<Post>) => {
|
||||
posts.update((currentPosts) =>
|
||||
currentPosts.map((post) => (post._id === postId ? { ...post, ...updatedData } : post))
|
||||
currentPosts.map((post) => (post.id === postId ? { ...post, ...updatedData } : post))
|
||||
);
|
||||
};
|
||||
|
||||
export const removePost = (postId: string) => {
|
||||
posts.update((currentPosts) => currentPosts.filter((post) => post._id !== postId));
|
||||
posts.update((currentPosts) => {
|
||||
const a = currentPosts.filter((post) => post.id !== postId);
|
||||
console.log(a);
|
||||
return a;
|
||||
});
|
||||
|
||||
console.log(postId);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { dev } from '$app/environment';
|
||||
import { writable } from 'svelte/store';
|
||||
import { readable } from 'svelte/store';
|
||||
|
||||
export const apiBase = writable(
|
||||
export const apiBase = readable(
|
||||
dev ? 'http://localhost:5000' : 'https://minix-back-dsuk.onrender.com'
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
import type { Sesion } from '../../types';
|
||||
import { apiBase } from '@/stores/url';
|
||||
@@ -29,7 +29,7 @@ if (browser) {
|
||||
if (browser) {
|
||||
const refreshAccessToken = async () => {
|
||||
try {
|
||||
const response = await fetch(baseUrl + '/api/auth/refresh', {
|
||||
const response = await fetch(get(apiBase) + '/api/auth/refresh', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user