@neetru/product-feedback 0.1.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/dist/feedback-engine.d.ts +59 -0
- package/dist/feedback-engine.js +186 -0
- package/dist/feedback-engine.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/product-feedback.d.ts +26 -0
- package/dist/product-feedback.js +273 -0
- package/dist/product-feedback.js.map +1 -0
- package/dist/types.d.ts +126 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feedback-engine — logica pura da maquina de estados + throttle (contrato
|
|
3
|
+
* `CONTRATO_PRODUCT_FEEDBACK_2026-08-15.md` §4, `HANDOFF_PRODUCT_FEEDBACK.md` §2/§3).
|
|
4
|
+
*
|
|
5
|
+
* Separado do componente visual de proposito (mesma razao do `use-tour-position.ts` no
|
|
6
|
+
* page-tour): a deteccao/throttle e a parte que nao muda entre produtos, e fica testavel sem
|
|
7
|
+
* montar React/jsdom. Zero deps, funcoes puras (recebem `now` explicito — nunca `Date.now()`
|
|
8
|
+
* direto — pra dar pra testar deterministicamente).
|
|
9
|
+
*
|
|
10
|
+
* Referencia real (`ticket-notificacoes.ts` do InterPay v2, producao desde 2026-08-14): os dois
|
|
11
|
+
* gates globais (intervalo entre tickets do modal 1, intervalo cruzado 1<->2) sao computados como
|
|
12
|
+
* `MAX(timestamp)` OVER TODOS os tickets do usuario — nao um contador em memoria local, entao o
|
|
13
|
+
* throttle sobrevive a reload de pagina/troca de aba (o dado already esta no proprio ticket).
|
|
14
|
+
* Ordena por `resolvedAt` ascendente (o mais antigo primeiro) — evita que um ticket recem-resolvido
|
|
15
|
+
* "fure a fila" na frente de um que o usuario espera ha mais tempo.
|
|
16
|
+
*
|
|
17
|
+
* Uma diferenca deliberada da referencia: o InterPay so aplica o gate cruzado de 30min ao modal (1)
|
|
18
|
+
* contra `MAX(notificado_resolucao_em)` E `MAX(avaliacao_ultima_tentativa_em)`, mas so aplica ao
|
|
19
|
+
* modal (2) contra `MAX(notificado_resolucao_em)` (nao contra outras tentativas do modal 2). O
|
|
20
|
+
* contrato descreve a regra como simetrica ("qualquer ordem, qualquer ticket") — aqui os dois
|
|
21
|
+
* sentidos sao aplicados aos dois modais, fechando essa lacuna latente da implementacao original.
|
|
22
|
+
*/
|
|
23
|
+
import type { FeedbackThrottleConfig, ResolvedThrottleConfig, SupportTicket } from './types.js';
|
|
24
|
+
export declare const DEFAULT_THROTTLE: ResolvedThrottleConfig;
|
|
25
|
+
export declare function resolveThrottleConfig(partial?: FeedbackThrottleConfig): ResolvedThrottleConfig;
|
|
26
|
+
export declare function isPathExcluded(path: string, excludedPaths: string[] | ((path: string) => boolean) | undefined): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `ticket.pageUrl` correlaciona com `currentPath` "quando aplicavel" (contrato §4): se o ticket
|
|
29
|
+
* nao tem `pageUrl` registrado (reports antigos, ou o produto host nao capturou), nao ha
|
|
30
|
+
* restricao de rota — mostra em qualquer pagina. Aceita `pageUrl` como URL completa ou so path.
|
|
31
|
+
*/
|
|
32
|
+
export declare function matchesCurrentPath(ticket: Pick<SupportTicket, 'pageUrl'>, currentPath: string): boolean;
|
|
33
|
+
/** Elegivel pro modal (1): resolvido, nunca notificado, ainda nao arquivado por avaliacao. */
|
|
34
|
+
export declare function isResolvedModalEligible(ticket: SupportTicket): boolean;
|
|
35
|
+
/** Elegivel pro modal (2): ja notificado, nao arquivado, dentro do teto de tentativas por ticket. */
|
|
36
|
+
export declare function isSatisfactionModalEligible(ticket: SupportTicket, throttle: ResolvedThrottleConfig): boolean;
|
|
37
|
+
export interface PickCandidateArgs {
|
|
38
|
+
tickets: SupportTicket[];
|
|
39
|
+
now: number;
|
|
40
|
+
currentPath: string;
|
|
41
|
+
excludedPaths?: string[] | ((path: string) => boolean);
|
|
42
|
+
throttle: ResolvedThrottleConfig;
|
|
43
|
+
}
|
|
44
|
+
/** Proximo candidato ao modal (1) ("foi resolvido"), respeitando exclusao de rota + os dois gates
|
|
45
|
+
* globais (intervalo entre tickets do modal 1, intervalo cruzado 1<->2) — ou `null`. */
|
|
46
|
+
export declare function pickResolvedCandidate(args: PickCandidateArgs): SupportTicket | null;
|
|
47
|
+
/** Proximo candidato ao modal (2) ("o que achou?"), respeitando exclusao de rota, correlacao de
|
|
48
|
+
* pagina "quando aplicavel", teto+intervalo por-ticket e o gate cruzado global — ou `null`. */
|
|
49
|
+
export declare function pickSatisfactionCandidate(args: PickCandidateArgs): SupportTicket | null;
|
|
50
|
+
export declare function applyMarkResolvedSeen(tickets: SupportTicket[], ticketId: string, nowIso: string): SupportTicket[];
|
|
51
|
+
export declare function applyRecordSatisfactionAttempt(tickets: SupportTicket[], ticketId: string, nowIso: string): SupportTicket[];
|
|
52
|
+
export declare function applySubmitSatisfaction(tickets: SupportTicket[], ticketId: string, input: {
|
|
53
|
+
rating: number | null;
|
|
54
|
+
comment?: string | null;
|
|
55
|
+
nowIso: string;
|
|
56
|
+
}): SupportTicket[];
|
|
57
|
+
/** Contestacao (v1): reabre e ZERA o ciclo inteiro de notificacao/avaliacao — quando o admin
|
|
58
|
+
* re-resolver, o usuario volta a ser elegivel pro modal (1) do zero (contrato §2.6). */
|
|
59
|
+
export declare function applyContest(tickets: SupportTicket[], ticketId: string): SupportTicket[];
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feedback-engine — logica pura da maquina de estados + throttle (contrato
|
|
3
|
+
* `CONTRATO_PRODUCT_FEEDBACK_2026-08-15.md` §4, `HANDOFF_PRODUCT_FEEDBACK.md` §2/§3).
|
|
4
|
+
*
|
|
5
|
+
* Separado do componente visual de proposito (mesma razao do `use-tour-position.ts` no
|
|
6
|
+
* page-tour): a deteccao/throttle e a parte que nao muda entre produtos, e fica testavel sem
|
|
7
|
+
* montar React/jsdom. Zero deps, funcoes puras (recebem `now` explicito — nunca `Date.now()`
|
|
8
|
+
* direto — pra dar pra testar deterministicamente).
|
|
9
|
+
*
|
|
10
|
+
* Referencia real (`ticket-notificacoes.ts` do InterPay v2, producao desde 2026-08-14): os dois
|
|
11
|
+
* gates globais (intervalo entre tickets do modal 1, intervalo cruzado 1<->2) sao computados como
|
|
12
|
+
* `MAX(timestamp)` OVER TODOS os tickets do usuario — nao um contador em memoria local, entao o
|
|
13
|
+
* throttle sobrevive a reload de pagina/troca de aba (o dado already esta no proprio ticket).
|
|
14
|
+
* Ordena por `resolvedAt` ascendente (o mais antigo primeiro) — evita que um ticket recem-resolvido
|
|
15
|
+
* "fure a fila" na frente de um que o usuario espera ha mais tempo.
|
|
16
|
+
*
|
|
17
|
+
* Uma diferenca deliberada da referencia: o InterPay so aplica o gate cruzado de 30min ao modal (1)
|
|
18
|
+
* contra `MAX(notificado_resolucao_em)` E `MAX(avaliacao_ultima_tentativa_em)`, mas so aplica ao
|
|
19
|
+
* modal (2) contra `MAX(notificado_resolucao_em)` (nao contra outras tentativas do modal 2). O
|
|
20
|
+
* contrato descreve a regra como simetrica ("qualquer ordem, qualquer ticket") — aqui os dois
|
|
21
|
+
* sentidos sao aplicados aos dois modais, fechando essa lacuna latente da implementacao original.
|
|
22
|
+
*/
|
|
23
|
+
export const DEFAULT_THROTTLE = {
|
|
24
|
+
resolvedModalHoursBetweenTickets: 3,
|
|
25
|
+
satisfactionMaxAttempts: 2,
|
|
26
|
+
satisfactionHoursBetweenAttempts: 6,
|
|
27
|
+
crossModalMinMinutes: 30,
|
|
28
|
+
};
|
|
29
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
30
|
+
const MINUTE_MS = 60 * 1000;
|
|
31
|
+
export function resolveThrottleConfig(partial) {
|
|
32
|
+
return {
|
|
33
|
+
resolvedModalHoursBetweenTickets: partial?.resolvedModalHoursBetweenTickets ?? DEFAULT_THROTTLE.resolvedModalHoursBetweenTickets,
|
|
34
|
+
satisfactionMaxAttempts: partial?.satisfactionMaxAttempts ?? DEFAULT_THROTTLE.satisfactionMaxAttempts,
|
|
35
|
+
satisfactionHoursBetweenAttempts: partial?.satisfactionHoursBetweenAttempts ?? DEFAULT_THROTTLE.satisfactionHoursBetweenAttempts,
|
|
36
|
+
crossModalMinMinutes: partial?.crossModalMinMinutes ?? DEFAULT_THROTTLE.crossModalMinMinutes,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function parseTime(iso) {
|
|
40
|
+
if (!iso)
|
|
41
|
+
return null;
|
|
42
|
+
const t = new Date(iso).getTime();
|
|
43
|
+
return Number.isNaN(t) ? null : t;
|
|
44
|
+
}
|
|
45
|
+
function maxTime(tickets, pick) {
|
|
46
|
+
let max = null;
|
|
47
|
+
for (const t of tickets) {
|
|
48
|
+
const v = parseTime(pick(t));
|
|
49
|
+
if (v != null && (max == null || v > max))
|
|
50
|
+
max = v;
|
|
51
|
+
}
|
|
52
|
+
return max;
|
|
53
|
+
}
|
|
54
|
+
function maxOf(a, b) {
|
|
55
|
+
if (a == null)
|
|
56
|
+
return b;
|
|
57
|
+
if (b == null)
|
|
58
|
+
return a;
|
|
59
|
+
return Math.max(a, b);
|
|
60
|
+
}
|
|
61
|
+
/** `since == null` (nunca aconteceu) sempre libera. */
|
|
62
|
+
function elapsedAtLeast(since, now, amountMs) {
|
|
63
|
+
if (since == null)
|
|
64
|
+
return true;
|
|
65
|
+
return now - since >= amountMs;
|
|
66
|
+
}
|
|
67
|
+
export function isPathExcluded(path, excludedPaths) {
|
|
68
|
+
if (!excludedPaths)
|
|
69
|
+
return false;
|
|
70
|
+
if (typeof excludedPaths === 'function')
|
|
71
|
+
return excludedPaths(path);
|
|
72
|
+
return excludedPaths.includes(path);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* `ticket.pageUrl` correlaciona com `currentPath` "quando aplicavel" (contrato §4): se o ticket
|
|
76
|
+
* nao tem `pageUrl` registrado (reports antigos, ou o produto host nao capturou), nao ha
|
|
77
|
+
* restricao de rota — mostra em qualquer pagina. Aceita `pageUrl` como URL completa ou so path.
|
|
78
|
+
*/
|
|
79
|
+
export function matchesCurrentPath(ticket, currentPath) {
|
|
80
|
+
if (!ticket.pageUrl)
|
|
81
|
+
return true;
|
|
82
|
+
try {
|
|
83
|
+
const u = new URL(ticket.pageUrl, 'http://localhost');
|
|
84
|
+
return u.pathname === currentPath;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return ticket.pageUrl === currentPath;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Elegivel pro modal (1): resolvido, nunca notificado, ainda nao arquivado por avaliacao. */
|
|
91
|
+
export function isResolvedModalEligible(ticket) {
|
|
92
|
+
return ticket.status === 'resolved' && !ticket.resolvedNotifiedAt && !ticket.satisfiedAt;
|
|
93
|
+
}
|
|
94
|
+
/** Elegivel pro modal (2): ja notificado, nao arquivado, dentro do teto de tentativas por ticket. */
|
|
95
|
+
export function isSatisfactionModalEligible(ticket, throttle) {
|
|
96
|
+
if (!ticket.resolvedNotifiedAt || ticket.satisfiedAt)
|
|
97
|
+
return false;
|
|
98
|
+
const attempts = ticket.satisfactionAttempts ?? 0;
|
|
99
|
+
return attempts < throttle.satisfactionMaxAttempts;
|
|
100
|
+
}
|
|
101
|
+
function pickOldestByResolvedAt(tickets) {
|
|
102
|
+
if (tickets.length === 0)
|
|
103
|
+
return null;
|
|
104
|
+
const sorted = [...tickets].sort((a, b) => {
|
|
105
|
+
const ta = parseTime(a.resolvedAt) ?? Number.POSITIVE_INFINITY;
|
|
106
|
+
const tb = parseTime(b.resolvedAt) ?? Number.POSITIVE_INFINITY;
|
|
107
|
+
if (ta !== tb)
|
|
108
|
+
return ta - tb;
|
|
109
|
+
return a.id.localeCompare(b.id);
|
|
110
|
+
});
|
|
111
|
+
return sorted[0] ?? null;
|
|
112
|
+
}
|
|
113
|
+
/** Proximo candidato ao modal (1) ("foi resolvido"), respeitando exclusao de rota + os dois gates
|
|
114
|
+
* globais (intervalo entre tickets do modal 1, intervalo cruzado 1<->2) — ou `null`. */
|
|
115
|
+
export function pickResolvedCandidate(args) {
|
|
116
|
+
const { tickets, now, currentPath, excludedPaths, throttle } = args;
|
|
117
|
+
if (isPathExcluded(currentPath, excludedPaths))
|
|
118
|
+
return null;
|
|
119
|
+
const lastResolvedModalAt = maxTime(tickets, (t) => t.resolvedNotifiedAt);
|
|
120
|
+
const lastSatisfactionModalAt = maxTime(tickets, (t) => t.lastSatisfactionAttemptAt);
|
|
121
|
+
const lastAnyModalAt = maxOf(lastResolvedModalAt, lastSatisfactionModalAt);
|
|
122
|
+
if (!elapsedAtLeast(lastAnyModalAt, now, throttle.crossModalMinMinutes * MINUTE_MS))
|
|
123
|
+
return null;
|
|
124
|
+
if (!elapsedAtLeast(lastResolvedModalAt, now, throttle.resolvedModalHoursBetweenTickets * HOUR_MS))
|
|
125
|
+
return null;
|
|
126
|
+
const candidates = tickets.filter(isResolvedModalEligible);
|
|
127
|
+
return pickOldestByResolvedAt(candidates);
|
|
128
|
+
}
|
|
129
|
+
/** Proximo candidato ao modal (2) ("o que achou?"), respeitando exclusao de rota, correlacao de
|
|
130
|
+
* pagina "quando aplicavel", teto+intervalo por-ticket e o gate cruzado global — ou `null`. */
|
|
131
|
+
export function pickSatisfactionCandidate(args) {
|
|
132
|
+
const { tickets, now, currentPath, excludedPaths, throttle } = args;
|
|
133
|
+
if (isPathExcluded(currentPath, excludedPaths))
|
|
134
|
+
return null;
|
|
135
|
+
const lastResolvedModalAt = maxTime(tickets, (t) => t.resolvedNotifiedAt);
|
|
136
|
+
const lastSatisfactionModalAt = maxTime(tickets, (t) => t.lastSatisfactionAttemptAt);
|
|
137
|
+
const lastAnyModalAt = maxOf(lastResolvedModalAt, lastSatisfactionModalAt);
|
|
138
|
+
if (!elapsedAtLeast(lastAnyModalAt, now, throttle.crossModalMinMinutes * MINUTE_MS))
|
|
139
|
+
return null;
|
|
140
|
+
const perTicketGapMs = throttle.satisfactionHoursBetweenAttempts * HOUR_MS;
|
|
141
|
+
const candidates = tickets.filter((t) => {
|
|
142
|
+
if (!isSatisfactionModalEligible(t, throttle))
|
|
143
|
+
return false;
|
|
144
|
+
if (!matchesCurrentPath(t, currentPath))
|
|
145
|
+
return false;
|
|
146
|
+
return elapsedAtLeast(parseTime(t.lastSatisfactionAttemptAt), now, perTicketGapMs);
|
|
147
|
+
});
|
|
148
|
+
return pickOldestByResolvedAt(candidates);
|
|
149
|
+
}
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
// Atualizacao otimista local — espelha o efeito que cada mutacao do SupportClient produz no
|
|
152
|
+
// servidor, aplicada IMEDIATAMENTE (sem esperar round-trip) pra: (a) o proximo pick* ja respeitar
|
|
153
|
+
// o novo estado sem precisar de refetch, (b) a regra-chave "mostrar ja conta como tentativa" valer
|
|
154
|
+
// mesmo se a chamada de rede falhar/demorar (a UI nao deve re-perguntar so por causa de latencia).
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
export function applyMarkResolvedSeen(tickets, ticketId, nowIso) {
|
|
157
|
+
return tickets.map((t) => (t.id === ticketId && !t.resolvedNotifiedAt ? { ...t, resolvedNotifiedAt: nowIso } : t));
|
|
158
|
+
}
|
|
159
|
+
export function applyRecordSatisfactionAttempt(tickets, ticketId, nowIso) {
|
|
160
|
+
return tickets.map((t) => t.id === ticketId
|
|
161
|
+
? { ...t, satisfactionAttempts: (t.satisfactionAttempts ?? 0) + 1, lastSatisfactionAttemptAt: nowIso }
|
|
162
|
+
: t);
|
|
163
|
+
}
|
|
164
|
+
export function applySubmitSatisfaction(tickets, ticketId, input) {
|
|
165
|
+
return tickets.map((t) => t.id === ticketId
|
|
166
|
+
? { ...t, satisfiedAt: input.nowIso, rating: input.rating, satisfactionComment: input.comment ?? null }
|
|
167
|
+
: t);
|
|
168
|
+
}
|
|
169
|
+
/** Contestacao (v1): reabre e ZERA o ciclo inteiro de notificacao/avaliacao — quando o admin
|
|
170
|
+
* re-resolver, o usuario volta a ser elegivel pro modal (1) do zero (contrato §2.6). */
|
|
171
|
+
export function applyContest(tickets, ticketId) {
|
|
172
|
+
return tickets.map((t) => t.id === ticketId
|
|
173
|
+
? {
|
|
174
|
+
...t,
|
|
175
|
+
status: 'open',
|
|
176
|
+
resolvedAt: null,
|
|
177
|
+
resolvedNotifiedAt: null,
|
|
178
|
+
satisfactionAttempts: 0,
|
|
179
|
+
lastSatisfactionAttemptAt: null,
|
|
180
|
+
satisfiedAt: null,
|
|
181
|
+
rating: null,
|
|
182
|
+
satisfactionComment: null,
|
|
183
|
+
}
|
|
184
|
+
: t);
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=feedback-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback-engine.js","sourceRoot":"","sources":["../src/feedback-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,gCAAgC,EAAE,CAAC;IACnC,uBAAuB,EAAE,CAAC;IAC1B,gCAAgC,EAAE,CAAC;IACnC,oBAAoB,EAAE,EAAE;CACzB,CAAC;AAEF,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/B,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5B,MAAM,UAAU,qBAAqB,CAAC,OAAgC;IACpE,OAAO;QACL,gCAAgC,EAC9B,OAAO,EAAE,gCAAgC,IAAI,gBAAgB,CAAC,gCAAgC;QAChG,uBAAuB,EAAE,OAAO,EAAE,uBAAuB,IAAI,gBAAgB,CAAC,uBAAuB;QACrG,gCAAgC,EAC9B,OAAO,EAAE,gCAAgC,IAAI,gBAAgB,CAAC,gCAAgC;QAChG,oBAAoB,EAAE,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,CAAC,oBAAoB;KAC7F,CAAC;AACJ,CAAC;AAED,SAAS,SAA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BAAkB,EAAE,IAAI;YACxB,oBAAoB,EAAE,CAAC;YACvB,yBAAyB,EAAE,IAAI;YAC/B,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;YACZ,mBAAmB,EAAE,IAAI;SAC1B;QACH,CAAC,CAAC,CAAC,CACN,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ProductFeedback } from './product-feedback.js';
|
|
2
|
+
export { DEFAULT_THROTTLE, applyContest, applyMarkResolvedSeen, applyRecordSatisfactionAttempt, applySubmitSatisfaction, isPathExcluded, isResolvedModalEligible, isSatisfactionModalEligible, matchesCurrentPath, pickResolvedCandidate, pickSatisfactionCandidate, resolveThrottleConfig, } from './feedback-engine.js';
|
|
3
|
+
export type { ContestTicketOptions, FeedbackThrottleConfig, ProductFeedbackClassNames, ProductFeedbackClient, ProductFeedbackProps, ResolvedModalProps, ResolvedModalTicket, ResolvedThrottleConfig, SatisfactionModalProps, SatisfactionModalTicket, SubmitSatisfactionInput, SupportClient, SupportTicket, } from './types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ProductFeedback } from './product-feedback.js';
|
|
2
|
+
export { DEFAULT_THROTTLE, applyContest, applyMarkResolvedSeen, applyRecordSatisfactionAttempt, applySubmitSatisfaction, isPathExcluded, isResolvedModalEligible, isSatisfactionModalEligible, matchesCurrentPath, pickResolvedCandidate, pickSatisfactionCandidate, resolveThrottleConfig, } from './feedback-engine.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACvB,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProductFeedback — fecha o loop "reportei um problema -> nunca soube se foi resolvido -> minha
|
|
3
|
+
* opiniao nunca foi pedida". Detecta client-side (via `client.support.listMyTickets()`) tickets
|
|
4
|
+
* do usuario que foram resolvidos e ainda nao avisados, e tickets ja avisados que ainda nao
|
|
5
|
+
* receberam avaliacao — mostra no maximo 1 modal por vez, respeitando throttle configuravel.
|
|
6
|
+
*
|
|
7
|
+
* Extraido do produto InterPay v2 (bug real: o usuario reportava um problema e nunca ficava
|
|
8
|
+
* sabendo se/quando foi resolvido, nem tinha como avaliar a solucao). Headless por padrao — sem
|
|
9
|
+
* Tailwind, sem lib de icones, sem componente de design system — so `classNames` pra estilizar o
|
|
10
|
+
* modal default, ou `render*` pra substitui-lo por completo. O modal default (Neetru-branded,
|
|
11
|
+
* BMW: retangular, sem glass/sombra pesada) e uma implementacao CONCRETA por cima da MESMA API
|
|
12
|
+
* headless, nao um caminho separado.
|
|
13
|
+
*
|
|
14
|
+
* Maquina de estados (4, `HANDOFF_PRODUCT_FEEDBACK.md` §2):
|
|
15
|
+
* ATIVO -> RESOLVIDO_NAO_NOTIFICADO -> RESOLVIDO_NOTIFICADO_NAO_AVALIADO -> {ARQUIVADO | ATIVO (contesta)}
|
|
16
|
+
*
|
|
17
|
+
* Regra-chave: EXIBIR o modal ja conta como tentativa (`markResolvedSeen`/`recordSatisfactionAttempt`
|
|
18
|
+
* chamados no SHOW, nao na resposta) — evita reprompt infinito quando o usuario so fecha sem
|
|
19
|
+
* interagir. Ver `feedback-engine.ts` pro throttle/deteccao (logica pura, testada isoladamente).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <ProductFeedback client={neetruClient} currentPath={usePathname()} suppressWhile={() => tourAberto} />
|
|
23
|
+
*/
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import type { ProductFeedbackProps } from './types.js';
|
|
26
|
+
export declare function ProductFeedback(props: ProductFeedbackProps): React.ReactNode;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* ProductFeedback — fecha o loop "reportei um problema -> nunca soube se foi resolvido -> minha
|
|
4
|
+
* opiniao nunca foi pedida". Detecta client-side (via `client.support.listMyTickets()`) tickets
|
|
5
|
+
* do usuario que foram resolvidos e ainda nao avisados, e tickets ja avisados que ainda nao
|
|
6
|
+
* receberam avaliacao — mostra no maximo 1 modal por vez, respeitando throttle configuravel.
|
|
7
|
+
*
|
|
8
|
+
* Extraido do produto InterPay v2 (bug real: o usuario reportava um problema e nunca ficava
|
|
9
|
+
* sabendo se/quando foi resolvido, nem tinha como avaliar a solucao). Headless por padrao — sem
|
|
10
|
+
* Tailwind, sem lib de icones, sem componente de design system — so `classNames` pra estilizar o
|
|
11
|
+
* modal default, ou `render*` pra substitui-lo por completo. O modal default (Neetru-branded,
|
|
12
|
+
* BMW: retangular, sem glass/sombra pesada) e uma implementacao CONCRETA por cima da MESMA API
|
|
13
|
+
* headless, nao um caminho separado.
|
|
14
|
+
*
|
|
15
|
+
* Maquina de estados (4, `HANDOFF_PRODUCT_FEEDBACK.md` §2):
|
|
16
|
+
* ATIVO -> RESOLVIDO_NAO_NOTIFICADO -> RESOLVIDO_NOTIFICADO_NAO_AVALIADO -> {ARQUIVADO | ATIVO (contesta)}
|
|
17
|
+
*
|
|
18
|
+
* Regra-chave: EXIBIR o modal ja conta como tentativa (`markResolvedSeen`/`recordSatisfactionAttempt`
|
|
19
|
+
* chamados no SHOW, nao na resposta) — evita reprompt infinito quando o usuario so fecha sem
|
|
20
|
+
* interagir. Ver `feedback-engine.ts` pro throttle/deteccao (logica pura, testada isoladamente).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <ProductFeedback client={neetruClient} currentPath={usePathname()} suppressWhile={() => tourAberto} />
|
|
24
|
+
*/
|
|
25
|
+
import * as React from 'react';
|
|
26
|
+
import { createPortal } from 'react-dom';
|
|
27
|
+
import { applyContest, applyMarkResolvedSeen, applyRecordSatisfactionAttempt, applySubmitSatisfaction, isPathExcluded, pickResolvedCandidate, pickSatisfactionCandidate, resolveThrottleConfig, } from './feedback-engine.js';
|
|
28
|
+
const EMPTY_CLASS_NAMES = {
|
|
29
|
+
resolvedModal: '',
|
|
30
|
+
satisfactionModal: '',
|
|
31
|
+
starButton: '',
|
|
32
|
+
starButtonActive: '',
|
|
33
|
+
};
|
|
34
|
+
export function ProductFeedback(props) {
|
|
35
|
+
const { client, currentPath, excludedPaths, suppressWhile, throttle: throttleProp, renderResolvedModal, renderSatisfactionModal, classNames, onResolvedModalShown, onSatisfactionShown, onSatisfactionSubmitted, onSatisfactionSkipped, onTicketContested, } = props;
|
|
36
|
+
const throttle = resolveThrottleConfig(throttleProp);
|
|
37
|
+
const [active, setActive] = React.useState(null);
|
|
38
|
+
// Correcao otimista "de um uso so": guarda o ticket como DEVERIA estar logo apos uma acao local
|
|
39
|
+
// (show/submit/skip/contest), pra o PROXIMO fetch (que dispara imediatamente ao fechar o modal,
|
|
40
|
+
// ja que o efeito depende de `active`) nao reconsiderar o MESMO ticket com dado stale do servidor
|
|
41
|
+
// (a chamada de rede da acao e fire-and-forget; sem isto, fechar o modal (1) e recarregar rapido
|
|
42
|
+
// demais podia reabrir o MESMO modal porque o servidor ainda nao tinha persistido `markResolvedSeen`).
|
|
43
|
+
// Consumida (`.clear()`) no fetch seguinte -- so cobre essa corrida imediata; dali em diante confia
|
|
44
|
+
// 100% na rede (nao mascara pra sempre um estado que o servidor legitimamente mudou depois, ex.:
|
|
45
|
+
// reabrir->re-resolver).
|
|
46
|
+
const localOverridesRef = React.useRef(new Map());
|
|
47
|
+
// Defesa extra (barata) contra disparo duplicado de markResolvedSeen/recordSatisfactionAttempt --
|
|
48
|
+
// nao estritamente necessaria dado o guard `alive` abaixo, mas espelha o padrao da referencia real
|
|
49
|
+
// (notificadosRef/tentativasRef em ticket-notificacoes.ts). Chave inclui a tentativa no modal (2)
|
|
50
|
+
// porque o MESMO ticket pode legitimamente ser mostrado de novo depois do cooldown por-ticket.
|
|
51
|
+
const shownRef = React.useRef(new Set());
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (active)
|
|
54
|
+
return; // ja tem modal aberto -- nao busca nem troca por baixo (nao empilha).
|
|
55
|
+
if (suppressWhile?.())
|
|
56
|
+
return; // ex.: @neetru/page-tour ativo (achado real, handoff §3).
|
|
57
|
+
// Espelha a referencia real (ROTA_EXCLUIDA em notificacoes-ticket.tsx): nem busca em rota
|
|
58
|
+
// excluida, nao so deixa de mostrar — evita trafego de rede inutil numa tela critica (checkout).
|
|
59
|
+
if (isPathExcluded(currentPath, excludedPaths))
|
|
60
|
+
return;
|
|
61
|
+
let alive = true;
|
|
62
|
+
(async () => {
|
|
63
|
+
let fresh;
|
|
64
|
+
try {
|
|
65
|
+
fresh = await client.support.listMyTickets();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return; // fail-quiet -- feedback e secundario, nunca deve quebrar a pagina host.
|
|
69
|
+
}
|
|
70
|
+
if (!alive)
|
|
71
|
+
return;
|
|
72
|
+
const overrides = localOverridesRef.current;
|
|
73
|
+
const merged = overrides.size > 0 ? fresh.map((t) => overrides.get(t.id) ?? t) : fresh;
|
|
74
|
+
overrides.clear();
|
|
75
|
+
const now = Date.now();
|
|
76
|
+
const resolvedCandidate = pickResolvedCandidate({ tickets: merged, now, currentPath, excludedPaths, throttle });
|
|
77
|
+
if (resolvedCandidate) {
|
|
78
|
+
showResolvedModal(resolvedCandidate);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const satisfactionCandidate = pickSatisfactionCandidate({
|
|
82
|
+
tickets: merged,
|
|
83
|
+
now,
|
|
84
|
+
currentPath,
|
|
85
|
+
excludedPaths,
|
|
86
|
+
throttle,
|
|
87
|
+
});
|
|
88
|
+
if (satisfactionCandidate) {
|
|
89
|
+
showSatisfactionModal(satisfactionCandidate);
|
|
90
|
+
}
|
|
91
|
+
})();
|
|
92
|
+
return () => {
|
|
93
|
+
alive = false;
|
|
94
|
+
};
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
+
}, [currentPath, active]);
|
|
97
|
+
function showResolvedModal(ticket) {
|
|
98
|
+
const guardKey = `resolved:${ticket.id}`;
|
|
99
|
+
if (shownRef.current.has(guardKey))
|
|
100
|
+
return;
|
|
101
|
+
shownRef.current.add(guardKey);
|
|
102
|
+
const nowIso = new Date().toISOString();
|
|
103
|
+
const optimistic = applyMarkResolvedSeen([ticket], ticket.id, nowIso).find((t) => t.id === ticket.id) ?? ticket;
|
|
104
|
+
localOverridesRef.current.set(ticket.id, optimistic);
|
|
105
|
+
setActive({ kind: 'resolved', ticket: optimistic });
|
|
106
|
+
onResolvedModalShown?.(ticket.id);
|
|
107
|
+
void client.support.markResolvedSeen(ticket.id).catch(() => { });
|
|
108
|
+
}
|
|
109
|
+
function showSatisfactionModal(ticket) {
|
|
110
|
+
const attempt = (ticket.satisfactionAttempts ?? 0) + 1;
|
|
111
|
+
const guardKey = `satisfaction:${ticket.id}:${attempt}`;
|
|
112
|
+
if (shownRef.current.has(guardKey))
|
|
113
|
+
return;
|
|
114
|
+
shownRef.current.add(guardKey);
|
|
115
|
+
const nowIso = new Date().toISOString();
|
|
116
|
+
const optimistic = applyRecordSatisfactionAttempt([ticket], ticket.id, nowIso).find((t) => t.id === ticket.id) ?? ticket;
|
|
117
|
+
localOverridesRef.current.set(ticket.id, optimistic);
|
|
118
|
+
setActive({ kind: 'satisfaction', ticket: optimistic, attempt });
|
|
119
|
+
onSatisfactionShown?.(ticket.id, attempt);
|
|
120
|
+
void client.support.recordSatisfactionAttempt(ticket.id).catch(() => { });
|
|
121
|
+
}
|
|
122
|
+
const closeActive = React.useCallback(() => setActive(null), []);
|
|
123
|
+
function handleSubmit(rating, comment) {
|
|
124
|
+
if (!active)
|
|
125
|
+
return;
|
|
126
|
+
const ticketId = active.ticket.id;
|
|
127
|
+
const nowIso = new Date().toISOString();
|
|
128
|
+
const optimistic = applySubmitSatisfaction([active.ticket], ticketId, { rating, comment, nowIso }).find((t) => t.id === ticketId) ??
|
|
129
|
+
active.ticket;
|
|
130
|
+
localOverridesRef.current.set(ticketId, optimistic);
|
|
131
|
+
onSatisfactionSubmitted?.(ticketId, rating, comment);
|
|
132
|
+
closeActive();
|
|
133
|
+
void client.support.submitSatisfaction({ ticketId, rating, comment, skipped: false }).catch(() => { });
|
|
134
|
+
}
|
|
135
|
+
function handleSkip() {
|
|
136
|
+
if (!active)
|
|
137
|
+
return;
|
|
138
|
+
const ticketId = active.ticket.id;
|
|
139
|
+
const nowIso = new Date().toISOString();
|
|
140
|
+
const optimistic = applySubmitSatisfaction([active.ticket], ticketId, { rating: null, comment: null, nowIso }).find((t) => t.id === ticketId) ?? active.ticket;
|
|
141
|
+
localOverridesRef.current.set(ticketId, optimistic);
|
|
142
|
+
onSatisfactionSkipped?.(ticketId);
|
|
143
|
+
closeActive();
|
|
144
|
+
void client.support.submitSatisfaction({ ticketId, rating: null, comment: null, skipped: true }).catch(() => { });
|
|
145
|
+
}
|
|
146
|
+
function handleContest(comment) {
|
|
147
|
+
if (!active)
|
|
148
|
+
return;
|
|
149
|
+
const ticketId = active.ticket.id;
|
|
150
|
+
const optimistic = applyContest([active.ticket], ticketId).find((t) => t.id === ticketId) ?? active.ticket;
|
|
151
|
+
localOverridesRef.current.set(ticketId, optimistic);
|
|
152
|
+
onTicketContested?.(ticketId);
|
|
153
|
+
closeActive();
|
|
154
|
+
void client.support.contestTicket(ticketId, comment ? { comment } : undefined).catch(() => { });
|
|
155
|
+
}
|
|
156
|
+
if (typeof document === 'undefined' || !active)
|
|
157
|
+
return null;
|
|
158
|
+
const cn = { ...EMPTY_CLASS_NAMES, ...classNames };
|
|
159
|
+
if (active.kind === 'resolved') {
|
|
160
|
+
const renderProps = {
|
|
161
|
+
ticket: {
|
|
162
|
+
id: active.ticket.id,
|
|
163
|
+
subject: active.ticket.subject,
|
|
164
|
+
message: active.ticket.message,
|
|
165
|
+
screenshotUrl: active.ticket.screenshotUrl ?? null,
|
|
166
|
+
},
|
|
167
|
+
onDismiss: closeActive,
|
|
168
|
+
onContest: handleContest,
|
|
169
|
+
};
|
|
170
|
+
return createPortal(renderResolvedModal ? (_jsx(_Fragment, { children: renderResolvedModal(renderProps) })) : (_jsx(DefaultResolvedModal, { ...renderProps, className: cn.resolvedModal })), document.body);
|
|
171
|
+
}
|
|
172
|
+
const renderProps = {
|
|
173
|
+
ticket: { id: active.ticket.id, subject: active.ticket.subject, message: active.ticket.message },
|
|
174
|
+
onSubmit: handleSubmit,
|
|
175
|
+
onSkip: handleSkip,
|
|
176
|
+
onDismiss: closeActive,
|
|
177
|
+
onContest: handleContest,
|
|
178
|
+
};
|
|
179
|
+
return createPortal(renderSatisfactionModal ? (_jsx(_Fragment, { children: renderSatisfactionModal(renderProps) })) : (_jsx(DefaultSatisfactionModal, { ...renderProps, className: cn.satisfactionModal, starButtonClassName: cn.starButton, starButtonActiveClassName: cn.starButtonActive })), document.body);
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// Modais default — Neetru-branded (BMW: retangular, sem glassmorphism/sombra pesada, sem lib de
|
|
183
|
+
// icones forcada — SVG inline). Estilo via `style` inline (nao Tailwind) pra funcionar em
|
|
184
|
+
// qualquer produto host sem exigir um design system especifico; `className` (de `classNames`)
|
|
185
|
+
// e aplicado JUNTO, pra o host poder estender/sobrescrever sem precisar de `render*`.
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
const overlayStyle = {
|
|
188
|
+
position: 'fixed',
|
|
189
|
+
inset: 0,
|
|
190
|
+
zIndex: 999999,
|
|
191
|
+
background: 'rgba(0,0,0,0.6)',
|
|
192
|
+
display: 'flex',
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
justifyContent: 'center',
|
|
195
|
+
padding: 16,
|
|
196
|
+
};
|
|
197
|
+
const cardStyle = {
|
|
198
|
+
background: '#fff',
|
|
199
|
+
color: '#0a0a0a',
|
|
200
|
+
border: '1px solid #0a0a0a',
|
|
201
|
+
borderRadius: 0,
|
|
202
|
+
boxShadow: 'none',
|
|
203
|
+
width: '100%',
|
|
204
|
+
maxWidth: 420,
|
|
205
|
+
maxHeight: 'calc(100vh - 32px)',
|
|
206
|
+
overflowY: 'auto',
|
|
207
|
+
};
|
|
208
|
+
const headerStyle = {
|
|
209
|
+
display: 'flex',
|
|
210
|
+
alignItems: 'flex-start',
|
|
211
|
+
justifyContent: 'space-between',
|
|
212
|
+
gap: 12,
|
|
213
|
+
padding: '16px 20px',
|
|
214
|
+
borderBottom: '1px solid #e5e5e5',
|
|
215
|
+
};
|
|
216
|
+
const bodyStyle = { padding: '16px 20px', display: 'flex', flexDirection: 'column', gap: 12 };
|
|
217
|
+
const footerStyle = {
|
|
218
|
+
display: 'flex',
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
justifyContent: 'space-between',
|
|
221
|
+
gap: 12,
|
|
222
|
+
padding: '16px 20px',
|
|
223
|
+
borderTop: '1px solid #e5e5e5',
|
|
224
|
+
};
|
|
225
|
+
const buttonBase = {
|
|
226
|
+
borderRadius: 0,
|
|
227
|
+
boxShadow: 'none',
|
|
228
|
+
border: '1px solid #0a0a0a',
|
|
229
|
+
padding: '10px 20px',
|
|
230
|
+
fontSize: 13,
|
|
231
|
+
letterSpacing: '0.04em',
|
|
232
|
+
textTransform: 'uppercase',
|
|
233
|
+
cursor: 'pointer',
|
|
234
|
+
};
|
|
235
|
+
const primaryButtonStyle = { ...buttonBase, background: '#0a0a0a', color: '#fff' };
|
|
236
|
+
const secondaryButtonStyle = { ...buttonBase, background: '#fff', color: '#0a0a0a' };
|
|
237
|
+
const ghostButtonStyle = {
|
|
238
|
+
border: 'none',
|
|
239
|
+
background: 'transparent',
|
|
240
|
+
color: '#6b6b6b',
|
|
241
|
+
fontSize: 12,
|
|
242
|
+
textDecoration: 'underline',
|
|
243
|
+
cursor: 'pointer',
|
|
244
|
+
padding: 0,
|
|
245
|
+
};
|
|
246
|
+
function CloseIcon() {
|
|
247
|
+
return (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", "aria-hidden": "true", children: _jsx("path", { d: "M18 6 6 18M6 6l12 12", strokeLinecap: "round" }) }));
|
|
248
|
+
}
|
|
249
|
+
function StarIcon({ filled }) {
|
|
250
|
+
return (_jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: filled ? '#0a0a0a' : 'none', stroke: "#0a0a0a", strokeWidth: 1.5, "aria-hidden": "true", children: _jsx("path", { d: "M12 2.5l2.9 6.06 6.6.77-4.87 4.62 1.28 6.55L12 17.4l-5.91 3.1 1.28-6.55L2.5 9.33l6.6-.77L12 2.5z", strokeLinejoin: "round" }) }));
|
|
251
|
+
}
|
|
252
|
+
function DefaultResolvedModal({ ticket, onDismiss, onContest, className, }) {
|
|
253
|
+
const [contesting, setContesting] = React.useState(false);
|
|
254
|
+
const [comment, setComment] = React.useState('');
|
|
255
|
+
return (_jsx("div", { style: overlayStyle, role: "presentation", onMouseDown: (e) => {
|
|
256
|
+
if (e.target === e.currentTarget)
|
|
257
|
+
onDismiss();
|
|
258
|
+
}, children: _jsxs("div", { style: cardStyle, className: className, role: "dialog", "aria-modal": "true", "data-testid": "neetru-product-feedback-resolved-modal", children: [_jsxs("div", { style: headerStyle, children: [_jsxs("div", { children: [_jsx("h4", { style: { margin: 0, fontWeight: 700 }, children: "Seu chamado foi resolvido" }), _jsxs("p", { style: { margin: '4px 0 0', fontSize: 12, color: '#6b6b6b' }, children: ["Ticket #", ticket.id] })] }), _jsx("button", { type: "button", onClick: onDismiss, "aria-label": "Fechar", style: { ...ghostButtonStyle, textDecoration: 'none' }, children: _jsx(CloseIcon, {}) })] }), _jsxs("div", { style: bodyStyle, children: [_jsxs("div", { children: [_jsx("p", { style: { margin: 0, fontSize: 11, fontWeight: 700, textTransform: 'uppercase', color: '#6b6b6b' }, children: "O que voc\u00EA reportou" }), _jsx("p", { style: { margin: '4px 0 0', fontSize: 14, whiteSpace: 'pre-wrap' }, children: ticket.message || ticket.subject })] }), ticket.screenshotUrl ? (
|
|
259
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
260
|
+
_jsx("img", { src: ticket.screenshotUrl, alt: "Print enviado no chamado", style: { width: '100%', border: '1px solid #e5e5e5' } })) : null, contesting ? (_jsxs("div", { children: [_jsx("label", { style: { display: 'block', fontSize: 11, fontWeight: 700, textTransform: 'uppercase', color: '#6b6b6b', marginBottom: 4 }, children: "O que n\u00E3o atendeu?" }), _jsx("textarea", { value: comment, onChange: (e) => setComment(e.target.value), rows: 3, maxLength: 2000, style: { width: '100%', border: '1px solid #0a0a0a', borderRadius: 0, padding: 8, fontSize: 13, resize: 'vertical' } })] })) : null] }), _jsx("div", { style: footerStyle, children: contesting ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => setContesting(false), style: ghostButtonStyle, children: "Cancelar" }), _jsx("button", { type: "button", onClick: () => onContest(comment.trim() || undefined), style: secondaryButtonStyle, children: "Reabrir chamado" })] })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => setContesting(true), style: ghostButtonStyle, children: "Isso n\u00E3o resolveu" }), _jsx("button", { type: "button", onClick: onDismiss, style: primaryButtonStyle, children: "Entendi" })] })) })] }) }));
|
|
261
|
+
}
|
|
262
|
+
function DefaultSatisfactionModal({ ticket, onSubmit, onSkip, onDismiss, onContest, className, starButtonClassName, starButtonActiveClassName, }) {
|
|
263
|
+
const [rating, setRating] = React.useState(0);
|
|
264
|
+
const [hover, setHover] = React.useState(0);
|
|
265
|
+
const [comment, setComment] = React.useState('');
|
|
266
|
+
const [contesting, setContesting] = React.useState(false);
|
|
267
|
+
const active = hover || rating;
|
|
268
|
+
return (_jsx("div", { style: overlayStyle, role: "presentation", onMouseDown: (e) => {
|
|
269
|
+
if (e.target === e.currentTarget)
|
|
270
|
+
onDismiss();
|
|
271
|
+
}, children: _jsxs("div", { style: cardStyle, className: className, role: "dialog", "aria-modal": "true", "data-testid": "neetru-product-feedback-satisfaction-modal", children: [_jsxs("div", { style: headerStyle, children: [_jsx("h4", { style: { margin: 0, fontWeight: 700 }, children: "O que achou da solu\u00E7\u00E3o?" }), _jsx("button", { type: "button", onClick: onDismiss, "aria-label": "Fechar", style: { ...ghostButtonStyle, textDecoration: 'none' }, children: _jsx(CloseIcon, {}) })] }), _jsxs("div", { style: bodyStyle, children: [_jsxs("p", { style: { margin: 0, fontSize: 13, color: '#6b6b6b' }, children: ["Ticket #", ticket.id, " \u2014 ", ticket.subject] }), _jsx("div", { style: { display: 'flex', justifyContent: 'center', gap: 6, padding: '8px 0' }, children: [1, 2, 3, 4, 5].map((n) => (_jsx("button", { type: "button", onClick: () => setRating(n), onMouseEnter: () => setHover(n), onMouseLeave: () => setHover(0), "aria-label": `${n} estrela${n > 1 ? 's' : ''}`, className: active >= n ? starButtonActiveClassName : starButtonClassName, style: { background: 'none', border: 'none', padding: 2, cursor: 'pointer' }, children: _jsx(StarIcon, { filled: active >= n }) }, n))) }), contesting ? (_jsxs("div", { children: [_jsx("label", { style: { display: 'block', fontSize: 11, fontWeight: 700, textTransform: 'uppercase', color: '#6b6b6b', marginBottom: 4 }, children: "O que n\u00E3o atendeu?" }), _jsx("textarea", { value: comment, onChange: (e) => setComment(e.target.value), rows: 3, maxLength: 2000, style: { width: '100%', border: '1px solid #0a0a0a', borderRadius: 0, padding: 8, fontSize: 13, resize: 'vertical' } })] })) : (_jsxs("div", { children: [_jsx("label", { style: { display: 'block', fontSize: 11, fontWeight: 700, textTransform: 'uppercase', color: '#6b6b6b', marginBottom: 4 }, children: "Coment\u00E1rio (opcional)" }), _jsx("textarea", { value: comment, onChange: (e) => setComment(e.target.value), rows: 3, maxLength: 2000, style: { width: '100%', border: '1px solid #0a0a0a', borderRadius: 0, padding: 8, fontSize: 13, resize: 'vertical' } })] })), _jsx("button", { type: "button", onClick: () => setContesting((v) => !v), style: { ...ghostButtonStyle, alignSelf: 'flex-start' }, children: contesting ? 'Cancelar / avaliar em vez disso' : 'Isso não resolveu meu problema' })] }), _jsxs("div", { style: footerStyle, children: [_jsx("button", { type: "button", onClick: onSkip, style: ghostButtonStyle, children: "Ignorar" }), contesting ? (_jsx("button", { type: "button", onClick: () => onContest(comment.trim() || undefined), style: secondaryButtonStyle, children: "Reabrir chamado" })) : (_jsx("button", { type: "button", onClick: () => onSubmit(rating, comment.trim() || null), disabled: rating === 0, style: primaryButtonStyle, children: "Enviar avalia\u00E7\u00E3o" }))] })] }) }));
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=product-feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-feedback.js","sourceRoot":"","sources":["../src/product-feedback.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,8BAA8B,EAC9B,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAc9B,MAAM,iBAAiB,GAAwC;IAC7D,aAAa,EAAE,EAAE;IACjB,iBAAiB,EAAE,EAAE;IACrB,UAAU,EAAE,EAAE;IACd,gBAAgB,EAAE,EAAE;CACrB,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EACJ,MAAM,EACN,WAAW,EACX,aAAa,EACb,aAAa,EACb,QAAQ,EAAE,YA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E,kBAAkB,2CAEvH,CACV,IACG,IACF,GACF,CACP,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Ticket de suporte, no subconjunto de campos que este pacote consome (contrato
|
|
4
|
+
* `CONTRATO_PRODUCT_FEEDBACK_2026-08-15.md` §1/§3). Tipado estruturalmente contra o retorno de
|
|
5
|
+
* `client.support.listMyTickets()` — NAO importa `@neetru/sdk` (o produto host casa os tipos).
|
|
6
|
+
*/
|
|
7
|
+
export interface SupportTicket {
|
|
8
|
+
id: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
message: string;
|
|
11
|
+
status: 'open' | 'in_progress' | 'resolved' | 'closed';
|
|
12
|
+
/** URL (completa ou so pathname) de onde o ticket foi reportado. Usada pra correlacionar com
|
|
13
|
+
* `currentPath` no modal de satisfacao — "quando aplicavel" (ver `matchesCurrentPath`). */
|
|
14
|
+
pageUrl?: string | null;
|
|
15
|
+
/** Primeiro anexo (screenshot), se houver — ja resolvido pelo SDK (`attachments[0] ?? null`). */
|
|
16
|
+
screenshotUrl?: string | null;
|
|
17
|
+
resolvedAt?: string | null;
|
|
18
|
+
/** ISO; null = elegivel pro modal (1). Setado (otimisticamente) quando o modal (1) e EXIBIDO. */
|
|
19
|
+
resolvedNotifiedAt?: string | null;
|
|
20
|
+
/** Default 0. Incrementado (otimisticamente) quando o modal (2) e EXIBIDO. */
|
|
21
|
+
satisfactionAttempts?: number;
|
|
22
|
+
lastSatisfactionAttemptAt?: string | null;
|
|
23
|
+
/** ISO; preenchido = arquivado (avaliou OU pulou). Nao mostra mais nenhum modal pra este ticket. */
|
|
24
|
+
satisfiedAt?: string | null;
|
|
25
|
+
rating?: number | null;
|
|
26
|
+
satisfactionComment?: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface SubmitSatisfactionInput {
|
|
29
|
+
ticketId: string;
|
|
30
|
+
/** 1-5; `null` quando `skipped: true`. */
|
|
31
|
+
rating: number | null;
|
|
32
|
+
comment?: string | null;
|
|
33
|
+
skipped: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ContestTicketOptions {
|
|
36
|
+
comment?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Subconjunto de `client.support` do `@neetru/sdk` que este componente consome (contrato §3).
|
|
40
|
+
* Definido aqui (nao importado do SDK) de proposito — o produto host passa seu client real, que
|
|
41
|
+
* so precisa CASAR ESTRUTURALMENTE com esta interface, sem criar um hard-dep de versao publicada.
|
|
42
|
+
*/
|
|
43
|
+
export interface SupportClient {
|
|
44
|
+
listMyTickets(): Promise<SupportTicket[]>;
|
|
45
|
+
/** Chamado quando o modal (1) e EXIBIDO — idempotente (server so seta se `resolvedNotifiedAt`
|
|
46
|
+
* ainda for null). NAO chamado no dismiss. */
|
|
47
|
+
markResolvedSeen(ticketId: string): Promise<void>;
|
|
48
|
+
/** Chamado quando o modal (2) e EXIBIDO — cada chamada soma 1 tentativa. NAO chamado na resposta. */
|
|
49
|
+
recordSatisfactionAttempt(ticketId: string): Promise<void>;
|
|
50
|
+
submitSatisfaction(input: SubmitSatisfactionInput): Promise<void>;
|
|
51
|
+
contestTicket(ticketId: string, options?: ContestTicketOptions): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/** Client do `@neetru/sdk` ja configurado — so precisa expor `support`. */
|
|
54
|
+
export interface ProductFeedbackClient {
|
|
55
|
+
support: SupportClient;
|
|
56
|
+
}
|
|
57
|
+
export interface FeedbackThrottleConfig {
|
|
58
|
+
/** Intervalo minimo entre exibir o modal (1) pra tickets DIFERENTES. Default: 3h. */
|
|
59
|
+
resolvedModalHoursBetweenTickets?: number;
|
|
60
|
+
/** Tentativas maximas do modal (2), por ticket. Default: 2. */
|
|
61
|
+
satisfactionMaxAttempts?: number;
|
|
62
|
+
/** Intervalo minimo entre tentativas do modal (2) do MESMO ticket. Default: 6h. */
|
|
63
|
+
satisfactionHoursBetweenAttempts?: number;
|
|
64
|
+
/** Intervalo minimo entre QUALQUER exibicao de modal (1) ou (2), em qualquer ordem/ticket. Default: 30min. */
|
|
65
|
+
crossModalMinMinutes?: number;
|
|
66
|
+
}
|
|
67
|
+
/** `FeedbackThrottleConfig` com todos os campos resolvidos (defaults aplicados). */
|
|
68
|
+
export type ResolvedThrottleConfig = Required<FeedbackThrottleConfig>;
|
|
69
|
+
export interface ResolvedModalTicket {
|
|
70
|
+
id: string;
|
|
71
|
+
subject: string;
|
|
72
|
+
message: string;
|
|
73
|
+
screenshotUrl: string | null;
|
|
74
|
+
}
|
|
75
|
+
export interface ResolvedModalProps {
|
|
76
|
+
ticket: ResolvedModalTicket;
|
|
77
|
+
/** Chama internamente so o fechamento — `markResolvedSeen` ja foi chamado quando o modal ABRIU. */
|
|
78
|
+
onDismiss: () => void;
|
|
79
|
+
/** Contestacao (v1, contrato §4/§7) — some do ciclo, reabre o ticket. Comentario opcional. */
|
|
80
|
+
onContest: (comment?: string) => void;
|
|
81
|
+
}
|
|
82
|
+
export interface SatisfactionModalTicket {
|
|
83
|
+
id: string;
|
|
84
|
+
subject: string;
|
|
85
|
+
message: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SatisfactionModalProps {
|
|
88
|
+
ticket: SatisfactionModalTicket;
|
|
89
|
+
onSubmit: (rating: number, comment: string | null) => void;
|
|
90
|
+
onSkip: () => void;
|
|
91
|
+
/** Fecha SEM arquivar — a tentativa ja foi contada na exibicao, uma proxima abertura (se dentro
|
|
92
|
+
* do throttle) ainda e possivel. */
|
|
93
|
+
onDismiss: () => void;
|
|
94
|
+
onContest: (comment?: string) => void;
|
|
95
|
+
}
|
|
96
|
+
export interface ProductFeedbackClassNames {
|
|
97
|
+
resolvedModal?: string;
|
|
98
|
+
satisfactionModal?: string;
|
|
99
|
+
starButton?: string;
|
|
100
|
+
starButtonActive?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ProductFeedbackProps {
|
|
103
|
+
/** Client do `@neetru/sdk` ja configurado — NUNCA fetch direto. So precisa expor `support`
|
|
104
|
+
* casando estruturalmente com `SupportClient`. */
|
|
105
|
+
client: ProductFeedbackClient;
|
|
106
|
+
/** Rota atual (pathname, sem querystring) — ex.: `usePathname()` do Next.js. */
|
|
107
|
+
currentPath: string;
|
|
108
|
+
/** Rotas onde NENHUM modal deve aparecer. String[] (match exato) ou callback (prefixo/regex). */
|
|
109
|
+
excludedPaths?: string[] | ((path: string) => boolean);
|
|
110
|
+
/** Suprime tudo (nao mostra nenhum modal) enquanto retornar true — ex.: `@neetru/page-tour`
|
|
111
|
+
* ativo (achado real: o overlay do tour bloqueia clique no modal de feedback). Checado no mount
|
|
112
|
+
* e a cada troca de `currentPath` — o mesmo grão do re-check do fetch, nao um poll continuo. */
|
|
113
|
+
suppressWhile?: () => boolean;
|
|
114
|
+
throttle?: FeedbackThrottleConfig;
|
|
115
|
+
/** Substitui o modal (1) por uma renderizacao totalmente customizada (headless). */
|
|
116
|
+
renderResolvedModal?: (props: ResolvedModalProps) => React.ReactNode;
|
|
117
|
+
/** Substitui o modal (2) por uma renderizacao totalmente customizada (headless). */
|
|
118
|
+
renderSatisfactionModal?: (props: SatisfactionModalProps) => React.ReactNode;
|
|
119
|
+
/** Classes CSS pros elementos dos modais default. Ignoradas se os `render*` forem usados. */
|
|
120
|
+
classNames?: Partial<ProductFeedbackClassNames>;
|
|
121
|
+
onResolvedModalShown?: (ticketId: string) => void;
|
|
122
|
+
onSatisfactionShown?: (ticketId: string, attempt: number) => void;
|
|
123
|
+
onSatisfactionSubmitted?: (ticketId: string, rating: number, comment: string | null) => void;
|
|
124
|
+
onSatisfactionSkipped?: (ticketId: string) => void;
|
|
125
|
+
onTicketContested?: (ticketId: string) => void;
|
|
126
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neetru/product-feedback",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fluxo de feedback pos-suporte (report -> resolvido -> satisfacao -> contestacao) reutilizavel para produtos SaaS Neetru — deteccao client-side via listMyTickets(), throttle por-usuario configuravel, maquina de estados de 4 estados. Extraido do InterPay v2; headless por padrao (voce estiliza), com modais default prontos pra uso.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"test": "vitest run"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=18",
|
|
25
|
+
"react-dom": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@testing-library/react": "^16.0.0",
|
|
29
|
+
"@types/react": "^19.0.0",
|
|
30
|
+
"@types/react-dom": "^19.0.0",
|
|
31
|
+
"jsdom": "^25.0.0",
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"react-dom": "^19.0.0",
|
|
34
|
+
"typescript": "^5.6.0",
|
|
35
|
+
"vitest": "^2.1.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
}
|
|
40
|
+
}
|