Search

코드가 글처럼 읽히게 하기 미니과제 - After

export function ProductPurchase({ id }) { const { data: product } = useSuspenseQuery(productQueryOption({ id })); return ( <div> <h1>{product.title}</h1> <p>{calculatePrice(product)}</p> <button onClick={() => { if (!validateStock(product.stock)) { return; } submitOrder({ productId: id, price: getFinalPrice(product), timestamp: Date.now(), }).then(() => { navigate('/success'); }); }} > 구매 </button> </div> ); } const getFinalPrice = product => { const { price } = calculatePrice(product); const discount = getDiscount(price); return price - discount; };
TypeScript
복사