Files
qapp-core/src/hooks/useAllResourceStatus.tsx
2025-11-15 11:59:38 +01:00

24 lines
720 B
TypeScript

import { usePublishStore } from '../state/publishes';
import { Service } from '../types/interfaces/resources';
export const useAllResourceStatus = () =>
usePublishStore((state) =>
Object.entries(state.resourceStatus)
.filter(([_, status]) => status !== null)
.map(([id, status]) => {
const parts = id.split('-');
const service = parts[0] as Service;
const name = parts[1] || '';
const identifier = parts.length > 2 ? parts.slice(2).join('-') : '';
const { path, filename, ...rest } = status!;
return {
id,
metadata: { service, name, identifier },
status: rest,
path,
filename,
};
})
);