날짜 형식 처리 안정성 강화 및 트랜잭션 삭제 시 앱 먹통 문제 해결

This commit is contained in:
hansoo
2025-03-18 01:07:17 +09:00
parent 6f91afeebe
commit acb9ae3d70
23 changed files with 732 additions and 18 deletions

View File

@@ -0,0 +1,59 @@
import React, { useEffect, useState } from 'react';
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
import { Skeleton } from '@/components/ui/skeleton';
import { getResourceImage } from '@/plugins/imagePlugin';
interface ResourceImageProps {
resourceName: string;
className?: string;
alt?: string;
fallback?: string;
}
const ResourceImage: React.FC<ResourceImageProps> = ({
resourceName,
className = "h-12 w-12",
alt = "이미지",
fallback = "ZY"
}) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
const [imageSrc, setImageSrc] = useState<string>("");
useEffect(() => {
const loadResourceImage = async () => {
try {
const imgSrc = await getResourceImage(resourceName);
setImageSrc(imgSrc);
setLoading(false);
} catch (err) {
console.error('이미지 로드 실패:', err);
setError(true);
setLoading(false);
}
};
loadResourceImage();
}, [resourceName]);
return (
<Avatar className={className}>
{loading ? (
<div className="h-full w-full flex items-center justify-center">
<Skeleton className="h-full w-full rounded-full" />
</div>
) : error ? (
<AvatarFallback delayMs={0}>{fallback}</AvatarFallback>
) : (
<img
src={imageSrc}
alt={alt}
className="h-full w-full object-cover"
onError={() => setError(true)}
/>
)}
</Avatar>
);
};
export default ResourceImage;