refactor: extract project info data to hook

This commit is contained in:
Carlos Valente
2025-07-24 07:20:43 +02:00
committed by Carlos Valente
parent c300fc18e1
commit 1ed08df198
3 changed files with 58 additions and 30 deletions
@@ -0,0 +1,26 @@
import { ProjectData } from 'ontime-types';
import useProjectData from '../../common/hooks-query/useProjectData';
import { useViewOptionsStore } from '../../common/stores/viewOptions';
import { ViewData } from '../utils/viewLoader.utils';
export interface ProjectInfoData {
projectData: ProjectData;
isMirrored: boolean;
}
export function useProjectInfoData(): ViewData<ProjectInfoData> {
// persisted app state
const isMirrored = useViewOptionsStore((state) => state.mirror);
// HTTP API data
const { data: projectData, status: projectDataStatus } = useProjectData();
return {
data: {
projectData,
isMirrored,
},
status: projectDataStatus,
};
}