mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 18:33:53 +00:00
refactor: improve sheet import UX
This commit is contained in:
committed by
Carlos Valente
parent
42dcf35f45
commit
f53cb687bf
@@ -1,5 +1,9 @@
|
||||
import axios, { AxiosResponse } from 'axios';
|
||||
import type { SpreadsheetPreviewResponse, SpreadsheetWorksheetMetadata, SpreadsheetWorksheetOptions } from 'ontime-types';
|
||||
import type {
|
||||
SpreadsheetPreviewResponse,
|
||||
SpreadsheetWorksheetMetadata,
|
||||
SpreadsheetWorksheetOptions,
|
||||
} from 'ontime-types';
|
||||
import { ImportMap } from 'ontime-utils';
|
||||
|
||||
import { apiEntryUrl } from './constants';
|
||||
|
||||
@@ -76,6 +76,9 @@ export const previewRundown = async (
|
||||
return response.data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches derived metadata for a single worksheet by reading its rows and detecting headers.
|
||||
*/
|
||||
export const getWorksheetMetadata = async (
|
||||
sheetId: string,
|
||||
worksheet: string,
|
||||
@@ -92,12 +95,15 @@ export const getWorksheetMetadata = async (
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getWorksheetNames = async (
|
||||
/**
|
||||
* Fetches the available worksheets for a Google Sheet. Metadata is loaded lazily per worksheet.
|
||||
*/
|
||||
export const getWorksheetOptions = async (
|
||||
sheetId: string,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<SpreadsheetWorksheetOptions> => {
|
||||
const response: AxiosResponse<SpreadsheetWorksheetOptions> = await axios.post(
|
||||
`${sheetsPath}/${sheetId}/worksheets`,
|
||||
`${sheetsPath}/${sheetId}/worksheet-options`,
|
||||
undefined,
|
||||
{
|
||||
signal: requestOptions?.signal,
|
||||
|
||||
Reference in New Issue
Block a user