Skip to content

Commit

Permalink
Add duplicate bid warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiehuang committed Jan 7, 2022
1 parent 5caa747 commit 1a4fc8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/components/bidpage/BidForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const PlaceBidButton = styled(Button)`
}
`;

const BidForm = () => {
const BidForm = ({ props }) => {
const { t } = useTranslation();
const { yobot, isAuthed, balance, address, refreshEvents } = useYobot();
const [validParams, setValidParams] = useState(false);
Expand Down Expand Up @@ -284,11 +284,19 @@ const BidForm = () => {
) : (
""
)}
{isAuthed && props.alreadyPlacedBid ? (
<Text mb="0.5em" fontSize="14px" color="red.500">
You&apos;ve already placed a bid on this project.
</Text>
) : (
""
)}
{!isAuthed ? (
<ConnectWallet fullWidth={true} darkerBackground={true} />
) : (
<PlaceBidButton
disabled={
props.alreadyPlacedBid ||
!validParams ||
insufficentFunds ||
bidPriceEmpty ||
Expand Down
8 changes: 4 additions & 4 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 [alreadyPlacedBid, setAlreadyPlacedBid] = useState(false);

const fetchUserOrdersAndTotalStats = async () => {
let _placed_orders = [];
Expand Down Expand Up @@ -48,9 +49,6 @@ const BidPageMain = ({ projectId }) => {
let _token_address = values["1"];
let _action_taken = values["4"];

// orders[msg.sender][_tokenAddress];
// for all orders for this token address, add qty

// TODO: implement orderID so easier to lookup orders to update order status & get stats... Otherwise need to loop thru all txs

// For this NFT contract,
Expand Down Expand Up @@ -107,6 +105,8 @@ const BidPageMain = ({ projectId }) => {
_cancelled_orders.reverse()
);

setAlreadyPlacedBid(_placed_orders.length > 0);

const highestBidInWei = Math.max(
highestFilledBidInWei,
Math.max(...Object.values(placedBidValuesForProject))
Expand Down Expand Up @@ -168,7 +168,7 @@ const BidPageMain = ({ projectId }) => {
<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 />
<BidForm props={{ alreadyPlacedBid }} />
<ProjectDetails
props={{
project: getProjectDetailsFromId(projectId),
Expand Down

0 comments on commit 1a4fc8a

Please sign in to comment.