refactor(Flows): utilize useQuery over useMutation

This commit is contained in:
Ali BARIN
2025-01-20 15:38:21 +00:00
parent 08c1abe193
commit b237b2a2bc
7 changed files with 26 additions and 75 deletions

View File

@@ -16,8 +16,7 @@ import useExportFlow from 'hooks/useExportFlow';
import useDownloadJsonAsFile from 'hooks/useDownloadJsonAsFile';
function ContextMenu(props) {
const { flowId, onClose, anchorEl, onDuplicateFlow, onDeleteFlow, appKey } =
props;
const { flowId, onClose, anchorEl, onDuplicateFlow, appKey } = props;
const enqueueSnackbar = useEnqueueSnackbar();
const formatMessage = useFormatMessage();
const queryClient = useQueryClient();
@@ -67,14 +66,12 @@ function ContextMenu(props) {
variant: 'success',
});
onDeleteFlow?.();
onClose();
}, [
deleteFlow,
appKey,
enqueueSnackbar,
formatMessage,
onDeleteFlow,
onClose,
queryClient,
]);
@@ -143,7 +140,6 @@ ContextMenu.propTypes = {
PropTypes.func,
PropTypes.shape({ current: PropTypes.instanceOf(Element) }),
]).isRequired,
onDeleteFlow: PropTypes.func,
onDuplicateFlow: PropTypes.func,
appKey: PropTypes.string,
};

View File

@@ -37,7 +37,7 @@ function FlowRow(props) {
const formatMessage = useFormatMessage();
const contextButtonRef = React.useRef(null);
const [anchorEl, setAnchorEl] = React.useState(null);
const { flow, onDuplicateFlow, onDeleteFlow, appKey } = props;
const { flow, onDuplicateFlow, appKey } = props;
const handleClose = () => {
setAnchorEl(null);
@@ -118,7 +118,6 @@ function FlowRow(props) {
flowId={flow.id}
onClose={handleClose}
anchorEl={anchorEl}
onDeleteFlow={onDeleteFlow}
onDuplicateFlow={onDuplicateFlow}
appKey={appKey}
/>
@@ -129,7 +128,6 @@ function FlowRow(props) {
FlowRow.propTypes = {
flow: FlowPropType.isRequired,
onDeleteFlow: PropTypes.func,
onDuplicateFlow: PropTypes.func,
appKey: PropTypes.string,
};