@credithub/harlan-components 1.47.1 → 1.48.1

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.
@@ -8,8 +8,8 @@ declare const useCardsAndProducts: ({ finderResponse, rfbResponse }: {
8
8
  }[];
9
9
  products: {
10
10
  title: string;
11
+ onClick: () => Promise<void>;
11
12
  price: number;
12
- onClick: () => void;
13
13
  hide: boolean;
14
14
  isLoading: boolean;
15
15
  }[];
@@ -279,7 +279,7 @@ var useCardsAndProducts = function (_a) {
279
279
  {
280
280
  title: 'Consultar Pefin/Refin Serasa',
281
281
  price: productsPrices === null || productsPrices === void 0 ? void 0 : productsPrices.refinSerasa,
282
- onClick: handleModalClick,
282
+ onClick: handleOnClick('refinSerasa'),
283
283
  hide: (_f = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _f === void 0 ? void 0 : _f.consultaRealizada,
284
284
  isLoading: loadingButtons['refinSerasa']
285
285
  },
@@ -30,6 +30,7 @@ import AddItem from '../common/addItem';
30
30
  import Button from '../common/button';
31
31
  import { Result, ResultContent } from '../interface/result';
32
32
  import EnvolvidosList from './envolvidosList';
33
+ import { sortProcessosByDate } from '../../utils/sortProcessosByDate';
33
34
  var AddProcessoJuridicoField = function (_a) {
34
35
  var value = _a.value, props = __rest(_a, ["value"]);
35
36
  return (React.createElement(AddItem, __assign({}, props, { value: value || 'Não Informado' })));
@@ -56,7 +57,8 @@ var ResultList = styled(Result)(templateObject_4 || (templateObject_4 = __makeTe
56
57
  });
57
58
  var ProcessosJuridicosList = function (_a) {
58
59
  var processos = _a.processos, onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico;
59
- return (React.createElement(ResultList, { resultContentStriped: false }, processos.map(function (processo, i) { return (React.createElement("div", { key: i },
60
+ var sortedProcessos = sortProcessosByDate(processos);
61
+ return (React.createElement(ResultList, { resultContentStriped: false }, sortedProcessos.map(function (processo, i) { return (React.createElement("div", { key: i },
60
62
  React.createElement(ProcessoJuridicoItem, { processo: processo },
61
63
  React.createElement(ConsultarProcessoBtn, { onClick: onClickConsultarProcessoJuridico
62
64
  ? function () { return onClickConsultarProcessoJuridico(processo.id); }
@@ -0,0 +1,4 @@
1
+ export declare const extractDateFromCNJ: (cnj: string) => Date | null;
2
+ export declare const sortProcessosByDate: <T extends {
3
+ numero_novo: string;
4
+ }>(processos: T[]) => T[];
@@ -0,0 +1,33 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ export var extractDateFromCNJ = function (cnj) {
11
+ var dateRegex = /\b(\d{4})\.(\d{1,2})\.(\d{1,2})\b/;
12
+ var match = cnj.match(dateRegex);
13
+ if (match) {
14
+ var _1 = match[0], year = match[1], month = match[2], day = match[3];
15
+ return new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
16
+ }
17
+ return null;
18
+ };
19
+ export var sortProcessosByDate = function (processos) {
20
+ try {
21
+ return __spreadArray([], processos, true).sort(function (a, b) {
22
+ var dateA = extractDateFromCNJ(a.numero_novo);
23
+ var dateB = extractDateFromCNJ(b.numero_novo);
24
+ if (!dateA || !dateB)
25
+ return 0;
26
+ return dateB.getTime() - dateA.getTime();
27
+ });
28
+ }
29
+ catch (error) {
30
+ console.error('Erro ao ordenar processos por data:', error);
31
+ return processos;
32
+ }
33
+ };