|
|
@@ -305,20 +305,24 @@ const monthOptions = computed(() => {
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
- const months = [
|
|
|
- ...new Set(
|
|
|
- availableReferences.value
|
|
|
- .filter((reference) => reference.reference_year === selectedYear.value)
|
|
|
- .map((reference) => reference.reference_month),
|
|
|
- ),
|
|
|
- ];
|
|
|
+ const now = new Date();
|
|
|
+ const currentYear = now.getFullYear();
|
|
|
+ const currentMonth = now.getMonth() + 1;
|
|
|
+
|
|
|
+ const lastMonth =
|
|
|
+ selectedYear.value < currentYear
|
|
|
+ ? 12
|
|
|
+ : Math.min(currentMonth, 12);
|
|
|
+
|
|
|
+ const months = Array.from(
|
|
|
+ { length: lastMonth },
|
|
|
+ (_, index) => index + 1,
|
|
|
+ );
|
|
|
|
|
|
- return months
|
|
|
- .sort((a, b) => a - b)
|
|
|
- .map((month) => ({
|
|
|
- label: monthLabels[month - 1] ?? String(month),
|
|
|
- value: month,
|
|
|
- }));
|
|
|
+ return months.map((month) => ({
|
|
|
+ label: monthLabels[month - 1] ?? String(month),
|
|
|
+ value: month,
|
|
|
+ }));
|
|
|
});
|
|
|
|
|
|
//
|
|
|
@@ -410,27 +414,26 @@ const channelColorsMap = {
|
|
|
"API airbnb": "#ff8f93",
|
|
|
"API Decolar": "#c4b5fd",
|
|
|
"Sem canal": "#d3d3d3",
|
|
|
- "Raniery Kohler": "#7BB2AB",
|
|
|
+ Kizzo: "#7BB2AB",
|
|
|
};
|
|
|
|
|
|
-const ranieryFallbackPalette = [
|
|
|
- "#7bb2ab",
|
|
|
- "#8bbdb7",
|
|
|
- "#9bc8c3",
|
|
|
- "#abd3cf",
|
|
|
- "#bbdedb",
|
|
|
- "#cbe9e7",
|
|
|
-];
|
|
|
-
|
|
|
const channelsBarItems = computed(() => {
|
|
|
const channels = dashboard.value?.channels ?? [];
|
|
|
|
|
|
- let fallbackIndex = 0;
|
|
|
+ const knownChannels = [];
|
|
|
+ let kizzoReservations = 0;
|
|
|
+ let kizzoShare = 0;
|
|
|
|
|
|
- return channels.map((item, index) => {
|
|
|
- const fallbackColor =
|
|
|
- ranieryFallbackPalette[fallbackIndex++ % ranieryFallbackPalette.length];
|
|
|
+ for (const item of channels) {
|
|
|
+ if (channelColorsMap[item.channel] && item.channel !== "Kizzo") {
|
|
|
+ knownChannels.push(item);
|
|
|
+ } else {
|
|
|
+ kizzoReservations += item.reservations_count ?? 0;
|
|
|
+ kizzoShare += item.share_percentage ?? 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ const items = knownChannels.map((item, index) => {
|
|
|
return {
|
|
|
key: `${item.channel}-${index}`,
|
|
|
|
|
|
@@ -442,9 +445,23 @@ const channelsBarItems = computed(() => {
|
|
|
|
|
|
percentage: Number(item.share_percentage ?? 0),
|
|
|
|
|
|
- color: channelColorsMap[item.channel] ?? fallbackColor,
|
|
|
+ color: channelColorsMap[item.channel],
|
|
|
};
|
|
|
});
|
|
|
+
|
|
|
+ if (kizzoReservations > 0) {
|
|
|
+ items.push({
|
|
|
+ key: "Kizzo",
|
|
|
+ label: "Kizzo",
|
|
|
+ valueLabel: `${formatInteger(
|
|
|
+ kizzoReservations,
|
|
|
+ )} reservas (${formatPercent(kizzoShare, 1)})`,
|
|
|
+ percentage: Number(kizzoShare.toFixed(2)),
|
|
|
+ color: channelColorsMap["Kizzo"],
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return items;
|
|
|
});
|
|
|
|
|
|
const shortMonthLabel = (month, year) => {
|