winofy-front/src/components/profile/profile-person-detail-card.tsx
Mohammadali b0ce5ce2f9 feat(profile): implement account fetching and context provider for user profile
feat(wallet): enhance wallet UI and transaction item display
fix(profile): update profile detail card to handle loading and error states
style: improve UI consistency across profile and wallet components
2026-08-30 13:28:27 +03:30

70 lines
No EOL
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client';
import { useAccount } from "@/lib/providers/account-provider";
import { getDisplayNameHelper, getInitialsHelper } from "@/lib/utils/account-utils";
const ProfilePersonDetailCard = () => {
const { data, error, isLoading } = useAccount();
if (isLoading) {
return (
<div className="w-full min-h-[128px] rounded-2xl bg-teal-light my-6 py-4 px-10 flex items-center justify-center">
<p className="text-sm text-gray-500">در حال بارگذاری...</p>
</div>
);
}
if (error) {
return (
<div className="w-full min-h-[128px] rounded-2xl bg-teal-light my-6 py-4 px-10 flex items-center justify-center">
<p className="text-sm text-destructive">{error}</p>
</div>
);
}
if (!data) {
return (
<div className="w-full min-h-[128px] rounded-2xl bg-teal-light my-6 py-4 px-10 flex items-center justify-center">
<p className="text-sm text-gray-500">اطلاعات پروفایل یافت نشد</p>
</div>
);
}
const displayName = getDisplayNameHelper(data);
const initials = getInitialsHelper(data);
return (
<div className="w-full min-h-[128px] rounded-2xl bg-teal-light my-6 py-4 px-10 flex items-center justify-center">
<div className="flex flex-row items-center w-full">
<div className="size-16 bg-primary-action rounded-full flex items-center justify-center text-lg font-bold text-white overflow-hidden shrink-0">
{data.avatar ? (
<img
src={data.avatar}
alt={displayName}
className="size-full object-cover"
/>
) : (
<span>{initials}</span>
)}
</div>
<div className="flex flex-col mr-6 items-start">
<p className="text-lg font-bold">{displayName}</p>
{data.phone_number && (
<p className="text-sm text-gray-700 my-2 font-normal" dir="ltr">
{data.phone_number}
</p>
)}
<button
className="text-sm font-semibold text-primary-action cursor-pointer underline"
onClick={() => alert('latter...')}
>
ویرایش پروفایل
</button>
</div>
</div>
</div>
);
};
export default ProfilePersonDetailCard;