Repository navigation
Expand file tree
/
Copy pathcomponents.js
More file actions
364 lines (335 loc) · 13.4 KB
/
Copy pathcomponents.js
File metadata and controls
364 lines (335 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
// ===================================
// JCDWS - Reusable UI Components
// ===================================
// Component: Notification Badge
function createNotificationBadge(count) {
if (count === 0) return '';
return `<span class="notification-badge">${count > 99 ? '99+' : count}</span>`;
}
// Component: Status Badge
function createStatusBadge(status) {
const statusConfig = {
'ACTIVE': { class: 'badge-success', text: 'Active' },
'PENDING': { class: 'badge-warning', text: 'Pending' },
'CLOSED': { class: 'badge-secondary', text: 'Closed' },
'HEARING_SCHEDULED': { class: 'badge-info', text: 'Hearing Scheduled' },
'DOCUMENT_PENDING': { class: 'badge-warning', text: 'Document Pending' },
'VERIFIED': { class: 'badge-success', text: 'Verified' },
'REJECTED': { class: 'badge-error', text: 'Rejected' },
'SCHEDULED': { class: 'badge-info', text: 'Scheduled' },
'COMPLETED': { class: 'badge-success', text: 'Completed' }
};
const config = statusConfig[status] || { class: 'badge-primary', text: status };
return `<span class="badge ${config.class}">${config.text}</span>`;
}
// Component: Priority Badge
function createPriorityBadge(priority) {
const priorityConfig = {
'HIGH': { class: 'badge-error', text: 'High Priority' },
'MEDIUM': { class: 'badge-warning', text: 'Medium' },
'LOW': { class: 'badge-info', text: 'Low' }
};
const config = priorityConfig[priority] || { class: 'badge-primary', text: priority };
return `<span class="badge ${config.class}">${config.text}</span>`;
}
// Component: User Avatar
function createUserAvatar(user, size = 'md') {
const sizeClass = `avatar-${size}`;
return `
<div class="avatar ${sizeClass}" title="${user.name}">
<img src="${user.avatar}" alt="${user.name}">
</div>
`;
}
// Component: Case Card
function createCaseCard(caseData) {
return `
<div class="card case-card" onclick="navigateTo('/case-detail.html?id=${caseData.id}')">
<div class="card-header">
<div class="flex justify-between items-center">
<h3 class="card-title">${caseData.caseNumber}</h3>
${createStatusBadge(caseData.status)}
</div>
<p class="text-secondary">${caseData.title}</p>
</div>
<div class="card-body">
<div class="case-info">
<div class="info-row">
<span class="info-label">Type:</span>
<span class="info-value">${caseData.type}</span>
</div>
<div class="info-row">
<span class="info-label">Court:</span>
<span class="info-value">${caseData.court}</span>
</div>
<div class="info-row">
<span class="info-label">Filing Date:</span>
<span class="info-value">${formatDate(caseData.filingDate)}</span>
</div>
${caseData.nextHearing ? `
<div class="info-row">
<span class="info-label">Next Hearing:</span>
<span class="info-value text-primary">${formatDate(caseData.nextHearing)}</span>
</div>
` : ''}
</div>
</div>
<div class="card-footer">
<div class="flex justify-between items-center">
${createPriorityBadge(caseData.priority)}
<button class="btn btn-sm btn-primary">View Details</button>
</div>
</div>
</div>
`;
}
// Component: Document Card
function createDocumentCard(document) {
return `
<div class="card document-card">
<div class="flex items-center gap-md">
<div class="document-icon">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
<polyline points="14 2 14 8 20 8"></polyline>
</svg>
</div>
<div class="flex-1">
<h4 class="document-name">${document.fileName}</h4>
<p class="text-secondary text-sm">${document.fileSize} • ${formatDate(document.uploadDate)}</p>
</div>
<div class="flex items-center gap-sm">
${createStatusBadge(document.status)}
<button class="btn btn-sm btn-ghost" onclick="downloadDocument('${document.id}')">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
<polyline points="7 10 12 15 17 10"></polyline>
<line x1="12" y1="15" x2="12" y2="3"></line>
</svg>
</button>
</div>
</div>
</div>
`;
}
// Component: Hearing Card
function createHearingCard(hearing) {
return `
<div class="card hearing-card">
<div class="card-header">
<div class="flex justify-between items-center">
<h4 class="card-title">${hearing.type}</h4>
${createStatusBadge(hearing.status)}
</div>
</div>
<div class="card-body">
<div class="hearing-info">
<div class="info-row">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
<line x1="16" y1="2" x2="16" y2="6"></line>
<line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
<span>${formatDate(hearing.date)} at ${hearing.time}</span>
</div>
<div class="info-row">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
</svg>
<span>${hearing.courtRoom}</span>
</div>
<div class="info-row">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
<circle cx="12" cy="7" r="4"></circle>
</svg>
<span>${hearing.judge}</span>
</div>
</div>
${hearing.notes ? `<p class="text-secondary mt-md">${hearing.notes}</p>` : ''}
</div>
</div>
`;
}
// Component: Message Thread
function createMessageThread(message) {
return `
<div class="message-thread ${message.read ? '' : 'unread'}" onclick="openMessage('${message.id}')">
<div class="flex items-center gap-md">
${createUserAvatar(message.from, 'sm')}
<div class="flex-1">
<div class="flex justify-between items-center">
<h4 class="message-sender">${message.from.name}</h4>
<span class="message-time text-secondary text-sm">${formatTimeAgo(message.timestamp)}</span>
</div>
<p class="message-subject">${message.subject}</p>
<p class="message-preview text-secondary">${message.message.substring(0, 80)}...</p>
</div>
${!message.read ? '<div class="unread-indicator"></div>' : ''}
</div>
</div>
`;
}
// Component: Notification Item
function createNotificationItem(notification) {
return `
<div class="notification-item ${notification.read ? 'read' : 'unread'}" onclick="handleNotificationClick('${notification.id}')">
<div class="notification-icon ${notification.priority.toLowerCase()}">
${getNotificationIcon(notification.type)}
</div>
<div class="flex-1">
<h4 class="notification-title">${notification.title}</h4>
<p class="notification-message text-secondary">${notification.message}</p>
<span class="notification-time text-tertiary text-xs">${formatTimeAgo(notification.timestamp)}</span>
</div>
${!notification.read ? '<div class="unread-indicator"></div>' : ''}
</div>
`;
}
// Component: Stat Card
function createStatCard(title, value, icon, trend = null) {
return `
<div class="card stat-card">
<div class="flex justify-between items-start">
<div>
<p class="stat-label text-secondary">${title}</p>
<h2 class="stat-value">${value}</h2>
${trend ? `<p class="stat-trend ${trend.direction}">${trend.text}</p>` : ''}
</div>
<div class="stat-icon">
${icon}
</div>
</div>
</div>
`;
}
// Component: Loading Spinner
function createLoadingSpinner() {
return `
<div class="loading-spinner">
<div class="spinner"></div>
</div>
`;
}
// Component: Empty State
function createEmptyState(title, message, actionText = null, actionHandler = null) {
return `
<div class="empty-state">
<svg width="80" height="80" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1">
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="8" x2="12" y2="12"></line>
<line x1="12" y1="16" x2="12.01" y2="16"></line>
</svg>
<h3>${title}</h3>
<p class="text-secondary">${message}</p>
${actionText ? `<button class="btn btn-primary mt-lg" onclick="${actionHandler}">${actionText}</button>` : ''}
</div>
`;
}
// Component: Modal
function createModal(id, title, content, actions = []) {
return `
<div id="${id}" class="modal-backdrop">
<div class="modal">
<div class="modal-header">
<h3 class="modal-title">${title}</h3>
<button class="modal-close" onclick="closeModal('${id}')">×</button>
</div>
<div class="modal-body">
${content}
</div>
${actions.length > 0 ? `
<div class="modal-footer flex justify-end gap-md">
${actions.map(action => `
<button class="btn ${action.class}" onclick="${action.handler}">${action.text}</button>
`).join('')}
</div>
` : ''}
</div>
</div>
`;
}
// Helper: Get notification icon
function getNotificationIcon(type) {
const icons = {
'HEARING_REMINDER': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>',
'DOCUMENT_VERIFIED': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"></polyline></svg>',
'NEW_MESSAGE': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>',
'DOCUMENT_PENDING': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>',
'CASE_UPDATE': '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>'
};
return icons[type] || icons['CASE_UPDATE'];
}
// Helper: Format date
function formatDate(dateString) {
if (!dateString) return 'N/A';
const date = new Date(dateString);
return date.toLocaleDateString('en-IN', {
year: 'numeric',
month: 'short',
day: 'numeric'
});
}
// Helper: Format time ago
function formatTimeAgo(timestamp) {
const date = new Date(timestamp);
const now = new Date();
const seconds = Math.floor((now - date) / 1000);
if (seconds < 60) return 'Just now';
if (seconds < 3600) return `${Math.floor(seconds / 60)} minutes ago`;
if (seconds < 86400) return `${Math.floor(seconds / 3600)} hours ago`;
if (seconds < 604800) return `${Math.floor(seconds / 86400)} days ago`;
return formatDate(timestamp);
}
// Helper: Navigate to page
function navigateTo(url) {
window.location.href = url;
}
// Helper: Show modal
function showModal(id) {
const modal = document.getElementById(id);
if (modal) {
modal.classList.add('active');
document.body.style.overflow = 'hidden';
}
}
// Helper: Close modal
function closeModal(id) {
const modal = document.getElementById(id);
if (modal) {
modal.classList.remove('active');
document.body.style.overflow = 'auto';
}
}
// Helper: Show toast notification
function showToast(message, type = 'info') {
const toast = document.createElement('div');
toast.className = `toast toast-${type}`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.classList.add('show');
}, 100);
setTimeout(() => {
toast.classList.remove('show');
setTimeout(() => toast.remove(), 300);
}, 3000);
}
// Helper: Download document
function downloadDocument(documentId) {
showToast('Document download started', 'success');
// In production, this would trigger actual download
console.log('Downloading document:', documentId);
}
// Helper: Handle notification click
function handleNotificationClick(notificationId) {
const notification = MockData.notifications.find(n => n.id === notificationId);
if (notification && notification.actionUrl) {
navigateTo(notification.actionUrl);
}
}
// Helper: Open message
function openMessage(messageId) {
navigateTo(`/messages.html?id=${messageId}`);
}