feat: Add profile details to session type; refactor component prop defaults, update dynamic component syntax, and enhance type safety in form and error handling.
This commit is contained in:
parent
451b2fe81b
commit
dadefeff99
14 changed files with 24 additions and 19 deletions
4
frontend/src/app.d.ts
vendored
4
frontend/src/app.d.ts
vendored
|
|
@ -12,6 +12,10 @@ declare global {
|
|||
currency_symbol?: string;
|
||||
default_country?: string | null;
|
||||
};
|
||||
profile?: {
|
||||
role?: string;
|
||||
is_organization_admin?: boolean;
|
||||
};
|
||||
}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { cn } from '$lib/utils.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, children, ...restProps } = $props();
|
||||
let { ref = $bindable(null), class: className = undefined, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<p
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
import { cn } from '$lib/utils.js';
|
||||
let { ref = $bindable(null), class: className, children, ...restProps } = $props();
|
||||
let { ref = $bindable(null), class: className = undefined, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import { cn } from '$lib/utils.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, children, ...restProps } = $props();
|
||||
let { ref = $bindable(null), class: className = undefined, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
import { cn } from "$lib/utils.js";
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
class: className,
|
||||
portalProps,
|
||||
class: className = undefined,
|
||||
portalProps = undefined,
|
||||
children,
|
||||
showCloseButton = true,
|
||||
...restProps
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
class: className,
|
||||
class: className = undefined,
|
||||
...restProps
|
||||
} = $props();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { cn } from "$lib/utils.js";
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
class: className,
|
||||
class: className = undefined,
|
||||
children,
|
||||
...restProps
|
||||
} = $props();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
class: className,
|
||||
class: className = undefined,
|
||||
children,
|
||||
...restProps
|
||||
} = $props();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
class: className,
|
||||
class: className = undefined,
|
||||
...restProps
|
||||
} = $props();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -258,8 +258,7 @@
|
|||
<div class="space-y-3">
|
||||
{#each activeMobileColumn.items as item (item.id)}
|
||||
{#if CardComponent}
|
||||
<svelte:component
|
||||
this={CardComponent}
|
||||
<CardComponent
|
||||
{item}
|
||||
onclick={() => onCardClick(item)}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@
|
|||
<div class="flex-1 space-y-2 overflow-y-auto p-2" style="max-height: calc(100vh - 280px)">
|
||||
{#each column.items as item (item.id)}
|
||||
{#if CardComponent}
|
||||
<svelte:component
|
||||
this={CardComponent}
|
||||
<CardComponent
|
||||
{item}
|
||||
onclick={() => onCardClick(item)}
|
||||
ondragstart={(e) => onCardDragStart(e, item)}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { Label as LabelPrimitive } from 'bits-ui';
|
||||
import { cn } from '$lib/utils.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, ...restProps } = $props();
|
||||
let { ref = $bindable(null), class: className = undefined, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<LabelPrimitive.Root
|
||||
|
|
|
|||
|
|
@ -796,7 +796,8 @@
|
|||
drawerData = result.data.lead;
|
||||
} else if (result.type === 'failure') {
|
||||
console.error('Server action failed:', result.data);
|
||||
throw new Error(result.data?.error || 'Failed to fetch lead');
|
||||
const errorMsg = /** @type {{ error?: string }} */ (result.data)?.error;
|
||||
throw new Error(errorMsg || 'Failed to fetch lead');
|
||||
} else if (result.type === 'error') {
|
||||
console.error('Server action error:', result.error);
|
||||
throw new Error(result.error?.message || 'Failed to fetch lead');
|
||||
|
|
|
|||
|
|
@ -25,13 +25,14 @@ export async function load({ cookies, locals }) {
|
|||
export const actions = {
|
||||
create: async ({ request, cookies }) => {
|
||||
const formData = await request.formData();
|
||||
const name = /** @type {string | null} */ (formData.get('name'));
|
||||
const data = {
|
||||
name: formData.get('name'),
|
||||
name,
|
||||
color: formData.get('color') || 'blue',
|
||||
description: formData.get('description') || ''
|
||||
};
|
||||
|
||||
if (!data.name?.trim()) {
|
||||
if (!name?.trim()) {
|
||||
return fail(400, { error: 'Tag name is required' });
|
||||
}
|
||||
|
||||
|
|
@ -47,13 +48,14 @@ export const actions = {
|
|||
update: async ({ request, cookies }) => {
|
||||
const formData = await request.formData();
|
||||
const tagId = formData.get('tagId');
|
||||
const name = /** @type {string | null} */ (formData.get('name'));
|
||||
const data = {
|
||||
name: formData.get('name'),
|
||||
name,
|
||||
color: formData.get('color'),
|
||||
description: formData.get('description') || ''
|
||||
};
|
||||
|
||||
if (!data.name?.trim()) {
|
||||
if (!name?.trim()) {
|
||||
return fail(400, { error: 'Tag name is required' });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue