@mui/icons-material#Create TypeScript Examples

The following examples show how to use @mui/icons-material#Create. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PictureDialog.tsx    From aws_serverless_photo_gallery with MIT License 5 votes vote down vote up
function CommentForm({
  filename,
  forceRefresh,
}: {
  filename: string
  forceRefresh: Function
}) {
  const [loading, setLoading] = useState(false)
  const [error, setError] = useState<unknown>()
  const [user, setUser] = useState('')
  const [message, setMessage] = useState('')
  const [password] = useQueryParam('password', StringParam)
  const classes = useStyles()

  return (
    <div>
      {error ? (
        <div className={classes.error}>{`${error}`}</div>
      ) : loading ? (
        <p>Loading...</p>
      ) : (
        <p>Write a comment...</p>
      )}

      <Create />
      <label htmlFor="user">name (optional)</label>
      <input
        id="user"
        type="text"
        value={user}
        onChange={event => setUser(event.target.value)}
      />
      <textarea
        style={{ width: '90%', height: 50 }}
        value={message}
        onChange={event => setMessage(event.target.value)}
      />
      <button
        disabled={loading}
        onClick={async () => {
          try {
            if (user || message) {
              setLoading(true)
              setError(undefined)

              const data = new FormData()
              data.append('message', message)
              data.append('user', user)
              data.append('filename', filename)
              data.append('password', password || '')
              await myfetchjson(API_ENDPOINT + '/postDixieComment', {
                method: 'POST',
                body: data,
              })
              setUser('')
              setMessage('')
              forceRefresh()
            }
          } catch (e) {
            setError(e)
          } finally {
            setLoading(false)
          }
        }}
      >
        Submit
      </button>
    </div>
  )
}