You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constNewTicket=()=>{return(<div><h1>Create a Ticket</h1><form><divclassName="form-group"><label>Title</label><inputclassName="form-control"/></div><divclassName="form-group"><label>Price</label><inputclassName="form-control"/></div><buttonclassName="btn btn-primary">Submit</button></form></div>);};exportdefaultNewTicket;
import{useState}from'react';constNewTicket=()=>{const[title,setTitle]=useState('');const[price,setPrice]=useState('');constonBlur=()=>{constvalue=parseFloat(price);if(isNaN(value)){return;}setPrice(value.toFixed(2));};return(<div><h1>Create a Ticket</h1><form><divclassName="form-group"><label>Title</label><inputvalue={title}onChange={(e)=>setTitle(e.target.value)}className="form-control"/></div><divclassName="form-group"><label>Price</label><inputvalue={price}onBlur={onBlur}onChange={(e)=>setPrice(e.target.value)}className="form-control"/></div><buttonclassName="btn btn-primary">Submit</button></form></div>);};exportdefaultNewTicket;
import{useEffect,useState}from'react';constOrderShow=({ order })=>{const[timeLeft,setTimeLeft]=useState('');useEffect(()=>{constfindTimeLeft=()=>{constmsLeft=newDate(order.expiresAt)-newDate();setTimeLeft(Math.round(msLeft/1000));};findTimeLeft();consttimerId=setInterval(findTimeLeft,1000);return()=>{clearInterval(timerId);};},[order]);return<div>Time left to pay: {timeLeft} seconds</div>;};OrderShow.getInitialProps=async(context,client)=>{const{ orderId }=context.query;const{ data }=awaitclient.get(`/api/orders/${orderId}`);return{order: data};};exportdefaultOrderShow;
return(<div>
Time left to pay: {timeLeft} seconds
<StripeCheckouttoken={(token)=>console.log(token)}stripeKey="pk_test_FlLFVapGHTly3FicMdTU06SC006tWtWbNH"amount={order.ticket.price*100}email={currentUser.email}/></div>);