@zauru-sdk/components 6.5.6 → 6.6.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.6.0](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.5.6...@zauru-sdk/components@6.6.0) (2026-09-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * registrar reglas automáticas de % rechazo en el historial ([4784849](https://github.com/intuitiva/zauru-typescript-sdk/commit/4784849904f9ac6570e60543895a858dece8e039))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.5.6](https://github.com/intuitiva/zauru-typescript-sdk/compare/@zauru-sdk/components@6.5.5...@zauru-sdk/components@6.5.6) (2026-09-17)
7
18
 
8
19
 
@@ -0,0 +1,23 @@
1
+ export type RejectionPercentageHistoryItem = {
2
+ discount: number;
3
+ description?: string;
4
+ agency_id?: number;
5
+ employee_id?: number;
6
+ employee_name?: string;
7
+ created_at?: string;
8
+ type?: string;
9
+ };
10
+ type NamedRecord = {
11
+ id?: number;
12
+ name?: string;
13
+ };
14
+ export type RejectionPercentageHistoryListProps = {
15
+ items: RejectionPercentageHistoryItem[];
16
+ employees?: NamedRecord[];
17
+ agencies?: NamedRecord[];
18
+ actorLabel?: string;
19
+ emptyText?: string;
20
+ className?: string;
21
+ };
22
+ export declare const RejectionPercentageHistoryList: ({ items, employees, agencies, actorLabel, emptyText, className, }: RejectionPercentageHistoryListProps) => import("react/jsx-runtime").JSX.Element;
23
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./RejectionPercentageHistoryList.js";
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { isAutomaticRejectionRuleHistoryType, toFixedIfNeeded, } from "@zauru-sdk/common";
3
+ const formatHistoryDate = (value) => {
4
+ if (!value)
5
+ return "";
6
+ const date = new Date(value);
7
+ if (Number.isNaN(date.getTime()))
8
+ return value;
9
+ return new Intl.DateTimeFormat("es-GT", {
10
+ day: "2-digit",
11
+ month: "2-digit",
12
+ year: "numeric",
13
+ hour: "2-digit",
14
+ minute: "2-digit",
15
+ hour12: false,
16
+ })
17
+ .format(date)
18
+ .replace(",", "");
19
+ };
20
+ const formatSignedPercentage = (value, forceSign) => {
21
+ const formatted = toFixedIfNeeded(Math.abs(value));
22
+ if (value < 0)
23
+ return `-${formatted}%`;
24
+ if (forceSign && value > 0)
25
+ return `+${formatted}%`;
26
+ return `${formatted}%`;
27
+ };
28
+ const findName = (records, id) => {
29
+ if (id == null)
30
+ return undefined;
31
+ return records?.find((record) => record.id === id)?.name;
32
+ };
33
+ export const RejectionPercentageHistoryList = ({ items, employees, agencies, actorLabel = "Empleado", emptyText = "No hay historial de porcentajes registrado", className = "", }) => {
34
+ if (!items.length) {
35
+ return _jsx("p", { className: "text-gray-500 italic", children: emptyText });
36
+ }
37
+ return (_jsx("div", { className: `space-y-3 max-h-60 overflow-y-auto ${className}`.trim(), children: items.map((item, index) => {
38
+ const isAutomatic = isAutomaticRejectionRuleHistoryType(item.type);
39
+ const employeeName = item.employee_name?.trim() ||
40
+ findName(employees, item.employee_id) ||
41
+ (item.employee_id != null ? `ID: ${item.employee_id}` : "No especificado");
42
+ const agencyName = findName(agencies, item.agency_id) ||
43
+ (item.agency_id != null ? `ID: ${item.agency_id}` : "No especificada");
44
+ const description = item.description || "Sin descripción";
45
+ return (_jsxs("div", { className: isAutomatic
46
+ ? "border border-indigo-200 rounded-lg p-3 bg-indigo-50"
47
+ : "border border-gray-100 rounded-lg p-3 bg-gray-50", children: [_jsxs("div", { className: "flex justify-between items-start gap-3 mb-2", children: [_jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [_jsx("span", { className: isAutomatic
48
+ ? "font-semibold text-indigo-800"
49
+ : "font-semibold text-blue-600", children: formatSignedPercentage(Number(item.discount) || 0, isAutomatic) }), isAutomatic ? (_jsx("span", { className: "shrink-0 whitespace-nowrap rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-800", children: "Autom\u00E1tico" })) : null] }), item.created_at ? (_jsx("span", { className: "text-xs text-gray-500 shrink-0", children: formatHistoryDate(item.created_at) })) : null] }), _jsx("p", { className: isAutomatic
50
+ ? "text-sm text-indigo-900 mb-1"
51
+ : "text-sm text-gray-700 mb-1", title: description, children: description }), _jsxs("div", { className: "flex justify-between gap-3 text-xs text-gray-500", children: [_jsx("span", { className: "min-w-0", children: isAutomatic
52
+ ? "Aplicado por el sistema"
53
+ : `${actorLabel}: ${employeeName}` }), _jsxs("span", { className: "shrink-0", children: ["Agencia: ", agencyName] })] })] }, `${item.created_at ?? "entry"}-${item.type ?? "manual"}-${index}`));
54
+ }) }));
55
+ };
@@ -0,0 +1 @@
1
+ export * from "./RejectionPercentageHistoryList.js";
package/dist/esm/index.js CHANGED
@@ -27,3 +27,4 @@ export * from "./HOC/ValidateEmployeeAccess/index.js";
27
27
  export * from "./Routes/index.js";
28
28
  export * from "./SidePanel/index.js";
29
29
  export * from "./observability/index.js";
30
+ export * from "./DiscountHistory/index.js";
package/dist/index.d.ts CHANGED
@@ -27,3 +27,4 @@ export * from "./HOC/ValidateEmployeeAccess/index.js";
27
27
  export * from "./Routes/index.js";
28
28
  export * from "./SidePanel/index.js";
29
29
  export * from "./observability/index.js";
30
+ export * from "./DiscountHistory/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/components",
3
- "version": "6.5.6",
3
+ "version": "6.6.0",
4
4
  "description": "Componentes reutilizables en las WebApps de Zauru.",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -44,12 +44,12 @@
44
44
  "@reduxjs/toolkit": "^2.2.1",
45
45
  "@remix-run/node": "^2.8.1",
46
46
  "@remix-run/react": "^2.8.1",
47
- "@zauru-sdk/common": "^6.6.0",
48
- "@zauru-sdk/hooks": "^6.3.11",
47
+ "@zauru-sdk/common": "^6.7.0",
48
+ "@zauru-sdk/hooks": "^6.3.12",
49
49
  "@zauru-sdk/icons": "^6.0.0",
50
- "@zauru-sdk/redux": "^6.5.9",
51
- "@zauru-sdk/types": "^6.16.0",
52
- "@zauru-sdk/utils": "^6.16.1",
50
+ "@zauru-sdk/redux": "^6.5.10",
51
+ "@zauru-sdk/types": "^6.17.0",
52
+ "@zauru-sdk/utils": "^6.17.0",
53
53
  "browser-image-compression": "^2.0.2",
54
54
  "framer-motion": "^12.0.0",
55
55
  "jsonwebtoken": "^9.0.2",
@@ -62,5 +62,5 @@
62
62
  "styled-components": "^5.3.5",
63
63
  "zod": "^3.23.8"
64
64
  },
65
- "gitHead": "563f879c95b2f3e76bc28623a9e09c8a103c599e"
65
+ "gitHead": "d3483aa3b55a9a692f955e6a56d13f33b70db1c4"
66
66
  }
@@ -0,0 +1,145 @@
1
+ import React from "react";
2
+ import {
3
+ isAutomaticRejectionRuleHistoryType,
4
+ toFixedIfNeeded,
5
+ } from "@zauru-sdk/common";
6
+
7
+ export type RejectionPercentageHistoryItem = {
8
+ discount: number;
9
+ description?: string;
10
+ agency_id?: number;
11
+ employee_id?: number;
12
+ employee_name?: string;
13
+ created_at?: string;
14
+ type?: string;
15
+ };
16
+
17
+ type NamedRecord = {
18
+ id?: number;
19
+ name?: string;
20
+ };
21
+
22
+ export type RejectionPercentageHistoryListProps = {
23
+ items: RejectionPercentageHistoryItem[];
24
+ employees?: NamedRecord[];
25
+ agencies?: NamedRecord[];
26
+ actorLabel?: string;
27
+ emptyText?: string;
28
+ className?: string;
29
+ };
30
+
31
+ const formatHistoryDate = (value?: string): string => {
32
+ if (!value) return "";
33
+ const date = new Date(value);
34
+ if (Number.isNaN(date.getTime())) return value;
35
+ return new Intl.DateTimeFormat("es-GT", {
36
+ day: "2-digit",
37
+ month: "2-digit",
38
+ year: "numeric",
39
+ hour: "2-digit",
40
+ minute: "2-digit",
41
+ hour12: false,
42
+ })
43
+ .format(date)
44
+ .replace(",", "");
45
+ };
46
+
47
+ const formatSignedPercentage = (
48
+ value: number,
49
+ forceSign: boolean,
50
+ ): string => {
51
+ const formatted = toFixedIfNeeded(Math.abs(value));
52
+ if (value < 0) return `-${formatted}%`;
53
+ if (forceSign && value > 0) return `+${formatted}%`;
54
+ return `${formatted}%`;
55
+ };
56
+
57
+ const findName = (
58
+ records: NamedRecord[] | undefined,
59
+ id: number | undefined,
60
+ ): string | undefined => {
61
+ if (id == null) return undefined;
62
+ return records?.find((record) => record.id === id)?.name;
63
+ };
64
+
65
+ export const RejectionPercentageHistoryList = ({
66
+ items,
67
+ employees,
68
+ agencies,
69
+ actorLabel = "Empleado",
70
+ emptyText = "No hay historial de porcentajes registrado",
71
+ className = "",
72
+ }: RejectionPercentageHistoryListProps) => {
73
+ if (!items.length) {
74
+ return <p className="text-gray-500 italic">{emptyText}</p>;
75
+ }
76
+
77
+ return (
78
+ <div className={`space-y-3 max-h-60 overflow-y-auto ${className}`.trim()}>
79
+ {items.map((item, index) => {
80
+ const isAutomatic = isAutomaticRejectionRuleHistoryType(item.type);
81
+ const employeeName =
82
+ item.employee_name?.trim() ||
83
+ findName(employees, item.employee_id) ||
84
+ (item.employee_id != null ? `ID: ${item.employee_id}` : "No especificado");
85
+ const agencyName =
86
+ findName(agencies, item.agency_id) ||
87
+ (item.agency_id != null ? `ID: ${item.agency_id}` : "No especificada");
88
+ const description = item.description || "Sin descripción";
89
+
90
+ return (
91
+ <div
92
+ key={`${item.created_at ?? "entry"}-${item.type ?? "manual"}-${index}`}
93
+ className={
94
+ isAutomatic
95
+ ? "border border-indigo-200 rounded-lg p-3 bg-indigo-50"
96
+ : "border border-gray-100 rounded-lg p-3 bg-gray-50"
97
+ }
98
+ >
99
+ <div className="flex justify-between items-start gap-3 mb-2">
100
+ <div className="flex items-center gap-2 min-w-0">
101
+ <span
102
+ className={
103
+ isAutomatic
104
+ ? "font-semibold text-indigo-800"
105
+ : "font-semibold text-blue-600"
106
+ }
107
+ >
108
+ {formatSignedPercentage(Number(item.discount) || 0, isAutomatic)}
109
+ </span>
110
+ {isAutomatic ? (
111
+ <span className="shrink-0 whitespace-nowrap rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-800">
112
+ Automático
113
+ </span>
114
+ ) : null}
115
+ </div>
116
+ {item.created_at ? (
117
+ <span className="text-xs text-gray-500 shrink-0">
118
+ {formatHistoryDate(item.created_at)}
119
+ </span>
120
+ ) : null}
121
+ </div>
122
+ <p
123
+ className={
124
+ isAutomatic
125
+ ? "text-sm text-indigo-900 mb-1"
126
+ : "text-sm text-gray-700 mb-1"
127
+ }
128
+ title={description}
129
+ >
130
+ {description}
131
+ </p>
132
+ <div className="flex justify-between gap-3 text-xs text-gray-500">
133
+ <span className="min-w-0">
134
+ {isAutomatic
135
+ ? "Aplicado por el sistema"
136
+ : `${actorLabel}: ${employeeName}`}
137
+ </span>
138
+ <span className="shrink-0">Agencia: {agencyName}</span>
139
+ </div>
140
+ </div>
141
+ );
142
+ })}
143
+ </div>
144
+ );
145
+ };
@@ -0,0 +1 @@
1
+ export * from "./RejectionPercentageHistoryList.js";
package/src/index.ts CHANGED
@@ -27,3 +27,4 @@ export * from "./HOC/ValidateEmployeeAccess/index.js";
27
27
  export * from "./Routes/index.js";
28
28
  export * from "./SidePanel/index.js";
29
29
  export * from "./observability/index.js";
30
+ export * from "./DiscountHistory/index.js";