feat: save recipe in progress

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-04-20 10:37:02 +07:00
parent 916e056389
commit 230d4abe0c
11 changed files with 310 additions and 41 deletions

View file

@ -11,6 +11,7 @@
import { columns, type RecipelistMaterial } from './columns';
import { get, readable, writable } from 'svelte/store';
import {
currentEditingRecipeProductCode,
latestRecipeToppingData,
materialFromMachineQuery,
materialFromServerQuery
@ -29,8 +30,9 @@
let {
recipeData,
onPendingChange,
productCode,
refPage
}: { recipeData: any; onPendingChange: any; refPage: string } = $props();
}: { recipeData: any; onPendingChange: any; productCode: string; refPage: string } = $props();
let menuName: string = $state('');
@ -126,7 +128,9 @@
}
}
async function saveRecipe() {}
async function saveRecipe() {
recipeDetailDispatch('saveRecipe');
}
async function sendTriggerBrewNow() {
// check queue ready
@ -155,8 +159,8 @@
}
}
async function checkChanges(original: any) {
console.log('old', original, 'updated', recipeListMatState);
async function checkChanges(productCode: string, original: any) {
// console.log('old', original, 'updated', recipeListMatState);
if (recipeListOriginal.length == 0) {
recipeListOriginal = original;
}
@ -164,6 +168,7 @@
if (original !== recipeListMatState) {
await onPendingChange({
target: 'recipeList',
ref_pd: productCode,
value: original
});
}
@ -187,6 +192,8 @@
latestRecipeToppingData.set(toppingSlotState);
currentEditingRecipeProductCode.set(productCode);
// save old value\
}
});
@ -237,7 +244,12 @@
</Tabs.Content>
<Tabs.Content value="details">
<RecipelistTable data={recipeListMatState} {columns} onStateChange={checkChanges} />
<RecipelistTable
data={recipeListMatState}
{columns}
onStateChange={checkChanges}
{productCode}
/>
</Tabs.Content>
</Tabs.Root>
</div>