UNPKG

use-google-sheets

Version:

### A React Hook wrapper library for google-sheets-mapper for getting data from Google Sheets API v4

32 lines (31 loc) 715 B
export interface HookOptions { apiKey: string; sheetId: string; sheetsNames?: Array<string>; } export interface Sheet { id: string; data: Array<object>; } export interface ApiResponse { url: string; status: number; statusText: string; } export interface ErrorResponse { response: ApiResponse; } export interface HookState { loading: boolean; error: null | ErrorResponse; data: Sheet[]; } export enum ActionTypes { loading = 'LOADING', error = 'ERROR', success = 'SUCCESS', } export type Action = | { type: ActionTypes.loading; payload: HookState['loading'] } | { type: ActionTypes.error; payload: HookState['error'] } | { type: ActionTypes.success; payload: HookState['data'] };