This commit is contained in:
2025-11-18 16:18:43 +07:00
parent f150a84cf0
commit 08b352f686
10 changed files with 2140 additions and 27 deletions

View File

@@ -127,21 +127,32 @@ export const useCart = () => {
}, []);
// Xóa tất cả sản phẩm
const clearCart = useCallback(async () => {
try {
const userId = await getUserId();
if (!userId) return false;
await cartService.clearCart(userId);
setCart(null);
Alert.alert('Thành công', 'Đã xóa tất cả sản phẩm');
return true;
} catch (error) {
console.error('Clear cart error:', error);
Alert.alert('Lỗi', 'Không thể xóa giỏ hàng');
return false;
}
}, []);
const clearCart = useCallback(
async (showAlert: boolean = true) => {
try {
const userId = await getUserId();
if (!userId) return false;
await cartService.clearCart(userId);
setCart(null);
if (showAlert) {
Alert.alert('Thành công', 'Đã xóa tất cả sản phẩm');
}
return true;
} catch (error) {
console.error('Clear cart error:', error);
if (showAlert) {
Alert.alert('Lỗi', 'Không thể xóa giỏ hàng');
}
return false;
}
},
[]
);
// Load cart khi component mount
useEffect(() => {