/**
* App eCommerce review
*/
'use strict';
// apex-chart
document.addEventListener('DOMContentLoaded', function (e) {
let cardColor, shadeColor, labelColor, headingColor, borderColor, bodyBg;
if (isDarkStyle) {
shadeColor = 'dark';
} else {
shadeColor = '';
}
cardColor = config.colors.cardColor;
labelColor = config.colors.textMuted;
headingColor = config.colors.headingColor;
borderColor = config.colors.borderColor;
bodyBg = config.colors.bodyBg;
// Visitor Bar Chart
// --------------------------------------------------------------------
const visitorBarChartEl = document.querySelector('#reviewsChart'),
visitorBarChartConfig = {
chart: {
height: 160,
width: 190,
type: 'bar',
toolbar: {
show: false
}
},
plotOptions: {
bar: {
barHeight: '75%',
columnWidth: '40%',
startingShape: 'rounded',
endingShape: 'rounded',
borderRadius: 5,
distributed: true
}
},
grid: {
show: false,
padding: {
top: -3,
bottom: -12
}
},
colors: [
config.colors_label.success,
config.colors_label.success,
config.colors_label.success,
config.colors_label.success,
config.colors.success,
config.colors_label.success,
config.colors_label.success
],
dataLabels: {
enabled: false
},
series: [
{
data: [20, 40, 60, 80, 100, 80, 60]
}
],
legend: {
show: false
},
xaxis: {
categories: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
axisBorder: {
show: false
},
axisTicks: {
show: false
},
labels: {
style: {
colors: labelColor,
fontSize: '13px'
}
}
},
yaxis: {
labels: {
show: false
}
},
responsive: [
{
breakpoint: 0,
options: {
chart: {
width: '100%'
},
plotOptions: {
bar: {
columnWidth: '40%'
}
}
}
},
{
breakpoint: 1440,
options: {
chart: {
height: 150,
width: 190,
toolbar: {
show: false
}
},
plotOptions: {
bar: {
borderRadius: 6,
columnWidth: '40%'
}
}
}
},
{
breakpoint: 1400,
options: {
plotOptions: {
bar: {
borderRadius: 6,
columnWidth: '40%'
}
}
}
},
{
breakpoint: 1200,
options: {
chart: {
height: 130,
width: 190,
toolbar: {
show: false
}
},
plotOptions: {
bar: {
borderRadius: 6,
columnWidth: '40%'
}
}
}
},
{
breakpoint: 992,
chart: {
height: 150,
width: 190,
toolbar: {
show: false
}
},
options: {
plotOptions: {
bar: {
borderRadius: 5,
columnWidth: '40%'
}
}
}
},
{
breakpoint: 883,
options: {
plotOptions: {
bar: {
borderRadius: 5,
columnWidth: '40%'
}
}
}
},
{
breakpoint: 768,
options: {
chart: {
height: 150,
width: 190,
toolbar: {
show: false
}
},
plotOptions: {
bar: {
borderRadius: 4,
columnWidth: '40%'
}
}
}
},
{
breakpoint: 576,
options: {
chart: {
width: '100%',
height: '200',
type: 'bar'
},
plotOptions: {
bar: {
borderRadius: 6,
columnWidth: '30% '
}
}
}
},
{
breakpoint: 420,
options: {
plotOptions: {
chart: {
width: '100%',
height: '200',
type: 'bar'
},
bar: {
borderRadius: 3,
columnWidth: '30%'
}
}
}
}
],
states: {
hover: {
filter: {
type: 'none'
}
},
active: {
filter: {
type: 'none'
}
}
}
};
if (typeof visitorBarChartEl !== undefined && visitorBarChartEl !== null) {
const visitorBarChart = new ApexCharts(visitorBarChartEl, visitorBarChartConfig);
visitorBarChart.render();
}
// Variable declaration for table
var dt_customer_review = document.querySelector('.datatables-review'),
customerView = 'app-ecommerce-customer-details-overview.html',
statusObj = {
Pending: { title: 'Pending', class: 'bg-label-warning' },
Published: { title: 'Published', class: 'bg-label-success' }
};
// reviewer datatable
if (dt_customer_review) {
const reviewFilter = document.createElement('div');
reviewFilter.classList.add('review_filter');
var dt_review = new DataTable(dt_customer_review, {
ajax: assetsPath + 'json/app-ecommerce-reviews.json', // JSON file to add data
columns: [
// columns according to JSON
{ data: 'id' },
{ data: 'id', orderable: false, render: DataTable.render.select() },
{ data: 'product' },
{ data: 'reviewer' },
{ data: 'review' },
{ data: 'date' },
{ data: 'status' },
{ data: 'id' }
],
columnDefs: [
{
// For Responsive
className: 'control',
searchable: false,
orderable: false,
responsivePriority: 2,
targets: 0,
render: function (data, type, full, meta) {
return '';
}
},
{
// For Checkboxes
targets: 1,
orderable: false,
searchable: false,
responsivePriority: 3,
checkboxes: true,
render: function () {
return '';
},
checkboxes: {
selectAllRender: ''
}
},
{
targets: 2,
render: function (data, type, full, meta) {
const product = full['product'];
const companyName = full['company_name'];
const id = full['id'];
const image = full['product_image'];
let output;
if (image) {
// For Product image
output = `
`;
} else {
// For Avatar badge
const stateNum = Math.floor(Math.random() * 6);
const states = ['success', 'danger', 'warning', 'info', 'dark', 'primary', 'secondary'];
const state = states[stateNum];
const initials = (product.match(/\b\w/g) || []).slice(0, 2).join('').toUpperCase();
output = `${initials}`;
}
// Creates full output for product and company name
const rowOutput = `
${firstCap}
${comment}