import jQ from "jquery";
import BaseComponent from "../../../base-component";
import Selector from "../../../../helpers/selector";
import Labels from "../../../../helpers/labels";
import SearchResultPanelItem from "./search-result-panel-item";
/**
* Rebots meta tag.
* @extends BaseComponent
*/
class SearchResultTotal extends BaseComponent {
/**
* @constructs
*/
constructor() {
super();
this.$element = jQ(Selector.searchTotalResult);
this.total = 0;
this.panalType = SearchResultPanelItem.Enum.PRODUCT;
}
/**
* Replace the brackets in raw html template with proper values
* @returns {String} HTML string
*/
compileTemplate() {
var result = '';
if (this.total > 1) {
result = Labels.search.searchTotalResults;
} else {
result = Labels.search.searchTotalResult;
}
return result.replace(/{{ count }}/g, '<strong>' + this.total + '</strong>');
}
/**
* Render the search result total
*/
render() {
var html = this.compileTemplate();
this.$element.html(html);
}
setData(total, panalType) {
if (typeof total === 'number') {
this.total = total;
}
if (panalType) {
this.panalType = panalType;
}
}
}
export default SearchResultTotal;