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.
		
		
		
		
		
			
		
			
				
					
					
						
							39 lines
						
					
					
						
							1017 B
						
					
					
				
			
		
		
	
	
							39 lines
						
					
					
						
							1017 B
						
					
					
				"use strict";
 | 
						|
 | 
						|
Object.defineProperty(exports, "__esModule", {
 | 
						|
  value: true
 | 
						|
});
 | 
						|
exports.useActionResponseHandler = void 0;
 | 
						|
 | 
						|
var _reactRouter = require("react-router");
 | 
						|
 | 
						|
var _appendForceRefresh = require("../../components/actions/utils/append-force-refresh");
 | 
						|
 | 
						|
var _useNotice = require("../use-notice");
 | 
						|
 | 
						|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
 | 
						|
const useActionResponseHandler = onActionCall => {
 | 
						|
  const location = (0, _reactRouter.useLocation)();
 | 
						|
  const navigate = (0, _reactRouter.useNavigate)();
 | 
						|
  const addNotice = (0, _useNotice.useNotice)();
 | 
						|
  return response => {
 | 
						|
    const {
 | 
						|
      data
 | 
						|
    } = response;
 | 
						|
 | 
						|
    if (data.notice) {
 | 
						|
      addNotice(data.notice);
 | 
						|
    }
 | 
						|
 | 
						|
    if (data.redirectUrl && location.pathname !== data.redirectUrl) {
 | 
						|
      const appended = (0, _appendForceRefresh.appendForceRefresh)(data.redirectUrl);
 | 
						|
      navigate(appended);
 | 
						|
    }
 | 
						|
 | 
						|
    if (onActionCall) {
 | 
						|
      onActionCall(data);
 | 
						|
    }
 | 
						|
  };
 | 
						|
};
 | 
						|
 | 
						|
exports.useActionResponseHandler = useActionResponseHandler; |