order
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user