1
1
import { HistoryEntry , HistoryEntryItem } from '@/vdb/components/shared/history-timeline/history-entry.js' ;
2
+ import { HistoryNoteEditor } from '@/vdb/components/shared/history-timeline/history-note-editor.js' ;
2
3
import { HistoryNoteInput } from '@/vdb/components/shared/history-timeline/history-note-input.js' ;
3
- import {
4
- HistoryTimeline ,
5
- useHistoryTimeline ,
6
- } from '@/vdb/components/shared/history-timeline/history-timeline.js' ;
4
+ import { HistoryTimeline } from '@/vdb/components/shared/history-timeline/history-timeline.js' ;
7
5
import { Badge } from '@/vdb/components/ui/badge.js' ;
8
6
import { Button } from '@/vdb/components/ui/button.js' ;
9
- import {
10
- DropdownMenu ,
11
- DropdownMenuContent ,
12
- DropdownMenuItem ,
13
- DropdownMenuTrigger ,
14
- } from '@/vdb/components/ui/dropdown-menu.js' ;
15
- import { Separator } from '@/vdb/components/ui/separator.js' ;
16
7
import { Trans } from '@/vdb/lib/trans.js' ;
17
8
import {
18
9
ArrowRightToLine ,
@@ -22,11 +13,7 @@ import {
22
13
ChevronUp ,
23
14
CreditCardIcon ,
24
15
Edit3 ,
25
- MoreVerticalIcon ,
26
- PencilIcon ,
27
- RefreshCcw ,
28
16
SquarePen ,
29
- TrashIcon ,
30
17
Truck ,
31
18
UserX ,
32
19
} from 'lucide-react' ;
@@ -56,7 +43,29 @@ export function OrderHistory({
56
43
onDeleteNote,
57
44
} : Readonly < OrderHistoryProps > ) {
58
45
const [ expandedGroups , setExpandedGroups ] = useState < Set < number > > ( new Set ( ) ) ;
59
- const { editNote, deleteNote } = useHistoryTimeline ( ) ;
46
+ const [ noteEditorOpen , setNoteEditorOpen ] = useState ( false ) ;
47
+ const [ noteEditorNote , setNoteEditorNote ] = useState < {
48
+ noteId : string ;
49
+ note : string ;
50
+ isPrivate : boolean ;
51
+ } > ( {
52
+ noteId : '' ,
53
+ note : '' ,
54
+ isPrivate : true ,
55
+ } ) ;
56
+
57
+ const handleEditNote = ( noteId : string , note : string , isPrivate : boolean ) => {
58
+ setNoteEditorNote ( { noteId, note, isPrivate } ) ;
59
+ setNoteEditorOpen ( true ) ;
60
+ } ;
61
+
62
+ const handleDeleteNote = ( noteId : string ) => {
63
+ onDeleteNote ?.( noteId ) ;
64
+ } ;
65
+
66
+ const handleNoteEditorSave = ( noteId : string , note : string , isPrivate : boolean ) => {
67
+ onUpdateNote ?.( noteId , note , isPrivate ) ;
68
+ } ;
60
69
61
70
const isPrimaryEvent = ( entry : HistoryEntryItem ) => {
62
71
// Based on Angular component's isFeatured method
@@ -229,7 +238,7 @@ export function OrderHistory({
229
238
< div className = "mb-4" >
230
239
< HistoryNoteInput onAddNote = { onAddNote } />
231
240
</ div >
232
- < HistoryTimeline onEditNote = { onUpdateNote } onDeleteNote = { onDeleteNote } >
241
+ < HistoryTimeline >
233
242
{ groupedEntries . map ( ( group , groupIndex ) => {
234
243
if ( group . type === 'primary' ) {
235
244
const entry = group . entry ;
@@ -242,6 +251,8 @@ export function OrderHistory({
242
251
title = { getTitle ( entry ) }
243
252
isPrimary = { true }
244
253
customer = { order . customer }
254
+ onEditNote = { handleEditNote }
255
+ onDeleteNote = { handleDeleteNote }
245
256
>
246
257
{ entry . type === 'ORDER_NOTE' && (
247
258
< div className = "space-y-2" >
@@ -253,36 +264,6 @@ export function OrderHistory({
253
264
>
254
265
{ entry . isPublic ? 'Public' : 'Private' }
255
266
</ Badge >
256
- < DropdownMenu >
257
- < DropdownMenuTrigger asChild >
258
- < Button variant = "ghost" size = "sm" className = "h-6 w-6 p-0" >
259
- < MoreVerticalIcon className = "h-3 w-3" />
260
- </ Button >
261
- </ DropdownMenuTrigger >
262
- < DropdownMenuContent align = "end" >
263
- < DropdownMenuItem
264
- onClick = { ( ) =>
265
- editNote (
266
- entry . id ,
267
- entry . data . note ,
268
- ! entry . isPublic ,
269
- )
270
- }
271
- className = "cursor-pointer"
272
- >
273
- < PencilIcon className = "mr-2 h-4 w-4" />
274
- < Trans > Edit</ Trans >
275
- </ DropdownMenuItem >
276
- < Separator className = "my-1" />
277
- < DropdownMenuItem
278
- onClick = { ( ) => deleteNote ( entry . id ) }
279
- className = "cursor-pointer text-red-600 focus:text-red-600"
280
- >
281
- < TrashIcon className = "mr-2 h-4 w-4" />
282
- < span > Delete</ span >
283
- </ DropdownMenuItem >
284
- </ DropdownMenuContent >
285
- </ DropdownMenu >
286
267
</ div >
287
268
</ div >
288
269
) }
@@ -307,39 +288,33 @@ export function OrderHistory({
307
288
</ Trans >
308
289
</ p >
309
290
) }
310
- { entry . type === 'ORDER_FULFILLMENT_TRANSITION' && entry . data . from !== 'Created' && (
311
- < p className = "text-xs text-muted-foreground" >
312
- < Trans >
313
- Fulfillment #{ entry . data . fulfillmentId } from { entry . data . from } to { entry . data . to }
314
- </ Trans >
315
- </ p >
316
- ) }
291
+ { entry . type === 'ORDER_FULFILLMENT_TRANSITION' &&
292
+ entry . data . from !== 'Created' && (
293
+ < p className = "text-xs text-muted-foreground" >
294
+ < Trans >
295
+ Fulfillment #{ entry . data . fulfillmentId } from { entry . data . from } { ' ' }
296
+ to { entry . data . to }
297
+ </ Trans >
298
+ </ p >
299
+ ) }
317
300
{ entry . type === 'ORDER_FULFILLMENT' && (
318
301
< p className = "text-xs text-muted-foreground" >
319
- < Trans >
320
- Fulfillment #{ entry . data . fulfillmentId } created
321
- </ Trans >
302
+ < Trans > Fulfillment #{ entry . data . fulfillmentId } created</ Trans >
322
303
</ p >
323
304
) }
324
305
{ entry . type === 'ORDER_MODIFIED' && (
325
306
< p className = "text-xs text-muted-foreground" >
326
- < Trans >
327
- Order modification #{ entry . data . modificationId }
328
- </ Trans >
307
+ < Trans > Order modification #{ entry . data . modificationId } </ Trans >
329
308
</ p >
330
309
) }
331
310
{ entry . type === 'ORDER_CUSTOMER_UPDATED' && (
332
311
< p className = "text-xs text-muted-foreground" >
333
- < Trans >
334
- Customer information updated
335
- </ Trans >
312
+ < Trans > Customer information updated</ Trans >
336
313
</ p >
337
314
) }
338
315
{ entry . type === 'ORDER_CANCELLATION' && (
339
316
< p className = "text-xs text-muted-foreground" >
340
- < Trans >
341
- Order cancelled
342
- </ Trans >
317
+ < Trans > Order cancelled</ Trans >
343
318
</ p >
344
319
) }
345
320
</ HistoryEntry >
@@ -362,6 +337,8 @@ export function OrderHistory({
362
337
title = { getTitle ( entry ) }
363
338
isPrimary = { false }
364
339
customer = { order . customer }
340
+ onEditNote = { handleEditNote }
341
+ onDeleteNote = { handleDeleteNote }
365
342
>
366
343
{ entry . type === 'ORDER_NOTE' && (
367
344
< div className = "space-y-1" >
@@ -393,43 +370,38 @@ export function OrderHistory({
393
370
{ entry . type === 'ORDER_REFUND_TRANSITION' && (
394
371
< p className = "text-xs text-muted-foreground" >
395
372
< Trans >
396
- Refund #{ entry . data . refundId } transitioned to { entry . data . to }
397
- </ Trans >
398
- </ p >
399
- ) }
400
- { entry . type === 'ORDER_FULFILLMENT_TRANSITION' && entry . data . from !== 'Created' && (
401
- < p className = "text-xs text-muted-foreground" >
402
- < Trans >
403
- Fulfillment #{ entry . data . fulfillmentId } from { entry . data . from } to { entry . data . to }
373
+ Refund #{ entry . data . refundId } transitioned to{ ' ' }
374
+ { entry . data . to }
404
375
</ Trans >
405
376
</ p >
406
377
) }
378
+ { entry . type === 'ORDER_FULFILLMENT_TRANSITION' &&
379
+ entry . data . from !== 'Created' && (
380
+ < p className = "text-xs text-muted-foreground" >
381
+ < Trans >
382
+ Fulfillment #{ entry . data . fulfillmentId } from{ ' ' }
383
+ { entry . data . from } to { entry . data . to }
384
+ </ Trans >
385
+ </ p >
386
+ ) }
407
387
{ entry . type === 'ORDER_FULFILLMENT' && (
408
388
< p className = "text-xs text-muted-foreground" >
409
- < Trans >
410
- Fulfillment #{ entry . data . fulfillmentId } created
411
- </ Trans >
389
+ < Trans > Fulfillment #{ entry . data . fulfillmentId } created</ Trans >
412
390
</ p >
413
391
) }
414
392
{ entry . type === 'ORDER_MODIFIED' && (
415
393
< p className = "text-xs text-muted-foreground" >
416
- < Trans >
417
- Order modification #{ entry . data . modificationId }
418
- </ Trans >
394
+ < Trans > Order modification #{ entry . data . modificationId } </ Trans >
419
395
</ p >
420
396
) }
421
397
{ entry . type === 'ORDER_CUSTOMER_UPDATED' && (
422
398
< p className = "text-xs text-muted-foreground" >
423
- < Trans >
424
- Customer information updated
425
- </ Trans >
399
+ < Trans > Customer information updated</ Trans >
426
400
</ p >
427
401
) }
428
402
{ entry . type === 'ORDER_CANCELLATION' && (
429
403
< p className = "text-xs text-muted-foreground" >
430
- < Trans >
431
- Order cancelled
432
- </ Trans >
404
+ < Trans > Order cancelled</ Trans >
433
405
</ p >
434
406
) }
435
407
</ HistoryEntry >
@@ -462,6 +434,15 @@ export function OrderHistory({
462
434
}
463
435
} ) }
464
436
</ HistoryTimeline >
437
+ < HistoryNoteEditor
438
+ key = { noteEditorNote . noteId }
439
+ note = { noteEditorNote . note }
440
+ onNoteChange = { handleNoteEditorSave }
441
+ open = { noteEditorOpen }
442
+ onOpenChange = { setNoteEditorOpen }
443
+ noteId = { noteEditorNote . noteId }
444
+ isPrivate = { noteEditorNote . isPrivate }
445
+ />
465
446
</ div >
466
447
) ;
467
448
}
0 commit comments