import { useState, useEffect } from 'react'; import { TransitionGroup, CSSTransition } from 'react-transition-group'; import { Button, ListGroup } from 'react-bootstrap'; import FormInput from './FormInput'; // This is a wrapper for google.script.run that lets us use promises. import { serverFunctions, scriptHostFunctions, } from '../../utils/serverFunctions'; const SheetEditor = () => { const [names, setNames] = useState([]); const [isExpanded, setIsExpanded] = useState(false); useEffect(() => { serverFunctions.getSheetsData().then(setNames).catch(alert); }, []); const deleteSheet = (sheetIndex) => { serverFunctions.deleteSheet(sheetIndex).then(setNames).catch(alert); }; const setActiveSheet = (sheetName) => { serverFunctions.setActiveSheet(sheetName).then(setNames).catch(alert); }; const submitNewSheet = async (newSheetName) => { try { const response = await serverFunctions.addSheet(newSheetName); setNames(response); } catch (error) { // eslint-disable-next-line no-alert alert(error); } }; return (
☀️ Bootstrap demo! ☀️
This is a sample app that uses the react-bootstrap library
to help us build a simple React app. Enter a name for a new sheet, hit
enter and the new sheet will be created. Click the red{' '}
× next to the sheet name to
delete it.