emile 10 months ago
parent 59d67ac89d
commit 4bdf4cecf3

Binary file not shown.

@ -49,17 +49,24 @@ class OnlineUserConsumer(WebsocketConsumer):
customer_connections = []
staff_connections = []
for connection in sorted_connections:
connection_data = {
'user_id': connection.user.id,
'username': connection.user.username,
'last_seen': connection.last_seen.isoformat() if connection.last_seen else None
}
if hasattr(connection.user, 'customerprofile'):
connection_data = {
'first_name': connection.user.first_name,
'last_name': connection.user.last_name,
'last_seen': connection.user.customerprofile.get_last_seen,
'online': connection.online
}
customer_connections.append(connection_data)
elif hasattr(connection.user, 'staffprofile'):
connection_data = {
'first_name': connection.user.first_name,
'last_name': connection.user.last_name,
'last_seen': connection.user.staffprofile.get_last_seen,
'image': connection.user.staffprofile.image.url,
'online': connection.online
}
staff_connections.append(connection_data)
print(staff_connections)
event = {
'type': 'online_user_connection_handler',
'staff_connections': staff_connections,

@ -19,17 +19,17 @@
<div class="w-full flex justify-start items-center gap-2">
<div class="relative">
<div class="w-[40px] h-[40px] rounded-full">
<img src="{{staff_connection.user.staffprofile.image.url}}"
<img src="{{staff_connection.image}}"
class="w-full h-full object-cover rounded-full">
</div>
</div>
<div class="flex flex-col">
<p class="text-secondosiblue text-sm">{{staff_connection.user.first_name}}
{{staff_connection.user.last_name}}</p>
<p class="text-secondosiblue text-sm">{{staff_connection.first_name}}
{{staff_connection.last_name}}</p>
{% if staff_connection.online %}
<p class="text-green-700 text-xs">Online</p>
{% else %}
<p class="text-gray-500 text-xs">{{staff_connection.user.staffprofile.get_last_seen}}</p>
<p class="text-gray-500 text-xs">{{staff_connection.last_seen}}</p>
{% endif %}
</div>
@ -50,16 +50,16 @@
<div class="w-full flex justify-start items-center gap-2">
<div
class="w-[40px] h-[40px] bg-secondosiblue flex justify-center items-center rounded-full text-white">
<p>{{customer_connection.user.first_name|slice:":1"}}{{customer_connection.user.last_name|slice:":1"}}
<p>{{customer_connection.first_name|slice:":1"}}{{customer_connection.last_name|slice:":1"}}
</p>
</div>
<div class="flex flex-col">
<p class="text-secondosiblue text-sm">{{customer_connection.user.first_name}}
{{customer_connection.user.last_name}}</p>
<p class="text-secondosiblue text-sm">{{customer_connection.first_name}}
{{customer_connection.last_name}}</p>
{% if customer_connection.online %}
<p class="text-green-700 text-xs">Online</p>
{% else %}
<p class="text-gray-500 text-xs"> {{customer_connection.user.customerprofile.get_last_seen}}</p>
<p class="text-gray-500 text-xs"> {{customer_connection.last_seen}}</p>
{% endif %}
</div>
</div>

Loading…
Cancel
Save