fix(buy button): Improved modal messages

This commit is contained in:
Chris Troutner
2025-03-16 06:46:08 -07:00
parent 82b86724eb
commit 28c515ea9b
4 changed files with 33 additions and 5 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ function AppBody (props) {
return ( return (
<> <>
<Routes> <Routes>
<Route path='/' element={<NftsForSale appData={appData} />} />} /> <Route path='/' element={<NftsForSale appData={appData} />} />
<Route path='/balance' element={<GetBalance wallet={appData.wallet} />} /> <Route path='/balance' element={<GetBalance wallet={appData.wallet} />} />
<Route path='/bch' element={<BchSend appData={appData} />} /> <Route path='/bch' element={<BchSend appData={appData} />} />
<Route path='/wallet' element={<Wallet appData={appData} />} /> <Route path='/wallet' element={<Wallet appData={appData} />} />
@@ -17,7 +17,9 @@ function BuyButton (props) {
const [noteId, setNoteId] = useState(false) // show the note id const [noteId, setNoteId] = useState(false) // show the note id
const [success, setSuccess] = useState(false) // show the success message const [success, setSuccess] = useState(false) // show the success message
const [showConfirmation, setShowConfirmation] = useState(true) // show the confirmation view const [showConfirmation, setShowConfirmation] = useState(true) // show the confirmation view
const [progressMsg, setProgressMsg] = useState([]) // show the progress message
// Handler for when user clicks the "Buy" button.
const handleBuy = async () => { const handleBuy = async () => {
try { try {
console.log('handleBuy()') console.log('handleBuy()')
@@ -33,6 +35,11 @@ function BuyButton (props) {
setOnFetch(false) setOnFetch(false)
return return
*/ */
const progress = progressMsg
progress.push(<p key='progress-msg1'>Generating counter offer transaction...</p>)
setProgressMsg(progress)
const targetOffer = token.nostrEventId const targetOffer = token.nostrEventId
console.log('targetOffer: ', targetOffer) console.log('targetOffer: ', targetOffer)
@@ -42,6 +49,9 @@ function BuyButton (props) {
targetOffer targetOffer
) )
progress.push(<p key='progress-msg2'>Uploading counter offer to Nostr...</p>)
setProgressMsg(progress)
console.log('offerData: ', offerData) console.log('offerData: ', offerData)
console.log('partialHex: ', partialHex) console.log('partialHex: ', partialHex)
@@ -66,6 +76,7 @@ function BuyButton (props) {
} }
} }
// Handler for when user requests to close the modal.
const handleClose = () => { const handleClose = () => {
console.log('handleClose()') console.log('handleClose()')
// Deny close if the purchase is in progress. // Deny close if the purchase is in progress.
@@ -105,6 +116,7 @@ function BuyButton (props) {
> >
Buy Buy
</Button> </Button>
<Modal show={show} onHide={handleClose} dialogClassName='buy-modal'> <Modal show={show} onHide={handleClose} dialogClassName='buy-modal'>
<Modal.Header closeButton> <Modal.Header closeButton>
<Modal.Title> <Modal.Title>
@@ -117,7 +129,9 @@ function BuyButton (props) {
)} )}
</Modal.Title> </Modal.Title>
</Modal.Header> </Modal.Header>
<Modal.Body className='text-center'> <Modal.Body className='text-center'>
{/** If the purchase is not confirmed, display the token details. and confirm button. */} {/** If the purchase is not confirmed, display the token details. and confirm button. */}
{showConfirmation && ( {showConfirmation && (
<Container className='text-start'> <Container className='text-start'>
@@ -147,7 +161,13 @@ function BuyButton (props) {
{/** show purchase progress */} {/** show purchase progress */}
<Container style={{ wordBreak: 'break-word' }}> <Container style={{ wordBreak: 'break-word' }}>
{onFetch && <Spinner animation='border' variant='primary' />} {onFetch && (
<>
<Spinner animation='border' variant='primary' />
{progressMsg}
</>
)}
{error && ( {error && (
<span style={{ color: 'red', fontStyle: 'italic' }}>{error}</span> <span style={{ color: 'red', fontStyle: 'italic' }}>{error}</span>
)} )}
@@ -165,10 +185,18 @@ function BuyButton (props) {
{noteId} {noteId}
</a> </a>
</p> </p>
<p>
What happens now:<br />
The Seller software must finalize the sale by accepting the Counter Offer transaction you just generated.
If their software is online, the token should appear in your wallet within a few minutes.
Before it is accepted, you can cancel the purchase by Sweeping your Counter Offer UXTO back to your wallet.
</p>
</> </>
)} )}
</Container> </Container>
</Modal.Body> </Modal.Body>
<Modal.Footer className='text-center'> <Modal.Footer className='text-center'>
{showConfirmation && ( {showConfirmation && (
<Row style={{ width: '100%' }}> <Row style={{ width: '100%' }}>
@@ -243,7 +243,7 @@ function NftsForSale (props) {
{/** Show spinner info if tokens are loaded but data is not loaded */ {/** Show spinner info if tokens are loaded but data is not loaded */
offersAreLoaded && !dataAreLoaded && ( offersAreLoaded && !dataAreLoaded && (
<div style={{ borderRadius: '10px', backgroundColor: '#f0f0f0', padding: '10px', display: 'flex', justifyContent: 'center', alignItems: 'center', width: 'fit-content' }}> <div style={{ borderRadius: '10px', backgroundColor: '#f0f0f0', padding: '10px', display: 'flex', justifyContent: 'center', alignItems: 'center', width: 'fit-content' }}>
<span style={{ marginRight: '10px' }}>Loading Tokens Data </span> <span style={{ marginRight: '10px' }}>Loading Token Data </span>
<Spinner animation='border' /> <Spinner animation='border' />
</div> </div>
) )
@@ -251,7 +251,7 @@ function NftsForSale (props) {
{/** Show spinner info if tokens are loaded but icons are not loaded */ {/** Show spinner info if tokens are loaded but icons are not loaded */
dataAreLoaded && !iconsAreLoaded && ( dataAreLoaded && !iconsAreLoaded && (
<div style={{ borderRadius: '10px', backgroundColor: '#f0f0f0', padding: '10px', display: 'flex', justifyContent: 'center', alignItems: 'center', width: 'fit-content' }}> <div style={{ borderRadius: '10px', backgroundColor: '#f0f0f0', padding: '10px', display: 'flex', justifyContent: 'center', alignItems: 'center', width: 'fit-content' }}>
<span style={{ marginRight: '10px' }}>Loading Tokens Icons </span> <span style={{ marginRight: '10px' }}>Loading Token Icons </span>
<Spinner animation='border' /> <Spinner animation='border' />
</div> </div>
) )
+1 -1
View File
@@ -78,7 +78,7 @@ function NavMenu (props) {
> >
Check Balance Check Balance
</NavLink> </NavLink>
</Nav> </Nav>
</Navbar.Collapse> </Navbar.Collapse>
</Navbar> </Navbar>