import { storefront } from '@/lib/storefront';
async function pollOrderStatus(locationId: string, cartId: string) {
const poll = setInterval(async () => {
const cart = await storefront.cart.get(locationId, cartId);
if (cart.status === 'COMPLETED') {
clearInterval(poll);
// Show confirmation screen
console.log('Order completed!');
} else if (cart.status === 'LOCKED') {
// Payment is processing
console.log('Processing payment...');
}
}, 3000); // Poll every 3 seconds
// Stop after 2 minutes to avoid infinite polling
setTimeout(() => clearInterval(poll), 120_000);
}