Add default price for all price fields

This commit is contained in:
NeilClack
2026-03-18 11:31:06 -05:00
parent b30281c19c
commit 61fe470451
+14
View File
@@ -26,6 +26,8 @@
submitLabel = 'Save' submitLabel = 'Save'
}: Props = $props(); }: Props = $props();
$inspect(fields);
function getValue(field: string): unknown { function getValue(field: string): unknown {
return form?.[field] ?? record?.[field] ?? ''; return form?.[field] ?? record?.[field] ?? '';
} }
@@ -74,6 +76,17 @@
class="w-full rounded-lg border border-gray-300 px-3 py-2 transition-shadow outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500" class="w-full rounded-lg border border-gray-300 px-3 py-2 transition-shadow outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500"
/> />
{:else if type === 'Int' || type === 'Float'} {:else if type === 'Int' || type === 'Float'}
{#if field === 'price'}
<input
type="number"
id={field}
name={field}
placeholder="0.99"
value={getValue(field) ?? '0.99'}
step={type === 'Float' ? '0.01' : '1'}
class="w-full rounded-lg border border-gray-300 px-3 py-2 transition-shadow outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500"
/>
{:else}
<input <input
type="number" type="number"
id={field} id={field}
@@ -82,6 +95,7 @@
step={type === 'Float' ? '0.01' : '1'} step={type === 'Float' ? '0.01' : '1'}
class="w-full rounded-lg border border-gray-300 px-3 py-2 transition-shadow outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500" class="w-full rounded-lg border border-gray-300 px-3 py-2 transition-shadow outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500"
/> />
{/if}
{:else if type === 'String'} {:else if type === 'String'}
<input <input
type="text" type="text"