Skip to content

Commit

Permalink
Add spinner & fix toast bug when order is submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiehuang committed Jan 7, 2022
1 parent 1a4fc8a commit 84fe82b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/components/bidpage/BidForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,18 @@ const BidForm = ({ props }) => {
onTxSubmitted(msg);
// resetFormInputs();
setPlacingBid(false);
props.onBidSubmitted(true);
},
async (msg) => {
onTxFailed(msg);
props.onBidSubmitted(false);
},
async (msg) => {
onTxConfirmed(msg);

// FIXME: we want to repull ALL events across all of Yobot every time a tx is confirmed?
refreshEvents();
props.onBidSubmitted(false);
},
async (msg) => {
userRejectedCallback();
Expand All @@ -181,6 +184,7 @@ const BidForm = ({ props }) => {
} catch (e) {
onTxFailed();
setPlacingBid(false);
props.onBidSubmitted(false);
console.error("Placing bid returned:", e);
}
};
Expand Down
9 changes: 7 additions & 2 deletions src/components/bidpage/BidPageMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const BidPageMain = ({ projectId }) => {
const [totalBids, setTotalBids] = useState("-");
const [highestBidInWei, setHighestBidInWei] = useState("-");
const [gettingActions, setGettingActions] = useState(true);
const [submittingBid, setSubmittingBid] = useState(false);
const [alreadyPlacedBid, setAlreadyPlacedBid] = useState(false);

const fetchUserOrdersAndTotalStats = async () => {
Expand Down Expand Up @@ -164,19 +165,23 @@ const BidPageMain = ({ projectId }) => {
return projectDetails;
}

const onBidSubmitted = (submitting) => {
setSubmittingBid(submitting);
};

return (
<div>
<div className="max-w-screen-lg m-auto mt-2 mt-12 text-gray-300 bg-black xl:max-w-7xl App font-Roboto sm:">
<div className="pb-6 mx-auto sm:pb-0 flex border border-gray-700 rounded-xl flex-col-reverse max-w-screen-xl m-auto bg-gray-800 sm:flex-row sm:mb-4">
<BidForm props={{ alreadyPlacedBid }} />
<BidForm props={{ alreadyPlacedBid, onBidSubmitted }} />
<ProjectDetails
props={{
project: getProjectDetailsFromId(projectId),
gettingActions: gettingActions,
}}
/>
</div>
<ProjectBidTable props={{ userBids, gettingActions }} />
<ProjectBidTable props={{ userBids, gettingActions, submittingBid }} />
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/bidpage/ProjectBidTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ProjectBidTable = ({ props }) => {
setCancellingOrder(false);
}, // txFailCallback
async (msg) => {
// txFailCallback
// txConfirmedCallback

// FIXME: we want to repull ALL events across all of Yobot every time a tx is confirmed?
onTxConfirmed(msg);
Expand Down Expand Up @@ -142,7 +142,7 @@ const ProjectBidTable = ({ props }) => {
</thead>

<tbody>
{props.gettingActions ? (
{isAuthed && (props.gettingActions || props.submittingBid) ? (
<tr className="p-4">
<Spinner
padding="1em"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/TransactionToasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const userRejectedCallback = async (msg = "❌ Transaction Rejected ❌") => {
};

// ** Callback for Transaction Confirmation **
const onTxConfirmed = async (msg = `💰 Minting Successfull💰`) => {
const onTxConfirmed = async (msg = "⚔️ Placed Order ⚔️") => {
// ** Then, let's toast **
toast.success(msg, {
position: "bottom-center",
Expand Down
2 changes: 1 addition & 1 deletion src/yobot-sdk/wrappers/ERC721LimitOrder/PlaceOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const placeOrder = async (
}
)
.on("receipt", () => {
txConfirmedCallback("⚔️ Placed Order ⚔️");
txConfirmedCallback();
});

// ** Just return the txn object **
Expand Down

1 comment on commit 84fe82b

@vercel
Copy link

@vercel vercel bot commented on 84fe82b Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.