import React from 'react' import { useAsyncCallback, useOnline } from 'actionsack' import Button from './Button' import Toolbar from './Toolbar' import Input from './Input' import ConfirmButton from './ConfirmButton' import { useAuth } from './AuthContext' import { COLORS } from '../lib/constants' function DeleteButton(props) { const [onClick, { loading }] = useAsyncCallback(props.onClick) return ( {loading ? 'Deleting…' : 'Delete'} ) } function DuplicateButton(props) { const [onClick, { loading }] = useAsyncCallback(props.onClick) return ( {loading ? 'Duplicating…' : 'Duplicate'} ) } function SnippetToolbar(props) { const user = useAuth() const online = useOnline() if (!online) return null if (!user) return null if (!props.snippet) return null const sameUser = user.uid === props.snippet.userId return ( {sameUser && } props.onChange('name', e.target.value)} /> ) } export default SnippetToolbar