import { useState, useEffect } from 'react'; import { Button, Typography } from '@mui/material'; import FormInput from './FormInput'; import SheetTable from './SheetTable'; // This is a wrapper for google.script.run that lets us use promises. import { serverFunctions } from '../../utils/serverFunctions'; const SheetEditor = () => { const [names, setNames] = useState([]); 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 (
☀️ MUI demo! ☀️ This is a sample app that uses the mui 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 button next to the sheet name to delete it. {names.length > 0 && { return { sheetName: name.name, goToButton: , deleteButton: } })} />}
); }; export default SheetEditor;