facetwp redirect category selection

(function($) {
    $(document).on('facetwp-refresh', function() {
        if ( 'fr/accueil' == FWP_HTTP.uri && 'undefined' !== typeof FWP.facets['categories'] && FWP.facets['categories'].length > 0  ) {
            var query = FWP.build_query_string();
            window.location.href = '/search-results/?' + query;
        }
    });
})(jQuery);