feat: agregar Toast global y mejorar mensajes de Copiar/Rotar

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
webui
brobert 2 weeks ago
parent 2e523b1f0b
commit 6305cba34a

@ -15,7 +15,7 @@
async function handleCopy() { async function handleCopy() {
if (!url) return; if (!url) return;
const ok = await copyToClipboard(url); const ok = await copyToClipboard(url);
if (ok) toasts.success('Enlace copiado al portapapeles'); if (ok) toasts.success('Enlace de calendario copiado');
else toasts.error('No se pudo copiar el enlace'); else toasts.error('No se pudo copiar el enlace');
} }
@ -36,8 +36,8 @@
{/if} {/if}
</div> </div>
<div class="actions"> <div class="actions">
<Button variant="secondary" size="sm" on:click={handleCopy} disabled={!url}>Copiar</Button> <Button variant="secondary" size="sm" on:click={handleCopy} disabled={!url} aria-disabled={!url} title={!url ? 'URL no disponible' : undefined}>Copiar</Button>
<Button variant="danger" size="sm" on:click={handleRotate} disabled={rotating}> <Button variant="danger" size="sm" on:click={handleRotate} disabled={rotating} aria-disabled={rotating} aria-busy={rotating} title={rotating ? 'Actualizando…' : undefined}>
{rotating ? 'Rotando…' : 'Rotar'} {rotating ? 'Rotando…' : 'Rotar'}
</Button> </Button>
</div> </div>

@ -2,6 +2,7 @@
import '$lib/styles/tokens.css'; import '$lib/styles/tokens.css';
import '$lib/styles/base.css'; import '$lib/styles/base.css';
import favicon from '$lib/assets/favicon.svg'; import favicon from '$lib/assets/favicon.svg';
import Toast from '$lib/ui/feedback/Toast.svelte';
</script> </script>
<svelte:head> <svelte:head>
@ -11,4 +12,5 @@
<slot /> <slot />
<Toast />

@ -21,6 +21,7 @@
if (type === 'group' && groupId) rotating[groupId] = true; if (type === 'group' && groupId) rotating[groupId] = true;
if (type === 'personal') rotating['personal'] = true; if (type === 'personal') rotating['personal'] = true;
if (type === 'aggregate') rotating['aggregate'] = true; if (type === 'aggregate') rotating['aggregate'] = true;
rotating = { ...rotating };
const res = await fetch('/api/integrations/feeds/rotate', { const res = await fetch('/api/integrations/feeds/rotate', {
method: 'POST', method: 'POST',
@ -28,8 +29,7 @@
body: JSON.stringify({ type, groupId: groupId ?? null }) body: JSON.stringify({ type, groupId: groupId ?? null })
}); });
if (!res.ok) { if (!res.ok) {
const msg = await res.text(); error('No se puedo actualizar');
error(`No se pudo rotar: ${msg || res.status}`);
return; return;
} }
const body = await res.json(); const body = await res.json();
@ -41,13 +41,14 @@
const idx = groups.findIndex(g => g.groupId === groupId); const idx = groups.findIndex(g => g.groupId === groupId);
if (idx >= 0) groups[idx].url = body.url || null; if (idx >= 0) groups[idx].url = body.url || null;
} }
success('Token rotado correctamente'); success('Feed de calendario actualizado');
} catch (e) { } catch (e) {
error('Error al rotar el token'); error('No se puedo actualizar');
} finally { } finally {
if (type === 'group' && groupId) rotating[groupId] = false; if (type === 'group' && groupId) rotating[groupId] = false;
if (type === 'personal') rotating['personal'] = false; if (type === 'personal') rotating['personal'] = false;
if (type === 'aggregate') rotating['aggregate'] = false; if (type === 'aggregate') rotating['aggregate'] = false;
rotating = { ...rotating };
} }
} }
</script> </script>

Loading…
Cancel
Save