Fix sender detection logic to use senderRef field
- Change IMessage interface to use senderRef instead of sender - Update message rendering logic to check if senderRef === 'Admin' for admin messages - All other messages are treated as seller messages
This commit is contained in:
@@ -146,46 +146,49 @@ const TicketMessages: FC = () => {
|
|||||||
هیچ پیامی یافت نشد
|
هیچ پیامی یافت نشد
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
messages.map((message: IMessage) => (
|
messages.map((message: IMessage) => {
|
||||||
<div
|
const isAdmin = message.senderRef === 'Admin'
|
||||||
key={message._id}
|
return (
|
||||||
className={`flex ${message.sender === 'admin' ? 'justify-end' : 'justify-start'}`}
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className={`max-w-[70%] p-4 rounded-2xl ${
|
key={message._id}
|
||||||
message.sender === 'admin'
|
className={`flex ${isAdmin ? 'justify-end' : 'justify-start'}`}
|
||||||
? 'bg-blue-500 text-white rounded-br-md'
|
|
||||||
: 'bg-gray-100 text-gray-900 rounded-bl-md'
|
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<div className="text-sm mb-2">
|
<div
|
||||||
{message.sender === 'admin' ? 'ادمین' : 'فروشنده'}
|
className={`max-w-[70%] p-4 rounded-2xl ${
|
||||||
</div>
|
isAdmin
|
||||||
<div className="whitespace-pre-wrap">
|
? 'bg-blue-500 text-white rounded-br-md'
|
||||||
{message.content}
|
: 'bg-gray-100 text-gray-900 rounded-bl-md'
|
||||||
</div>
|
}`}
|
||||||
{message.attachments && message.attachments.length > 0 && (
|
>
|
||||||
<div className="mt-2 space-y-1">
|
<div className="text-sm mb-2">
|
||||||
{message.attachments.map((attachment, index) => (
|
{isAdmin ? 'ادمین' : 'فروشنده'}
|
||||||
<div
|
</div>
|
||||||
key={index}
|
<div className="whitespace-pre-wrap">
|
||||||
className={`text-xs underline ${
|
{message.content}
|
||||||
message.sender === 'admin' ? 'text-blue-100' : 'text-blue-600'
|
</div>
|
||||||
}`}
|
{message.attachments && message.attachments.length > 0 && (
|
||||||
>
|
<div className="mt-2 space-y-1">
|
||||||
فایل ضمیمه: {attachment}
|
{message.attachments.map((attachment, index) => (
|
||||||
</div>
|
<div
|
||||||
))}
|
key={index}
|
||||||
|
className={`text-xs underline ${
|
||||||
|
isAdmin ? 'text-blue-100' : 'text-blue-600'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
فایل ضمیمه: {attachment}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className={`text-xs mt-2 ${
|
||||||
|
isAdmin ? 'text-blue-100' : 'text-gray-500'
|
||||||
|
}`}>
|
||||||
|
{message.createdAt && formatDate(message.createdAt)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
<div className={`text-xs mt-2 ${
|
|
||||||
message.sender === 'admin' ? 'text-blue-100' : 'text-gray-500'
|
|
||||||
}`}>
|
|
||||||
{message.createdAt && formatDate(message.createdAt)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)
|
||||||
))
|
})
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export interface IMessage {
|
|||||||
attachments?: string[];
|
attachments?: string[];
|
||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
updatedAt?: string;
|
updatedAt?: string;
|
||||||
sender?: "admin" | "seller";
|
senderRef?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITicketResponse extends IBaseResponse {
|
export interface ITicketResponse extends IBaseResponse {
|
||||||
|
|||||||
Reference in New Issue
Block a user