Skip to content

Commit

Permalink
fixed accept/decline all
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristen Yee authored and Kristen Yee committed Apr 18, 2024
1 parent 9a14232 commit aa8a09f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/Notifications/AccountNotification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ const AccountNotification = ({
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));

const [removeNotificationBlock, setRemoveNotificationBlock] = useState(false);
let timeoutId = undefined;
const [timeoutId, setTimeoutId] = useState(undefined);
// let timeoutId = undefined;

const acceptAll = async accounts => {
console.log('calling accept all function');

const timeId = setTimeout(async () => {
console.log("calling approve callback map");
await Promise.all(
accounts.map(async account => {
await account.approveCallback();
Expand All @@ -51,7 +53,8 @@ const AccountNotification = ({
setRemoveNotificationBlock(true);
setApproveAfterTimer(true);
}, 5000); // set 5 sec timer for accept all requests
timeoutId=timeId;
console.log("set timeoutid in accept all: ", timeId);
setTimeoutId(timeId);

// toast({
// title: `Approved ${accounts?.length} accounts.`,
Expand All @@ -77,8 +80,7 @@ const AccountNotification = ({
setRemoveNotificationBlock(true);
setDeclineAfterTimer(true);
}, 5000); // set 5 sec timer for accept all requests
timeoutId=timeId;

setTimeoutId(timeId);
// toast({
// title: `Declined ${accounts?.length} accounts.`,
// status: 'info',
Expand All @@ -91,9 +93,9 @@ const AccountNotification = ({

const undoAll = async () => {
console.log('calling undo all function');
console.log("clearing timeoutid from undoall");
console.log("clearing timeoutid from undoall: ", timeoutId);
clearTimeout(timeoutId);
timeoutId = undefined;
setTimeoutId(undefined);
console.log("undo called, set remove notif block false");
setRemoveNotificationBlock(false);
setApproveAfterTimer(false);
Expand Down

0 comments on commit aa8a09f

Please sign in to comment.