Fix errored

This commit is contained in:
ferreo 2024-07-30 20:43:27 +01:00
parent 63171686dd
commit 352d7aa896
2 changed files with 14 additions and 19 deletions

View File

@ -66,11 +66,10 @@ const Errored: React.FC = () => {
}, [loadPackages]); }, [loadPackages]);
const handleRebuildClick = (pkg: any) => { const handleRebuildClick = (pkg: any) => {
const firstPackage = Object.values(pkg.Packages)[0] as any;
setSelectedPackage(pkg); setSelectedPackage(pkg);
setRebuildData({ setRebuildData({
packageName: pkg.Name, packageName: pkg.Name,
version: firstPackage.NewVersion || firstPackage.Version, version: pkg.BuildVersion,
buildType: "lto", buildType: "lto",
rebuild: false, rebuild: false,
}); });
@ -130,7 +129,6 @@ const Errored: React.FC = () => {
</TableRow> </TableRow>
) : ( ) : (
errPackages.map((pkg) => { errPackages.map((pkg) => {
const firstPackage = Object.values(pkg.Packages)[0];
return ( return (
<TableRow <TableRow
key={pkg.Name} key={pkg.Name}
@ -143,36 +141,26 @@ const Errored: React.FC = () => {
{pkg.Name} {pkg.Name}
</span> </span>
<span className="text-sm md:hidden truncate"> <span className="text-sm md:hidden truncate">
{firstPackage.Status} {pkg.Status}
</span> </span>
</div> </div>
<div className="md:hidden text-sm text-muted-foreground text-center"> <div className="md:hidden text-sm text-muted-foreground text-center">
<span className="truncate"> <span className="truncate">
{firstPackage.Version} {pkg.BuildVersion}
</span> </span>
{firstPackage.NewVersion && (
<span className="truncate block">
{firstPackage.NewVersion}
</span>
)}
</div> </div>
</div> </div>
</TableCell> </TableCell>
<TableCell className="hidden md:table-cell md:w-1/4 py-4 text-left"> <TableCell className="hidden md:table-cell md:w-1/4 py-4 text-left">
<div className="flex flex-col"> <div className="flex flex-col">
<span className="truncate"> <span className="truncate">
{firstPackage.Version} {pkg.BuildVersion}
</span> </span>
{firstPackage.NewVersion && (
<span className="text-sm text-muted-foreground truncate">
{firstPackage.NewVersion}
</span>
)}
</div> </div>
</TableCell> </TableCell>
<TableCell className="hidden md:table-cell md:w-1/4 py-2 md:py-4 text-left"> <TableCell className="hidden md:table-cell md:w-1/4 py-2 md:py-4 text-left">
<span className="truncate"> <span className="truncate">
{firstPackage.Status} {pkg.Status}
</span> </span>
</TableCell> </TableCell>
{isLoggedIn && ( {isLoggedIn && (

View File

@ -25,6 +25,13 @@ interface PackageData {
}; };
} }
interface ErrorData {
Name: string;
Status: string;
BuildVersion: string;
BuildNumber: number;
}
interface PackagesResponse { interface PackagesResponse {
total: number; total: number;
packages: PackageData[]; packages: PackageData[];
@ -37,7 +44,7 @@ const usePackageData = () => {
const [pkg, setPackage] = useState<PackageData | null>(null); const [pkg, setPackage] = useState<PackageData | null>(null);
const [totalCount, setTotalCount] = useState(0); const [totalCount, setTotalCount] = useState(0);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [errPackages, setErrPackages] = useState<PackageData[]>([]); const [errPackages, setErrPackages] = useState<ErrorData[]>([]);
const fetchStatsAttempted = useRef(false); const fetchStatsAttempted = useRef(false);
const fetchStats = useCallback(async () => { const fetchStats = useCallback(async () => {
@ -104,7 +111,7 @@ const usePackageData = () => {
setLoading(true); setLoading(true);
try { try {
const response = await fetch('/api/errored'); const response = await fetch('/api/errored');
const data: PackageData[] = await response.json(); const data: ErrorData[] = await response.json();
setErrPackages(data); setErrPackages(data);
} catch (error) { } catch (error) {
console.error("Error fetching errored:", error); console.error("Error fetching errored:", error);