@credithub/harlan-components 1.47.1 → 1.48.0

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.
@@ -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
+ };