mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
5a3629badf
Added the ability to view and re-download leave application forms in the Employee History page (Leave, Permit, and Sick tabs) Added employee alpha stats and employee alpha detail in Employee Performance Page Added total WFO, WFH and WFS in Admin Summary Report Added batch import from Excel files in Admin Manual Attendance
105 lines
4.6 KiB
TypeScript
105 lines
4.6 KiB
TypeScript
'use client'
|
|
|
|
import { FC } from 'react';
|
|
import { LazyLoadImage } from 'react-lazy-load-image-component';
|
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from './ui/dialog';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
type Props = {
|
|
avatar: string | null; // Allow null to handle fallback logic safely
|
|
className?: string;
|
|
isPresence?: boolean;
|
|
// sizes and quality are removed as they are specific to Next/Image server processing
|
|
};
|
|
|
|
const ViewAvatar: FC<Props> = ({ avatar, className, isPresence }) => {
|
|
return (
|
|
<>
|
|
{avatar ? (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
{/* 1. TRIGGER IMAGE
|
|
Removed the wrapper div. Applied classes directly to LazyLoadImage.
|
|
Added `block` to wrapperClassName to prevent extra inline spacing.
|
|
*/}
|
|
<span className={cn("inline-block h-9 w-9 sm:h-10 sm:w-10", className)}>
|
|
<LazyLoadImage
|
|
alt="avatar"
|
|
src={`${process.env.BASE_URL_IMG}${avatar}`}
|
|
effect="blur"
|
|
wrapperClassName="w-full h-full"
|
|
className="w-full h-full rounded-full object-cover shadow-sm border border-border cursor-pointer hover:scale-110 duration-300"
|
|
/>
|
|
</span>
|
|
</DialogTrigger>
|
|
|
|
<DialogContent className={cn(
|
|
"overflow-hidden p-0 rounded-2xl",
|
|
isPresence ? "w-full max-w-screen-3xl h-auto" : "w-full h-[400px] sm:w-[500px] sm:h-[500px]"
|
|
)}>
|
|
<DialogHeader className='sr-only'>
|
|
<DialogTitle>Profile</DialogTitle>
|
|
<DialogDescription>Description of profile avatar</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
{/* 2. DIALOG CONTENT IMAGE
|
|
Logic for Presence vs Standard is much simpler now.
|
|
Standard CSS handles the width/height.
|
|
*/}
|
|
<LazyLoadImage
|
|
src={`${process.env.BASE_URL_IMG}${avatar}`}
|
|
alt="avatar"
|
|
effect="blur"
|
|
wrapperClassName="w-full h-full block" // Ensures the wrapper fills the dialog
|
|
className={cn(
|
|
"w-full", // Always full width of container
|
|
isPresence ? "h-auto object-contain" : "h-full object-cover shadow-sm border border-border"
|
|
)}
|
|
/>
|
|
</DialogContent>
|
|
</Dialog>
|
|
) : (
|
|
// 3. FALLBACK IMAGE
|
|
<span className={cn("inline-block h-9 w-9 sm:h-10 sm:w-10", className)}>
|
|
<LazyLoadImage
|
|
alt='avatar'
|
|
src='/assets/no-avatar.jpg'
|
|
effect="blur"
|
|
wrapperClassName="w-full h-full"
|
|
className='w-full h-full shadow-sm rounded-full object-cover border border-border'
|
|
/>
|
|
</span>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export const Avatar: FC<Props> = ({ avatar, className }) => {
|
|
return (
|
|
<>
|
|
{avatar ? (
|
|
<span className={cn("inline-block h-9 w-9 sm:h-10 sm:w-10", className)}>
|
|
<LazyLoadImage
|
|
src={`${process.env.BASE_URL_IMG}${avatar}`}
|
|
alt="avatar"
|
|
effect="blur"
|
|
wrapperClassName="w-full h-full"
|
|
className="w-full h-full rounded-full object-cover shadow-sm border border-border cursor-pointer hover:scale-110 duration-200"
|
|
/>
|
|
</span>
|
|
) : (
|
|
<span className={cn("inline-block h-9 w-9 sm:h-10 sm:w-10", className)}>
|
|
<LazyLoadImage
|
|
alt='avatar'
|
|
src='/assets/no-avatar.jpg'
|
|
effect="blur"
|
|
wrapperClassName="w-full h-full"
|
|
className='w-full h-full shadow-sm rounded-full object-cover border border-border'
|
|
/>
|
|
</span>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default ViewAvatar; |