@primocaredentgroup/chat-ui 1.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/README.md +272 -0
- package/dist/ChatConvexProvider.d.ts +16 -0
- package/dist/ChatConvexProvider.d.ts.map +1 -0
- package/dist/ChatConvexProvider.js +62 -0
- package/dist/ChatConvexProvider.js.map +1 -0
- package/dist/LabChatWidget.d.ts +10 -0
- package/dist/LabChatWidget.d.ts.map +1 -0
- package/dist/LabChatWidget.js +165 -0
- package/dist/LabChatWidget.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/useChatQueries.d.ts +32 -0
- package/dist/useChatQueries.d.ts.map +1 -0
- package/dist/useChatQueries.js +83 -0
- package/dist/useChatQueries.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# @primocaredentgroup/chat-ui
|
|
2
|
+
|
|
3
|
+
**Batteries Included** - Componente chat React per Software B (Laboratorio Odontotecnico) che si connette al backend di Software A (PrimoUp Core).
|
|
4
|
+
|
|
5
|
+
## โจ Approccio "Batteries Included"
|
|
6
|
+
|
|
7
|
+
Questo pacchetto รจ **completamente self-contained**:
|
|
8
|
+
- Crea internamente un `ConvexReactClient` isolato che si connette a Software A
|
|
9
|
+
- **Non interferisce** con l'eventuale client Convex esistente di Software B
|
|
10
|
+
- Include tutte le definizioni di tipo necessarie
|
|
11
|
+
- Richiede solo `convexUrl` e `authToken`
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
// Semplicissimo - nessun provider esterno necessario!
|
|
15
|
+
<LabChatWidget
|
|
16
|
+
convexUrl="https://software-a.convex.cloud"
|
|
17
|
+
authToken={token}
|
|
18
|
+
/>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## ๐ฆ Installazione
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @primocaredentgroup/chat-ui
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## ๐ง Requisiti
|
|
28
|
+
|
|
29
|
+
- React 18+ o 19+
|
|
30
|
+
- Auth0 React SDK (@auth0/auth0-react)
|
|
31
|
+
- Convex (come peer dependency - per i tipi)
|
|
32
|
+
- Tailwind CSS (per lo stile)
|
|
33
|
+
|
|
34
|
+
## ๐๏ธ Architettura Interna
|
|
35
|
+
|
|
36
|
+
Il componente crea un **ConvexReactClient isolato** internamente:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Software B App
|
|
40
|
+
โโโ Software B's Convex Client (esistente, non toccato)
|
|
41
|
+
โ โโโ Connesso a: Software B's Convex Backend
|
|
42
|
+
โ
|
|
43
|
+
โโโ LabChatWidget
|
|
44
|
+
โโโ ChatConvexProvider (isolato)
|
|
45
|
+
โโโ ConvexReactClient (nuovo, isolato)
|
|
46
|
+
โโโ Connesso a: Software A's Convex Backend
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Questo significa:
|
|
50
|
+
- โ
Zero conflitti con l'esistente setup Convex di Software B
|
|
51
|
+
- โ
Autenticazione indipendente verso Software A
|
|
52
|
+
- โ
Nessun provider esterno richiesto
|
|
53
|
+
|
|
54
|
+
## ๐ Utilizzo
|
|
55
|
+
|
|
56
|
+
### 1. Configurazione Auth0
|
|
57
|
+
|
|
58
|
+
Nel tuo Software B, devi configurare Auth0 per richiedere un token valido anche per l'audience di Software A:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// App.tsx di Software B
|
|
62
|
+
import { Auth0Provider } from '@auth0/auth0-react';
|
|
63
|
+
|
|
64
|
+
<Auth0Provider
|
|
65
|
+
domain="tuo-auth0-domain.auth0.com"
|
|
66
|
+
clientId="tuo-client-id-software-b"
|
|
67
|
+
authorizationParams={{
|
|
68
|
+
redirect_uri: window.location.origin,
|
|
69
|
+
audience: "https://api.primoup-core.com", // <-- Audience di Software A!
|
|
70
|
+
scope: "openid profile email"
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<App />
|
|
74
|
+
</Auth0Provider>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Utilizzo del Componente
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { LabChatWidget } from '@primocaredentgroup/chat-ui';
|
|
81
|
+
import { useAuth0 } from '@auth0/auth0-react';
|
|
82
|
+
|
|
83
|
+
function App() {
|
|
84
|
+
const { getAccessTokenSilently } = useAuth0();
|
|
85
|
+
const [token, setToken] = useState<string>('');
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const getToken = async () => {
|
|
89
|
+
try {
|
|
90
|
+
const accessToken = await getAccessTokenSilently();
|
|
91
|
+
setToken(accessToken);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('Error getting token:', error);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
getToken();
|
|
97
|
+
}, [getAccessTokenSilently]);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div>
|
|
101
|
+
{/* Il resto della tua app */}
|
|
102
|
+
|
|
103
|
+
{token && (
|
|
104
|
+
<LabChatWidget
|
|
105
|
+
convexUrl="https://tuo-deployment.convex.cloud" // URL Convex di Software A
|
|
106
|
+
authToken={token}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## โ๏ธ Props
|
|
115
|
+
|
|
116
|
+
| Prop | Tipo | Obbligatorio | Descrizione |
|
|
117
|
+
|------|------|--------------|-------------|
|
|
118
|
+
| `convexUrl` | `string` | โ
| URL del deployment Convex di Software A |
|
|
119
|
+
| `authToken` | `string` | โ
| Auth0 access token (deve avere audience di Software A) |
|
|
120
|
+
| `className` | `string` | โ | Classi CSS aggiuntive per il widget |
|
|
121
|
+
| `onClose` | `() => void` | โ | Callback quando il widget viene chiuso |
|
|
122
|
+
|
|
123
|
+
## ๐ Autenticazione Cross-Domain
|
|
124
|
+
|
|
125
|
+
### Opzione 1: Shared Audience (Consigliata)
|
|
126
|
+
|
|
127
|
+
Configura Software B per usare la stessa audience API di Software A:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// auth0.com Dashboard -> Applications -> Software B
|
|
131
|
+
// Settings -> Advanced Settings -> OAuth
|
|
132
|
+
// audience: "https://api.primoup-core.com"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Opzione 2: Token Exchange
|
|
136
|
+
|
|
137
|
+
Se non puoi condividere l'audience, crea un endpoint su Software A per scambiare il token:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Su Software A (backend)
|
|
141
|
+
export const exchangeToken = mutation({
|
|
142
|
+
args: { token: v.string() },
|
|
143
|
+
handler: async (ctx, args) => {
|
|
144
|
+
// Verifica token Software B con Auth0
|
|
145
|
+
// Genera nuovo token per audience di Software A
|
|
146
|
+
// Restituisci nuovo token
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Opzione 3: Trusted Clients
|
|
152
|
+
|
|
153
|
+
Configura Software A per accettare clientId di Software B come trusted:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// convex/auth.config.ts
|
|
157
|
+
export default {
|
|
158
|
+
providers: [
|
|
159
|
+
{
|
|
160
|
+
domain: "https://tuo-auth0-domain.auth0.com",
|
|
161
|
+
applicationID: ["software-a-client-id", "software-b-client-id"], // <-- Aggiungi entrambi!
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## ๐จ Styling
|
|
168
|
+
|
|
169
|
+
Il componente usa Tailwind CSS. Assicurati che le seguenti classi siano disponibili nel tuo progetto:
|
|
170
|
+
|
|
171
|
+
- Colori: `bg-blue-600`, `text-white`, `bg-gray-50`, ecc.
|
|
172
|
+
- Layout: `flex`, `grid`, `fixed`, `absolute`
|
|
173
|
+
- Spaziature: `p-4`, `m-2`, `gap-3`, ecc.
|
|
174
|
+
- Bordi: `rounded-lg`, `border`, `shadow-lg`
|
|
175
|
+
|
|
176
|
+
## ๐ฃ Hooks e Provider (Avanzato)
|
|
177
|
+
|
|
178
|
+
Per casi d'uso avanzati, puoi usare i provider e gli hook esposti:
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import {
|
|
182
|
+
ChatConvexProvider,
|
|
183
|
+
useChatConvex,
|
|
184
|
+
useListAllChannels,
|
|
185
|
+
useGetPatientChatStructure,
|
|
186
|
+
useListMessages,
|
|
187
|
+
useSendMessage,
|
|
188
|
+
useChatQuery,
|
|
189
|
+
useChatMutation
|
|
190
|
+
} from '@primocaredentgroup/chat-ui';
|
|
191
|
+
|
|
192
|
+
// Provider isolato
|
|
193
|
+
function MyCustomChat() {
|
|
194
|
+
return (
|
|
195
|
+
<ChatConvexProvider
|
|
196
|
+
convexUrl="https://software-a.convex.cloud"
|
|
197
|
+
authToken={token}
|
|
198
|
+
>
|
|
199
|
+
<CustomChatUI />
|
|
200
|
+
</ChatConvexProvider>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Hook personalizzato per query
|
|
205
|
+
function CustomChatUI() {
|
|
206
|
+
const { data: channels } = useListAllChannels();
|
|
207
|
+
const { data: structure } = useGetPatientChatStructure("patient-id");
|
|
208
|
+
const { data: messages } = useListMessages("subchannel-id");
|
|
209
|
+
const { mutate: sendMessage } = useSendMessage();
|
|
210
|
+
|
|
211
|
+
// ... la tua UI personalizzata
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## ๐ Struttura Chat
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
Paziente (Macro Canale)
|
|
219
|
+
โโโ Generale (sub-canale)
|
|
220
|
+
โ โโโ Messaggi generali
|
|
221
|
+
โโโ Laboratorio (sub-canale)
|
|
222
|
+
โ โโโ Prescrizione 1
|
|
223
|
+
โ โโโ Prescrizione 2
|
|
224
|
+
โ โโโ Prescrizione 3
|
|
225
|
+
โโโ Abaddon (sub-canale)
|
|
226
|
+
โโโ Messaggi per Abaddon
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## ๐ Tipi Esportati
|
|
230
|
+
|
|
231
|
+
Il pacchetto include tutte le definizioni di tipo per l'API di Software A:
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
import type {
|
|
235
|
+
Patient,
|
|
236
|
+
ChatMessage,
|
|
237
|
+
ChatStructure,
|
|
238
|
+
Channel,
|
|
239
|
+
Subchannel,
|
|
240
|
+
PrescriptionSubchannel,
|
|
241
|
+
// ... e altri tipi
|
|
242
|
+
} from '@primocaredentgroup/chat-ui';
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## ๐ Debug
|
|
246
|
+
|
|
247
|
+
### Il widget non si connette
|
|
248
|
+
|
|
249
|
+
1. Verifica che `convexUrl` sia corretto
|
|
250
|
+
2. Verifica che `authToken` sia valido e non scaduto
|
|
251
|
+
3. Controlla console per errori CORS
|
|
252
|
+
4. Verifica che Software A accetti il tuo clientId Auth0
|
|
253
|
+
|
|
254
|
+
### "Unauthorized" error
|
|
255
|
+
|
|
256
|
+
1. Verifica che l'audience nel token corrisponda a quello di Software A
|
|
257
|
+
2. Verifica che l'utente esista nel database di Software A
|
|
258
|
+
3. Controlla che il token non sia scaduto
|
|
259
|
+
|
|
260
|
+
## ๐ Licenza
|
|
261
|
+
|
|
262
|
+
MIT
|
|
263
|
+
|
|
264
|
+
## ๐ Link Utili
|
|
265
|
+
|
|
266
|
+
- [Convex Docs](https://docs.convex.dev/)
|
|
267
|
+
- [Auth0 React SDK](https://auth0.com/docs/libraries/auth0-react)
|
|
268
|
+
- [PrimoCare Documentation](https://docs.primocare.it/)
|
|
269
|
+
|
|
270
|
+
## ๐ฌ Supporto
|
|
271
|
+
|
|
272
|
+
Per domande o problemi, contatta il team di sviluppo PrimoCare.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ConvexReactClient } from "convex/react";
|
|
3
|
+
interface ChatConvexContextValue {
|
|
4
|
+
client: ConvexReactClient | null;
|
|
5
|
+
isReady: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
}
|
|
8
|
+
export declare const useChatConvex: () => ChatConvexContextValue;
|
|
9
|
+
export interface ChatConvexProviderProps {
|
|
10
|
+
convexUrl: string;
|
|
11
|
+
authToken: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const ChatConvexProvider: React.FC<ChatConvexProviderProps>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=ChatConvexProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatConvexProvider.d.ts","sourceRoot":"","sources":["../src/ChatConvexProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAQD,eAAO,MAAM,aAAa,8BAMzB,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAkEhE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, useEffect, useState } from "react";
|
|
3
|
+
import { ConvexReactClient } from "convex/react";
|
|
4
|
+
const ChatConvexContext = createContext({
|
|
5
|
+
client: null,
|
|
6
|
+
isReady: false,
|
|
7
|
+
error: null,
|
|
8
|
+
});
|
|
9
|
+
export const useChatConvex = () => {
|
|
10
|
+
const context = useContext(ChatConvexContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error("useChatConvex must be used within ChatConvexProvider");
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
export const ChatConvexProvider = ({ convexUrl, authToken, children, }) => {
|
|
17
|
+
const [isReady, setIsReady] = useState(false);
|
|
18
|
+
const [error, setError] = useState(null);
|
|
19
|
+
const client = useMemo(() => {
|
|
20
|
+
try {
|
|
21
|
+
if (!convexUrl) {
|
|
22
|
+
throw new Error("convexUrl is required");
|
|
23
|
+
}
|
|
24
|
+
const convexClient = new ConvexReactClient(convexUrl);
|
|
25
|
+
return convexClient;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
setError(err instanceof Error ? err : new Error("Failed to create Convex client"));
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}, [convexUrl]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!client || !authToken)
|
|
34
|
+
return;
|
|
35
|
+
const setupAuth = async () => {
|
|
36
|
+
try {
|
|
37
|
+
client.setAuth(async () => authToken);
|
|
38
|
+
setIsReady(true);
|
|
39
|
+
setError(null);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
setError(err instanceof Error ? err : new Error("Failed to set auth token"));
|
|
43
|
+
setIsReady(false);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
setupAuth();
|
|
47
|
+
}, [client, authToken]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
return () => {
|
|
50
|
+
if (client) {
|
|
51
|
+
client.close();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [client]);
|
|
55
|
+
const value = useMemo(() => ({
|
|
56
|
+
client,
|
|
57
|
+
isReady,
|
|
58
|
+
error,
|
|
59
|
+
}), [client, isReady, error]);
|
|
60
|
+
return (_jsx(ChatConvexContext.Provider, { value: value, children: children }));
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=ChatConvexProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatConvexProvider.js","sourceRoot":"","sources":["../src/ChatConvexProvider.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjD,MAAM,iBAAiB,GAAG,aAAa,CAAyB;IAC9D,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,kBAAkB,GAAsC,CAAC,EACpE,SAAS,EACT,SAAS,EACT,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IAIvD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,C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AAC,CAAC;IAEb,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,OAAO;QACP,KAAK;KACN,CAAC,EACF,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CACzB,CAAC;IAEF,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACrC,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface LabChatWidgetProps {
|
|
3
|
+
convexUrl: string;
|
|
4
|
+
authToken: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const LabChatWidget: React.FC<LabChatWidgetProps>;
|
|
9
|
+
export default LabChatWidget;
|
|
10
|
+
//# sourceMappingURL=LabChatWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LabChatWidget.d.ts","sourceRoot":"","sources":["../src/LabChatWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAuB3D,MAAM,WAAW,kBAAkB;IAEjC,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AA0iBD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAWtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
3
|
+
import { X, Loader2, MessageCircle, Search, User, Beaker, FileText, ChevronRight, ChevronDown, Send } from "lucide-react";
|
|
4
|
+
import { ChatConvexProvider } from "./ChatConvexProvider";
|
|
5
|
+
import { useListAllChannels, useGetPatientChatStructure, useListMessages, useSendMessage } from "./useChatQueries";
|
|
6
|
+
const mapPatient = (p) => ({
|
|
7
|
+
_id: p.id,
|
|
8
|
+
firstName: p.firstName,
|
|
9
|
+
lastName: p.lastName,
|
|
10
|
+
fiscalCode: p.fiscalCode,
|
|
11
|
+
email: p.email,
|
|
12
|
+
phone: p.phone,
|
|
13
|
+
});
|
|
14
|
+
const mapChatStructure = (cs) => ({
|
|
15
|
+
patient: mapPatient(cs.patient),
|
|
16
|
+
channelId: cs.channel._id,
|
|
17
|
+
generale: cs.subchannels.generale ? {
|
|
18
|
+
_id: cs.subchannels.generale._id,
|
|
19
|
+
name: cs.subchannels.generale.name,
|
|
20
|
+
kind: cs.subchannels.generale.kind,
|
|
21
|
+
externalReferenceId: cs.subchannels.generale.externalReferenceId,
|
|
22
|
+
} : undefined,
|
|
23
|
+
laboratorio: cs.subchannels.laboratorio ? {
|
|
24
|
+
_id: cs.subchannels.laboratorio._id,
|
|
25
|
+
name: cs.subchannels.laboratorio.name,
|
|
26
|
+
kind: cs.subchannels.laboratorio.kind,
|
|
27
|
+
externalReferenceId: cs.subchannels.laboratorio.externalReferenceId,
|
|
28
|
+
} : undefined,
|
|
29
|
+
abaddon: cs.subchannels.abaddon ? {
|
|
30
|
+
_id: cs.subchannels.abaddon._id,
|
|
31
|
+
name: cs.subchannels.abaddon.name,
|
|
32
|
+
kind: cs.subchannels.abaddon.kind,
|
|
33
|
+
externalReferenceId: cs.subchannels.abaddon.externalReferenceId,
|
|
34
|
+
} : undefined,
|
|
35
|
+
prescriptions: cs.subchannels.prescriptions.map(p => ({
|
|
36
|
+
_id: p._id,
|
|
37
|
+
name: p.name,
|
|
38
|
+
kind: p.kind,
|
|
39
|
+
externalReferenceId: p.externalReferenceId,
|
|
40
|
+
prescriptionNumber: p.metadata?.prescriptionNumber,
|
|
41
|
+
})),
|
|
42
|
+
});
|
|
43
|
+
const formatTime = (timestamp) => {
|
|
44
|
+
return new Date(timestamp).toLocaleTimeString('it-IT', {
|
|
45
|
+
hour: '2-digit',
|
|
46
|
+
minute: '2-digit'
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const formatDate = (timestamp) => {
|
|
50
|
+
const date = new Date(timestamp);
|
|
51
|
+
const today = new Date();
|
|
52
|
+
const yesterday = new Date(today);
|
|
53
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
54
|
+
if (date.toDateString() === today.toDateString()) {
|
|
55
|
+
return "Oggi";
|
|
56
|
+
}
|
|
57
|
+
if (date.toDateString() === yesterday.toDateString()) {
|
|
58
|
+
return "Ieri";
|
|
59
|
+
}
|
|
60
|
+
return date.toLocaleDateString('it-IT', { day: 'numeric', month: 'long' });
|
|
61
|
+
};
|
|
62
|
+
const LabChatWidgetInner = ({ className = "", onClose }) => {
|
|
63
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
64
|
+
const [selectedPatientId, setSelectedPatientId] = useState(null);
|
|
65
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
66
|
+
const [activeTab, setActiveTab] = useState("generale");
|
|
67
|
+
const [selectedPrescription, setSelectedPrescription] = useState(null);
|
|
68
|
+
const [newMessage, setNewMessage] = useState("");
|
|
69
|
+
const messagesEndRef = useRef(null);
|
|
70
|
+
const { data: channels, isLoading: isLoadingChannels, error: channelsError } = useListAllChannels(false);
|
|
71
|
+
const { data: chatStructure, isLoading: isLoadingStructure } = useGetPatientChatStructure(selectedPatientId);
|
|
72
|
+
const currentSubchannelId = React.useMemo(() => {
|
|
73
|
+
if (!chatStructure)
|
|
74
|
+
return null;
|
|
75
|
+
if (activeTab === "generale" && chatStructure.subchannels.generale) {
|
|
76
|
+
return chatStructure.subchannels.generale._id;
|
|
77
|
+
}
|
|
78
|
+
if (activeTab === "abaddon" && chatStructure.subchannels.abaddon) {
|
|
79
|
+
return chatStructure.subchannels.abaddon._id;
|
|
80
|
+
}
|
|
81
|
+
if (activeTab === "laboratorio") {
|
|
82
|
+
if (selectedPrescription) {
|
|
83
|
+
const prescription = chatStructure.subchannels.prescriptions.find((p) => p._id === selectedPrescription);
|
|
84
|
+
return prescription?._id || null;
|
|
85
|
+
}
|
|
86
|
+
return chatStructure.subchannels.laboratorio?._id || null;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}, [chatStructure, activeTab, selectedPrescription]);
|
|
90
|
+
const { data: messages, isLoading: isLoadingMessages } = useListMessages(currentSubchannelId, 50);
|
|
91
|
+
const { mutate: sendMessageMut, isLoading: isSending } = useSendMessage();
|
|
92
|
+
const patients = React.useMemo(() => {
|
|
93
|
+
if (!channels)
|
|
94
|
+
return [];
|
|
95
|
+
return channels
|
|
96
|
+
.filter(ch => ch.metadata?.patientId)
|
|
97
|
+
.map(ch => ({
|
|
98
|
+
_id: ch.metadata.patientId,
|
|
99
|
+
firstName: ch.metadata.patientName?.split(' ')[0] || 'Unknown',
|
|
100
|
+
lastName: ch.metadata.patientName?.split(' ').slice(1).join(' ') || '',
|
|
101
|
+
fiscalCode: ch.metadata.patientFiscalCode,
|
|
102
|
+
}));
|
|
103
|
+
}, [channels]);
|
|
104
|
+
const currentStructure = React.useMemo(() => {
|
|
105
|
+
if (!chatStructure)
|
|
106
|
+
return null;
|
|
107
|
+
return mapChatStructure(chatStructure);
|
|
108
|
+
}, [chatStructure]);
|
|
109
|
+
const filteredPatients = React.useMemo(() => {
|
|
110
|
+
if (!searchTerm)
|
|
111
|
+
return patients;
|
|
112
|
+
return patients.filter(p => `${p.firstName} ${p.lastName}`.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
113
|
+
(p.fiscalCode && p.fiscalCode.toLowerCase().includes(searchTerm.toLowerCase())));
|
|
114
|
+
}, [patients, searchTerm]);
|
|
115
|
+
const handleSendMessage = async () => {
|
|
116
|
+
if (!newMessage.trim() || !currentSubchannelId)
|
|
117
|
+
return;
|
|
118
|
+
try {
|
|
119
|
+
await sendMessageMut({
|
|
120
|
+
subchannelId: currentSubchannelId,
|
|
121
|
+
body: newMessage,
|
|
122
|
+
});
|
|
123
|
+
setNewMessage("");
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
console.error("Failed to send message:", err);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleKeyDown = (e) => {
|
|
130
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
handleSendMessage();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
137
|
+
}, [messages]);
|
|
138
|
+
const isLoading = isLoadingChannels || isLoadingStructure || isLoadingMessages;
|
|
139
|
+
const isLaboratorioExpanded = activeTab === "laboratorio";
|
|
140
|
+
if (selectedPatientId && currentStructure) {
|
|
141
|
+
return (_jsxs("div", { className: `fixed bottom-6 right-6 z-50 w-[900px] h-[700px] bg-white rounded-lg shadow-2xl flex flex-col border overflow-hidden ${className}`, children: [_jsxs("div", { className: "flex items-center justify-between px-4 py-3 bg-blue-600 text-white", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "w-10 h-10 rounded-full bg-white/20 flex items-center justify-center", children: _jsxs("span", { className: "font-semibold text-lg", children: [currentStructure.patient.firstName[0], currentStructure.patient.lastName[0]] }) }), _jsxs("div", { children: [_jsxs("h3", { className: "font-semibold", children: [currentStructure.patient.firstName, " ", currentStructure.patient.lastName] }), _jsx("div", { className: "flex items-center gap-3 text-xs text-blue-100", children: currentStructure.patient.fiscalCode && (_jsx("span", { className: "font-mono", children: currentStructure.patient.fiscalCode })) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { onClick: () => setSelectedPatientId(null), className: "px-3 py-1.5 bg-white/10 hover:bg-white/20 rounded text-sm transition-colors", children: "Torna alla lista" }), onClose && (_jsx("button", { onClick: onClose, className: "p-2 hover:bg-white/10 rounded-full transition-colors", children: _jsx(X, { className: "w-5 h-5" }) }))] })] }), _jsxs("div", { className: "flex-1 flex overflow-hidden", children: [_jsxs("div", { className: "w-64 bg-gray-50 border-r flex flex-col", children: [_jsx("div", { className: "p-3 border-b bg-gray-100", children: _jsx("h4", { className: "text-sm font-semibold text-gray-600 uppercase tracking-wider", children: "Canali" }) }), _jsxs("div", { className: "flex-1 overflow-y-auto py-2 space-y-1", children: [_jsxs("button", { onClick: () => { setActiveTab("generale"); setSelectedPrescription(null); }, className: `w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${activeTab === "generale"
|
|
142
|
+
? "bg-blue-50 text-blue-700 border-r-2 border-blue-600"
|
|
143
|
+
: "text-gray-700 hover:bg-gray-100"}`, children: [_jsx(MessageCircle, { className: "w-4 h-4" }), _jsx("span", { className: "flex-1 text-left", children: "Generale" })] }), _jsxs("div", { children: [_jsxs("button", { onClick: () => { setActiveTab("laboratorio"); setSelectedPrescription(null); }, className: `w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${activeTab === "laboratorio" && !selectedPrescription
|
|
144
|
+
? "bg-blue-50 text-blue-700 border-r-2 border-blue-600"
|
|
145
|
+
: "text-gray-700 hover:bg-gray-100"}`, children: [_jsx(Beaker, { className: "w-4 h-4" }), _jsx("span", { className: "flex-1 text-left", children: "Laboratorio" }), isLaboratorioExpanded ? (_jsx(ChevronDown, { className: "w-4 h-4" })) : (_jsx(ChevronRight, { className: "w-4 h-4" }))] }), isLaboratorioExpanded && currentStructure.prescriptions.length > 0 && (_jsx("div", { className: "ml-4 border-l-2 border-gray-200", children: currentStructure.prescriptions
|
|
146
|
+
.sort((a, b) => (a.prescriptionNumber || 0) - (b.prescriptionNumber || 0))
|
|
147
|
+
.map((prescription) => (_jsxs("button", { onClick: () => { setActiveTab("laboratorio"); setSelectedPrescription(prescription._id); }, className: `w-full flex items-center gap-2 px-4 py-2 text-sm transition-colors ${selectedPrescription === prescription._id
|
|
148
|
+
? "bg-blue-50 text-blue-600"
|
|
149
|
+
: "text-gray-500 hover:bg-gray-100"}`, children: [_jsx(FileText, { className: "w-3 h-3" }), _jsx("span", { className: "flex-1 text-left truncate", children: prescription.name })] }, prescription._id))) }))] }), _jsxs("button", { onClick: () => { setActiveTab("abaddon"); setSelectedPrescription(null); }, className: `w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${activeTab === "abaddon"
|
|
150
|
+
? "bg-blue-50 text-blue-700 border-r-2 border-blue-600"
|
|
151
|
+
: "text-gray-700 hover:bg-gray-100"}`, children: [_jsx("span", { className: "w-4 h-4 flex items-center justify-center font-bold text-xs", children: "A" }), _jsx("span", { className: "flex-1 text-left", children: "Abaddon" })] })] }), _jsxs("div", { className: "p-3 border-t bg-gray-50", children: [_jsx("h4", { className: "text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2", children: "Info Paziente" }), _jsxs("div", { className: "space-y-1 text-xs text-gray-500", children: [currentStructure.patient.email && (_jsx("p", { className: "truncate", children: currentStructure.patient.email })), currentStructure.patient.phone && (_jsx("p", { children: currentStructure.patient.phone }))] })] })] }), _jsxs("div", { className: "flex-1 flex flex-col bg-white", children: [_jsx("div", { className: "flex items-center justify-between px-4 py-2 border-b bg-gray-50", children: _jsxs("div", { className: "flex items-center gap-2", children: [activeTab === "generale" && _jsx(MessageCircle, { className: "w-4 h-4 text-gray-500" }), activeTab === "laboratorio" && _jsx(Beaker, { className: "w-4 h-4 text-gray-500" }), activeTab === "abaddon" && _jsx("span", { className: "w-4 h-4 flex items-center justify-center font-bold text-xs text-gray-500", children: "A" }), _jsxs("span", { className: "text-sm font-medium text-gray-700", children: [activeTab === "generale" && "Generale", activeTab === "laboratorio" && !selectedPrescription && "Laboratorio", activeTab === "laboratorio" && selectedPrescription && (currentStructure.prescriptions.find(p => p._id === selectedPrescription)?.name), activeTab === "abaddon" && "Abaddon"] })] }) }), _jsxs("div", { className: "flex-1 overflow-y-auto p-4 space-y-4", children: [isLoadingMessages ? (_jsx("div", { className: "flex items-center justify-center h-full", children: _jsx(Loader2, { className: "w-6 h-6 animate-spin text-blue-600" }) })) : !messages || messages.length === 0 ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full text-gray-400", children: [_jsx(MessageCircle, { className: "w-12 h-12 mb-2 opacity-50" }), _jsx("p", { className: "text-sm", children: "Nessun messaggio" }), _jsx("p", { className: "text-xs mt-1", children: "Inizia la conversazione" })] })) : (messages.map((message, index) => {
|
|
152
|
+
const showDate = index === 0 ||
|
|
153
|
+
formatDate(messages[index - 1].createdAt) !== formatDate(message.createdAt);
|
|
154
|
+
return (_jsxs("div", { children: [showDate && (_jsx("div", { className: "flex items-center justify-center my-4", children: _jsx("span", { className: "text-xs text-gray-400 bg-gray-100 px-3 py-1 rounded-full", children: formatDate(message.createdAt) }) })), _jsx("div", { className: `flex ${message.authorId === currentStructure.patient._id ? "justify-start" : "justify-end"}`, children: _jsxs("div", { className: `max-w-[80%] rounded-lg px-4 py-2 ${message.authorId === currentStructure.patient._id
|
|
155
|
+
? "bg-gray-100 text-gray-800 rounded-bl-none"
|
|
156
|
+
: "bg-blue-600 text-white rounded-br-none"}`, children: [message.authorName && message.authorId !== currentStructure.patient._id && (_jsx("p", { className: "text-xs font-medium text-blue-200 mb-1", children: message.authorName })), message.authorName && message.authorId === currentStructure.patient._id && (_jsx("p", { className: "text-xs font-medium text-gray-600 mb-1", children: message.authorName })), _jsx("p", { className: "text-sm whitespace-pre-wrap", children: message.body }), _jsx("p", { className: `text-xs mt-1 text-right ${message.authorId === currentStructure.patient._id ? "text-gray-400" : "text-blue-200"}`, children: formatTime(message.createdAt) })] }) })] }, message._id));
|
|
157
|
+
})), _jsx("div", { ref: messagesEndRef })] }), _jsxs("div", { className: "border-t p-4", children: [_jsxs("div", { className: "flex items-end gap-2", children: [_jsx("textarea", { value: newMessage, onChange: (e) => setNewMessage(e.target.value), onKeyDown: handleKeyDown, placeholder: "Scrivi un messaggio...", rows: 1, disabled: isSending, className: "flex-1 resize-none rounded-lg border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent max-h-32 disabled:bg-gray-100", style: { minHeight: "40px" } }), _jsx("button", { onClick: handleSendMessage, disabled: !newMessage.trim() || isSending, className: "flex items-center justify-center w-10 h-10 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed text-white rounded-lg transition-colors", children: isSending ? (_jsx(Loader2, { className: "w-5 h-5 animate-spin" })) : (_jsx(Send, { className: "w-5 h-5" })) })] }), _jsx("p", { className: "text-xs text-gray-400 mt-1", children: "Premi Enter per inviare, Shift+Enter per andare a capo" })] })] })] })] }));
|
|
158
|
+
}
|
|
159
|
+
return (_jsxs(_Fragment, { children: [!isOpen && (_jsxs("button", { onClick: () => setIsOpen(true), className: `fixed bottom-6 right-6 z-50 flex items-center justify-center w-14 h-14 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg transition-all duration-200 hover:scale-110 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${className}`, "aria-label": "Open chat", children: [_jsx(MessageCircle, { className: "w-6 h-6" }), patients.length > 0 && (_jsx("span", { className: "absolute -top-1 -right-1 flex items-center justify-center w-5 h-5 bg-red-500 text-white text-xs font-bold rounded-full", children: patients.length > 9 ? "9+" : patients.length }))] })), isOpen && (_jsxs("div", { className: `fixed bottom-6 right-6 z-50 w-80 bg-white rounded-lg shadow-2xl flex flex-col border overflow-hidden max-h-[600px] ${className}`, children: [_jsxs("div", { className: "flex items-center justify-between px-4 py-3 bg-blue-600 text-white", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MessageCircle, { className: "w-5 h-5" }), _jsx("h3", { className: "font-semibold", children: "Chat Laboratorio" })] }), _jsx("button", { onClick: () => setIsOpen(false), className: "p-1 hover:bg-white/10 rounded transition-colors", children: _jsx(X, { className: "w-5 h-5" }) })] }), _jsx("div", { className: "p-3 border-b", children: _jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" }), _jsx("input", { type: "text", placeholder: "Cerca paziente...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "w-full pl-9 pr-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" })] }) }), _jsx("div", { className: "flex-1 overflow-y-auto max-h-[400px]", children: isLoadingChannels ? (_jsx("div", { className: "flex items-center justify-center py-8", children: _jsx(Loader2, { className: "w-6 h-6 animate-spin text-blue-600" }) })) : channelsError ? (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 text-red-500", children: [_jsx("p", { className: "text-sm", children: "Errore di connessione" }), _jsx("p", { className: "text-xs mt-1", children: "Riprova pi\u00F9 tardi" })] })) : filteredPatients.length === 0 ? (_jsxs("div", { className: "flex flex-col items-center justify-center py-8 text-gray-400", children: [_jsx(User, { className: "w-12 h-12 mb-2 opacity-50" }), _jsx("p", { className: "text-sm", children: searchTerm ? "Nessun paziente trovato" : "Nessun paziente" })] })) : (_jsx("div", { className: "divide-y divide-gray-100", children: filteredPatients.map((patient) => (_jsxs("button", { onClick: () => setSelectedPatientId(patient._id), className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-colors text-left", children: [_jsx("div", { className: "w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center flex-shrink-0", children: _jsxs("span", { className: "text-blue-600 font-medium text-sm", children: [patient.firstName[0], patient.lastName[0]] }) }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsxs("p", { className: "font-medium text-gray-900 truncate", children: [patient.firstName, " ", patient.lastName] }), _jsx("p", { className: "text-xs text-gray-500 truncate", children: patient.fiscalCode || "Chat attiva" })] }), _jsx(MessageCircle, { className: "w-4 h-4 text-gray-400" })] }, patient._id))) })) }), _jsx("div", { className: "px-4 py-2 bg-gray-50 border-t text-center", children: _jsxs("p", { className: "text-xs text-gray-500", children: [patients.length, " ", patients.length === 1 ? "paziente" : "pazienti"] }) })] }))] }));
|
|
160
|
+
};
|
|
161
|
+
export const LabChatWidget = ({ convexUrl, authToken, className, onClose, }) => {
|
|
162
|
+
return (_jsx(ChatConvexProvider, { convexUrl: convexUrl, authToken: authToken, children: _jsx(LabChatWidgetInner, { className: className, onClose: onClose }) }));
|
|
163
|
+
};
|
|
164
|
+
export default LabChatWidget;
|
|
165
|
+
//# sourceMappingURL=LabChatWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LabChatWidget.js","sourceRoot":"","sources":["../src/LabChatWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EACL,CAAC,EACD,OAAO,EACP,aAAa,EACb,MAAM,EACN,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,IAAI,EACL,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,cAAc,EACf,MAAM,kBAAkB,CAAC;AA6C1B,MAAM,UAAU,GAAG,CAAC,CAAU,EAAa,EAAE,CAAC,CAAC;IAC7C,GAAG,EAAE,CAAC,CAAC,EAAE;IACT,SAAS,EAAE,CAAC,CAAC,SAAS;IACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ;IACpB,UAAU,EAAE,CAAC,CAAC,UAAU;IACxB,KAAK,EAAE,CAAC,CAAC,KAAK;IACd,KAAK,EAAE,CAAC,CAAC,KAAK;CACf,CAAC,CAAC;AAGH,MAAM,gBAAgB,GAAG,CAAC,EAAiB,EAAmB,EAAE,CAAC,CAAC;IAChE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC;IAC/B,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG;IACzB,QAAQ,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AC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { LabChatWidget } from './LabChatWidget';
|
|
2
|
+
export type { LabChatWidgetProps } from './LabChatWidget';
|
|
3
|
+
export { ChatConvexProvider, useChatConvex } from './ChatConvexProvider';
|
|
4
|
+
export type { ChatConvexProviderProps } from './ChatConvexProvider';
|
|
5
|
+
export { useChatQuery, useChatMutation, useListAllChannels, useGetPatientChatStructure, useListMessages, useSendMessage, } from './useChatQueries';
|
|
6
|
+
export type { Patient, ChatMessage, PrescriptionSubchannel, Subchannel, Channel, ChatStructure, ListAllChannelsArgs, GetPatientChatStructureArgs, ListMessagesArgs, SendMessageArgs, ChatOrchestratorApi, ChatApi, } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,UAAU,EACV,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,OAAO,GACR,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { LabChatWidget } from './LabChatWidget';
|
|
2
|
+
export { ChatConvexProvider, useChatConvex } from './ChatConvexProvider';
|
|
3
|
+
export { useChatQuery, useChatMutation, useListAllChannels, useGetPatientChatStructure, useListMessages, useSendMessage, } from './useChatQueries';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGzE,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export interface Patient {
|
|
2
|
+
id: string;
|
|
3
|
+
firstName: string;
|
|
4
|
+
lastName: string;
|
|
5
|
+
fiscalCode?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
phone?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChatMessage {
|
|
10
|
+
_id: string;
|
|
11
|
+
body: string;
|
|
12
|
+
authorId: string;
|
|
13
|
+
authorName?: string;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
metadata?: any;
|
|
16
|
+
}
|
|
17
|
+
export interface PrescriptionSubchannel {
|
|
18
|
+
_id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
kind: string;
|
|
21
|
+
externalReferenceId: string;
|
|
22
|
+
metadata?: {
|
|
23
|
+
type?: string;
|
|
24
|
+
prescriptionNumber?: number;
|
|
25
|
+
parentSubchannel?: string;
|
|
26
|
+
};
|
|
27
|
+
prescriptionNumber?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface Subchannel {
|
|
30
|
+
_id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
kind: "general" | "custom";
|
|
33
|
+
externalReferenceId: string;
|
|
34
|
+
metadata?: any;
|
|
35
|
+
}
|
|
36
|
+
export interface Channel {
|
|
37
|
+
_id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
externalId: string;
|
|
40
|
+
metadata?: any;
|
|
41
|
+
createdAt: number;
|
|
42
|
+
updatedAt: number;
|
|
43
|
+
archived?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ChatStructure {
|
|
46
|
+
patient: Patient;
|
|
47
|
+
channel: Channel;
|
|
48
|
+
subchannels: {
|
|
49
|
+
generale?: Subchannel;
|
|
50
|
+
laboratorio?: Subchannel;
|
|
51
|
+
abaddon?: Subchannel;
|
|
52
|
+
prescriptions: PrescriptionSubchannel[];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export interface ListAllChannelsArgs {
|
|
56
|
+
includeArchived?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface GetPatientChatStructureArgs {
|
|
59
|
+
patientId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ListMessagesArgs {
|
|
62
|
+
subchannelId: string;
|
|
63
|
+
limit?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface SendMessageArgs {
|
|
66
|
+
subchannelId: string;
|
|
67
|
+
body: string;
|
|
68
|
+
metadata?: any;
|
|
69
|
+
}
|
|
70
|
+
export interface ChatOrchestratorApi {
|
|
71
|
+
listAllChannels: {
|
|
72
|
+
_args: ListAllChannelsArgs;
|
|
73
|
+
_return: Channel[];
|
|
74
|
+
};
|
|
75
|
+
getPatientChatStructure: {
|
|
76
|
+
_args: GetPatientChatStructureArgs;
|
|
77
|
+
_return: ChatStructure | null;
|
|
78
|
+
};
|
|
79
|
+
listMessages: {
|
|
80
|
+
_args: ListMessagesArgs;
|
|
81
|
+
_return: ChatMessage[];
|
|
82
|
+
};
|
|
83
|
+
sendMessage: {
|
|
84
|
+
_args: SendMessageArgs;
|
|
85
|
+
_return: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export type ChatApi = {
|
|
89
|
+
"chat/orchestrator": ChatOrchestratorApi;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAGD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAGD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAGD,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,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MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Channel, ChatStructure, ChatMessage } from "./types";
|
|
2
|
+
export declare function useChatQuery<T>(queryName: string, args: Record<string, any> | "skip"): {
|
|
3
|
+
data: T | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function useChatMutation<T = string>(mutationName: string): {
|
|
8
|
+
mutate: (args: Record<string, any>) => Promise<T>;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function useListAllChannels(includeArchived?: boolean): {
|
|
13
|
+
data: Channel[] | undefined;
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
};
|
|
17
|
+
export declare function useGetPatientChatStructure(patientId: string | null): {
|
|
18
|
+
data: ChatStructure | null | undefined;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
};
|
|
22
|
+
export declare function useListMessages(subchannelId: string | null, limit?: number): {
|
|
23
|
+
data: ChatMessage[] | undefined;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
error: Error | null;
|
|
26
|
+
};
|
|
27
|
+
export declare function useSendMessage(): {
|
|
28
|
+
mutate: (args: Record<string, any>) => Promise<string>;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
error: Error | null;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useChatQueries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatQueries.d.ts","sourceRoot":"","sources":["../src/useChatQueries.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAKV,OAAO,EACP,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAC;AAGjB,wBAAgB,YAAY,CAAC,CAAC,EAC5B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GACjC;IAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,CAmDlE;AAGD,wBAAgB,eAAe,CAAC,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM;mBAM/C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC;;;EAwBhD;AAID,wBAAgB,kBAAkB,CAAC,eAAe,CAAC,EAAE,OAAO;;eAxFvB,OAAO;WAAS,KAAK,GAAG,IAAI;EA4FhE;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;;eA9F9B,OAAO;WAAS,KAAK,GAAG,IAAI;EAkGhE;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM;;eApGtC,OAAO;WAAS,KAAK,GAAG,IAAI;EAwGhE;AAED,wBAAgB,cAAc;mBA9Cb,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;EAgDnC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useEffect, useState, useCallback } from "react";
|
|
2
|
+
import { useChatConvex } from "./ChatConvexProvider";
|
|
3
|
+
export function useChatQuery(queryName, args) {
|
|
4
|
+
const { client, isReady } = useChatConvex();
|
|
5
|
+
const [data, setData] = useState(undefined);
|
|
6
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!client || !isReady || args === "skip") {
|
|
10
|
+
setData(undefined);
|
|
11
|
+
setIsLoading(false);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
setIsLoading(true);
|
|
15
|
+
setError(null);
|
|
16
|
+
const functionPath = `chat/orchestrator:${queryName}`;
|
|
17
|
+
try {
|
|
18
|
+
const watch = client.watchQuery(functionPath, args);
|
|
19
|
+
const handleUpdate = () => {
|
|
20
|
+
try {
|
|
21
|
+
const result = watch.localQueryResult();
|
|
22
|
+
setData(result);
|
|
23
|
+
setError(null);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
setError(err instanceof Error ? err : new Error("Query failed"));
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
setIsLoading(false);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const unsubscribe = watch.onUpdate(handleUpdate);
|
|
33
|
+
handleUpdate();
|
|
34
|
+
return () => {
|
|
35
|
+
unsubscribe();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
setError(err instanceof Error ? err : new Error("Failed to create query"));
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}, [client, isReady, queryName, JSON.stringify(args)]);
|
|
43
|
+
return { data, isLoading, error };
|
|
44
|
+
}
|
|
45
|
+
export function useChatMutation(mutationName) {
|
|
46
|
+
const { client, isReady } = useChatConvex();
|
|
47
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
48
|
+
const [error, setError] = useState(null);
|
|
49
|
+
const mutate = useCallback(async (args) => {
|
|
50
|
+
if (!client || !isReady) {
|
|
51
|
+
throw new Error("Convex client not ready");
|
|
52
|
+
}
|
|
53
|
+
setIsLoading(true);
|
|
54
|
+
setError(null);
|
|
55
|
+
try {
|
|
56
|
+
const functionPath = `chat/orchestrator:${mutationName}`;
|
|
57
|
+
const result = await client.mutation(functionPath, args);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
const error = err instanceof Error ? err : new Error("Mutation failed");
|
|
62
|
+
setError(error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
setIsLoading(false);
|
|
67
|
+
}
|
|
68
|
+
}, [client, isReady, mutationName]);
|
|
69
|
+
return { mutate, isLoading, error };
|
|
70
|
+
}
|
|
71
|
+
export function useListAllChannels(includeArchived) {
|
|
72
|
+
return useChatQuery("listAllChannels", { includeArchived });
|
|
73
|
+
}
|
|
74
|
+
export function useGetPatientChatStructure(patientId) {
|
|
75
|
+
return useChatQuery("getPatientChatStructure", patientId ? { patientId } : "skip");
|
|
76
|
+
}
|
|
77
|
+
export function useListMessages(subchannelId, limit) {
|
|
78
|
+
return useChatQuery("listMessages", subchannelId ? { subchannelId, limit } : "skip");
|
|
79
|
+
}
|
|
80
|
+
export function useSendMessage() {
|
|
81
|
+
return useChatMutation("sendMessage");
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=useChatQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChatQueries.js","sourceRoot":"","sources":["../src/useChatQueries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAYrD,MAAM,UAAU,YAAY,CAC1B,SAAiB,EACjB,IAAkC;IAElC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAAC;IAC5C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAgB,SAAS,CAAC,CAAC;IAC3D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IA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O,EAAE,YAAY,CAAC,CAChC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACtC,CAAC;AAID,MAAM,UAAU,kBAAkB,CAAC,eAAyB;IAC1D,OAAO,YAAY,CAAY,iBAAiB,EAC9C,EAAE,eAAe,EAAyB,CAC3C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,SAAwB;IACjE,OAAO,YAAY,CAAuB,yBAAyB,EACjE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAiC,CAAC,CAAC,CAAC,MAAM,CAClE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,YAA2B,EAAE,KAAc;IACzE,OAAO,YAAY,CAAgB,cAAc,EAC/C,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAsB,CAAC,CAAC,CAAC,MAAM,CACpE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,eAAe,CAAS,aAAa,CAAC,CAAC;AAChD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@primocaredentgroup/chat-ui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Chat UI component for PrimoCare Lab (Software B)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
18
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
19
|
+
"convex": "^1.14.0",
|
|
20
|
+
"@auth0/auth0-react": "^2.9.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "^19.0.0",
|
|
24
|
+
"@types/react-dom": "^19.0.0",
|
|
25
|
+
"react": "^19.2.0",
|
|
26
|
+
"react-dom": "^19.2.0",
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"lucide-react": "^0.460.0",
|
|
31
|
+
"date-fns": "^2.30.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"chat",
|
|
38
|
+
"react",
|
|
39
|
+
"convex",
|
|
40
|
+
"primo",
|
|
41
|
+
"laboratory",
|
|
42
|
+
"odontoiatria"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT"
|
|
45
|
+
}
|