@rsc-labs/medusa-store-analytics
Version:
Get analytics data about your store
37 lines (36 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SalesByNewChart = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
/*
* Copyright 2024 RSC-Labs, https://rsoftcon.com/
*
* MIT License
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const ui_1 = require("@medusajs/ui");
const chart_components_1 = require("../common/chart-components");
const helpers_1 = require("../utils/helpers");
const SalesByNewChart = ({ salesHistoryResponse, compareEnabled }) => {
const rawChartData = {
current: salesHistoryResponse.analytics.current.map(currentData => {
return {
date: new Date(currentData.date),
value: (0, helpers_1.amountToDisplay)(parseInt(currentData.total), salesHistoryResponse.analytics.currencyDecimalDigits)
};
}),
previous: salesHistoryResponse.analytics.previous.map(previousData => {
return {
date: new Date(previousData.date),
value: (0, helpers_1.amountToDisplay)(parseInt(previousData.total), salesHistoryResponse.analytics.currencyDecimalDigits)
};
}),
};
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.Heading, { level: "h3", children: "Sales by time" }), (0, jsx_runtime_1.jsx)(chart_components_1.ChartCurrentPrevious, { rawChartData: rawChartData, fromDate: new Date(salesHistoryResponse.analytics.dateRangeFrom), toDate: new Date(salesHistoryResponse.analytics.dateRangeTo), fromCompareDate: salesHistoryResponse.analytics.dateRangeFromCompareTo ? new Date(salesHistoryResponse.analytics.dateRangeFromCompareTo) : undefined, toCompareDate: salesHistoryResponse.analytics.dateRangeToCompareTo ? new Date(salesHistoryResponse.analytics.dateRangeToCompareTo) : undefined, compareEnabled: compareEnabled })] }));
};
exports.SalesByNewChart = SalesByNewChart;