You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
import { useCallback, useState } from 'react';
|
|
import { useMetricEvent } from './useMetricEvent';
|
|
|
|
/**
|
|
* @typedef {Object} RetryTransactionReturnValue
|
|
* @property {(event: Event) => void} retryTransaction - open edit gas popover
|
|
* to begin setting retry gas fees
|
|
* @property {boolean} showRetryEditGasPopover - Whether to show the popover
|
|
* @property {() => void} closeRetryEditGasPopover - close the popover.
|
|
*/
|
|
|
|
/**
|
|
* Provides a reusable hook that, given a transactionGroup, will return
|
|
* a method for beginning the retry process
|
|
* @param {Object} transactionGroup - the transaction group
|
|
* @return {RetryTransactionReturnValue}
|
|
*/
|
|
export function useRetryTransaction() {
|
|
const trackMetricsEvent = useMetricEvent({
|
|
eventOpts: {
|
|
category: 'Navigation',
|
|
action: 'Activity Log',
|
|
name: 'Clicked "Speed Up"',
|
|
},
|
|
});
|
|
const [showRetryEditGasPopover, setShowRetryEditGasPopover] = useState(false);
|
|
|
|
const closeRetryEditGasPopover = () => setShowRetryEditGasPopover(false);
|
|
|
|
const retryTransaction = useCallback(
|
|
async (event) => {
|
|
event.stopPropagation();
|
|
setShowRetryEditGasPopover(true);
|
|
trackMetricsEvent();
|
|
},
|
|
[trackMetricsEvent],
|
|
);
|
|
|
|
return {
|
|
retryTransaction,
|
|
showRetryEditGasPopover,
|
|
closeRetryEditGasPopover,
|
|
};
|
|
}
|
|
|