mautourco-components 0.2.91 → 0.2.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
- import { DetailResumeAccommodation, DetailResumeExcursion, DetailResumeOtherService, DetailResumeTransfer } from '@/src/types/table';
1
+ import { ComparisonAccom, ComparisonData, ComparisonExcursion, ComparisonOtherService, ComparisonTransfer } from '@/src/types/table/multi-quote-comparison.types';
2
2
  import { ColumnType } from '../Table/TableCell';
3
3
  import './DialogComparison.css';
4
- export type ComparisonData = DetailResumeAccommodation | DetailResumeTransfer | DetailResumeExcursion | DetailResumeOtherService;
5
4
  export interface MultiComparisonData {
6
5
  id: string;
7
6
  name: string;
@@ -17,8 +16,8 @@ export interface DialogComparisonProps {
17
16
  filteredData: MultiComparisonData[];
18
17
  }) => void;
19
18
  }
20
- export declare const isComparisonAccommodation: (data: ComparisonData) => data is ComparisonData & DetailResumeAccommodation;
21
- export declare const isComparisonTransfer: (data: ComparisonData) => data is ComparisonData & DetailResumeTransfer;
22
- export declare const isComparisonExcursion: (data: ComparisonData) => data is ComparisonData & DetailResumeExcursion;
23
- export declare const isComparisonOtherService: (data: ComparisonData) => data is ComparisonData & DetailResumeOtherService;
19
+ export declare const isComparisonAccommodation: (data: ComparisonData) => data is ComparisonData & ComparisonAccom;
20
+ export declare const isComparisonTransfer: (data: ComparisonData) => data is ComparisonData & ComparisonTransfer;
21
+ export declare const isComparisonExcursion: (data: ComparisonData) => data is ComparisonData & ComparisonExcursion;
22
+ export declare const isComparisonOtherService: (data: ComparisonData) => data is ComparisonData & ComparisonOtherService;
24
23
  export declare function DialogComparison(props: DialogComparisonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,17 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ServiceType, } from '../../../types/table/index';
3
- import { useEffect, useState } from 'react';
13
+ import { ServiceType } from '../../../types/table/index';
14
+ import { useEffect, useMemo, useState } from 'react';
4
15
  import Button from '../../atoms/Button/Button';
5
16
  import Chip from '../../atoms/Chip/Chip';
6
17
  import MultiSelectDropdown from '../../molecules/MultiSelectDropdown/MultiSelectDropdown';
@@ -9,16 +20,16 @@ import { Table } from '../Table';
9
20
  import { columns as defaultColumns } from '../Table/columns';
10
21
  import './DialogComparison.css';
11
22
  export var isComparisonAccommodation = function (data) {
12
- return data.Type === ServiceType.ACCOMMODATION;
23
+ return data.serviceType === ServiceType.ACCOMMODATION;
13
24
  };
14
25
  export var isComparisonTransfer = function (data) {
15
- return data.Type === ServiceType.TRANSFER;
26
+ return data.serviceType === ServiceType.TRANSFER;
16
27
  };
17
28
  export var isComparisonExcursion = function (data) {
18
- return data.Type === ServiceType.EXCURSION;
29
+ return data.serviceType === ServiceType.EXCURSION;
19
30
  };
20
31
  export var isComparisonOtherService = function (data) {
21
- return data.Type === ServiceType.OTHER_SERVICE;
32
+ return data.serviceType === ServiceType.OTHER_SERVICE;
22
33
  };
23
34
  export function DialogComparison(props) {
24
35
  var open = props.open, data = props.data, columns = props.columns, setOpen = props.setOpen, onBookNow = props.onBookNow;
@@ -26,25 +37,18 @@ export function DialogComparison(props) {
26
37
  var _b = useState(data), filteredData = _b[0], setFilteredData = _b[1];
27
38
  var getTotalRows = function (comparisonData) {
28
39
  var totalMap = new Map();
29
- comparisonData.forEach(function (item) {
30
- if (isComparisonAccommodation(item)) {
31
- var currency = item.Currency;
32
- var total = parseFloat(item.Total) || 0;
33
- var currentTotal = totalMap.get(currency) || 0;
34
- totalMap.set(currency, currentTotal + total);
35
- }
36
- if (isComparisonTransfer(item) || isComparisonExcursion(item)) {
37
- var currency = item.Currency;
38
- var total = parseFloat(item.TotalPrice) || 0;
39
- var currentTotal = totalMap.get(currency) || 0;
40
- totalMap.set(currency, currentTotal + total);
41
- }
42
- if (isComparisonOtherService(item)) {
43
- var currency = item.currency;
44
- var total = parseFloat(item.total_price) || 0;
45
- var currentTotal = totalMap.get(currency) || 0;
46
- totalMap.set(currency, currentTotal + total);
40
+ var allDatas = comparisonData.flatMap(function (item) {
41
+ var _a;
42
+ if ((_a = item.children) === null || _a === void 0 ? void 0 : _a.length) {
43
+ return item.children;
47
44
  }
45
+ return item;
46
+ });
47
+ allDatas.forEach(function (item) {
48
+ var currency = item.currency;
49
+ var total = item.total || 0;
50
+ var currentTotal = totalMap.get(currency) || 0;
51
+ totalMap.set(currency, currentTotal + total);
48
52
  });
49
53
  return Object.fromEntries(totalMap);
50
54
  };
@@ -54,13 +58,29 @@ export function DialogComparison(props) {
54
58
  setFilteredData(data.filter(function (d) { return selectedValues.includes(d.id); }));
55
59
  }
56
60
  };
61
+ var remapFilteredData = useMemo(function () {
62
+ return filteredData.map(function (f) {
63
+ if (f.data.length > 0) {
64
+ f.data = f.data.map(function (d) {
65
+ if (isComparisonAccommodation(d)) {
66
+ d.children = d.rooms.map(function (r, index) {
67
+ return __assign(__assign({}, r), { serviceType: ServiceType.ACCOMMODATION, className: 'table__row-border-0', hotelName: index === 0 ? d.hotelName : '' });
68
+ });
69
+ }
70
+ return d;
71
+ });
72
+ }
73
+ return f;
74
+ });
75
+ }, [filteredData]);
57
76
  useEffect(function () {
58
77
  setSelectedValues(data.map(function (d) { return d.id; }));
78
+ setFilteredData(data);
59
79
  }, [data]);
60
80
  return (_jsx(DialogBookingConfirm, { title: "Comparison of the quotations", open: open, setOpen: setOpen, className: "!max-w-[1255px]", closeOnOverlayClick: true, children: _jsxs("div", { className: "dialog-comparison", children: [_jsx("div", { className: "dialog-comparison__filter", children: _jsx(MultiSelectDropdown, { options: data.map(function (d) { return ({
61
81
  id: d.id,
62
82
  label: d.name,
63
- }); }), selectedValues: selectedValues, onSelectionChange: handleSelectionChange, maxDisplayedChips: 2, useTextForMaxDisplayedChips: true }) }), _jsx("div", { className: "dialog-comparison__list", children: filteredData.map(function (d, index) { return (_jsxs("div", { className: "dialog-comparison__item", children: [_jsx(Chip, { label: d.name, color: "brand", type: "outline", size: "lg" }), _jsx(Table, { data: d.data, columns: columns || defaultColumns.comparison(), totalRows: getTotalRows(d.data), isTotalBorderDash: false, totalSubstractedSpace: 0 })] }, "cp-".concat(index))); }) }), _jsx("div", { className: "dialog-comparison__footer", children: _jsx(Button, { variant: "secondary", onClick: function () {
83
+ }); }), selectedValues: selectedValues, onSelectionChange: handleSelectionChange, maxDisplayedChips: 2, useTextForMaxDisplayedChips: true }) }), _jsx("div", { className: "dialog-comparison__list", children: remapFilteredData.map(function (d, index) { return (_jsxs("div", { className: "dialog-comparison__item", children: [_jsx(Chip, { label: d.name, color: "brand", type: "outline", size: "lg" }), _jsx(Table, { data: d.data, columns: columns || defaultColumns.comparison(), totalRows: getTotalRows(d.data), isTotalBorderDash: false, totalSubstractedSpace: 0, isGrouped: true })] }, "cp-".concat(index))); }) }), _jsx("div", { className: "dialog-comparison__footer", children: _jsx(Button, { variant: "secondary", onClick: function () {
64
84
  return onBookNow({
65
85
  selectedValues: selectedValues,
66
86
  filteredData: filteredData,
@@ -1,3 +1,3 @@
1
- import { ComparisonData } from '../../DialogComparison/DialogComparison';
1
+ import { ComparisonData } from '@/src/types/table/multi-quote-comparison.types';
2
2
  import { ColumnType } from '../TableCell';
3
3
  export declare const comparisonColumns: () => ColumnType<ComparisonData>[];
@@ -6,25 +6,24 @@ import { RowOtherServices } from '../../../molecules/TableServiceItem/RowOtherSe
6
6
  import { RowTransfer } from '../../../molecules/TableServiceItem/RowTransfer';
7
7
  import { priceFormatter } from '../../../../lib/price-formatter';
8
8
  import { ServiceType } from '../../../../types/table/index';
9
- import { isComparisonAccommodation, isComparisonExcursion, isComparisonOtherService, isComparisonTransfer, } from '../../DialogComparison/DialogComparison';
9
+ import { isComparisonAccommodation, isComparisonExcursion, isComparisonTransfer, } from '../../DialogComparison/DialogComparison';
10
10
  var COLUMNS_WIDTH = 532 / 3;
11
11
  export var comparisonColumns = function () {
12
12
  return [
13
13
  {
14
14
  header: 'Item',
15
- key: 'Type',
15
+ key: 'serviceType',
16
16
  width: COLUMNS_WIDTH,
17
17
  cell: function (value, raw) {
18
18
  if (isComparisonAccommodation(raw)) {
19
- var accom = raw;
20
- return (_jsx(RowAccommodation.FirstCol, { serviceName: raw.HotelName, offers: raw.Offers, status: raw.RoomStatus }));
19
+ return (_jsx(RowAccommodation.FirstCol, { serviceName: raw.hotelName, offers: raw.offers, status: raw.roomName }));
21
20
  }
22
21
  if (isComparisonExcursion(raw)) {
23
- return _jsx(RowExcursion.FirstCol, { serviceName: raw.ExcursionName });
22
+ return _jsx(RowExcursion.FirstCol, { serviceName: raw.name });
24
23
  }
25
24
  if (isComparisonTransfer(raw)) {
26
25
  var transfer = raw;
27
- return (_jsx(RowTransfer.FirstCol, { serviceName: transfer.VehicleTypeName, transferType: transfer.TransferType, from: transfer.LocationFromName, to: transfer.LocationToName }));
26
+ return (_jsx(RowTransfer.FirstCol, { serviceName: transfer.vehicleType, transferType: transfer.transferType, from: transfer.from, to: transfer.to }));
28
27
  }
29
28
  if (value === ServiceType.OTHER_SERVICE) {
30
29
  return _jsx(RowOtherServices.FirstCol, {});
@@ -34,28 +33,28 @@ export var comparisonColumns = function () {
34
33
  },
35
34
  {
36
35
  header: 'Details',
37
- key: 'Type',
36
+ key: 'serviceType',
38
37
  width: COLUMNS_WIDTH,
39
38
  cell: function (value, raw, index) {
40
39
  if (isComparisonAccommodation(raw)) {
41
40
  return (_jsx(RowAccommodation.DetailsCol, { data: {
42
- RoomName: raw.RoomName,
43
- Dates: raw.Dates,
44
- ClientCategory: raw.ClientCategory,
45
- MealPlan: raw.MealPlan,
46
- }, index: (index || 0) + 1 }));
41
+ RoomName: raw.roomName,
42
+ Dates: raw.dates,
43
+ ClientCategory: raw.clientType,
44
+ MealPlan: raw.mealPlan,
45
+ }, index: index }));
47
46
  }
48
47
  if (isComparisonExcursion(raw)) {
49
48
  return (_jsx(RowExcursion.DetailsCol, { data: {
50
- languages: raw.AvailableLanguages,
51
- duration: raw.Duration,
52
- accessibility: raw.Accessibility,
53
- transferType: raw.TransferType,
49
+ languages: raw.languages,
50
+ duration: raw.duration,
51
+ accessibility: raw.accessibility,
52
+ transferType: raw.transferType,
54
53
  } }));
55
54
  }
56
55
  if (isComparisonTransfer(raw)) {
57
56
  return (_jsx(RowTransfer.DetailsCol, { data: {
58
- carType: raw.VehicleTypeName,
57
+ carType: raw.vehicleType,
59
58
  clientType: 'STD',
60
59
  } }));
61
60
  }
@@ -67,29 +66,13 @@ export var comparisonColumns = function () {
67
66
  },
68
67
  {
69
68
  header: 'Price',
70
- key: 'Type',
69
+ key: 'serviceType',
71
70
  width: COLUMNS_WIDTH,
72
71
  cell: function (_value, raw) {
73
72
  var total = {
74
- currency: undefined,
75
- total: undefined,
73
+ currency: raw.currency,
74
+ total: String(raw.total),
76
75
  };
77
- if (isComparisonAccommodation(raw)) {
78
- total.currency = raw.Currency;
79
- total.total = raw.Total;
80
- }
81
- if (isComparisonExcursion(raw)) {
82
- total.currency = raw.Currency;
83
- total.total = raw.TotalPrice;
84
- }
85
- if (isComparisonTransfer(raw)) {
86
- total.currency = raw.Currency;
87
- total.total = raw.TotalPrice;
88
- }
89
- if (isComparisonOtherService(raw)) {
90
- total.currency = raw.currency;
91
- total.total = raw.total_price;
92
- }
93
76
  return (_jsx("div", { className: "flex items-center justify-between", children: _jsx(Text, { size: "sm", variant: "bold", children: priceFormatter(total.total, total.currency) }) }));
94
77
  },
95
78
  },
@@ -18,6 +18,6 @@ declare const columns: {
18
18
  bookingCancelService: (params?: {
19
19
  onRemove?: (value: import("../../../..").DetailResumeItem, index?: number, childIndex?: number) => void;
20
20
  }) => import("../TableCell").ColumnType<import("../../../..").DetailResumeItem>[];
21
- comparison: () => import("../TableCell").ColumnType<import("../../DialogComparison/DialogComparison").ComparisonData>[];
21
+ comparison: () => import("../TableCell").ColumnType<import("../../../..").ComparisonData>[];
22
22
  };
23
23
  export { columns };
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ export { DateDisplay } from './components/molecules/DateDisplay/DateDisplay';
17
17
  export { DocketPrices } from './components/molecules/DocketPrices/DocketPrices';
18
18
  export { PriceDisplay } from './components/molecules/PriceDisplay/PriceDisplay';
19
19
  export { TransferDocket } from './components/molecules/TransferDocket/TransferDocket';
20
- export { ActionDropdown, type ActionDropdownItem } from './components/molecules/ActionDropdown/ActionDropdown';
20
+ export { ActionDropdown, type ActionDropdownItem, } from './components/molecules/ActionDropdown/ActionDropdown';
21
21
  export { AddItemButton } from './components/molecules/AddItemButton/AddItemButton';
22
22
  export { default as AgeSelector } from './components/molecules/AgeSelector/AgeSelector';
23
23
  export * from './components/molecules/BookingResume';
@@ -42,7 +42,7 @@ export { default as TextWithIcon } from './components/molecules/TextWithIcon/Tex
42
42
  export { default as TimelineItem } from './components/molecules/TimelineItem/TimelineItem';
43
43
  export { default as Toast } from './components/molecules/Toast/Toast';
44
44
  export * from './components/molecules/TooltipDisplay/TooltipDisplay';
45
- export type { Supplement, SupplementValue, VehicleSupplementProps } from './components/molecules/VehicleSupplement';
45
+ export type { Supplement, SupplementValue, VehicleSupplementProps, } from './components/molecules/VehicleSupplement';
46
46
  export { default as VehicleSupplement } from './components/molecules/VehicleSupplement/VehicleSupplement';
47
47
  export { Illustration } from './components/atoms/Illustration/Illustration';
48
48
  export * from './components/molecules/BookingPax';
@@ -89,44 +89,44 @@ export { default as UserIcon } from './components/atoms/Icon/icons/User';
89
89
  export { priceFormatter } from './lib/price-formatter';
90
90
  export type { DividerProps } from './components/atoms/Divider/Divider';
91
91
  export type { FeatureRowProps } from './components/molecules/FeatureRow/FeatureRow';
92
- export type { LocationData, LocationDropdownProps, LocationGroup, LocationOption } from './components/molecules/LocationDropdown/LocationDropdown';
93
- export type { ServiceOption, ServiceSelectorProps, ServiceType } from './components/molecules/ServiceSelector/ServiceSelector';
92
+ export type { LocationData, LocationDropdownProps, LocationGroup, LocationOption, } from './components/molecules/LocationDropdown/LocationDropdown';
93
+ export type { ServiceOption, ServiceSelectorProps, ServiceType, } from './components/molecules/ServiceSelector/ServiceSelector';
94
94
  export type { StepperProps } from './components/molecules/Stepper/Stepper';
95
- export type { CarBookingCardPriceRow, CarBookingCardProps, CarBookingCardSize, CarBookingCardState, CarBookingCardType } from './components/organisms/CarBookingCard/CarBookingCard';
96
- export type { CardContainerProps, CardContainerSpacing } from './components/organisms/CardContainer/CardContainer';
95
+ export type { CarBookingCardPriceRow, CarBookingCardProps, CarBookingCardSize, CarBookingCardState, CarBookingCardType, } from './components/organisms/CarBookingCard/CarBookingCard';
96
+ export type { CardContainerProps, CardContainerSpacing, } from './components/organisms/CardContainer/CardContainer';
97
97
  export type { DateTimePickerProps } from './components/organisms/DateTimePicker/DateTimePicker';
98
98
  export type { DialogProps, DialogSize } from './components/organisms/Dialog/Dialog';
99
99
  export type { FooterProps } from './components/organisms/Footer/Footer';
100
- export type { DocketDetailsData, DocketServiceType, MultipleQuotationDocketProps } from './components/organisms/MultipleQuotationDocket';
100
+ export type { DocketDetailsData, DocketServiceType, MultipleQuotationDocketProps, } from './components/organisms/MultipleQuotationDocket';
101
101
  export { CHILD_CATEGORY_AGES } from './components/organisms/PaxSelector/PaxSelector';
102
- export type { ClientType, PaxData, PaxSelectorProps } from './components/organisms/PaxSelector/PaxSelector';
103
- export type { RoundTripData, RoundTripProps, RoundTripTransfer } from './components/organisms/RoundTrip/RoundTrip';
104
- export type { SearchBarTransferData, SearchBarTransferProps, TransferMode } from './components/organisms/SearchBarTransfer/SearchBarTransfer';
102
+ export type { ClientType, PaxData, PaxSelectorProps, } from './components/organisms/PaxSelector/PaxSelector';
103
+ export type { RoundTripData, RoundTripProps, RoundTripTransfer, } from './components/organisms/RoundTrip/RoundTrip';
104
+ export type { SearchBarTransferData, SearchBarTransferProps, TransferMode, } from './components/organisms/SearchBarTransfer/SearchBarTransfer';
105
105
  export type { TopNavigationProps } from './components/organisms/TopNavigation/TopNavigation';
106
- export type { TransferLineData, TransferLineProps, TransferType } from './components/organisms/TransferLine/TransferLine';
106
+ export type { TransferLineData, TransferLineProps, TransferType, } from './components/organisms/TransferLine/TransferLine';
107
107
  export type { CheckboxProps } from './components/atoms/Checkbox/Checkbox';
108
108
  export type { InputProps } from './components/atoms/Inputs/Input/Input';
109
109
  export type { AddItemButtonProps } from './components/molecules/AddItemButton/AddItemButton';
110
110
  export type { AgeSelectorProps } from './components/molecules/AgeSelector/AgeSelector';
111
- export type { BreadcrumbsItem, BreadcrumbsProps } from './components/molecules/Breadcrumbs/Breadcrumbs';
111
+ export type { BreadcrumbsItem, BreadcrumbsProps, } from './components/molecules/Breadcrumbs/Breadcrumbs';
112
112
  export type { DocketPricesProps } from './components/molecules/DocketPrices/DocketPrices';
113
113
  export type { FromToProps } from './components/molecules/FromTo/FromTo';
114
114
  export type { PaxChipsProps, PaxCount } from './components/molecules/PaxChips/PaxChips';
115
115
  export type { PriceDisplayProps } from './components/molecules/PriceDisplay/PriceDisplay';
116
116
  export type { SectionTitleProps } from './components/molecules/SectionTitle/SectionTitle';
117
- export type { DetailsColProps, ItemColProps, RowAccommodationProps, RowExcursionProps, RowTransferProps } from './components/molecules/TableServiceItem';
117
+ export type { DetailsColProps, ItemColProps, RowAccommodationProps, RowExcursionProps, RowTransferProps, } from './components/molecules/TableServiceItem';
118
118
  export type { ServiceAccommodationProps } from './components/molecules/TimelineItem/ServiceAccommodation';
119
119
  export type { ServiceExcursionProps } from './components/molecules/TimelineItem/ServiceExcursion';
120
120
  export type { ServiceTransferProps } from './components/molecules/TimelineItem/ServiceTransfer';
121
121
  export type { TimelineHeaderProps } from './components/molecules/TimelineItem/TimelineHeader';
122
122
  export type { ToastProps } from './components/molecules/Toast/Toast';
123
123
  export type { TransferDocketProps } from './components/molecules/TransferDocket/TransferDocket';
124
- export type { ComparisonData, DialogComparisonProps, MultiComparisonData } from './components/organisms/DialogComparison/DialogComparison';
124
+ export type { DialogComparisonProps, MultiComparisonData, } from './components/organisms/DialogComparison/DialogComparison';
125
125
  export type { DialogDeleteConfirmProps } from './components/organisms/DialogDeleteConfirm/DialogDeleteConfirm';
126
126
  export type { DialogQuoteRenameProps } from './components/organisms/DialogQuoteRename/DialogQuoteRename';
127
127
  export type { SelectedQuote } from './components/organisms/DialogSendingMail/DialogSendingMailMultiple/DialogSendingMailMultiple';
128
- export type { FilterType, QuoteHeaderProps } from './components/organisms/QuoteHeader/QuoteHeader';
129
- export type { TimelineProps, TimelineServices } from './components/organisms/Timeline/Timeline';
130
- export type { AccomodationDocket as AccomodationDocketType, ExcursionDocket as ExcursionDocketType, OtherServiceDocket as OtherServiceDocketType, ServiceDocket as ServiceDocketType, TransferDocket as TransferDocketType } from './types/docket/services.types';
128
+ export type { FilterType, QuoteHeaderProps, } from './components/organisms/QuoteHeader/QuoteHeader';
129
+ export type { TimelineProps, TimelineServices, } from './components/organisms/Timeline/Timeline';
130
+ export type { AccomodationDocket as AccomodationDocketType, ExcursionDocket as ExcursionDocketType, OtherServiceDocket as OtherServiceDocketType, ServiceDocket as ServiceDocketType, TransferDocket as TransferDocketType, } from './types/docket/services.types';
131
131
  export * from './types/table';
132
132
  export * from './hooks/useStays';
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ export { DocketPrices } from './components/molecules/DocketPrices/DocketPrices';
19
19
  export { PriceDisplay } from './components/molecules/PriceDisplay/PriceDisplay';
20
20
  export { TransferDocket } from './components/molecules/TransferDocket/TransferDocket';
21
21
  // Molecules - Composed components
22
- export { ActionDropdown } from './components/molecules/ActionDropdown/ActionDropdown';
22
+ export { ActionDropdown, } from './components/molecules/ActionDropdown/ActionDropdown';
23
23
  export { AddItemButton } from './components/molecules/AddItemButton/AddItemButton';
24
24
  export { default as AgeSelector } from './components/molecules/AgeSelector/AgeSelector';
25
25
  export * from './components/molecules/BookingResume';
@@ -1,3 +1,4 @@
1
1
  export * from './action-dropdown-type.types';
2
2
  export * from './detail-resume.types';
3
+ export * from './multi-quote-comparison.types';
3
4
  export * from './quotation.types';
@@ -1,3 +1,4 @@
1
1
  export * from './action-dropdown-type.types';
2
2
  export * from './detail-resume.types';
3
+ export * from './multi-quote-comparison.types';
3
4
  export * from './quotation.types';
@@ -0,0 +1,40 @@
1
+ import { TableRowData } from '@/src/components/organisms/Table';
2
+ import { Offer, ServiceType } from './detail-resume.types';
3
+ export interface ComparisonService {
4
+ serviceType: ServiceType;
5
+ currency: string;
6
+ total: number;
7
+ dates: string[];
8
+ }
9
+ export interface ComparisonAccomRoom extends TableRowData<ComparisonAccomRoom> {
10
+ roomName: string;
11
+ dates: string[];
12
+ clientType: string;
13
+ mealPlan: string;
14
+ roomStatus: string;
15
+ offers?: Offer[];
16
+ currency: string;
17
+ total: number;
18
+ }
19
+ export interface ComparisonAccom extends Omit<ComparisonAccomRoom, 'children'>, ComparisonService, TableRowData<ComparisonData> {
20
+ hotelName: string;
21
+ rooms: ComparisonAccomRoom[];
22
+ }
23
+ export interface ComparisonTransfer extends ComparisonService, TableRowData<ComparisonData> {
24
+ transferType: string;
25
+ from: string;
26
+ to: string;
27
+ vehicleType: string;
28
+ clientType: string;
29
+ }
30
+ export interface ComparisonExcursion extends ComparisonService, TableRowData<ComparisonData> {
31
+ name: string;
32
+ languages: string[];
33
+ duration: string;
34
+ transferType: string;
35
+ pickUpPoint: string;
36
+ accessibility: string;
37
+ }
38
+ export interface ComparisonOtherService extends ComparisonService, TableRowData<ComparisonData> {
39
+ }
40
+ export type ComparisonData = ComparisonAccom | ComparisonTransfer | ComparisonExcursion | ComparisonOtherService;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.91",
3
+ "version": "0.2.92",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Mautourco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -1,11 +1,12 @@
1
+ import { ServiceType } from '@/src/types/table';
1
2
  import {
2
- DetailResumeAccommodation,
3
- DetailResumeExcursion,
4
- DetailResumeOtherService,
5
- DetailResumeTransfer,
6
- ServiceType,
7
- } from '@/src/types/table';
8
- import { useEffect, useState } from 'react';
3
+ ComparisonAccom,
4
+ ComparisonData,
5
+ ComparisonExcursion,
6
+ ComparisonOtherService,
7
+ ComparisonTransfer,
8
+ } from '@/src/types/table/multi-quote-comparison.types';
9
+ import { useEffect, useMemo, useState } from 'react';
9
10
  import Button from '../../atoms/Button/Button';
10
11
  import Chip from '../../atoms/Chip/Chip';
11
12
  import MultiSelectDropdown from '../../molecules/MultiSelectDropdown/MultiSelectDropdown';
@@ -15,12 +16,6 @@ import { columns as defaultColumns } from '../Table/columns';
15
16
  import { ColumnType } from '../Table/TableCell';
16
17
  import './DialogComparison.css';
17
18
 
18
- export type ComparisonData =
19
- | DetailResumeAccommodation
20
- | DetailResumeTransfer
21
- | DetailResumeExcursion
22
- | DetailResumeOtherService;
23
-
24
19
  export interface MultiComparisonData {
25
20
  id: string;
26
21
  name: string;
@@ -40,26 +35,26 @@ export interface DialogComparisonProps {
40
35
 
41
36
  export const isComparisonAccommodation = (
42
37
  data: ComparisonData
43
- ): data is ComparisonData & DetailResumeAccommodation => {
44
- return data.Type === ServiceType.ACCOMMODATION;
38
+ ): data is ComparisonData & ComparisonAccom => {
39
+ return data.serviceType === ServiceType.ACCOMMODATION;
45
40
  };
46
41
 
47
42
  export const isComparisonTransfer = (
48
43
  data: ComparisonData
49
- ): data is ComparisonData & DetailResumeTransfer => {
50
- return data.Type === ServiceType.TRANSFER;
44
+ ): data is ComparisonData & ComparisonTransfer => {
45
+ return data.serviceType === ServiceType.TRANSFER;
51
46
  };
52
47
 
53
48
  export const isComparisonExcursion = (
54
49
  data: ComparisonData
55
- ): data is ComparisonData & DetailResumeExcursion => {
56
- return data.Type === ServiceType.EXCURSION;
50
+ ): data is ComparisonData & ComparisonExcursion => {
51
+ return data.serviceType === ServiceType.EXCURSION;
57
52
  };
58
53
 
59
54
  export const isComparisonOtherService = (
60
55
  data: ComparisonData
61
- ): data is ComparisonData & DetailResumeOtherService => {
62
- return data.Type === ServiceType.OTHER_SERVICE;
56
+ ): data is ComparisonData & ComparisonOtherService => {
57
+ return data.serviceType === ServiceType.OTHER_SERVICE;
63
58
  };
64
59
 
65
60
  export function DialogComparison(props: DialogComparisonProps) {
@@ -70,25 +65,18 @@ export function DialogComparison(props: DialogComparisonProps) {
70
65
  const getTotalRows = (comparisonData: ComparisonData[]) => {
71
66
  const totalMap = new Map<string, number>();
72
67
 
73
- comparisonData.forEach((item) => {
74
- if (isComparisonAccommodation(item)) {
75
- const currency = item.Currency;
76
- const total = parseFloat(item.Total) || 0;
77
- const currentTotal = totalMap.get(currency) || 0;
78
- totalMap.set(currency, currentTotal + total);
79
- }
80
- if (isComparisonTransfer(item) || isComparisonExcursion(item)) {
81
- const currency = item.Currency;
82
- const total = parseFloat(item.TotalPrice) || 0;
83
- const currentTotal = totalMap.get(currency) || 0;
84
- totalMap.set(currency, currentTotal + total);
85
- }
86
- if (isComparisonOtherService(item)) {
87
- const currency = item.currency;
88
- const total = parseFloat(item.total_price) || 0;
89
- const currentTotal = totalMap.get(currency) || 0;
90
- totalMap.set(currency, currentTotal + total);
68
+ const allDatas = comparisonData.flatMap((item) => {
69
+ if (item.children?.length) {
70
+ return item.children;
91
71
  }
72
+ return item;
73
+ });
74
+
75
+ allDatas.forEach((item) => {
76
+ const currency = item.currency;
77
+ const total = item.total || 0;
78
+ const currentTotal = totalMap.get(currency) || 0;
79
+ totalMap.set(currency, currentTotal + total);
92
80
  });
93
81
 
94
82
  return Object.fromEntries(totalMap);
@@ -101,8 +89,32 @@ export function DialogComparison(props: DialogComparisonProps) {
101
89
  }
102
90
  };
103
91
 
92
+ const remapFilteredData = useMemo(() => {
93
+ return filteredData.map((f) => {
94
+ if (f.data.length > 0) {
95
+ f.data = f.data.map((d) => {
96
+ if (isComparisonAccommodation(d)) {
97
+ d.children = d.rooms.map((r, index) => {
98
+ return {
99
+ ...r,
100
+ serviceType: ServiceType.ACCOMMODATION,
101
+ className: 'table__row-border-0',
102
+ hotelName: index === 0 ? d.hotelName : '',
103
+ };
104
+ }) as ComparisonData[];
105
+ }
106
+
107
+ return d;
108
+ });
109
+ }
110
+
111
+ return f;
112
+ });
113
+ }, [filteredData]);
114
+
104
115
  useEffect(() => {
105
116
  setSelectedValues(data.map((d) => d.id));
117
+ setFilteredData(data);
106
118
  }, [data]);
107
119
 
108
120
  return (
@@ -126,7 +138,7 @@ export function DialogComparison(props: DialogComparisonProps) {
126
138
  />
127
139
  </div>
128
140
  <div className="dialog-comparison__list">
129
- {filteredData.map((d, index) => (
141
+ {remapFilteredData.map((d, index) => (
130
142
  <div key={`cp-${index}`} className="dialog-comparison__item">
131
143
  <Chip label={d.name} color="brand" type="outline" size="lg" />
132
144
  <Table<ComparisonData>
@@ -135,6 +147,7 @@ export function DialogComparison(props: DialogComparisonProps) {
135
147
  totalRows={getTotalRows(d.data)}
136
148
  isTotalBorderDash={false}
137
149
  totalSubstractedSpace={0}
150
+ isGrouped
138
151
  />
139
152
  </div>
140
153
  ))}
@@ -5,11 +5,10 @@ import { RowOtherServices } from '@/src/components/molecules/TableServiceItem/Ro
5
5
  import { RowTransfer } from '@/src/components/molecules/TableServiceItem/RowTransfer';
6
6
  import { priceFormatter } from '@/src/lib/price-formatter';
7
7
  import { ServiceType } from '@/src/types/table';
8
+ import { ComparisonData } from '@/src/types/table/multi-quote-comparison.types';
8
9
  import {
9
- ComparisonData,
10
10
  isComparisonAccommodation,
11
11
  isComparisonExcursion,
12
- isComparisonOtherService,
13
12
  isComparisonTransfer,
14
13
  } from '../../DialogComparison/DialogComparison';
15
14
  import { ColumnType } from '../TableCell';
@@ -20,30 +19,29 @@ export const comparisonColumns: () => ColumnType<ComparisonData>[] = () => {
20
19
  return [
21
20
  {
22
21
  header: 'Item',
23
- key: 'Type',
22
+ key: 'serviceType',
24
23
  width: COLUMNS_WIDTH,
25
24
  cell: (value, raw) => {
26
25
  if (isComparisonAccommodation(raw)) {
27
- const accom = raw;
28
26
  return (
29
27
  <RowAccommodation.FirstCol
30
- serviceName={raw.HotelName as string}
31
- offers={raw.Offers}
32
- status={raw.RoomStatus}
28
+ serviceName={raw.hotelName as string}
29
+ offers={raw.offers}
30
+ status={raw.roomName}
33
31
  />
34
32
  );
35
33
  }
36
34
  if (isComparisonExcursion(raw)) {
37
- return <RowExcursion.FirstCol serviceName={raw.ExcursionName as string} />;
35
+ return <RowExcursion.FirstCol serviceName={raw.name as string} />;
38
36
  }
39
37
  if (isComparisonTransfer(raw)) {
40
38
  const transfer = raw;
41
39
  return (
42
40
  <RowTransfer.FirstCol
43
- serviceName={transfer.VehicleTypeName as string}
44
- transferType={transfer.TransferType}
45
- from={transfer.LocationFromName}
46
- to={transfer.LocationToName}
41
+ serviceName={transfer.vehicleType as string}
42
+ transferType={transfer.transferType}
43
+ from={transfer.from}
44
+ to={transfer.to}
47
45
  />
48
46
  );
49
47
  }
@@ -56,19 +54,19 @@ export const comparisonColumns: () => ColumnType<ComparisonData>[] = () => {
56
54
  },
57
55
  {
58
56
  header: 'Details',
59
- key: 'Type',
57
+ key: 'serviceType',
60
58
  width: COLUMNS_WIDTH,
61
59
  cell: (value, raw, index) => {
62
60
  if (isComparisonAccommodation(raw)) {
63
61
  return (
64
62
  <RowAccommodation.DetailsCol
65
63
  data={{
66
- RoomName: raw.RoomName,
67
- Dates: raw.Dates,
68
- ClientCategory: raw.ClientCategory,
69
- MealPlan: raw.MealPlan,
64
+ RoomName: raw.roomName,
65
+ Dates: raw.dates,
66
+ ClientCategory: raw.clientType,
67
+ MealPlan: raw.mealPlan,
70
68
  }}
71
- index={(index || 0) + 1}
69
+ index={index}
72
70
  />
73
71
  );
74
72
  }
@@ -76,10 +74,10 @@ export const comparisonColumns: () => ColumnType<ComparisonData>[] = () => {
76
74
  return (
77
75
  <RowExcursion.DetailsCol
78
76
  data={{
79
- languages: raw.AvailableLanguages,
80
- duration: raw.Duration,
81
- accessibility: raw.Accessibility,
82
- transferType: raw.TransferType,
77
+ languages: raw.languages,
78
+ duration: raw.duration,
79
+ accessibility: raw.accessibility,
80
+ transferType: raw.transferType,
83
81
  }}
84
82
  />
85
83
  );
@@ -88,7 +86,7 @@ export const comparisonColumns: () => ColumnType<ComparisonData>[] = () => {
88
86
  return (
89
87
  <RowTransfer.DetailsCol
90
88
  data={{
91
- carType: raw.VehicleTypeName,
89
+ carType: raw.vehicleType,
92
90
  clientType: 'STD',
93
91
  }}
94
92
  />
@@ -102,31 +100,14 @@ export const comparisonColumns: () => ColumnType<ComparisonData>[] = () => {
102
100
  },
103
101
  {
104
102
  header: 'Price',
105
- key: 'Type',
103
+ key: 'serviceType',
106
104
  width: COLUMNS_WIDTH,
107
105
  cell: (_value, raw) => {
108
106
  let total: Record<'currency' | 'total', string | undefined> = {
109
- currency: undefined,
110
- total: undefined,
107
+ currency: raw.currency,
108
+ total: String(raw.total),
111
109
  };
112
110
 
113
- if (isComparisonAccommodation(raw)) {
114
- total.currency = raw.Currency;
115
- total.total = raw.Total;
116
- }
117
- if (isComparisonExcursion(raw)) {
118
- total.currency = raw.Currency;
119
- total.total = raw.TotalPrice;
120
- }
121
- if (isComparisonTransfer(raw)) {
122
- total.currency = raw.Currency;
123
- total.total = raw.TotalPrice;
124
- }
125
- if (isComparisonOtherService(raw)) {
126
- total.currency = raw.currency;
127
- total.total = raw.total_price;
128
- }
129
-
130
111
  return (
131
112
  <div className="flex items-center justify-between">
132
113
  <Text size="sm" variant="bold">
@@ -1,3 +1,4 @@
1
1
  export * from './action-dropdown-type.types';
2
2
  export * from './detail-resume.types';
3
+ export * from './multi-quote-comparison.types';
3
4
  export * from './quotation.types';
@@ -0,0 +1,58 @@
1
+ import { TableRowData } from '@/src/components/organisms/Table';
2
+ import { Offer, ServiceType } from './detail-resume.types';
3
+
4
+ export interface ComparisonService {
5
+ serviceType: ServiceType;
6
+ currency: string;
7
+ total: number;
8
+ dates: string[];
9
+ }
10
+
11
+ export interface ComparisonAccomRoom extends TableRowData<ComparisonAccomRoom> {
12
+ roomName: string;
13
+ dates: string[];
14
+ clientType: string;
15
+ mealPlan: string;
16
+ roomStatus: string;
17
+ offers?: Offer[];
18
+ currency: string;
19
+ total: number;
20
+ }
21
+
22
+ export interface ComparisonAccom
23
+ extends
24
+ Omit<ComparisonAccomRoom, 'children'>,
25
+ ComparisonService,
26
+ TableRowData<ComparisonData> {
27
+ hotelName: string;
28
+ rooms: ComparisonAccomRoom[];
29
+ }
30
+
31
+ export interface ComparisonTransfer
32
+ extends ComparisonService, TableRowData<ComparisonData> {
33
+ transferType: string;
34
+ from: string;
35
+ to: string;
36
+ vehicleType: string;
37
+ clientType: string;
38
+ }
39
+
40
+ export interface ComparisonExcursion
41
+ extends ComparisonService, TableRowData<ComparisonData> {
42
+ name: string;
43
+ languages: string[];
44
+ duration: string;
45
+ transferType: string;
46
+ pickUpPoint: string;
47
+ accessibility: string;
48
+ }
49
+
50
+ export interface ComparisonOtherService
51
+ extends ComparisonService, TableRowData<ComparisonData> {}
52
+
53
+ // Forward declaration for ComparisonData
54
+ export type ComparisonData =
55
+ | ComparisonAccom
56
+ | ComparisonTransfer
57
+ | ComparisonExcursion
58
+ | ComparisonOtherService;