Services: per-service get-ready time (items.bufferMinutes)
Migration adds the field to existing databases; pb_schema.json mirrors it in the 0.23 top-level format (min/onlyInt under "options" is ignored). Edited next to Duration in Services & products. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
This commit is contained in:
parent
13b5f2bbcb
commit
1a71c9db73
6 changed files with 50 additions and 6 deletions
|
|
@ -8,8 +8,10 @@ function itemPayload(data: FormData) {
|
|||
const type: ItemType = String(data.get('type')) === 'item_with_time' ? 'item_with_time' : 'item';
|
||||
const rawStock = String(data.get('stock') ?? '').trim();
|
||||
const rawDuration = String(data.get('duration') ?? '').trim();
|
||||
const rawBuffer = String(data.get('bufferMinutes') ?? '').trim();
|
||||
const stock = type === 'item' && rawStock !== '' ? parseInt(rawStock, 10) : null;
|
||||
const duration = type === 'item_with_time' && rawDuration !== '' ? parseInt(rawDuration, 10) : null;
|
||||
const bufferMinutes = type === 'item_with_time' && rawBuffer !== '' ? parseInt(rawBuffer, 10) : null;
|
||||
|
||||
return {
|
||||
name: String(data.get('name') || '').trim(),
|
||||
|
|
@ -19,6 +21,7 @@ function itemPayload(data: FormData) {
|
|||
type,
|
||||
stock: Number.isNaN(stock) ? null : stock,
|
||||
duration: Number.isNaN(duration) ? null : duration,
|
||||
bufferMinutes: Number.isNaN(bufferMinutes) ? null : bufferMinutes,
|
||||
active: String(data.get('active')) === 'true'
|
||||
};
|
||||
}
|
||||
|
|
@ -35,6 +38,7 @@ function normalizeItem(record: Record<string, any>): ItemRecord {
|
|||
type: record.type === 'item_with_time' ? 'item_with_time' : 'item',
|
||||
stock: record.stock ?? null,
|
||||
duration: record.duration ?? null,
|
||||
bufferMinutes: record.bufferMinutes ?? null,
|
||||
active: record.active !== false
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
type: ItemType;
|
||||
stock: string;
|
||||
duration: string;
|
||||
bufferMinutes: string;
|
||||
active: boolean;
|
||||
};
|
||||
|
||||
|
|
@ -30,7 +31,7 @@
|
|||
let money = $derived(new Intl.NumberFormat('en-GB', { style: 'currency', currency: data.currency }));
|
||||
|
||||
function emptyDraft(): ItemDraft {
|
||||
return { id: '', name: '', description: '', price: 0, image: '', imageUrl: '', type: 'item', stock: '', duration: '', active: true };
|
||||
return { id: '', name: '', description: '', price: 0, image: '', imageUrl: '', type: 'item', stock: '', duration: '', bufferMinutes: '', active: true };
|
||||
}
|
||||
|
||||
function createItem() {
|
||||
|
|
@ -50,6 +51,7 @@
|
|||
type: item.type,
|
||||
stock: item.stock == null ? '' : String(item.stock),
|
||||
duration: item.duration == null ? '' : String(item.duration),
|
||||
bufferMinutes: item.bufferMinutes == null ? '' : String(item.bufferMinutes),
|
||||
active: item.active
|
||||
};
|
||||
uploadError = '';
|
||||
|
|
@ -107,7 +109,7 @@
|
|||
<td><span class="badge">{item.type === 'item_with_time' ? 'Service' : 'Product'}</span></td>
|
||||
<td>{money.format(item.price)}</td>
|
||||
<td>{item.type === 'item' ? (item.stock ?? '∞') : '—'}</td>
|
||||
<td>{item.type === 'item_with_time' ? `${item.duration ?? 0} min` : '—'}</td>
|
||||
<td>{item.type === 'item_with_time' ? `${item.duration ?? 0} min${item.bufferMinutes ? ` + ${item.bufferMinutes} get-ready` : ''}` : '—'}</td>
|
||||
<td><span class="badge" class:badge-success={item.active}>{item.active ? 'Active' : 'Inactive'}</span></td>
|
||||
<td class="text-right"><button class="btn btn-sm" type="button" onclick={() => editItem(item)}>Edit</button></td>
|
||||
</tr>
|
||||
|
|
@ -156,10 +158,17 @@
|
|||
<input class="input w-full" type="number" min="0" step="1" name="stock" placeholder="Unlimited when empty" bind:value={draft.stock} />
|
||||
</label>
|
||||
{:else}
|
||||
<label class="fieldset">
|
||||
<span class="fieldset-legend">Duration (minutes)</span>
|
||||
<input class="input w-full" type="number" min="1" step="1" name="duration" placeholder="60" required bind:value={draft.duration} />
|
||||
</label>
|
||||
<div class="grid gap-x-4 md:grid-cols-2">
|
||||
<label class="fieldset">
|
||||
<span class="fieldset-legend">Duration (minutes)</span>
|
||||
<input class="input w-full" type="number" min="1" step="1" name="duration" placeholder="60" required bind:value={draft.duration} />
|
||||
</label>
|
||||
<label class="fieldset">
|
||||
<span class="fieldset-legend">Get-ready time (minutes)</span>
|
||||
<input class="input w-full" type="number" min="0" step="1" name="bufferMinutes" placeholder="0" bind:value={draft.bufferMinutes} />
|
||||
<span class="label">Gap left after each appointment when generating slots</span>
|
||||
</label>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="fieldset">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue