Spaces:
Paused

dushyantsingh0 commited on
Commit
7e1cd85
·
1 Parent(s): 4ae2101

backend stabilization

Browse files
frontend/apps/customer/src/components/ThreadView.module.css CHANGED
@@ -42,6 +42,24 @@
42
  white-space: nowrap;
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  .mainTitle {
46
  font-size: 20px;
47
  font-weight: 900;
@@ -279,6 +297,15 @@
279
  background: rgba(239, 68, 68, 0.05);
280
  }
281
 
 
 
 
 
 
 
 
 
 
282
  .headerBtn {
283
  background: transparent;
284
  border: none;
@@ -498,34 +525,66 @@
498
  }
499
 
500
  .replyArea {
 
501
  background: var(--bg-dark);
502
- border-radius: 12px;
503
- padding: 4px;
504
- border: 1px solid var(--border-subtle);
505
  transition: all 0.2s;
506
  }
507
 
508
  .replyArea:focus-within {
509
  border-color: var(--primary);
510
- background: #fff;
511
  box-shadow: 0 0 0 4px var(--primary-glow);
512
  }
513
 
514
  .replyTextarea {
515
  width: 100%;
516
- min-height: 80px;
517
- padding: 12px;
518
- border: none;
519
  background: transparent;
 
520
  color: var(--text-main);
521
  font-size: 14px;
522
  font-weight: 500;
523
  resize: none;
524
  outline: none;
525
- font-family: inherit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  }
527
 
528
  .consoleFooter {
 
529
  display: flex;
530
  justify-content: space-between;
531
  align-items: center;
@@ -539,13 +598,13 @@
539
  .toolBtn {
540
  width: 32px;
541
  height: 32px;
542
- border-radius: 8px;
543
- border: 1px solid var(--border-subtle);
544
- background: #fff;
545
- color: var(--text-muted);
546
  display: flex;
547
  align-items: center;
548
  justify-content: center;
 
 
 
 
549
  cursor: pointer;
550
  transition: all 0.2s;
551
  }
@@ -568,3 +627,75 @@
568
  padding: 24px 32px;
569
  }
570
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  white-space: nowrap;
43
  }
44
 
45
+ .escalatedBadge {
46
+ background: var(--error);
47
+ color: white;
48
+ padding: 4px 12px;
49
+ border-radius: 6px;
50
+ font-size: 10px;
51
+ font-weight: 900;
52
+ letter-spacing: 0.05em;
53
+ box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
54
+ animation: pulse-red 2s infinite;
55
+ }
56
+
57
+ @keyframes pulse-red {
58
+ 0% { opacity: 1; }
59
+ 50% { opacity: 0.7; }
60
+ 100% { opacity: 1; }
61
+ }
62
+
63
  .mainTitle {
64
  font-size: 20px;
65
  font-weight: 900;
 
297
  background: rgba(239, 68, 68, 0.05);
298
  }
299
 
300
+ .btnEscalated {
301
+ background: rgba(239, 68, 68, 0.05);
302
+ border: 1.5px solid var(--error) !important;
303
+ color: var(--error);
304
+ opacity: 0.7;
305
+ cursor: not-allowed;
306
+ font-weight: 900;
307
+ }
308
+
309
  .headerBtn {
310
  background: transparent;
311
  border: none;
 
525
  }
526
 
527
  .replyArea {
528
+ position: relative;
529
  background: var(--bg-dark);
530
+ border-radius: 16px;
531
+ overflow: hidden;
532
+ border: 1.5px solid var(--border-subtle);
533
  transition: all 0.2s;
534
  }
535
 
536
  .replyArea:focus-within {
537
  border-color: var(--primary);
 
538
  box-shadow: 0 0 0 4px var(--primary-glow);
539
  }
540
 
541
  .replyTextarea {
542
  width: 100%;
543
+ min-height: 100px;
544
+ max-height: 300px;
545
+ padding: 16px 60px 16px 16px; /* Right padding for the small button */
546
  background: transparent;
547
+ border: none;
548
  color: var(--text-main);
549
  font-size: 14px;
550
  font-weight: 500;
551
  resize: none;
552
  outline: none;
553
+ line-height: 1.6;
554
+ }
555
+
556
+ .sendBtnSmall {
557
+ position: absolute;
558
+ top: 12px;
559
+ right: 12px;
560
+ width: 32px;
561
+ height: 32px;
562
+ padding: 0;
563
+ display: flex;
564
+ align-items: center;
565
+ justify-content: center;
566
+ border-radius: 8px;
567
+ background: var(--primary);
568
+ color: white;
569
+ border: none;
570
+ cursor: pointer;
571
+ transition: all 0.2s;
572
+ box-shadow: 0 4px 12px var(--primary-glow);
573
+ }
574
+
575
+ .sendBtnSmall:hover {
576
+ transform: translateY(-2px);
577
+ background: var(--primary-hi);
578
+ }
579
+
580
+ .sendBtnSmall:disabled {
581
+ opacity: 0.5;
582
+ cursor: not-allowed;
583
+ transform: none;
584
  }
585
 
586
  .consoleFooter {
587
+ padding: 12px 16px;
588
  display: flex;
589
  justify-content: space-between;
590
  align-items: center;
 
598
  .toolBtn {
599
  width: 32px;
600
  height: 32px;
 
 
 
 
601
  display: flex;
602
  align-items: center;
603
  justify-content: center;
604
+ border-radius: 8px;
605
+ background: white;
606
+ border: 1px solid var(--border-subtle);
607
+ color: var(--text-dim);
608
  cursor: pointer;
609
  transition: all 0.2s;
610
  }
 
627
  padding: 24px 32px;
628
  }
629
  }
630
+
631
+ /* --- History Timeline --- */
632
+ .historyTimeline {
633
+ padding: 24px;
634
+ display: flex;
635
+ flex-direction: column;
636
+ gap: 24px;
637
+ overflow-y: auto;
638
+ flex: 1;
639
+ }
640
+
641
+ .historyItem {
642
+ position: relative;
643
+ display: flex;
644
+ gap: 16px;
645
+ }
646
+
647
+ .historyLine {
648
+ position: absolute;
649
+ left: 15px;
650
+ top: 32px;
651
+ bottom: -24px;
652
+ width: 2px;
653
+ background: var(--border-subtle);
654
+ }
655
+
656
+ .historyItem:last-child .historyLine {
657
+ display: none;
658
+ }
659
+
660
+ .historyIcon {
661
+ width: 32px;
662
+ height: 32px;
663
+ border-radius: 50%;
664
+ background: white;
665
+ border: 1.5px solid var(--border-subtle);
666
+ display: flex;
667
+ align-items: center;
668
+ justify-content: center;
669
+ font-size: 14px;
670
+ z-index: 1;
671
+ }
672
+
673
+ .historyContent {
674
+ flex: 1;
675
+ }
676
+
677
+ .historyMeta {
678
+ display: flex;
679
+ justify-content: space-between;
680
+ align-items: center;
681
+ margin-bottom: 4px;
682
+ }
683
+
684
+ .historyLabel {
685
+ font-size: 11px;
686
+ font-weight: 800;
687
+ letter-spacing: 0.05em;
688
+ color: var(--text-main);
689
+ }
690
+
691
+ .historyTime {
692
+ font-size: 9px;
693
+ font-weight: 700;
694
+ color: var(--text-muted);
695
+ }
696
+
697
+ .historyDetail {
698
+ font-size: 13px;
699
+ color: var(--text-dim);
700
+ line-height: 1.5;
701
+ }
frontend/apps/customer/src/components/ThreadView.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef, useCallback } from 'react';
2
  import { StatusBadge } from './Badges';
3
  import { api, NexusMarkdown, getFileIcon, getStorageKey } from '@nexus/shared';
4
  import styles from './ThreadView.module.css';
@@ -70,7 +70,7 @@ interface Ticket {
70
  resolved_by_name?: string;
71
  resolution_text?: string;
72
  expected_resolution_at: string;
73
- is_escalated: boolean;
74
  created_at: string;
75
  rating?: number;
76
  feedback_comment?: string;
@@ -242,6 +242,45 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
242
  };
243
  }, [isResizing]);
244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  // --- MENTION LOGIC ---
246
  const handleMentionInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
247
  const val = e.target.value;
@@ -465,6 +504,9 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
465
  </button>
466
  <div className={styles.headerTitleArea}>
467
  <div className={styles.ticketIdBadge}>#{ticket.id.slice(0, 8).toUpperCase()}</div>
 
 
 
468
  <h1 className={styles.mainTitle}>{ticket.title}</h1>
469
  </div>
470
  </div>
@@ -478,10 +520,16 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
478
  {isReopening ? 'REOPENING...' : 'REOPEN TICKET'}
479
  </button>
480
  )}
481
- {!ticket.is_escalated && !['RESOLVED', 'CLOSED'].includes((ticket.status || '').toUpperCase()) && (
482
- <button onClick={() => setShowConfirmEscalate(true)} disabled={isEscalating} className={`${styles.btn} ${styles.btnEscalate}`} style={{ padding: '8px 16px' }}>
483
- {isEscalating ? 'ESCALATING...' : 'ESCALATE'}
484
- </button>
 
 
 
 
 
 
485
  )}
486
  <button onClick={() => setIsSidebarOpen(!isSidebarOpen)} className={styles.feedToggle}>
487
  {isSidebarOpen ? <Maximize2 size={18} /> : <MessageSquare size={18} />}
@@ -701,6 +749,15 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
701
  className={styles.replyTextarea}
702
  />
703
 
 
 
 
 
 
 
 
 
 
704
  {showMentionList && filteredUsers.length > 0 && (
705
  <div className={styles.mentionOverlay}>
706
  <div className={styles.mentionHeader}>Organization Members</div>
@@ -724,9 +781,6 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
724
  </button>
725
  <input type="file" ref={fileInputRef} onChange={e => e.target.files?.[0] && handleUpload(e.target.files[0], false)} style={{ display: 'none' }} />
726
  </div>
727
- <button onClick={handleSend} disabled={sending || !newMessage.trim() || isUploading} className={styles.btnPrimary} style={{ height: 36, padding: '0 24px', borderRadius: 10, display: 'flex', alignItems: 'center', gap: 8 }}>
728
- {sending ? <Loader2 size={14} className={styles.spin} /> : <><Send size={14} /> SEND</>}
729
- </button>
730
  </div>
731
  </div>
732
  </>
@@ -751,6 +805,27 @@ export const ThreadView: React.FC<ThreadViewProps> = ({ ticket: initialTicket, o
751
  )}
752
  </div>
753
  )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  </div>
755
  </div>
756
  </div>
 
1
+ import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
2
  import { StatusBadge } from './Badges';
3
  import { api, NexusMarkdown, getFileIcon, getStorageKey } from '@nexus/shared';
4
  import styles from './ThreadView.module.css';
 
70
  resolved_by_name?: string;
71
  resolution_text?: string;
72
  expected_resolution_at: string;
73
+ is_escalated: string | null;
74
  created_at: string;
75
  rating?: number;
76
  feedback_comment?: string;
 
242
  };
243
  }, [isResizing]);
244
 
245
+ // --- HISTORY LOGIC ---
246
+ const historyEvents = useMemo(() => {
247
+ if (!ticket) return [];
248
+ const events: { id: string; time: string; label: string; detail: string; icon: string }[] = [];
249
+
250
+ // 1. Creation
251
+ events.push({
252
+ id: 'creation',
253
+ time: ticket.created_at,
254
+ label: 'INCIDENT LOGGED',
255
+ detail: 'Core ticket state initialized via portal.',
256
+ icon: '🎫'
257
+ });
258
+
259
+ // 2. Escalation
260
+ if (ticket.is_escalated) {
261
+ events.push({
262
+ id: 'escalation',
263
+ time: ticket.is_escalated,
264
+ label: 'CRITICAL ESCALATION',
265
+ detail: 'Incident priority elevated for lead intervention.',
266
+ icon: '🚨'
267
+ });
268
+ }
269
+
270
+ // 3. Resolution
271
+ if (ticket.status === 'RESOLVED' || ticket.status === 'CLOSED') {
272
+ events.push({
273
+ id: 'resolution',
274
+ time: ticket.resolved_at || new Date().toISOString(),
275
+ label: 'RESOLVED & VERIFIED',
276
+ detail: 'Ticket state transitioned to closure.',
277
+ icon: '✅'
278
+ });
279
+ }
280
+
281
+ return events.sort((a, b) => new Date(b.time).getTime() - new Date(a.time).getTime());
282
+ }, [ticket]);
283
+
284
  // --- MENTION LOGIC ---
285
  const handleMentionInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
286
  const val = e.target.value;
 
504
  </button>
505
  <div className={styles.headerTitleArea}>
506
  <div className={styles.ticketIdBadge}>#{ticket.id.slice(0, 8).toUpperCase()}</div>
507
+ {ticket.is_escalated && (
508
+ <div className={styles.escalatedBadge}>ESCALATED</div>
509
+ )}
510
  <h1 className={styles.mainTitle}>{ticket.title}</h1>
511
  </div>
512
  </div>
 
520
  {isReopening ? 'REOPENING...' : 'REOPEN TICKET'}
521
  </button>
522
  )}
523
+ {!['RESOLVED', 'CLOSED'].includes((ticket.status || '').toUpperCase()) && (
524
+ ticket.is_escalated ? (
525
+ <button disabled className={`${styles.btn} ${styles.btnEscalated}`} style={{ padding: '8px 16px' }}>
526
+ ESCALATED
527
+ </button>
528
+ ) : (
529
+ <button onClick={() => setShowConfirmEscalate(true)} disabled={isEscalating} className={`${styles.btn} ${styles.btnEscalate}`} style={{ padding: '8px 16px' }}>
530
+ {isEscalating ? 'ESCALATING...' : 'ESCALATE'}
531
+ </button>
532
+ )
533
  )}
534
  <button onClick={() => setIsSidebarOpen(!isSidebarOpen)} className={styles.feedToggle}>
535
  {isSidebarOpen ? <Maximize2 size={18} /> : <MessageSquare size={18} />}
 
749
  className={styles.replyTextarea}
750
  />
751
 
752
+ <button
753
+ onClick={handleSend}
754
+ disabled={sending || !newMessage.trim() || isUploading}
755
+ className={styles.sendBtnSmall}
756
+ title="Send Message"
757
+ >
758
+ {sending ? <Loader2 size={14} className={styles.spin} /> : <Send size={14} />}
759
+ </button>
760
+
761
  {showMentionList && filteredUsers.length > 0 && (
762
  <div className={styles.mentionOverlay}>
763
  <div className={styles.mentionHeader}>Organization Members</div>
 
781
  </button>
782
  <input type="file" ref={fileInputRef} onChange={e => e.target.files?.[0] && handleUpload(e.target.files[0], false)} style={{ display: 'none' }} />
783
  </div>
 
 
 
784
  </div>
785
  </div>
786
  </>
 
805
  )}
806
  </div>
807
  )}
808
+
809
+ {sidebarTab === 'history' && (
810
+ <div className={styles.historyTimeline}>
811
+ {historyEvents.map((event) => (
812
+ <div key={event.id} className={styles.historyItem}>
813
+ <div className={styles.historyLine} />
814
+ <div className={styles.historyIcon}>{event.icon}</div>
815
+ <div className={styles.historyContent}>
816
+ <div className={styles.historyMeta}>
817
+ <span className={styles.historyLabel}>{event.label}</span>
818
+ <span className={styles.historyTime}>{new Date(event.time).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' })}</span>
819
+ </div>
820
+ <div className={styles.historyDetail}>{event.detail}</div>
821
+ </div>
822
+ </div>
823
+ ))}
824
+ {historyEvents.length === 0 && (
825
+ <div style={{ textAlign: 'center', padding: 40, color: 'var(--text-muted)', fontSize: 12, fontWeight: 600 }}>No operational events recorded.</div>
826
+ )}
827
+ </div>
828
+ )}
829
  </div>
830
  </div>
831
  </div>