mautourco-components 0.2.66 → 0.2.67

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.
@@ -5,6 +5,7 @@ declare const columns: {
5
5
  isChild?: boolean;
6
6
  quote: import("../../../..").QuotationListItem;
7
7
  }) => (action: import("../../../..").ActionDropdownType) => void;
8
+ onBookNow?: (type: "request" | "book", value?: import("../../../..").QuotationListItem) => void;
8
9
  keywords?: string;
9
10
  }) => import("../TableCell").ColumnType<import("../../../..").QuotationListItem>[];
10
11
  detailResume: (params?: {
@@ -7,5 +7,6 @@ export declare const quotationColumns: (params: {
7
7
  isChild?: boolean;
8
8
  quote: QuotationListItem;
9
9
  }) => (action: ActionDropdownType) => void;
10
+ onBookNow?: (type: 'request' | 'book', value?: QuotationListItem) => void;
10
11
  keywords?: string;
11
12
  }) => ColumnType<QuotationListItem>[];
@@ -4,10 +4,11 @@ import Chip from '../../../atoms/Chip/Chip';
4
4
  import { Text } from '../../../atoms/Typography/Typography';
5
5
  import { ActionDropdown } from '../../../molecules/ActionDropdown/ActionDropdown';
6
6
  import { DateDisplay } from '../../../molecules/DateDisplay/DateDisplay';
7
+ import { TooltipDisplay } from '../../../molecules/TooltipDisplay/TooltipDisplay';
7
8
  import { cn } from '../../../../lib/utils';
8
9
  import { actionDropdownData, chipVariant, clientTypeMap } from '../constant';
9
10
  export var quotationColumns = function (_a) {
10
- var onExpand = _a.onExpand, onAction = _a.onAction, _b = _a.keywords, keywords = _b === void 0 ? '' : _b;
11
+ var onExpand = _a.onExpand, onAction = _a.onAction, onBookNow = _a.onBookNow, _b = _a.keywords, keywords = _b === void 0 ? '' : _b;
11
12
  return [
12
13
  {
13
14
  header: 'Quote nb.',
@@ -92,9 +93,13 @@ export var quotationColumns = function (_a) {
92
93
  if (raw.date[0]) {
93
94
  isPast = new Date(raw.date[0]) < new Date();
94
95
  }
95
- return (_jsx("div", { children: hasChildren ? (_jsx(Button, { variant: "outline-primary", size: "sm", trailingIcon: "chevron-down", className: cn('table__button', isExpanded && 'table__button-expanded'), onClick: function () { return onExpand === null || onExpand === void 0 ? void 0 : onExpand(raw, index, childIndex); }, children: buttonLabel })) : (_jsxs("div", { className: "flex items-center gap-x-8", children: [_jsx(Button, { variant: isOnRequest ? 'outline-secondary' : 'secondary', size: "sm", className: cn('table__button', {
96
- 'opacity-50 pointer-events-none': isPast,
97
- }), children: isOnRequest ? 'Request to book' : 'Book now' }), _jsx("div", { children: _jsx(ActionDropdown, { data: actionDropdownData((_b = onAction === null || onAction === void 0 ? void 0 : onAction({ isChild: childIndex !== undefined, quote: raw })) !== null && _b !== void 0 ? _b : (function () { })) }) })] })) }));
96
+ var buttonType = isOnRequest ? 'request' : 'book';
97
+ var getButton = function () {
98
+ return (_jsx(Button, { variant: isOnRequest ? 'outline-secondary' : 'secondary', size: "sm", onClick: isPast ? undefined : function () { return onBookNow === null || onBookNow === void 0 ? void 0 : onBookNow(buttonType, raw); }, className: cn('table__button', {
99
+ 'opacity-50 !cursor-not-allowed': isPast,
100
+ }), children: isOnRequest ? 'Request to book' : 'Book now' }));
101
+ };
102
+ return (_jsx("div", { children: hasChildren ? (_jsx(Button, { variant: "outline-primary", size: "sm", trailingIcon: "chevron-down", className: cn('table__button', isExpanded && 'table__button-expanded'), onClick: function () { return onExpand === null || onExpand === void 0 ? void 0 : onExpand(raw, index, childIndex); }, children: buttonLabel })) : (_jsxs("div", { className: "flex items-center gap-x-8", children: [isPast ? (_jsx(TooltipDisplay, { content: "This quotation cannot be booked because the service dates have already passed.", side: "left", maxWidth: "325px", children: getButton() })) : (getButton()), _jsx("div", { children: _jsx(ActionDropdown, { data: actionDropdownData((_b = onAction === null || onAction === void 0 ? void 0 : onAction({ isChild: childIndex !== undefined, quote: raw })) !== null && _b !== void 0 ? _b : (function () { })) }) })] })) }));
98
103
  },
99
104
  },
100
105
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mautourco-components",
3
- "version": "0.2.66",
3
+ "version": "0.2.67",
4
4
  "private": false,
5
5
  "description": "Bibliothèque de composants Mautourco pour le redesign",
6
6
  "main": "dist/index.js",
@@ -3,6 +3,7 @@ import Chip from '@/src/components/atoms/Chip/Chip';
3
3
  import { Text } from '@/src/components/atoms/Typography/Typography';
4
4
  import { ActionDropdown } from '@/src/components/molecules/ActionDropdown/ActionDropdown';
5
5
  import { DateDisplay } from '@/src/components/molecules/DateDisplay/DateDisplay';
6
+ import { TooltipDisplay } from '@/src/components/molecules/TooltipDisplay/TooltipDisplay';
6
7
  import { cn } from '@/src/lib/utils';
7
8
  import { ActionDropdownType } from '@/src/types/table/action-dropdown-type.types';
8
9
  import { QuotationListItem } from '@/src/types/table/quotation.types';
@@ -15,8 +16,14 @@ export const quotationColumns: (params: {
15
16
  isChild?: boolean;
16
17
  quote: QuotationListItem;
17
18
  }) => (action: ActionDropdownType) => void;
19
+ onBookNow?: (type: 'request' | 'book', value?: QuotationListItem) => void;
18
20
  keywords?: string;
19
- }) => ColumnType<QuotationListItem>[] = ({ onExpand, onAction, keywords = '' }) => [
21
+ }) => ColumnType<QuotationListItem>[] = ({
22
+ onExpand,
23
+ onAction,
24
+ onBookNow,
25
+ keywords = '',
26
+ }) => [
20
27
  {
21
28
  header: 'Quote nb.',
22
29
  key: 'file_nb',
@@ -158,6 +165,22 @@ export const quotationColumns: (params: {
158
165
  isPast = new Date(raw.date[0]) < new Date();
159
166
  }
160
167
 
168
+ const buttonType = isOnRequest ? 'request' : 'book';
169
+
170
+ const getButton = () => {
171
+ return (
172
+ <Button
173
+ variant={isOnRequest ? 'outline-secondary' : 'secondary'}
174
+ size="sm"
175
+ onClick={isPast ? undefined : () => onBookNow?.(buttonType, raw)}
176
+ className={cn('table__button', {
177
+ 'opacity-50 !cursor-not-allowed': isPast,
178
+ })}>
179
+ {isOnRequest ? 'Request to book' : 'Book now'}
180
+ </Button>
181
+ );
182
+ };
183
+
161
184
  return (
162
185
  <div>
163
186
  {hasChildren ? (
@@ -171,14 +194,17 @@ export const quotationColumns: (params: {
171
194
  </Button>
172
195
  ) : (
173
196
  <div className="flex items-center gap-x-8">
174
- <Button
175
- variant={isOnRequest ? 'outline-secondary' : 'secondary'}
176
- size="sm"
177
- className={cn('table__button', {
178
- 'opacity-50 pointer-events-none': isPast,
179
- })}>
180
- {isOnRequest ? 'Request to book' : 'Book now'}
181
- </Button>
197
+ {isPast ? (
198
+ <TooltipDisplay
199
+ content="This quotation cannot be booked because the service dates have already passed."
200
+ side="left"
201
+ maxWidth="325px">
202
+ {getButton()}
203
+ </TooltipDisplay>
204
+ ) : (
205
+ getButton()
206
+ )}
207
+
182
208
  <div>
183
209
  <ActionDropdown
184
210
  data={actionDropdownData(