fix: brew machine cannot show value

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-03-16 17:17:12 +07:00
parent e6d1ac9a99
commit ee57dd1163
6 changed files with 43 additions and 8 deletions

View file

@ -12,7 +12,10 @@
latestRecipeToppingData,
recipeDataEvent,
toppingGroupFromServerQuery,
toppingListFromServerQuery
toppingListFromServerQuery,
toppingGroupFromMachineQuery,
toppingListFromMachineQuery,
referenceFromPage
} from '$lib/core/stores/recipeStore';
import { onMount } from 'svelte';
import { addNotification } from '$lib/core/stores/noti';
@ -189,8 +192,13 @@
// recipelist-value-editor.svelte?t=1773541064272:57 GET requested data: {"mat_id":9501,"mat_type":"cup","mat_name":"CUP paper (9501)","params":{},"toppings":[{"ListGroupID":[1,0,0,0],"defaultIDSelect":1,"groupID":"1","isUse":true},{"ListGroupID":[6,0,0,0],"defaultIDSelect":31,"groupID":"6","isUse":true},{"ListGroupID":[7,0,0,0],"defaultIDSelect":33,"groupID":"7","isUse":true},{"ListGroupID":[0,0,0,0],"defaultIDSelect":0,"groupID":"0","isUse":false},{"ListGroupID":[0,0,0,0],"defaultIDSelect":0,"groupID":"0","isUse":false},{"ListGroupID":[0,0,0,0],"defaultIDSelect":0,"groupID":"0","isUse":false},{"ListGroupID":[530,0,0,0],"defaultIDSelect":532,"groupID":"530","isUse":true},{"ListGroupID":[500,0,0,0],"defaultIDSelect":502,"groupID":"500","isUse":true}],"current_topping_list":[],"has_mix_ord":false,"feed":{"pattern":0,"parameter":0},"water":{"cold":0,"yield":0},"powder":{"gram":0,"time":0},"syrup":{"gram":0,"time":0},"stir_time":0}
onMount(() => {
categories = get(toppingGroupFromServerQuery);
topping_lists = get(toppingListFromServerQuery);
let refFrom = get(referenceFromPage);
categories = get(
refFrom === 'overview' ? toppingGroupFromServerQuery : toppingGroupFromMachineQuery
);
topping_lists = get(
refFrom === 'overview' ? toppingListFromServerQuery : toppingListFromMachineQuery
);
return recipeDataEvent.subscribe((event) => {
if (event !== null && event.index !== undefined && event.index === row_id) {
@ -230,7 +238,7 @@
<Input
id="material_name"
placeholder="Material Name"
value={`${current_editing_data.mat_name}`}
value={`${current_editing_data.mat_name ?? '-'}`}
disabled={true}
/>
<Field.Description>

View file

@ -16,7 +16,10 @@
latestRecipeToppingData,
recipeDataEvent,
toppingGroupFromServerQuery,
toppingListFromServerQuery
toppingListFromServerQuery,
toppingGroupFromMachineQuery,
toppingListFromMachineQuery,
referenceFromPage
} from '$lib/core/stores/recipeStore';
import { get } from 'svelte/store';
@ -106,9 +109,14 @@
}
function getToppingDisplay() {
let refFrom = get(referenceFromPage);
let current_row_topping = currentToppings[getToppingSlot()];
let groupQuery = get(toppingGroupFromServerQuery);
let listQuery = get(toppingListFromServerQuery);
let groupQuery = get(
refFrom === 'overview' ? toppingGroupFromServerQuery : toppingGroupFromMachineQuery
);
let listQuery = get(
refFrom === 'overview' ? toppingListFromServerQuery : toppingListFromMachineQuery
);
// console.log(JSON.stringify(groupQuery[0]));
// console.log(JSON.stringify(listQuery[0]));

View file

@ -4,6 +4,8 @@ import { sendMessage } from '../handlers/ws_messageSender';
import { auth } from '../stores/auth';
import { extractCookieOnNonBrowser } from '$lib/helpers/cookie';
import { browser } from '$app/environment';
import { permission } from '../stores/permissions';
import { addNotification } from '../stores/noti';
export async function getRecipes() {
if (browser && !get(departmentStore)) {
@ -14,6 +16,14 @@ export async function getRecipes() {
let countryTarget = get(departmentStore);
let country = '';
let countryPerm = `document.read.${countryTarget}`;
let user_perms = get(permission);
if (!user_perms.includes(countryPerm)) {
addNotification('ERR:Invalid permission');
return [];
}
// if (!countryTarget && !browser) {
// countryTarget = extractCookieOnNonBrowser()['department'];
// }

View file

@ -20,6 +20,8 @@ export const materialData = writable<Material | undefined>();
export const recipeFromMachine = writable<any>(null);
export const recipeFromMachineLoading = writable(false);
export const recipeFromMachineError = writable<string | null>(null);
export const toppingListFromMachineQuery = writable<any>([]);
export const toppingGroupFromMachineQuery = writable<any>([]);
export const recipeFromServerQuery = writable<any>({});
export const materialFromServerQuery = writable<any>([]);

View file

@ -17,6 +17,7 @@
import { auth } from '$lib/core/stores/auth.js';
import { get } from 'svelte/store';
import { getRecipes } from '$lib/core/client/server.js';
import { permission } from '$lib/core/stores/permissions';
let data: { recipes: RecipeOverview[] } = $state({
recipes: []
@ -32,6 +33,7 @@
// do load recipe
// loadRecipe();
referenceFromPage.set('overview');
await getRecipes();
});

View file

@ -11,7 +11,9 @@
recipeFromMachine,
recipeFromMachineLoading,
recipeFromMachineQuery,
referenceFromPage
toppingListFromMachineQuery,
referenceFromPage,
toppingGroupFromMachineQuery
} from '$lib/core/stores/recipeStore';
import DataTable from '../../recipe/overview/data-table.svelte';
import { handleIncomingMessages } from '$lib/core/handlers/messageHandler';
@ -313,6 +315,9 @@
recipeFromMachineQuery.set(currentQuery);
materialFromMachineQuery.set(currentMaterialsQuery);
toppingListFromMachineQuery.set(devRecipe['Topping']['ToppingList']);
toppingGroupFromMachineQuery.set(devRecipe['Topping']['ToppingGroup']);
}
}
</script>