diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-05-26 14:39:39 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-05-26 14:39:39 +0700 |
| commit | 1a247903bf7bb87e0a43b4e5e338ea67ec90e6de (patch) | |
| tree | 6482f0a980cd914f89497da33e59a0301810139b /src-migrate/utils | |
| parent | 8ef5d44ff4aaf3f8826ffbb28e4466451a750af1 (diff) | |
<miqdad> cleaning code
Diffstat (limited to 'src-migrate/utils')
| -rw-r--r-- | src-migrate/utils/cart.js | 7 | ||||
| -rw-r--r-- | src-migrate/utils/checkBoxState.js | 20 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src-migrate/utils/cart.js b/src-migrate/utils/cart.js index 1ddc5446..ebd771e5 100644 --- a/src-migrate/utils/cart.js +++ b/src-migrate/utils/cart.js @@ -117,7 +117,7 @@ export const syncCartWithCookie = (cart) => { try { if (!cart || !cart.products) return { needsUpdate: false }; - // Transform data dari API ke format cookie + // Transform data API ke cookie const serverCartData = transformCartItemsForCookie(cart.products); // Ambil data lama dari cookie @@ -126,7 +126,7 @@ export const syncCartWithCookie = (cart) => { // Ambil selected status dari cookie const selectedItems = getSelectedItemsFromCookie(); - // Gabungkan data cart, prioritaskan data server + // Gabungkan data cart, (prioritize data server) const mergedCartData = { ...existingCartData, ...serverCartData }; // Periksa apakah ada perbedaan status selected @@ -142,12 +142,11 @@ export const syncCartWithCookie = (cart) => { item.selected = selectedItems[item.id]; } } else if (item.id) { - // Jika tidak ada di cookie, tambahkan dari cart selectedItems[item.id] = item.selected; } } - // Simpan kembali ke cookie + // Simpan ke cookie setCartDataToCookie(mergedCartData); setSelectedItemsToCookie(selectedItems); diff --git a/src-migrate/utils/checkBoxState.js b/src-migrate/utils/checkBoxState.js index 8e65ea66..2b527f36 100644 --- a/src-migrate/utils/checkBoxState.js +++ b/src-migrate/utils/checkBoxState.js @@ -1,5 +1,3 @@ -// ~/modules/cart/utils/checkboxUpdateState.js - /** * Enhanced state manager for checkbox updates * Tracks both global update state and individual checkbox update states @@ -53,17 +51,17 @@ const checkboxUpdateState = { }, // Get IDs of all checkboxes currently updating (for debugging) - getUpdatingCheckboxIds: () => [...updatingCheckboxIds], + // getUpdatingCheckboxIds: () => [...updatingCheckboxIds], - // Add a listener function to be called when update state changes - addListener: (callback) => { - if (typeof callback === 'function') { - listeners.push(callback); + // // Add a listener function to be called when update state changes + // addListener: (callback) => { + // if (typeof callback === 'function') { + // listeners.push(callback); - // Immediately call with current state - callback(updateCount > 0); - } - }, + // // Immediately call with current state + // callback(updateCount > 0); + // } + // }, // Remove a listener removeListener: (callback) => { |
