Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1343311
style(seeder): fix indentation and formatting in helpers
Wilovy09 Mar 21, 2026
9e91567
feat(style): add custom color palette and surface vars
Wilovy09 Mar 21, 2026
84fbd91
refactor(nav): redesign sidebar structure and styles
Wilovy09 Mar 21, 2026
bb01dda
style(header): modernize page header with accent bar
Wilovy09 Mar 21, 2026
f3f4ec1
fix(auth): use runtime ADMINS env for admin access
Wilovy09 Mar 21, 2026
44a754d
style(layout): use flex layout and theme background
Wilovy09 Mar 21, 2026
7a1cb96
feat(forms): modernize forms list with grid and cards
Wilovy09 Mar 21, 2026
51dd423
refactor(forms): decouple core actions from UI kit
Wilovy09 Mar 21, 2026
71427b6
refactor(forms): simplify server actions and error handling
Wilovy09 Mar 21, 2026
2631dcd
fix(forms): improve UI for form and question editing
Wilovy09 Mar 21, 2026
73e0443
fix(forms): improve session and answer listing UX
Wilovy09 Mar 21, 2026
ff6d6e7
style(forms): fix formatting in session store
Wilovy09 Mar 21, 2026
f84a0c8
build(deps): add sweetalert2 and lockfile updates
Wilovy09 Mar 22, 2026
6b2f873
feat(forms): add toast notifications and editability improvements
Wilovy09 Mar 22, 2026
6c9124b
feat(forms): implement in-app form preview and answers UI
Wilovy09 Mar 22, 2026
4a078da
fix(db): cascade delete answers and sessions on form/question removal
Wilovy09 Mar 22, 2026
3579414
feat(utils): add reusable swal toast and dialog helpers
Wilovy09 Mar 22, 2026
0cfedb5
style(format): Format files
Wilovy09 Mar 22, 2026
e8543a3
fix(conflicts): Resolve merge conflicts
Wilovy09 Mar 22, 2026
b3e7650
Merge branch 'main' into feat/new_ui
Wilovy09 Mar 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"type": "module",
"dependencies": {
"@auth/core": "^0.34.2",
"@auth/sveltekit": "^1.4.2"
"@auth/sveltekit": "^1.4.2",
"sweetalert2": "^11.26.24"
}
}
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/routes/(dashboard)/forms/[slug]/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { loadDetails } from '$lib/forms/service/stores/form';
import { redirect } from '@sveltejs/kit';
import type { LayoutServerLoad } from './$types';

export const load: LayoutServerLoad = async ({ platform, params }) => {
const { form, questions } = await loadDetails(platform, params.slug);

if (!form) redirect(302, '/forms');

return { form, questions };
};
97 changes: 88 additions & 9 deletions src/routes/(dashboard)/forms/[slug]/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script lang="ts">
import PageHeader from '$lib/presentation/PageHeader.svelte';
import Button from '$lib/components/Button.svelte';
import { Divider, Switch, TextInput, Tooltip } from '@svelteuidev/core';
import { Divider, TextInput } from '@svelteuidev/core';

import type { Form, Question } from '$lib/forms/models';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { showSuccessToast, showErrorToast } from '../../../../utils/swalFunctions';

export let data: { form: Form; questions: Question[] };

Expand All @@ -14,6 +15,23 @@
let edition = data.form.edition;
let multiple_times = data.form.multiple_times === 1;
let description = data.form.description;
let lastFormId = data.form.id;

$: if (data.form.id !== lastFormId) {
lastFormId = data.form.id;
title = data.form.title;
require_login = data.form.require_login === 1;
edition = data.form.edition;
multiple_times = data.form.multiple_times === 1;
description = data.form.description;
}

$: isDirty =
title !== data.form.title ||
description !== data.form.description ||
edition !== data.form.edition ||
require_login !== (data.form.require_login === 1) ||
multiple_times !== (data.form.multiple_times === 1);

function handleClick() {
goto(`/forms/${$page.params.slug}/question/create`);
Expand All @@ -27,9 +45,11 @@
body: JSON.stringify({ form_id: parseInt($page.params.slug) })
});
if (!response.ok) throw new Error(`${response.status}`);
await showSuccessToast('Formulario eliminado');
goto('/forms');
} catch (error) {
console.error(error);
showErrorToast('Error al eliminar el formulario');
}
}

Expand All @@ -48,8 +68,15 @@
})
});
if (!response.ok) throw new Error(`${response.status}`);
data.form.title = title;
data.form.description = description;
data.form.edition = edition;
data.form.require_login = require_login ? 1 : 0;
data.form.multiple_times = multiple_times ? 1 : 0;
showSuccessToast('Formulario actualizado');
} catch (error) {
console.error('Error updating form:', error);
showErrorToast('Error al actualizar el formulario');
}
}
</script>
Expand All @@ -58,7 +85,7 @@
<Button variant="ghost" on:click={() => goto(`/forms/${$page.params.slug}/answers`)}>
Answers
</Button>
<Button variant="primary" on:click={handleUpdate}>Update</Button>
<Button variant="primary" disabled={!isDirty} on:click={handleUpdate}>Update</Button>
<Button variant="danger" on:click={handleDelete}>Delete</Button>
</PageHeader>

Expand All @@ -75,12 +102,14 @@
</div>

<div class="toggles">
<Tooltip label="The user requires login to respond to this form">
<Switch label="Require login" bind:checked={require_login} />
</Tooltip>
<Tooltip label="The user can respond multiple times">
<Switch label="Multiple times" bind:checked={multiple_times} />
</Tooltip>
<label class="toggle-row" title="The user requires login to respond to this form">
<input type="checkbox" bind:checked={require_login} />
Require login
</label>
<label class="toggle-row" title="The user can respond multiple times">
<input type="checkbox" bind:checked={multiple_times} />
Multiple times
</label>
</div>

<div class="questions-section">
Expand Down Expand Up @@ -144,6 +173,56 @@
border-radius: 8px;
}

.toggle-row {
display: flex;
align-items: center;
gap: 0.625rem;
font-size: 0.85rem;
font-weight: 600;
color: var(--n-200);
cursor: pointer;
user-select: none;
}

.toggle-row input[type='checkbox'] {
appearance: none;
position: relative;
width: 36px;
height: 20px;
min-width: 36px;
border-radius: 9999px;
background: var(--n-700);
border: 1px solid rgba(255, 255, 255, 0.1);
cursor: pointer;
transition:
background 0.15s,
border-color 0.15s;
}

.toggle-row input[type='checkbox']::before {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 14px;
height: 14px;
border-radius: 50%;
background: var(--n-400);
transition:
transform 0.15s,
background 0.15s;
}

.toggle-row input[type='checkbox']:checked {
background: var(--p-500);
border-color: var(--p-600);
}

.toggle-row input[type='checkbox']:checked::before {
transform: translateX(16px);
background: #fff;
}

.questions-section {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -213,7 +292,7 @@
}

.editor__preview {
overflow: hidden;
overflow-y: auto;
padding: 1.25rem;
}
</style>
Loading
Loading