mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
sort import and fix variant
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
|
||||||
|
|
||||||
import { SHEET_STATE } from '../api/apiConstants';
|
|
||||||
import { getSheetState } from '../api/ontimeApi';
|
|
||||||
|
|
||||||
export default function useSheetState(id: string | null, worksheet: string | null) {
|
|
||||||
const { data, status, isFetching, isError, refetch } = useQuery({
|
|
||||||
queryKey: [SHEET_STATE, { id, worksheet }],
|
|
||||||
queryFn: () => (id !== null && worksheet !== null ? getSheetState(id, worksheet) : null),
|
|
||||||
placeholderData: null,
|
|
||||||
enabled: false,
|
|
||||||
networkMode: 'always',
|
|
||||||
});
|
|
||||||
|
|
||||||
return { data, status, isFetching, isError, refetch };
|
|
||||||
}
|
|
||||||
@@ -21,14 +21,13 @@ import { OntimeRundown, ProjectData, SheetState, UserFields } from 'ontime-types
|
|||||||
import { PROJECT_DATA, RUNDOWN, USERFIELDS } from '../../../common/api/apiConstants';
|
import { PROJECT_DATA, RUNDOWN, USERFIELDS } from '../../../common/api/apiConstants';
|
||||||
import { maybeAxiosError } from '../../../common/api/apiUtils';
|
import { maybeAxiosError } from '../../../common/api/apiUtils';
|
||||||
import {
|
import {
|
||||||
getSheetState,
|
|
||||||
getSheetsAuthUrl,
|
getSheetsAuthUrl,
|
||||||
|
getSheetState,
|
||||||
patchData,
|
patchData,
|
||||||
postPreviewSheet,
|
postPreviewSheet,
|
||||||
postPushSheet,
|
postPushSheet,
|
||||||
uploadSheetClientFile,
|
uploadSheetClientFile,
|
||||||
} from '../../../common/api/ontimeApi';
|
} from '../../../common/api/ontimeApi';
|
||||||
import useSheetState from '../../../common/hooks-query/useSheetState';
|
|
||||||
import { projectDataPlaceholder } from '../../../common/models/ProjectData';
|
import { projectDataPlaceholder } from '../../../common/models/ProjectData';
|
||||||
import { userFieldsPlaceholder } from '../../../common/models/UserFields';
|
import { userFieldsPlaceholder } from '../../../common/models/UserFields';
|
||||||
import ModalLink from '../ModalLink';
|
import ModalLink from '../ModalLink';
|
||||||
@@ -53,10 +52,6 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const sheetRef = useRef<HTMLInputElement>(null);
|
const sheetRef = useRef<HTMLInputElement>(null);
|
||||||
const worksheetRef = useRef<HTMLSelectElement>(null);
|
const worksheetRef = useRef<HTMLSelectElement>(null);
|
||||||
// const [sheetId, setSheetId] = useState<string | null>(null);
|
|
||||||
// const [worksheet, setWorksheet] = useState<string | null>(null);
|
|
||||||
|
|
||||||
// const { data: sheetState, refetch } = useSheetState(sheetId, worksheet);
|
|
||||||
|
|
||||||
const [sheetState, setState] = useState<SheetState>({
|
const [sheetState, setState] = useState<SheetState>({
|
||||||
secret: false,
|
secret: false,
|
||||||
@@ -68,7 +63,6 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
|
|
||||||
//TODO: soulde the be a button like now or on change?
|
//TODO: soulde the be a button like now or on change?
|
||||||
const testId = async () => {
|
const testId = async () => {
|
||||||
console.log('test', sheetRef.current?.value, worksheetRef.current?.value);
|
|
||||||
setState(await getSheetState(sheetRef.current?.value ?? '', worksheetRef.current?.value ?? ''));
|
setState(await getSheetState(sheetRef.current?.value ?? '', worksheetRef.current?.value ?? ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,14 +89,12 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
// TODO: show this in the modal
|
// TODO: show this in the modal
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
// refetch();
|
|
||||||
setState(await getSheetState(sheetRef.current?.value ?? '', worksheetRef.current?.value ?? ''));
|
setState(await getSheetState(sheetRef.current?.value ?? '', worksheetRef.current?.value ?? ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
getSheetState(sheetRef.current?.value ?? '', worksheetRef.current?.value ?? '').then((data) => setState(data));
|
getSheetState(sheetRef.current?.value ?? '', worksheetRef.current?.value ?? '').then((data) => setState(data));
|
||||||
// refetch();
|
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
// Alex: This function will be run when the component unmounts
|
// Alex: This function will be run when the component unmounts
|
||||||
@@ -195,7 +187,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
accept='.json'
|
accept='.json'
|
||||||
data-testid='file-input'
|
data-testid='file-input'
|
||||||
/>
|
/>
|
||||||
<Button size='sm' variant='ontime-ghosted-on-light' onClick={handleClick}>
|
<Button size='sm' variant='ontime-subtle-on-light' onClick={handleClick}>
|
||||||
Upload Client Secret
|
Upload Client Secret
|
||||||
</Button>
|
</Button>
|
||||||
</Step>
|
</Step>
|
||||||
@@ -208,7 +200,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
size='sm'
|
size='sm'
|
||||||
variant='ontime-ghosted-on-light'
|
variant='ontime-subtle-on-light'
|
||||||
onClick={handleAuthenticate}
|
onClick={handleAuthenticate}
|
||||||
disabled={!sheetState?.secret}
|
disabled={!sheetState?.secret}
|
||||||
>
|
>
|
||||||
@@ -228,7 +220,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
disabled={!sheetState?.auth}
|
disabled={!sheetState?.auth}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<Button variant='ontime-filled' padding='0 2em' onClick={testId}>
|
<Button variant='ontime-subtle-on-light' padding='0 2em' onClick={testId}>
|
||||||
Test Sheet ID
|
Test Sheet ID
|
||||||
</Button>
|
</Button>
|
||||||
</Step>
|
</Step>
|
||||||
@@ -255,7 +247,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
<div style={{ display: 'flex', gap: '1em' }}>
|
<div style={{ display: 'flex', gap: '1em' }}>
|
||||||
<Button
|
<Button
|
||||||
disabled={!sheetState?.worksheet}
|
disabled={!sheetState?.worksheet}
|
||||||
variant='ontime-ghosted-on-light'
|
variant='ontime-subtle-on-light'
|
||||||
padding='0 2em'
|
padding='0 2em'
|
||||||
onClick={handlePushData}
|
onClick={handlePushData}
|
||||||
>
|
>
|
||||||
@@ -263,7 +255,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
disabled={!sheetState?.worksheet}
|
disabled={!sheetState?.worksheet}
|
||||||
variant='ontime-ghosted-on-light'
|
variant='ontime-subtle-on-light'
|
||||||
padding='0 2em'
|
padding='0 2em'
|
||||||
onClick={handlePullData}
|
onClick={handlePullData}
|
||||||
>
|
>
|
||||||
@@ -281,7 +273,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
|||||||
)}
|
)}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button variant='ontime-ghost-on-light'>Reset</Button>
|
<Button variant='ontime-subtle-on-light'>Reset</Button>
|
||||||
{rundown && (
|
{rundown && (
|
||||||
<Button variant='ontime-filled' padding='0 2em' onClick={handleFinalise}>
|
<Button variant='ontime-filled' padding='0 2em' onClick={handleFinalise}>
|
||||||
Import
|
Import
|
||||||
|
|||||||
Reference in New Issue
Block a user