update brew route

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-02-24 17:32:51 +07:00
parent 7075f4a664
commit 29a1a82cfb
12 changed files with 344 additions and 203 deletions

View file

@ -8,14 +8,18 @@
import { columns, type RecipelistMaterial } from './columns';
import { get, readable, writable } from 'svelte/store';
import { materialFromMachineQuery } from '$lib/core/stores/recipeStore';
import { materialFromMachineQuery, materialFromServerQuery } from '$lib/core/stores/recipeStore';
import { generateIcing } from '$lib/helpers/icingGen';
import { machineInfoStore } from '$lib/core/stores/machineInfoStore';
import MachineInfo from '../machine-info.svelte';
import { v4 as uuidv4 } from 'uuid';
//
let { recipeData, onPendingChange }: { recipeData: any; onPendingChange: any } = $props();
let {
recipeData,
onPendingChange,
refPage
}: { recipeData: any; onPendingChange: any; refPage: string } = $props();
let menuName: string = $state('');
@ -31,9 +35,12 @@
if (materialSnapshot) {
let d_cnt = 0;
for (let rpl of data) {
let mat = materialSnapshot.filter(
(x: any) => x['id'].toString() === rpl['materialPathId'].toString()
)[0];
let mat =
refPage == 'brew'
? materialSnapshot.filter(
(x: any) => x['id'].toString() === rpl['materialPathId'].toString()
)[0]
: materialSnapshot[rpl['materialPathId']];
// console.log('mat filter get', Object(mat), Object.keys(mat));
@ -99,7 +106,14 @@
if (recipeData) {
menuName =
recipeData['name'] ?? (recipeData['otherName'] ? recipeData['otherName'] : 'Not set');
materialSnapshot = get(materialFromMachineQuery);
if (refPage == 'overview') {
materialSnapshot = get(materialFromServerQuery);
} else if (refPage == 'brew') {
materialSnapshot = get(materialFromMachineQuery);
}
console.log(`detail : ${JSON.stringify(recipeData)}`);
recipeListMatState = remappingToColumn(recipeData['recipes']);
// save old value\

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { recipeFromMachineQuery } from '$lib/core/stores/recipeStore';
import { recipeFromMachineQuery, recipeFromServerQuery } from '$lib/core/stores/recipeStore';
import { onMount } from 'svelte';
import { MediaQuery } from 'svelte/reactivity';
import { get } from 'svelte/store';
@ -72,6 +72,15 @@
}
}
} else if (refPage === 'overview') {
let recipeServerSnapshot = get(recipeFromServerQuery) ?? {};
let recipe01Snap = recipeServerSnapshot['recipe'];
if (recipe01Snap) {
currentData = recipe01Snap[productCode] ?? {};
console.log(`current data : ${JSON.stringify(Object.keys(recipe01Snap))}`);
if (currentData.MenuStatus) {
currentMenuStatus = matchMenuStatus(currentData.MenuStatus);
}
}
}
});
</script>
@ -89,7 +98,7 @@
</Dialog.Header>
<!-- render more -->
<RecipeDetail recipeData={currentData} {onPendingChange} />
<RecipeDetail recipeData={currentData} {onPendingChange} {refPage} />
</Dialog.Content>
</Dialog.Root>
{:else}{/if}