diff --git a/src/routes/[slug]/+page.svelte b/src/routes/[slug]/+page.svelte index b0ebb2c..0d8aa9f 100644 --- a/src/routes/[slug]/+page.svelte +++ b/src/routes/[slug]/+page.svelte @@ -1,52 +1,52 @@ - Carteles DMD - Plantilla {data.slug} + Carteles DMD - Plantilla {data.slug}
-
+
- {#if templateIndex !== undefined} -
- -
- {/if} + {#if templateIndex !== undefined} +
+ +
+ {/if}
diff --git a/src/routes/todos/+page.server.js b/src/routes/todos/+page.server.js deleted file mode 100644 index a3ce2ba..0000000 --- a/src/routes/todos/+page.server.js +++ /dev/null @@ -1,66 +0,0 @@ -import { error } from '@sveltejs/kit'; -import { api } from './api'; - -/** - * @typedef {{ - * uid: string; - * created_at: Date; - * text: string; - * done: boolean; - * pending_delete: boolean; - * }} Todo - */ - -/** @type {import('./$types').PageServerLoad} */ -export const load = async ({ locals }) => { - // locals.userid comes from src/hooks.js - const response = await api('GET', `todos/${locals.userid}`); - - if (response.status === 404) { - // user hasn't created a todo list. - // start with an empty array - return { - /** @type {Todo[]} */ - todos: [] - }; - } - - if (response.status === 200) { - return { - /** @type {Todo[]} */ - todos: await response.json() - }; - } - - throw error(response.status); -}; - -/** @type {import('./$types').Actions} */ -export const actions = { - add: async ({ request, locals }) => { - const form = await request.formData(); - - await api('POST', `todos/${locals.userid}`, { - text: form.get('text') - }); - }, - edit: async ({ request, locals }) => { - const form = await request.formData(); - - await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, { - text: form.get('text') - }); - }, - toggle: async ({ request, locals }) => { - const form = await request.formData(); - - await api('PATCH', `todos/${locals.userid}/${form.get('uid')}`, { - done: !!form.get('done') - }); - }, - delete: async ({ request, locals }) => { - const form = await request.formData(); - - await api('DELETE', `todos/${locals.userid}/${form.get('uid')}`); - } -}; diff --git a/src/routes/todos/+page.svelte b/src/routes/todos/+page.svelte deleted file mode 100644 index 992427a..0000000 --- a/src/routes/todos/+page.svelte +++ /dev/null @@ -1,182 +0,0 @@ - - - - Todos - - - -
-

Todos

- - { - return ({ form, result }) => { - if (result.type === 'success') { - form.reset(); - invalidateAll(); - } - }; - }} - > - - - - {#each todos as todo (todo.uid)} -
-
{ - todo.done = !!data.get('done'); - }} - > - - -
- {/each} -
- - diff --git a/src/routes/todos/api.js b/src/routes/todos/api.js deleted file mode 100644 index 497db29..0000000 --- a/src/routes/todos/api.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - This module is used by the /todos endpoint to - make calls to api.svelte.dev, which stores todos - for each user. - - (The data on the todo app will expire periodically; no - guarantees are made. Don't use it to organise your life.) -*/ - -const base = 'https://api.svelte.dev'; - -/** - * @param {string} method - * @param {string} resource - * @param {Record} [data] - */ -export function api(method, resource, data) { - return fetch(`${base}/${resource}`, { - method, - headers: { - 'content-type': 'application/json' - }, - body: data && JSON.stringify(data) - }); -}