@portnet/ui 5.0.27 → 5.0.29

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.
@@ -37,14 +37,31 @@ const reclamationApi = axiosInstance => ({
37
37
  throw (error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || new Error("Impossible de charger les réclamations");
38
38
  }
39
39
  },
40
+ getListNatureReclamationApi: async (portailId, serviceCode) => {
41
+ try {
42
+ const response = await axiosInstance.get("/reclamation/list-nature", {
43
+ params: {
44
+ portailId,
45
+ service: serviceCode || undefined
46
+ }
47
+ });
48
+ return response.data.body;
49
+ } catch (error) {
50
+ var _error$response2;
51
+ throw (error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || new Error("Impossible de charger les natures");
52
+ }
53
+ },
40
54
  createReclamationApi: async (data, portailId) => {
41
55
  try {
56
+ var _data$nature;
42
57
  const formData = new FormData();
43
58
  const serviceConcerne = data.service.codigo;
44
59
  formData.append("type", data.type);
45
60
  formData.append("service", serviceConcerne);
46
61
  formData.append("objet", data.objet);
47
62
  formData.append("description", data.sujet);
63
+ formData.append("telephone", data.telephone);
64
+ formData.append("nature", ((_data$nature = data.nature) === null || _data$nature === void 0 ? void 0 : _data$nature.codigo) || "");
48
65
  if (data.files && data.files.length > 0) {
49
66
  data.files.forEach(file => {
50
67
  formData.append("files", file);
@@ -61,8 +78,8 @@ const reclamationApi = axiosInstance => ({
61
78
  });
62
79
  return response.data.body;
63
80
  } catch (error) {
64
- var _error$response2;
65
- throw (error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || new Error("Impossible de create nouvelle réclamation");
81
+ var _error$response3;
82
+ throw (error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || new Error("Impossible de créer une nouvelle réclamation");
66
83
  }
67
84
  },
68
85
  downloadDocumentApi: async documentGuid => {
@@ -70,8 +87,8 @@ const reclamationApi = axiosInstance => ({
70
87
  const response = await axiosInstance.post("/reclamation/download?guid=".concat(documentGuid));
71
88
  return response.data.body;
72
89
  } catch (error) {
73
- var _error$response3;
74
- throw (error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || new Error("Impossible de charger les réclamations");
90
+ var _error$response4;
91
+ throw (error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data) || new Error("Impossible de charger les réclamations");
75
92
  }
76
93
  },
77
94
  getListServiceReclamationApi: async () => {
@@ -79,8 +96,8 @@ const reclamationApi = axiosInstance => ({
79
96
  const response = await axiosInstance.get("/reclamation/list-service");
80
97
  return response.data.body;
81
98
  } catch (error) {
82
- var _error$response4;
83
- throw (error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data) || new Error("Impossible de charger les réclamations");
99
+ var _error$response5;
100
+ throw (error === null || error === void 0 || (_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.data) || new Error("Impossible de charger les réclamations");
84
101
  }
85
102
  },
86
103
  getListServiceReclamationByPortailApi: async portailId => {
@@ -88,8 +105,8 @@ const reclamationApi = axiosInstance => ({
88
105
  const response = await axiosInstance.get("/reclamation/list-service/".concat(portailId));
89
106
  return response.data.body;
90
107
  } catch (error) {
91
- var _error$response5;
92
- throw (error === null || error === void 0 || (_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.data) || new Error("Impossible de charger les réclamations");
108
+ var _error$response6;
109
+ throw (error === null || error === void 0 || (_error$response6 = error.response) === null || _error$response6 === void 0 ? void 0 : _error$response6.data) || new Error("Impossible de charger les réclamations");
93
110
  }
94
111
  },
95
112
  cloturerReclamation: id => axiosInstance.patch("/reclamation/".concat(id, "/cloturer")).then(r => r.data),
@@ -12,6 +12,7 @@ require("core-js/modules/es.promise.js");
12
12
  require("core-js/modules/es.regexp.exec.js");
13
13
  require("core-js/modules/es.regexp.test.js");
14
14
  require("core-js/modules/es.string.includes.js");
15
+ require("core-js/modules/es.string.replace.js");
15
16
  require("core-js/modules/es.string.split.js");
16
17
  require("core-js/modules/es.string.trim.js");
17
18
  require("core-js/modules/es.typed-array.uint8-array.js");
@@ -34,6 +35,7 @@ var _reactFontawesome = require("@fortawesome/react-fontawesome");
34
35
  var _reactToastify = require("react-toastify");
35
36
  var _reactstrap = require("reactstrap");
36
37
  var _freeRegularSvgIcons = require("@fortawesome/free-regular-svg-icons");
38
+ var _dompurify = _interopRequireDefault(require("dompurify"));
37
39
  var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
38
40
  var _iconsMaterial = require("@mui/icons-material");
39
41
  var _material = require("@mui/material");
@@ -52,6 +54,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
52
54
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
53
55
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
54
56
  const WIDGET_FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif";
57
+ const PHONE_RE = /^(0|\+212|0212)[5-7]\d{8}$/;
55
58
  const ContentPanel = _ref => {
56
59
  let {
57
60
  isOpen,
@@ -1252,6 +1255,7 @@ const CustomChatInterface = _ref3 => {
1252
1255
  });
1253
1256
  };
1254
1257
  const ReclamationFormModal = _ref4 => {
1258
+ var _formData$service;
1255
1259
  let {
1256
1260
  open,
1257
1261
  onClose
@@ -1260,8 +1264,10 @@ const ReclamationFormModal = _ref4 => {
1260
1264
  const [formData, setFormData] = (0, _react.useState)({
1261
1265
  type: "",
1262
1266
  service: "",
1267
+ nature: "",
1263
1268
  objet: "",
1264
1269
  sujet: "",
1270
+ telephone: "",
1265
1271
  files: []
1266
1272
  });
1267
1273
  const [submitted, setSubmitted] = (0, _react.useState)(false);
@@ -1274,6 +1280,10 @@ const ReclamationFormModal = _ref4 => {
1274
1280
  data: listServiceReclamation,
1275
1281
  isFetching: isFetchingListServiceReclamation
1276
1282
  } = (0, _useReclamation.useListServiceReclamation)();
1283
+ const {
1284
+ data: listNatureReclamation,
1285
+ isFetching: isFetchingListNatureReclamation
1286
+ } = (0, _useReclamation.useListNatureReclamation)((_formData$service = formData.service) === null || _formData$service === void 0 ? void 0 : _formData$service.codigo);
1277
1287
  const [error, setError] = (0, _react.useState)(null);
1278
1288
  const errorRef = (0, _react.useRef)(null);
1279
1289
  const CustomPopper = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popper, _objectSpread(_objectSpread({}, props), {}, {
@@ -1311,6 +1321,11 @@ const ReclamationFormModal = _ref4 => {
1311
1321
  }, 300);
1312
1322
  }
1313
1323
  }, [open]);
1324
+ (0, _react.useEffect)(() => {
1325
+ setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1326
+ nature: ""
1327
+ }));
1328
+ }, [formData.service]);
1314
1329
  (0, _react.useEffect)(() => {
1315
1330
  if (error && errorRef.current) {
1316
1331
  errorRef.current.scrollIntoView({
@@ -1391,8 +1406,8 @@ const ReclamationFormModal = _ref4 => {
1391
1406
  onClose();
1392
1407
  };
1393
1408
  const canProceedStep1 = formData.type !== "";
1394
- const canProceedStep2 = formData.service !== "";
1395
- const canSubmit = formData.objet && formData.sujet;
1409
+ const canProceedStep2 = formData.service !== "" && formData.nature !== "";
1410
+ const canSubmit = formData.objet && formData.sujet && PHONE_RE.test(formData.telephone.replace(/[\s.-]/g, ""));
1396
1411
  const renderStepContent = () => {
1397
1412
  switch (activeStep) {
1398
1413
  case 0:
@@ -1513,6 +1528,37 @@ const ReclamationFormModal = _ref4 => {
1513
1528
  PopperComponent: CustomPopper,
1514
1529
  noOptionsText: "Aucun service trouv\xE9",
1515
1530
  className: "service-autocomplete"
1531
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Autocomplete, {
1532
+ options: listNatureReclamation || [],
1533
+ loading: isFetchingListNatureReclamation,
1534
+ value: formData.nature || "",
1535
+ disabled: !formData.service,
1536
+ onChange: (e, value) => setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1537
+ nature: value
1538
+ })),
1539
+ getOptionLabel: option => (option === null || option === void 0 ? void 0 : option.libelle) || "",
1540
+ renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, _objectSpread(_objectSpread({}, params), {}, {
1541
+ label: "Nature de la demande",
1542
+ placeholder: formData.service ? "Commencez à taper..." : "Sélectionnez d'abord un service",
1543
+ variant: "outlined",
1544
+ fullWidth: true
1545
+ })),
1546
+ renderOption: (props, option) => /*#__PURE__*/(0, _jsxRuntime.jsx)("li", _objectSpread(_objectSpread({}, props), {}, {
1547
+ className: "service-option",
1548
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1549
+ display: "flex",
1550
+ alignItems: "center",
1551
+ gap: 1,
1552
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1553
+ className: "service-bullet"
1554
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1555
+ children: option === null || option === void 0 ? void 0 : option.libelle
1556
+ })]
1557
+ })
1558
+ })),
1559
+ PopperComponent: CustomPopper,
1560
+ noOptionsText: "Aucune nature trouv\xE9e",
1561
+ className: "service-autocomplete"
1516
1562
  })]
1517
1563
  })
1518
1564
  });
@@ -1537,6 +1583,18 @@ const ReclamationFormModal = _ref4 => {
1537
1583
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1538
1584
  className: "form-fields",
1539
1585
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
1586
+ fullWidth: true,
1587
+ required: true,
1588
+ label: "T\xE9l\xE9phone",
1589
+ value: formData.telephone,
1590
+ onChange: e => setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1591
+ telephone: e.target.value
1592
+ })),
1593
+ error: Boolean(formData.telephone) && !PHONE_RE.test(formData.telephone.replace(/[\s.-]/g, "")),
1594
+ helperText: "Format : 06 61 00 00 00, +212 6 61 00 00 00 ou 0212 6 61 00 00 00.",
1595
+ variant: "outlined",
1596
+ className: "form-field"
1597
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
1540
1598
  fullWidth: true,
1541
1599
  required: true,
1542
1600
  label: "Objet",
@@ -1694,7 +1752,7 @@ const ReclamationFormModal = _ref4 => {
1694
1752
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1695
1753
  variant: "h6",
1696
1754
  className: "header-title",
1697
- children: "Nouvelle r\xE9clamation"
1755
+ children: "Nouvelle demande d'assistance"
1698
1756
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1699
1757
  variant: "caption",
1700
1758
  color: "white",
@@ -1828,15 +1886,18 @@ const ReclamationsList = _ref5 => {
1828
1886
  return "#757575";
1829
1887
  }
1830
1888
  };
1889
+ const URL_RE = /(https?:\/\/[^\s)]+)/g;
1831
1890
  const renderTextWithLinks = text => {
1832
1891
  if (!text) return null;
1833
- const parts = text.split(/(https?:\/\/[^\s)]+)/g);
1892
+ const parts = text.split(URL_RE);
1834
1893
  return parts.map((part, i) => /^https?:\/\//.test(part) ? /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
1835
1894
  href: part,
1836
1895
  target: "_blank",
1837
1896
  rel: "noopener noreferrer",
1838
1897
  style: {
1839
1898
  color: "var(--primary-color, #222f67)",
1899
+ fontWeight: 600,
1900
+ textDecoration: "underline",
1840
1901
  wordBreak: "break-all"
1841
1902
  },
1842
1903
  children: part
@@ -1844,6 +1905,7 @@ const ReclamationsList = _ref5 => {
1844
1905
  children: part
1845
1906
  }, i));
1846
1907
  };
1908
+ const isHtml = str => /<\/?[a-z][\s\S]*>/i.test(str);
1847
1909
  const handleReclamationClick = reclamation => {
1848
1910
  setSelectedReclamation(reclamation);
1849
1911
  setDetailsDialogOpen(true);
@@ -1991,7 +2053,7 @@ const ReclamationsList = _ref5 => {
1991
2053
  margin: 0,
1992
2054
  lineHeight: "normal"
1993
2055
  },
1994
- children: "Mes r\xE9clamations"
2056
+ children: "Mes demandes d'assistance"
1995
2057
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1996
2058
  component: "div",
1997
2059
  sx: {
@@ -2417,7 +2479,7 @@ const ReclamationsList = _ref5 => {
2417
2479
  whiteSpace: "pre-line",
2418
2480
  fontFamily: WIDGET_FONT
2419
2481
  },
2420
- children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.description
2482
+ children: renderTextWithLinks(selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.description)
2421
2483
  })]
2422
2484
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2423
2485
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -2636,7 +2698,7 @@ const ReclamationsList = _ref5 => {
2636
2698
  fontFamily: WIDGET_FONT
2637
2699
  },
2638
2700
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
2639
- children: [entry.changedByNom ? entry.changedByNom : "Service Odoo", " \xB7 "]
2701
+ children: [entry.changedByNom ? entry.changedByNom : "Service Odoo", " ", "\xB7", " "]
2640
2702
  }), formatDate(entry.dateChangement)]
2641
2703
  })]
2642
2704
  })
@@ -2652,7 +2714,7 @@ const ReclamationsList = _ref5 => {
2652
2714
  border: "1px solid #e0e0e0",
2653
2715
  whiteSpace: "pre-line"
2654
2716
  },
2655
- children: entry.commentaire
2717
+ children: renderTextWithLinks(entry.commentaire)
2656
2718
  }), entry.reponse && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2657
2719
  style: {
2658
2720
  marginTop: "8px",
@@ -2675,7 +2737,19 @@ const ReclamationsList = _ref5 => {
2675
2737
  marginBottom: "4px"
2676
2738
  },
2677
2739
  children: "\uD83D\uDCAC R\xE9ponse"
2678
- }), renderTextWithLinks(entry.reponse)]
2740
+ }), isHtml(entry.reponse) ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2741
+ style: {
2742
+ whiteSpace: "normal"
2743
+ },
2744
+ dangerouslySetInnerHTML: {
2745
+ __html: _dompurify.default.sanitize(entry.reponse)
2746
+ }
2747
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2748
+ style: {
2749
+ whiteSpace: "pre-line"
2750
+ },
2751
+ children: renderTextWithLinks(entry.reponse)
2752
+ })]
2679
2753
  }), ((_entry$documents = entry.documents) === null || _entry$documents === void 0 ? void 0 : _entry$documents.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2680
2754
  style: {
2681
2755
  marginTop: "8px",
@@ -3726,7 +3800,7 @@ const PuiHelpWidget = _ref7 => {
3726
3800
  action: handleFaqClick
3727
3801
  }, ...(showReclamation ? [{
3728
3802
  icon: _freeSolidSvgIcons.faClipboardList,
3729
- title: "Mes réclamations",
3803
+ title: "Mes demandes d'assistance",
3730
3804
  id: "mes-reclamations",
3731
3805
  action: () => {
3732
3806
  queryClient.invalidateQueries("get_list_reclamation");
@@ -3734,7 +3808,7 @@ const PuiHelpWidget = _ref7 => {
3734
3808
  }
3735
3809
  }, {
3736
3810
  icon: _freeSolidSvgIcons.faBullhorn,
3737
- title: "Nouvelle réclamation",
3811
+ title: "Nouvelle demande d'assistance",
3738
3812
  id: "nouvelle-reclamation",
3739
3813
  action: () => setReclamationModalOpen(true)
3740
3814
  }] : []), {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useReouvreReclamation = exports.useListServiceReclamation = exports.useListReclamation = exports.useDownloadDocument = exports.useCreateReclamation = exports.useClotureReclamation = void 0;
6
+ exports.useReouvreReclamation = exports.useListServiceReclamation = exports.useListReclamation = exports.useListNatureReclamation = exports.useDownloadDocument = exports.useCreateReclamation = exports.useClotureReclamation = void 0;
7
7
  var _reactQuery = require("react-query");
8
8
  var _PuiHelpWidgetContext = require("../components/common/PuiHelpWidgetContext");
9
9
  const useListReclamation = (page, search) => {
@@ -24,6 +24,22 @@ const useListReclamation = (page, search) => {
24
24
  });
25
25
  };
26
26
  exports.useListReclamation = useListReclamation;
27
+ const useListNatureReclamation = serviceCode => {
28
+ const {
29
+ reclamationApi,
30
+ portailId
31
+ } = (0, _PuiHelpWidgetContext.useHelpWidget)();
32
+ return (0, _reactQuery.useQuery)({
33
+ queryKey: ["get_list_nature_reclamation", portailId, serviceCode],
34
+ queryFn: () => reclamationApi.getListNatureReclamationApi(portailId, serviceCode),
35
+ enabled: Boolean(serviceCode),
36
+ initialData: [],
37
+ retry: 1,
38
+ refetchOnWindowFocus: false,
39
+ refetchOnReconnect: false
40
+ });
41
+ };
42
+ exports.useListNatureReclamation = useListNatureReclamation;
27
43
  const useCreateReclamation = () => {
28
44
  const {
29
45
  reclamationApi,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portnet/ui",
3
- "version": "5.0.27",
3
+ "version": "5.0.29",
4
4
  "description": "Portnet UI",
5
5
  "keywords": [
6
6
  "react",
@@ -30,8 +30,8 @@
30
30
  "@testing-library/jest-dom": "^5.16.5",
31
31
  "@testing-library/react": "^13.4.0",
32
32
  "@testing-library/user-event": "^13.5.0",
33
- "axios": "^1.13.2",
34
33
  "bootstrap": "^5.3.2",
34
+ "dompurify": "^3.4.12",
35
35
  "formik": "^2.2.9",
36
36
  "lodash": "^4.17.21",
37
37
  "moment": "^2.30.1",
@@ -48,6 +48,9 @@
48
48
  "web-vitals": "^2.1.4",
49
49
  "yup": "^0.32.11"
50
50
  },
51
+ "peerDependencies": {
52
+ "axios": "0.27.2"
53
+ },
51
54
  "scripts": {
52
55
  "start": "react-scripts start",
53
56
  "build": "rimraf dist && cross-env NODE_ENV=production babel src/lib --out-dir dist --copy-files",
@@ -100,6 +103,7 @@
100
103
  "@storybook/testing-library": "^0.2.2",
101
104
  "ajv": "^8.17.1",
102
105
  "ajv-keywords": "^5.1.0",
106
+ "axios": "^0.27.2",
103
107
  "cross-env": "^7.0.3",
104
108
  "husky": "^4.3.8",
105
109
  "prop-types": "^15.8.1",
@@ -107,4 +111,4 @@
107
111
  "storybook": "^7.6.4",
108
112
  "webpack": "^5.75.0"
109
113
  }
110
- }
114
+ }