From d55864e0837c10b07f3de42d059066b20212a012 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Mon, 29 Jul 2024 08:59:23 +0200 Subject: [PATCH] logging and awaits added --- src/Components/Profile/ProfileForm.tsx | 11 +++++++++++ src/Components/Profile/itemFunctions.ts | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Components/Profile/ProfileForm.tsx b/src/Components/Profile/ProfileForm.tsx index 74ce8ad0..232b9887 100644 --- a/src/Components/Profile/ProfileForm.tsx +++ b/src/Components/Profile/ProfileForm.tsx @@ -65,6 +65,17 @@ export function ProfileForm({ userType }: { userType: string }) { }, [items]) + useEffect(() => { + console.log(state.offers); + console.log(state.needs); + console.log(state.id); + console.log(item); + + + + }, [state]) + + useEffect(() => { const newColor = item.layer?.itemColorField && getValue(item, item.layer?.itemColorField) ? getValue(item, item.layer?.itemColorField) diff --git a/src/Components/Profile/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts index 0fa840cb..e5387e20 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -103,7 +103,7 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga let offer_updates: Array = []; //check for new offers - state.offers?.map(o => { + await state.offers?.map(o => { const existingOffer = item?.offers?.find(t => t.tags_id === o.id) existingOffer && offer_updates.push(existingOffer.id) if (!existingOffer && !tags.some(t => t.id === o.id)) addTag({ ...o, offer_or_need: true }) @@ -112,7 +112,7 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga let needs_updates: Array = []; - state.needs?.map(n => { + await state.needs?.map(n => { const existingNeed = item?.needs?.find(t => t.tags_id === n.id) existingNeed && needs_updates.push(existingNeed.id) !existingNeed && needs_updates.push({ items_id: item?.id, tags_id: n.id })