@consilioweb/payload-support 0.9.10 → 0.9.12
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/components/TicketConversation/hooks/useAI.cjs +24 -5
- package/dist/components/TicketConversation/hooks/useAI.js +24 -5
- package/dist/index.cjs +301 -13
- package/dist/index.js +301 -13
- package/dist/styles/BillingView.module.scss +132 -0
- package/dist/views/BillingView/client.cjs +287 -170
- package/dist/views/BillingView/client.js +287 -170
- package/dist/views/TicketDetailView/client.cjs +28 -6
- package/dist/views/TicketDetailView/client.js +28 -6
- package/package.json +1 -1
- package/src/collections/Tickets.ts +78 -0
- package/src/components/TicketConversation/hooks/useAI.ts +29 -5
- package/src/endpoints/ai.ts +13 -8
- package/src/endpoints/billing.ts +70 -9
- package/src/endpoints/index.ts +3 -0
- package/src/endpoints/ticket-synthesis.ts +67 -0
- package/src/styles/BillingView.module.scss +132 -0
- package/src/utils/generateTicketSynthesis.ts +178 -0
- package/src/views/BillingView/client.tsx +234 -102
- package/src/views/TicketDetailView/client.tsx +24 -6
|
@@ -136,7 +136,9 @@ export const TicketDetailClient: React.FC = () => {
|
|
|
136
136
|
// Inline message edit
|
|
137
137
|
const [editingMsgId, setEditingMsgId] = useState<string | number | null>(null)
|
|
138
138
|
const [editingBody, setEditingBody] = useState('')
|
|
139
|
+
const [editingHtml, setEditingHtml] = useState('')
|
|
139
140
|
const [editSaving, setEditSaving] = useState(false)
|
|
141
|
+
const editEditorRef = useRef<RichTextEditorHandle>(null)
|
|
140
142
|
const [sending, setSending] = useState(false)
|
|
141
143
|
|
|
142
144
|
const [showMenu, setShowMenu] = useState(false)
|
|
@@ -449,11 +451,14 @@ const [clientTyping, setClientTyping] = useState(false)
|
|
|
449
451
|
const startEditMessage = (msg: Message) => {
|
|
450
452
|
setEditingMsgId(msg.id)
|
|
451
453
|
setEditingBody(msg.body || '')
|
|
454
|
+
// Prefer existing bodyHtml for WYSIWYG edit, fallback to body with <br/> conversion
|
|
455
|
+
setEditingHtml(msg.bodyHtml || (msg.body || '').replace(/\n/g, '<br/>'))
|
|
452
456
|
}
|
|
453
457
|
|
|
454
458
|
const cancelEditMessage = () => {
|
|
455
459
|
setEditingMsgId(null)
|
|
456
460
|
setEditingBody('')
|
|
461
|
+
setEditingHtml('')
|
|
457
462
|
}
|
|
458
463
|
|
|
459
464
|
const saveEditMessage = async () => {
|
|
@@ -464,11 +469,12 @@ const [clientTyping, setClientTyping] = useState(false)
|
|
|
464
469
|
method: 'PATCH',
|
|
465
470
|
headers: { 'Content-Type': 'application/json' },
|
|
466
471
|
credentials: 'include',
|
|
467
|
-
body: JSON.stringify({ body: editingBody, bodyHtml: null, skipNotification: true }),
|
|
472
|
+
body: JSON.stringify({ body: editingBody, bodyHtml: editingHtml || null, skipNotification: true }),
|
|
468
473
|
})
|
|
469
474
|
if (res.ok) {
|
|
470
475
|
setEditingMsgId(null)
|
|
471
476
|
setEditingBody('')
|
|
477
|
+
setEditingHtml('')
|
|
472
478
|
fetchAll()
|
|
473
479
|
}
|
|
474
480
|
} catch { /* silent */ } finally {
|
|
@@ -654,11 +660,23 @@ const [clientTyping, setClientTyping] = useState(false)
|
|
|
654
660
|
</div>
|
|
655
661
|
{editingMsgId === msg.id ? (
|
|
656
662
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
|
657
|
-
<
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
663
|
+
<RichTextEditor
|
|
664
|
+
ref={editEditorRef}
|
|
665
|
+
initialValue={editingHtml}
|
|
666
|
+
onChange={(html, text) => { setEditingHtml(html); setEditingBody(text) }}
|
|
667
|
+
placeholder="Éditer le message..."
|
|
668
|
+
minHeight={120}
|
|
669
|
+
onFileUpload={async (file) => {
|
|
670
|
+
try {
|
|
671
|
+
const formData = new FormData()
|
|
672
|
+
formData.append('file', file)
|
|
673
|
+
formData.append('_payload', JSON.stringify({ alt: file.name }))
|
|
674
|
+
const ur = await fetch('/api/media', { method: 'POST', credentials: 'include', body: formData })
|
|
675
|
+
if (!ur.ok) return null
|
|
676
|
+
const ud = await ur.json()
|
|
677
|
+
return ud.doc?.url || null
|
|
678
|
+
} catch { return null }
|
|
679
|
+
}}
|
|
662
680
|
/>
|
|
663
681
|
<div style={{ display: 'flex', gap: 6, justifyContent: 'flex-end' }}>
|
|
664
682
|
<button onClick={cancelEditMessage} disabled={editSaving} style={{ padding: '5px 12px', fontSize: 12, borderRadius: 5, border: '1px solid var(--theme-elevation-200)', background: 'var(--theme-elevation-0)', color: 'var(--theme-text)', cursor: 'pointer' }}>Annuler</button>
|