mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 20:03:52 +00:00
refactor: extract project info data to hook
This commit is contained in:
committed by
Carlos Valente
parent
c300fc18e1
commit
1ed08df198
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user