fix(dashboard): empty state for comments and messages tabs
These tabs have no backend endpoint yet (only per-doctor comments and admin exist; user messages don't), so they read the always-empty user.comments/user.messages. Guard against null and show a clear empty state instead of a blank list. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
import Comment from "./Comment";
|
||||
|
||||
function Comments({ user, loading }) {
|
||||
const comments = user?.comments ?? [];
|
||||
|
||||
if (comments.length === 0) {
|
||||
return (
|
||||
<p className="text-[#7E7E7E] opacity-page text-[14px] md:text-[16px] font-medium text-center py-[56px]">
|
||||
نظری ثبت نکردهاید.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="flex opacity-page flex-col items-start justify-start gap-[24px] md:gap-[22px] lg:gap-[20px]">
|
||||
{user.comments.map((item, idx) => (
|
||||
{comments.map((item, idx) => (
|
||||
<Comment
|
||||
key={idx}
|
||||
idx={idx}
|
||||
data={item}
|
||||
loading={loading}
|
||||
length={user.comments.length}
|
||||
length={comments.length}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
import Message from "./Message";
|
||||
|
||||
function Messages({ user, loading }) {
|
||||
const messages = user?.messages ?? [];
|
||||
|
||||
if (messages.length === 0) {
|
||||
return (
|
||||
<p className="text-[#7E7E7E] opacity-page text-[14px] md:text-[16px] font-medium text-center py-[56px]">
|
||||
پیامی ندارید.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ul className="flex opacity-page flex-col gap-[24px] md:gap-[20px] lg:gap-[16px]">
|
||||
{user.messages.map((item, idx) => (
|
||||
{messages.map((item, idx) => (
|
||||
<Message
|
||||
key={idx}
|
||||
idx={idx}
|
||||
data={item}
|
||||
loading={loading}
|
||||
length={user.messages.length}
|
||||
length={messages.length}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user