refactor: rename messageHistory to smsHistory and update schema with unique IDs and timestamps
This commit is contained in:
@@ -98,7 +98,7 @@ interface Request {
|
|||||||
appointmentDate?: string;
|
appointmentDate?: string;
|
||||||
|
|
||||||
notes: string[];
|
notes: string[];
|
||||||
messageHistory: { date: string; message: string; from: 'admin' | 'user' }[];
|
smsHistory: { id: string; message: string; sentAt: string; sentBy: string }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockRequests: Request[] = [
|
const mockRequests: Request[] = [
|
||||||
@@ -123,7 +123,7 @@ const mockRequests: Request[] = [
|
|||||||
riderPlan: 'daily_rent',
|
riderPlan: 'daily_rent',
|
||||||
employmentInfo: { company: 'Foodpanda', monthlyEarning: 2500, whyEV: 'Low maintenance, good for delivery', experience: '3 years bike riding' },
|
employmentInfo: { company: 'Foodpanda', monthlyEarning: 2500, whyEV: 'Low maintenance, good for delivery', experience: '3 years bike riding' },
|
||||||
notes: ['Downloaded app and applied through mobile'],
|
notes: ['Downloaded app and applied through mobile'],
|
||||||
messageHistory: [],
|
smsHistory: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'REQ002',
|
id: 'REQ002',
|
||||||
@@ -143,9 +143,9 @@ const mockRequests: Request[] = [
|
|||||||
{ id: 'd6', name: 'TIN Certificate', status: 'pending' },
|
{ id: 'd6', name: 'TIN Certificate', status: 'pending' },
|
||||||
{ id: 'd7', name: 'Bank Statement', status: 'pending' },
|
{ id: 'd7', name: 'Bank Statement', status: 'pending' },
|
||||||
],
|
],
|
||||||
messageHistory: [
|
smsHistory: [
|
||||||
{ date: '2024-03-19', message: 'Please upload your TIN certificate and latest bank statement', from: 'admin' },
|
{ id: 'sms1', message: 'Please upload your TIN certificate and latest bank statement', sentAt: '2024-03-19', sentBy: 'admin' },
|
||||||
{ date: '2024-03-19', message: 'I will upload them today', from: 'user' },
|
{ id: 'sms2', message: 'I will upload them today', sentAt: '2024-03-19', sentBy: 'user' },
|
||||||
],
|
],
|
||||||
notes: ['Walked in at Gulshan office - referred by current biker'],
|
notes: ['Walked in at Gulshan office - referred by current biker'],
|
||||||
},
|
},
|
||||||
@@ -167,7 +167,7 @@ const mockRequests: Request[] = [
|
|||||||
{ id: 'd10', name: 'Shop Photos', status: 'uploaded', uploadedAt: '2024-03-18' },
|
{ id: 'd10', name: 'Shop Photos', status: 'uploaded', uploadedAt: '2024-03-18' },
|
||||||
],
|
],
|
||||||
notes: ['Applied through website'],
|
notes: ['Applied through website'],
|
||||||
messageHistory: [],
|
smsHistory: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'REQ004',
|
id: 'REQ004',
|
||||||
@@ -199,7 +199,7 @@ const mockRequests: Request[] = [
|
|||||||
scheduleDate: '2024-03-15',
|
scheduleDate: '2024-03-15',
|
||||||
appointmentDate: '2024-03-15',
|
appointmentDate: '2024-03-15',
|
||||||
notes: ['Approved and active - EV allocated'],
|
notes: ['Approved and active - EV allocated'],
|
||||||
messageHistory: [],
|
smsHistory: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'REQ005',
|
id: 'REQ005',
|
||||||
@@ -219,8 +219,8 @@ const mockRequests: Request[] = [
|
|||||||
{ id: 'd15', name: 'TIN Certificate', status: 'uploaded', uploadedAt: '2024-03-10' },
|
{ id: 'd15', name: 'TIN Certificate', status: 'uploaded', uploadedAt: '2024-03-10' },
|
||||||
{ id: 'd16', name: 'Bank Statement', status: 'uploaded', uploadedAt: '2024-03-10' },
|
{ id: 'd16', name: 'Bank Statement', status: 'uploaded', uploadedAt: '2024-03-10' },
|
||||||
],
|
],
|
||||||
messageHistory: [
|
smsHistory: [
|
||||||
{ date: '2024-03-10', message: 'Your NID document is not clear. Please re-upload.', from: 'admin' },
|
{ id: 'sms3', message: 'Your NID document is not clear. Please re-upload.', sentAt: '2024-03-10', sentBy: 'admin' },
|
||||||
],
|
],
|
||||||
notes: ['NID was unclear/blurry'],
|
notes: ['NID was unclear/blurry'],
|
||||||
},
|
},
|
||||||
@@ -245,7 +245,7 @@ const mockRequests: Request[] = [
|
|||||||
nomineeDetails: { name: 'Rashid', phone: '01798765432', relationship: 'Brother', nid: '9876543210987' },
|
nomineeDetails: { name: 'Rashid', phone: '01798765432', relationship: 'Brother', nid: '9876543210987' },
|
||||||
employmentInfo: { company: ' ssl', monthlyEarning: 2000, whyEV: 'Better income than fuel bike', experience: '2 years' },
|
employmentInfo: { company: ' ssl', monthlyEarning: 2000, whyEV: 'Better income than fuel bike', experience: '2 years' },
|
||||||
notes: [],
|
notes: [],
|
||||||
messageHistory: [],
|
smsHistory: [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -398,9 +398,9 @@ export default function RequestsPage() {
|
|||||||
return {
|
return {
|
||||||
...req,
|
...req,
|
||||||
status: 'documents_needed' as const,
|
status: 'documents_needed' as const,
|
||||||
messageHistory: [
|
smsHistory: [
|
||||||
...req.messageHistory,
|
...req.smsHistory,
|
||||||
{ date: new Date().toISOString().split('T')[0], message: messageText, from: 'admin' as const }
|
{ id: `sms-${Date.now()}`, message: messageText, sentAt: new Date().toISOString(), sentBy: 'admin' }
|
||||||
],
|
],
|
||||||
notes: [...req.notes, messageText]
|
notes: [...req.notes, messageText]
|
||||||
};
|
};
|
||||||
@@ -630,9 +630,9 @@ export default function RequestsPage() {
|
|||||||
<Check className="w-3 h-3" /> {stageLabels[request.verificationStage]}
|
<Check className="w-3 h-3" /> {stageLabels[request.verificationStage]}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{request.messageHistory.length > 0 && (
|
{request.smsHistory.length > 0 && (
|
||||||
<p className="flex items-center gap-1 text-blue-600">
|
<p className="flex items-center gap-1 text-blue-600">
|
||||||
<MessageSquare className="w-3 h-3" /> {request.messageHistory.length} msg
|
<MessageSquare className="w-3 h-3" /> {request.smsHistory.length} msg
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -701,7 +701,7 @@ export default function RequestsPage() {
|
|||||||
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
|
||||||
<div className="bg-white rounded-xl shadow-xl w-full max-w-lg">
|
<div className="bg-white rounded-xl shadow-xl w-full max-w-lg">
|
||||||
<div className="p-4 border-b border-slate-100 flex items-center justify-between">
|
<div className="p-4 border-b border-slate-100 flex items-center justify-between">
|
||||||
<h3 className="font-semibold text-slate-800">Send Message to {selectedRequest.name}</h3>
|
<h3 className="font-semibold text-slate-800">SMS to {selectedRequest.phone}</h3>
|
||||||
<button onClick={() => setShowMessageModal(false)} className="p-1 hover:bg-slate-100 rounded">
|
<button onClick={() => setShowMessageModal(false)} className="p-1 hover:bg-slate-100 rounded">
|
||||||
<X className="w-5 h-5 text-slate-400" />
|
<X className="w-5 h-5 text-slate-400" />
|
||||||
</button>
|
</button>
|
||||||
@@ -940,17 +940,17 @@ export default function RequestsPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{selectedRequest.messageHistory.length > 0 && (
|
{selectedRequest.smsHistory.length > 0 && (
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<h4 className="font-semibold text-slate-700 mb-3">Message History</h4>
|
<h4 className="font-semibold text-slate-700 mb-3">SMS History</h4>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{selectedRequest.messageHistory.map((msg, idx) => (
|
{selectedRequest.smsHistory.slice().reverse().map((msg) => (
|
||||||
<div key={idx} className={`p-3 rounded-lg ${msg.from === 'admin' ? 'bg-blue-50' : 'bg-slate-50'}`}>
|
<div key={msg.id} className={`p-3 rounded-lg ${msg.sentBy === 'admin' ? 'bg-blue-50' : 'bg-slate-50'}`}>
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<span className={`text-xs font-medium ${msg.from === 'admin' ? 'text-blue-600' : 'text-slate-600'}`}>
|
<span className={`text-xs font-medium ${msg.sentBy === 'admin' ? 'text-blue-600' : 'text-slate-600'}`}>
|
||||||
{msg.from === 'admin' ? 'Admin' : 'User'}
|
{msg.sentBy === 'admin' ? 'Admin' : 'User'}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-xs text-slate-400">{msg.date}</span>
|
<span className="text-xs text-slate-400">{msg.sentAt}</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-sm text-slate-700">{msg.message}</p>
|
<p className="text-sm text-slate-700">{msg.message}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -1095,7 +1095,7 @@ export default function RequestsPage() {
|
|||||||
bikeRequested: data.bikeRequested,
|
bikeRequested: data.bikeRequested,
|
||||||
scheduleDate: data.scheduleDate,
|
scheduleDate: data.scheduleDate,
|
||||||
notes: [],
|
notes: [],
|
||||||
messageHistory: [],
|
smsHistory: [],
|
||||||
};
|
};
|
||||||
setRequests([newRequest, ...requests]);
|
setRequests([newRequest, ...requests]);
|
||||||
setShowNewApplicationModal(false);
|
setShowNewApplicationModal(false);
|
||||||
@@ -1259,7 +1259,7 @@ function NewApplicationModal({ isOpen, onClose, onSave }: { isOpen: boolean; onC
|
|||||||
employmentInfo: formData.employmentInfo,
|
employmentInfo: formData.employmentInfo,
|
||||||
nomineeDetails: formData.nomineeDetails,
|
nomineeDetails: formData.nomineeDetails,
|
||||||
notes: [],
|
notes: [],
|
||||||
messageHistory: [],
|
smsHistory: [],
|
||||||
};
|
};
|
||||||
onSave(newRequest);
|
onSave(newRequest);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user