mitre-form-component 0.1.4 → 2.0.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/index.d.ts CHANGED
@@ -5,15 +5,24 @@ interface Product {
5
5
  name: string;
6
6
  }
7
7
 
8
+ type Ambiente = "homol" | "prod";
9
+
8
10
  declare enum PreferenciaContato {
9
11
  Whatsapp = "Whatsapp",
10
12
  Email = "Email",
11
13
  Ligacao = "Liga\u00E7\u00E3o"
12
14
  }
15
+
16
+ type Canal = "form" | "chat" | "whatsapp";
13
17
  interface MitreFormComponentProps {
14
18
  products: Product[];
15
- apiUrl: string;
16
- apiToken: string;
19
+ /**
20
+ * Define de qual config interno o componente lê `apiUrl`, `apiToken`,
21
+ * `whatsappPhone` e `chatUrl`. Default `"homol"`.
22
+ */
23
+ ambiente?: Ambiente;
24
+ /** Default `"form"`. Ver doc/canal-feature.md. */
25
+ canal?: Canal;
17
26
  showHeader?: boolean;
18
27
  title?: string;
19
28
  subtitle?: string;
@@ -28,8 +37,15 @@ interface MitreFormComponentProps {
28
37
  inputTextColor?: string;
29
38
  inputPlaceholderColor?: string;
30
39
  showPreferenciaContato?: boolean;
31
- onSuccess?: (requestBody: RequestBody, leadId: string) => void;
32
- onError?: (error: Error) => void;
40
+ /** Opcional. Repassado no body do POST /leads e no `virtual_obj` (modo chat). */
41
+ idProdutoTerceiro?: string | number;
42
+ /** Opcional. Repassado no body do POST /leads e no `virtual_obj` (modo chat). */
43
+ idEmpreendimento?: string | number;
44
+ /**
45
+ * Default: `true` em `canal === "chat"` / `"whatsapp"` (paridade com `atendimento.html`),
46
+ * `false` em `canal === "form"`. Passe `false` para forçar criação do evento.
47
+ */
48
+ naoCriarEvento?: boolean;
33
49
  }
34
50
  interface RequestBody {
35
51
  name: string;
@@ -42,7 +58,27 @@ interface RequestBody {
42
58
  utm_campaign?: string;
43
59
  utm_term?: string;
44
60
  preferencia_contato?: string;
61
+ /** Presente quando `canal !== "form"`. */
62
+ canal?: Canal;
63
+ /**
64
+ * Presente (e sempre `true`) quando `canal !== "form"`. Paridade com o fluxo legado
65
+ * `atendimento.html`, cujo `<form id="chat-form">` enviava o hidden `is_chat=true`
66
+ * em ambos os canais (chat e whatsapp).
67
+ */
68
+ is_chat?: boolean;
69
+ /** Presente quando `canal !== "form"`. `window.location.href` no momento do submit. */
70
+ pagina?: string;
71
+ /** Presente quando a prop homônima for informada e `canal !== "form"`. */
72
+ idProdutoTerceiro?: string | number;
73
+ /** Presente quando a prop homônima for informada e `canal !== "form"`. */
74
+ idEmpreendimento?: string | number;
75
+ /**
76
+ * Presente quando o flag efetivo é `true`. Por default vai `true` em
77
+ * `canal === "chat"` / `canal === "whatsapp"`; pode ser desligado com
78
+ * `naoCriarEvento={false}`.
79
+ */
80
+ naoCriarEvento?: boolean;
45
81
  }
46
82
  declare const MitreFormComponent: React.ForwardRefExoticComponent<MitreFormComponentProps & React.RefAttributes<HTMLDivElement>>;
47
83
 
48
- export { MitreFormComponent, type MitreFormComponentProps, PreferenciaContato, type RequestBody };
84
+ export { type Ambiente, type Canal, MitreFormComponent, type MitreFormComponentProps, PreferenciaContato, type RequestBody };