mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 19:03:47 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { OntimeView } from 'ontime-types';
|
|
import { useMemo } from 'react';
|
|
|
|
import EmptyPage from '../../common/components/state/EmptyPage';
|
|
import ViewLogo from '../../common/components/view-logo/ViewLogo';
|
|
import ViewParamsEditor from '../../common/components/view-params-editor/ViewParamsEditor';
|
|
import { useWindowTitle } from '../../common/hooks/useWindowTitle';
|
|
import { cx } from '../../common/utils/styleUtils';
|
|
import { getDefaultFormat } from '../../common/utils/time';
|
|
import Loader from '../common/loader/Loader';
|
|
import { getStudioOptions, useStudioOptions } from './studio.options';
|
|
import StudioClock from './StudioClock';
|
|
import StudioTimers from './StudioTimers';
|
|
import { StudioData, useStudioData } from './useStudioData';
|
|
|
|
import './Studio.scss';
|
|
|
|
export default function StudioLoader() {
|
|
const { data, status } = useStudioData();
|
|
|
|
useWindowTitle('Studio Clock');
|
|
|
|
if (status === 'pending') {
|
|
return <Loader />;
|
|
}
|
|
|
|
if (status === 'error') {
|
|
return <EmptyPage text='There was an error fetching data, please refresh the page.' />;
|
|
}
|
|
|
|
return <Studio {...data} />;
|
|
}
|
|
|
|
function Studio({ customFields, projectData, isMirrored, settings, viewSettings }: StudioData) {
|
|
const { hideCards } = useStudioOptions();
|
|
|
|
// gather option data
|
|
const defaultFormat = getDefaultFormat(settings?.timeFormat);
|
|
const studioOptions = useMemo(() => getStudioOptions(defaultFormat, customFields), [defaultFormat, customFields]);
|
|
|
|
return (
|
|
<div className={cx(['studio', isMirrored && 'mirror'])} data-testid='studio-view'>
|
|
<ViewParamsEditor target={OntimeView.StudioClock} viewOptions={studioOptions} />
|
|
|
|
<div className='project-header'>
|
|
{projectData?.logo && <ViewLogo name={projectData.logo} className='logo' />}
|
|
<div className='title'>{projectData.title}</div>
|
|
</div>
|
|
|
|
<div className={cx(['studio-contents', hideCards && 'studio-contents--onecol'])}>
|
|
<StudioClock hideCards={hideCards} />
|
|
{!hideCards && <StudioTimers viewSettings={viewSettings} />}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|