@portnet/ui 5.0.28 → 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");
@@ -53,6 +54,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
53
54
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
54
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); }
55
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}$/;
56
58
  const ContentPanel = _ref => {
57
59
  let {
58
60
  isOpen,
@@ -1253,6 +1255,7 @@ const CustomChatInterface = _ref3 => {
1253
1255
  });
1254
1256
  };
1255
1257
  const ReclamationFormModal = _ref4 => {
1258
+ var _formData$service;
1256
1259
  let {
1257
1260
  open,
1258
1261
  onClose
@@ -1261,8 +1264,10 @@ const ReclamationFormModal = _ref4 => {
1261
1264
  const [formData, setFormData] = (0, _react.useState)({
1262
1265
  type: "",
1263
1266
  service: "",
1267
+ nature: "",
1264
1268
  objet: "",
1265
1269
  sujet: "",
1270
+ telephone: "",
1266
1271
  files: []
1267
1272
  });
1268
1273
  const [submitted, setSubmitted] = (0, _react.useState)(false);
@@ -1275,6 +1280,10 @@ const ReclamationFormModal = _ref4 => {
1275
1280
  data: listServiceReclamation,
1276
1281
  isFetching: isFetchingListServiceReclamation
1277
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);
1278
1287
  const [error, setError] = (0, _react.useState)(null);
1279
1288
  const errorRef = (0, _react.useRef)(null);
1280
1289
  const CustomPopper = props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popper, _objectSpread(_objectSpread({}, props), {}, {
@@ -1312,6 +1321,11 @@ const ReclamationFormModal = _ref4 => {
1312
1321
  }, 300);
1313
1322
  }
1314
1323
  }, [open]);
1324
+ (0, _react.useEffect)(() => {
1325
+ setFormData(prev => _objectSpread(_objectSpread({}, prev), {}, {
1326
+ nature: ""
1327
+ }));
1328
+ }, [formData.service]);
1315
1329
  (0, _react.useEffect)(() => {
1316
1330
  if (error && errorRef.current) {
1317
1331
  errorRef.current.scrollIntoView({
@@ -1392,8 +1406,8 @@ const ReclamationFormModal = _ref4 => {
1392
1406
  onClose();
1393
1407
  };
1394
1408
  const canProceedStep1 = formData.type !== "";
1395
- const canProceedStep2 = formData.service !== "";
1396
- 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, ""));
1397
1411
  const renderStepContent = () => {
1398
1412
  switch (activeStep) {
1399
1413
  case 0:
@@ -1514,6 +1528,37 @@ const ReclamationFormModal = _ref4 => {
1514
1528
  PopperComponent: CustomPopper,
1515
1529
  noOptionsText: "Aucun service trouv\xE9",
1516
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"
1517
1562
  })]
1518
1563
  })
1519
1564
  });
@@ -1538,6 +1583,18 @@ const ReclamationFormModal = _ref4 => {
1538
1583
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1539
1584
  className: "form-fields",
1540
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, {
1541
1598
  fullWidth: true,
1542
1599
  required: true,
1543
1600
  label: "Objet",
@@ -1695,7 +1752,7 @@ const ReclamationFormModal = _ref4 => {
1695
1752
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
1696
1753
  variant: "h6",
1697
1754
  className: "header-title",
1698
- children: "Nouvelle r\xE9clamation"
1755
+ children: "Nouvelle demande d'assistance"
1699
1756
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1700
1757
  variant: "caption",
1701
1758
  color: "white",
@@ -1829,16 +1886,18 @@ const ReclamationsList = _ref5 => {
1829
1886
  return "#757575";
1830
1887
  }
1831
1888
  };
1832
- const isHtml = str => /<\/?[a-z][\s\S]*>/i.test(str);
1889
+ const URL_RE = /(https?:\/\/[^\s)]+)/g;
1833
1890
  const renderTextWithLinks = text => {
1834
1891
  if (!text) return null;
1835
- const parts = text.split(/(https?:\/\/[^\s)]+)/g);
1892
+ const parts = text.split(URL_RE);
1836
1893
  return parts.map((part, i) => /^https?:\/\//.test(part) ? /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
1837
1894
  href: part,
1838
1895
  target: "_blank",
1839
1896
  rel: "noopener noreferrer",
1840
1897
  style: {
1841
1898
  color: "var(--primary-color, #222f67)",
1899
+ fontWeight: 600,
1900
+ textDecoration: "underline",
1842
1901
  wordBreak: "break-all"
1843
1902
  },
1844
1903
  children: part
@@ -1846,6 +1905,7 @@ const ReclamationsList = _ref5 => {
1846
1905
  children: part
1847
1906
  }, i));
1848
1907
  };
1908
+ const isHtml = str => /<\/?[a-z][\s\S]*>/i.test(str);
1849
1909
  const handleReclamationClick = reclamation => {
1850
1910
  setSelectedReclamation(reclamation);
1851
1911
  setDetailsDialogOpen(true);
@@ -1993,7 +2053,7 @@ const ReclamationsList = _ref5 => {
1993
2053
  margin: 0,
1994
2054
  lineHeight: "normal"
1995
2055
  },
1996
- children: "Mes r\xE9clamations"
2056
+ children: "Mes demandes d'assistance"
1997
2057
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
1998
2058
  component: "div",
1999
2059
  sx: {
@@ -2419,7 +2479,7 @@ const ReclamationsList = _ref5 => {
2419
2479
  whiteSpace: "pre-line",
2420
2480
  fontFamily: WIDGET_FONT
2421
2481
  },
2422
- children: selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.description
2482
+ children: renderTextWithLinks(selectedReclamation === null || selectedReclamation === void 0 ? void 0 : selectedReclamation.description)
2423
2483
  })]
2424
2484
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2425
2485
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
@@ -2638,7 +2698,7 @@ const ReclamationsList = _ref5 => {
2638
2698
  fontFamily: WIDGET_FONT
2639
2699
  },
2640
2700
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
2641
- children: [entry.changedByNom ? entry.changedByNom : "Service Odoo", " \xB7 "]
2701
+ children: [entry.changedByNom ? entry.changedByNom : "Service Odoo", " ", "\xB7", " "]
2642
2702
  }), formatDate(entry.dateChangement)]
2643
2703
  })]
2644
2704
  })
@@ -2654,7 +2714,7 @@ const ReclamationsList = _ref5 => {
2654
2714
  border: "1px solid #e0e0e0",
2655
2715
  whiteSpace: "pre-line"
2656
2716
  },
2657
- children: entry.commentaire
2717
+ children: renderTextWithLinks(entry.commentaire)
2658
2718
  }), entry.reponse && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2659
2719
  style: {
2660
2720
  marginTop: "8px",
@@ -2688,7 +2748,7 @@ const ReclamationsList = _ref5 => {
2688
2748
  style: {
2689
2749
  whiteSpace: "pre-line"
2690
2750
  },
2691
- children: entry.reponse
2751
+ children: renderTextWithLinks(entry.reponse)
2692
2752
  })]
2693
2753
  }), ((_entry$documents = entry.documents) === null || _entry$documents === void 0 ? void 0 : _entry$documents.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2694
2754
  style: {
@@ -3740,7 +3800,7 @@ const PuiHelpWidget = _ref7 => {
3740
3800
  action: handleFaqClick
3741
3801
  }, ...(showReclamation ? [{
3742
3802
  icon: _freeSolidSvgIcons.faClipboardList,
3743
- title: "Mes réclamations",
3803
+ title: "Mes demandes d'assistance",
3744
3804
  id: "mes-reclamations",
3745
3805
  action: () => {
3746
3806
  queryClient.invalidateQueries("get_list_reclamation");
@@ -3748,7 +3808,7 @@ const PuiHelpWidget = _ref7 => {
3748
3808
  }
3749
3809
  }, {
3750
3810
  icon: _freeSolidSvgIcons.faBullhorn,
3751
- title: "Nouvelle réclamation",
3811
+ title: "Nouvelle demande d'assistance",
3752
3812
  id: "nouvelle-reclamation",
3753
3813
  action: () => setReclamationModalOpen(true)
3754
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.28",
3
+ "version": "5.0.29",
4
4
  "description": "Portnet UI",
5
5
  "keywords": [
6
6
  "react",
@@ -103,6 +103,7 @@
103
103
  "@storybook/testing-library": "^0.2.2",
104
104
  "ajv": "^8.17.1",
105
105
  "ajv-keywords": "^5.1.0",
106
+ "axios": "^0.27.2",
106
107
  "cross-env": "^7.0.3",
107
108
  "husky": "^4.3.8",
108
109
  "prop-types": "^15.8.1",
@@ -110,4 +111,4 @@
110
111
  "storybook": "^7.6.4",
111
112
  "webpack": "^5.75.0"
112
113
  }
113
- }
114
+ }