oa-componentbook 1.0.1-stage.4 → 1.0.1-stage.40

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.
Files changed (31) hide show
  1. package/build/components/oa-component-accordion/Accordion.js +16 -5
  2. package/build/components/oa-component-feedback-form/FeedbackForm.js +75 -0
  3. package/build/components/oa-component-feedback-tooltip/FeedbackTooltip.js +69 -0
  4. package/build/components/oa-component-info/CustomInfo.js +9 -4
  5. package/build/components/oa-component-info/styles.js +3 -3
  6. package/build/global-css/GridLayout.js +1 -1
  7. package/build/images/oaChat.svg +5 -0
  8. package/build/index.js +17 -3
  9. package/build/layout/paymentAndConsent/CancelScreen.js +46 -0
  10. package/build/layout/paymentAndConsent/ConsentCard.js +68 -0
  11. package/build/layout/paymentAndConsent/DetailsCard.js +75 -0
  12. package/build/layout/paymentAndConsent/DetailsList.js +38 -0
  13. package/build/layout/paymentAndConsent/Header.js +33 -0
  14. package/build/layout/paymentAndConsent/InProgressScreen.js +46 -0
  15. package/build/layout/paymentAndConsent/Loader.js +21 -0
  16. package/build/layout/paymentAndConsent/Modal.js +28 -0
  17. package/build/layout/paymentAndConsent/PaymentAndConsent.js +22 -0
  18. package/build/layout/paymentAndConsent/PaymentCard.js +83 -0
  19. package/build/layout/paymentAndConsent/Section.js +34 -0
  20. package/build/layout/paymentAndConsent/SuccessScreen.js +46 -0
  21. package/build/layout/paymentAndConsent/TimeLineCard.js +28 -0
  22. package/build/layout/paymentAndConsent/TncList.js +32 -0
  23. package/build/layout/paymentAndConsent/style.js +12 -0
  24. package/build/widgets/oa-widget-feedback/FeedbackWidget.js +83 -0
  25. package/build/widgets/oa-widget-feedback/styles.js +13 -0
  26. package/build/widgets/oa-widget-track-shipment/TrackShipmentWidget.js +28 -6
  27. package/build/widgets/oa-widget-track-shipment-list/TrackShipmentWidgetList.js +103 -0
  28. package/build/widgets/oa-widget-track-shipment-list/fn.js +69 -0
  29. package/package.json +4 -1
  30. package/build/dev/oa-widget-track-shipment/TrackShipmentWidget.js +0 -195
  31. /package/build/{dev/oa-widget-track-shipment → widgets/oa-widget-track-shipment-list}/styles.js +0 -0
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _fn = require("./fn");
10
+ var _TrackShipmentWidget = _interopRequireDefault(require("../oa-widget-track-shipment/TrackShipmentWidget"));
11
+ var _Accordion = _interopRequireDefault(require("../../components/oa-component-accordion/Accordion"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function TrackShipmentWidgetList(_ref) {
14
+ var _assignments$map;
15
+ let {
16
+ shipmentData,
17
+ onChange
18
+ } = _ref;
19
+ const assignments = (shipmentData === null || shipmentData === void 0 ? void 0 : shipmentData.assignments) || [];
20
+ if (assignments.length === 0) {
21
+ return /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, (0, _fn.getSingleShipmentHistory)(shipmentData));
22
+ }
23
+ if (assignments.length === 1) {
24
+ return /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, (0, _fn.getSingleShipmentHistory)(assignments[0]));
25
+ }
26
+ const lastReassignmentId = assignments && assignments.length > 0 ? assignments[assignments.length - 1].assignmentId || 0 : 0;
27
+ return assignments === null || assignments === void 0 || (_assignments$map = assignments.map) === null || _assignments$map === void 0 ? void 0 : _assignments$map.call(assignments, (item, index) => {
28
+ const {
29
+ assignmentId,
30
+ assignmentDate,
31
+ assignmentClosedTime,
32
+ status
33
+ } = item !== null && item !== void 0 ? item : {};
34
+ return /*#__PURE__*/_react.default.createElement("div", {
35
+ className: "margin-bottom-16",
36
+ key: assignmentId
37
+ }, /*#__PURE__*/_react.default.createElement(_Accordion.default, {
38
+ defaultActiveKey: lastReassignmentId,
39
+ activeKey: assignmentId,
40
+ body: /*#__PURE__*/_react.default.createElement(_TrackShipmentWidget.default, (0, _fn.getSingleShipmentHistory)(item)),
41
+ headerText: (0, _fn.headerText)(index, assignmentDate, assignmentClosedTime, status)
42
+ }));
43
+ });
44
+ }
45
+ const HistoryPropType = _propTypes.default.shape({
46
+ shipmentStatus: _propTypes.default.string.isRequired,
47
+ fromDate: _propTypes.default.string.isRequired,
48
+ toDate: _propTypes.default.string.isRequired,
49
+ partnerStatus: _propTypes.default.string,
50
+ customerDisplayStatus: _propTypes.default.string.isRequired,
51
+ oneassistDisplayStatus: _propTypes.default.string.isRequired,
52
+ stageConsistent: _propTypes.default.bool.isRequired
53
+ });
54
+ const AssignmentPropType = _propTypes.default.shape({
55
+ assignmentDate: _propTypes.default.number.isRequired,
56
+ assignmentClosedTime: _propTypes.default.number.isRequired,
57
+ logisticPartnerName: _propTypes.default.string.isRequired,
58
+ assignmentId: _propTypes.default.number.isRequired,
59
+ logisticPartnerRefNum: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
60
+ originAddressLine1: _propTypes.default.string.isRequired,
61
+ originDistrict: _propTypes.default.string.isRequired,
62
+ originPincode: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
63
+ destAddressLine1: _propTypes.default.string.isRequired,
64
+ destDistrict: _propTypes.default.string,
65
+ destPincode: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
66
+ history: _propTypes.default.arrayOf(HistoryPropType).isRequired,
67
+ origAddressFullName: _propTypes.default.string.isRequired,
68
+ destAddressFullName: _propTypes.default.string.isRequired,
69
+ assignments: _propTypes.default.arrayOf(_propTypes.default.shape({
70
+ logisticPartnerRefNum: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
71
+ originAddressLine1: _propTypes.default.string.isRequired,
72
+ originDistrict: _propTypes.default.string.isRequired,
73
+ originPincode: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
74
+ destAddressLine1: _propTypes.default.string.isRequired,
75
+ destDistrict: _propTypes.default.string,
76
+ destPincode: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
77
+ history: _propTypes.default.arrayOf(HistoryPropType).isRequired,
78
+ origAddressFullName: _propTypes.default.string.isRequired,
79
+ destAddressFullName: _propTypes.default.string.isRequired,
80
+ assignments: _propTypes.default.array // Placeholder to break recursion
81
+ }))
82
+ });
83
+ TrackShipmentWidgetList.propTypes = {
84
+ shipmentData: _propTypes.default.shape({
85
+ logisticPartnerRefNum: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
86
+ originAddressLine1: _propTypes.default.string.isRequired,
87
+ originDistrict: _propTypes.default.string.isRequired,
88
+ originPincode: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
89
+ destAddressLine1: _propTypes.default.string.isRequired,
90
+ destDistrict: _propTypes.default.string,
91
+ destPincode: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
92
+ history: _propTypes.default.arrayOf(HistoryPropType).isRequired,
93
+ origAddressFullName: _propTypes.default.string.isRequired,
94
+ destAddressFullName: _propTypes.default.string.isRequired,
95
+ assignments: _propTypes.default.arrayOf(AssignmentPropType)
96
+ }),
97
+ onChange: _propTypes.default.func
98
+ };
99
+ TrackShipmentWidgetList.defaultProps = {
100
+ shipmentData: {},
101
+ onChange: () => {}
102
+ };
103
+ var _default = exports.default = TrackShipmentWidgetList;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isActive = exports.headerText = exports.getSingleShipmentHistory = exports.getDateString = exports.getCurrentShipmentLabel = void 0;
7
+ function numberToOrdinal(number) {
8
+ const suffixes = ['th', 'st', 'nd', 'rd'];
9
+ const value = number % 100;
10
+ const suffix = value >= 11 && value <= 13 ? suffixes[0] // 11th, 12th, 13th
11
+ : suffixes[number % 10] || suffixes[0]; // 1st, 2nd, 3rd, others
12
+ return "".concat(number).concat(suffix); // Use template literal correctly
13
+ }
14
+ const getDateFromEpoch = date => {
15
+ if (!date) {
16
+ return '';
17
+ }
18
+ const dateObj = new Date(date);
19
+ const day = dateObj.getDate();
20
+ const month = dateObj.getMonth();
21
+ const year = dateObj.getFullYear();
22
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
23
+ return "".concat(day, " ").concat(months[month], " ").concat(year);
24
+ };
25
+ const getDateString = (startTime, endTime) => {
26
+ const startDate = getDateFromEpoch(startTime);
27
+ const endDate = getDateFromEpoch(endTime);
28
+ if (startDate === '' && endDate === '') {
29
+ return '';
30
+ }
31
+ if (endDate === '') {
32
+ return startDate;
33
+ }
34
+ return "".concat(startDate, " - ").concat(endDate);
35
+ };
36
+ exports.getDateString = getDateString;
37
+ const getCurrentShipmentLabel = number => {
38
+ const ordinalNumber = numberToOrdinal(number);
39
+ return "".concat(ordinalNumber, " Shipment");
40
+ };
41
+ exports.getCurrentShipmentLabel = getCurrentShipmentLabel;
42
+ const isActive = time => time === null;
43
+ exports.isActive = isActive;
44
+ const headerText = (index, reassignmentTime, modifiedTime, status) => "".concat(getCurrentShipmentLabel(index + 1), " | ").concat(getDateString(reassignmentTime, modifiedTime)).concat(isActive(modifiedTime) ? ' - Present' : '');
45
+ exports.headerText = headerText;
46
+ const getSingleShipmentHistory = item => {
47
+ var _item$history;
48
+ return {
49
+ partnerName: item === null || item === void 0 ? void 0 : item.logisticPartnerName,
50
+ errorReason: item === null || item === void 0 ? void 0 : item.failureReason,
51
+ awbNumber: item === null || item === void 0 ? void 0 : item.logisticPartnerRefNum,
52
+ fromAddress: {
53
+ heading: 'From Address:',
54
+ addressLine1: item === null || item === void 0 ? void 0 : item.origAddressFullName,
55
+ addressLine2: item === null || item === void 0 ? void 0 : item.originAddressLine1,
56
+ pincode: item === null || item === void 0 ? void 0 : item.originPincode,
57
+ city: item === null || item === void 0 ? void 0 : item.originDistrict
58
+ },
59
+ toAddress: {
60
+ heading: 'To Address:',
61
+ addressLine1: item === null || item === void 0 ? void 0 : item.destAddressFullName,
62
+ addressLine2: item === null || item === void 0 ? void 0 : item.destAddressLine1,
63
+ pincode: item === null || item === void 0 ? void 0 : item.destPincode,
64
+ city: item === null || item === void 0 ? void 0 : item.destDistrict
65
+ },
66
+ tableData: (_item$history = item === null || item === void 0 ? void 0 : item.history) !== null && _item$history !== void 0 ? _item$history : []
67
+ };
68
+ };
69
+ exports.getSingleShipmentHistory = getSingleShipmentHistory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-componentbook",
3
- "version": "1.0.1-stage.4",
3
+ "version": "1.0.1-stage.40",
4
4
  "private": false,
5
5
  "description": "Reusable components",
6
6
  "main": "build/index.js",
@@ -47,6 +47,7 @@
47
47
  "babel-plugin-named-exports-order": "^0.0.2",
48
48
  "eslint-config-airbnb": "^19.0.4",
49
49
  "eslint-plugin-storybook": "^0.6.15",
50
+ "onchange": "^6.1.0",
50
51
  "pre-commit": "^1.2.2",
51
52
  "react-scripts": "^5.0.1",
52
53
  "storybook": "^7.6.3",
@@ -66,6 +67,8 @@
66
67
  "scripts": {
67
68
  "start": "react-scripts start",
68
69
  "build": "rm -rf build && NODE_ENV=production babel src/lib --out-dir build --copy-files",
70
+ "publish:local": "npm run build && yalc push --force",
71
+ "watch:publish": "onchange 'src/lib/**/*' -- npm run publish:local",
69
72
  "storybook": "storybook dev -p 6006",
70
73
  "build-storybook": "storybook build",
71
74
  "update-package-lock": "npm i --package-lock-only",
@@ -1,195 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.weak-map.js");
4
- require("core-js/modules/web.dom-collections.iterator.js");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
- var _FileCopyOutlined = _interopRequireDefault(require("@material-ui/icons/FileCopyOutlined"));
12
- var _AddressWidget = _interopRequireDefault(require("../../widgets/oa-widget-address/AddressWidget"));
13
- var _CustomTable = _interopRequireDefault(require("../../components/oa-component-table/CustomTable"));
14
- var _CustomTimeline = _interopRequireDefault(require("../oa-component-timeline/CustomTimeline"));
15
- var _MaterialIcon = _interopRequireDefault(require("../../components/oa-component-icons/MaterialIcon"));
16
- var _styles = require("./styles");
17
- var _CustomNotification = _interopRequireDefault(require("../../components/oa-component-notification/CustomNotification"));
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
- function TrackShipmentWidget(_ref) {
22
- var _tableData, _tableData2;
23
- let {
24
- awbNumber,
25
- fromAddress,
26
- tableData,
27
- title,
28
- toAddress,
29
- heading
30
- } = _ref;
31
- // local variables
32
- const deilveryStageText = 'SHIPMENT DELIVERED to Customer';
33
-
34
- // show notification when user click on clipboard
35
- const notificationRef = (0, _react.useRef)(null);
36
- const openNotification = parameters => {
37
- var _notificationRef$curr;
38
- return notificationRef === null || notificationRef === void 0 || (_notificationRef$curr = notificationRef.current) === null || _notificationRef$curr === void 0 ? void 0 : _notificationRef$curr.openNotification(parameters);
39
- };
40
- const handleCopyToClipboard = () => {
41
- navigator.clipboard.writeText(awbNumber).then(() => {
42
- openNotification({
43
- description: 'Copy to clipboard',
44
- type: 'success'
45
- });
46
- }).catch(err => {
47
- openNotification({
48
- description: 'Failed to copy text',
49
- type: 'failure'
50
- });
51
- });
52
- };
53
-
54
- // return circle color depands on stageConsistent key coming from backend
55
- const getCircleClass = (row, isTimeLineStep) => {
56
- if (row.stageConsistent) {
57
- return isTimeLineStep ? 'finish' : 'greenBg';
58
- }
59
- if (row.toDate === null && row.oneassistDisplayStatus === deilveryStageText) {
60
- return isTimeLineStep ? 'process' : 'greenBr';
61
- }
62
- return isTimeLineStep ? 'error' : 'redBg';
63
- };
64
-
65
- // check if current stage is delivery stage or not
66
- const isOnDeliveryStage = Array.isArray(tableData) && tableData.length > 0 && ((_tableData = tableData[tableData.length - 1]) === null || _tableData === void 0 ? void 0 : _tableData.oneassistDisplayStatus) === deilveryStageText && ((_tableData2 = tableData[tableData.length - 1]) === null || _tableData2 === void 0 ? void 0 : _tableData2.toDate) === null;
67
-
68
- // remove duplicate consicutive objects only show single unique objects
69
- const stepsData = tableData.map(item => ({
70
- title: item.oneassistDisplayStatus,
71
- status: getCircleClass(item, true)
72
- })).filter((item, index) => {
73
- var _tableData3;
74
- return item.title !== ((_tableData3 = tableData[index - 1]) === null || _tableData3 === void 0 ? void 0 : _tableData3.oneassistDisplayStatus);
75
- });
76
- return /*#__PURE__*/_react.default.createElement(_styles.StyleTrackShipment, {
77
- className: "trackingDetails"
78
- }, /*#__PURE__*/_react.default.createElement(_CustomNotification.default, {
79
- ref: notificationRef
80
- }), title ? /*#__PURE__*/_react.default.createElement("h1", {
81
- className: "type-t1-500"
82
- }, title) : null, /*#__PURE__*/_react.default.createElement("h3", {
83
- className: "type-t1-500"
84
- }, heading), /*#__PURE__*/_react.default.createElement("p", {
85
- className: "type-b2-400 disFlex"
86
- }, "AWB Number:", awbNumber, awbNumber && /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
87
- icon: _FileCopyOutlined.default,
88
- size: 20,
89
- onClick: handleCopyToClipboard,
90
- style: {
91
- cursor: 'pointer',
92
- color: '014FC5'
93
- }
94
- })), /*#__PURE__*/_react.default.createElement(_styles.AddressesContainer, null, /*#__PURE__*/_react.default.createElement(_AddressWidget.default, {
95
- address: fromAddress
96
- }), /*#__PURE__*/_react.default.createElement(_AddressWidget.default, {
97
- address: toAddress
98
- })), /*#__PURE__*/_react.default.createElement("div", {
99
- className: "cstScroll"
100
- }, /*#__PURE__*/_react.default.createElement(_CustomTimeline.default, {
101
- currentStep: isOnDeliveryStage ? stepsData.length : stepsData.length - 1,
102
- stepsData: stepsData
103
- })), /*#__PURE__*/_react.default.createElement(_CustomTable.default, {
104
- bordered: true,
105
- rowKey: "key",
106
- columns: [{
107
- title: 'Stage',
108
- dataIndex: 'oneassistDisplayStatus',
109
- key: 'oneassistDisplayStatus',
110
- render: (text, row, index) => {
111
- const obj = {
112
- children: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("em", {
113
- className: "comIcon ".concat(getCircleClass(row))
114
- }), text),
115
- props: {}
116
- };
117
- if (index === 0 || tableData[index - 1].oneassistDisplayStatus !== text) {
118
- let rowSpanCount = 1;
119
- for (let i = index + 1; i < tableData.length; i += 1) {
120
- if (tableData[i].oneassistDisplayStatus === text) {
121
- rowSpanCount += 1;
122
- } else {
123
- break;
124
- }
125
- }
126
- obj.props.rowSpan = rowSpanCount;
127
- } else {
128
- obj.props.rowSpan = 0;
129
- }
130
- return obj;
131
- }
132
- }, {
133
- title: 'description from partner',
134
- dataIndex: 'partnerStatus',
135
- key: 'partnerStatus'
136
- }, {
137
- title: 'Time',
138
- dataIndex: 'toDate',
139
- key: 'toDate'
140
- }],
141
- dataSource: tableData
142
- }));
143
- }
144
- TrackShipmentWidget.propTypes = {
145
- awbNumber: _propTypes.default.string.isRequired,
146
- fromAddress: _propTypes.default.shape({
147
- heading: _propTypes.default.string,
148
- addressLine1: _propTypes.default.string,
149
- addressLine2: _propTypes.default.string,
150
- addressLine3: _propTypes.default.string,
151
- landmark: _propTypes.default.string,
152
- pincode: _propTypes.default.string || _propTypes.default.number,
153
- city: _propTypes.default.string,
154
- state: _propTypes.default.string,
155
- type: _propTypes.default.oneOf(['permanent', 'temporary']),
156
- additional_info: _propTypes.default.shape({
157
- lat: _propTypes.default.string,
158
- long: _propTypes.default.string
159
- })
160
- }),
161
- tableData: _propTypes.default.arrayOf(_propTypes.default.shape({
162
- key: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
163
- oneassistDisplayStatus: _propTypes.default.string,
164
- partnerStatus: _propTypes.default.string,
165
- toDate: _propTypes.default.string
166
- })).isRequired,
167
- title: _propTypes.default.string,
168
- heading: _propTypes.default.string,
169
- toAddress: _propTypes.default.shape({
170
- heading: _propTypes.default.string,
171
- addressLine1: _propTypes.default.string,
172
- addressLine2: _propTypes.default.string,
173
- addressLine3: _propTypes.default.string,
174
- landmark: _propTypes.default.string,
175
- pincode: _propTypes.default.string || _propTypes.default.number,
176
- city: _propTypes.default.string,
177
- state: _propTypes.default.string,
178
- type: _propTypes.default.oneOf(['permanent', 'temporary']),
179
- additional_info: _propTypes.default.shape({
180
- lat: _propTypes.default.string,
181
- long: _propTypes.default.string
182
- })
183
- })
184
- };
185
- TrackShipmentWidget.defaultProps = {
186
- fromAddress: {
187
- heading: ''
188
- },
189
- title: '',
190
- heading: 'Shipment tracking details',
191
- toAddress: {
192
- heading: ''
193
- }
194
- };
195
- var _default = exports.default = TrackShipmentWidget;