{"size": 1124, "ext": "js", "max_stars_repo_path": "web/src/components/NewShopNote/NewShopNote.js", "max_stars_repo_name": "rkmitra1/rajshopnote", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "web/src/components/NewShopNote/NewShopNote.js", "max_issues_repo_name": "rkmitra1/rajshopnote", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "web/src/components/NewShopNote/NewShopNote.js", "max_forks_repo_name": "rkmitra1/rajshopnote", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.5454545455, "max_line_length": 73, "alphanum_fraction": 0.6432384342}
import { useMutation, useFlash } from '@redwoodjs/web'
import { navigate, routes } from '@redwoodjs/router'
import ShopNoteForm from 'src/components/ShopNoteForm'

import { QUERY } from 'src/components/ShopNotesCell'

const CREATE_SHOP_NOTE_MUTATION = gql`
  mutation CreateShopNoteMutation($input: CreateShopNoteInput!) {
    createShopNote(input: $input) {
      id
    }
  }
`

const NewShopNote = () => {
  const { addMessage } = useFlash()
  const [createShopNote, { loading, error }] = useMutation(
    CREATE_SHOP_NOTE_MUTATION,
    {
      onCompleted: () => {
        navigate(routes.home())
        addMessage('ShopNote created.', { classes: 'rw-flash-success' })
      },
    }
  )

  const onSave = (input) => {
    createShopNote({ variables: { input } })
  }

  return (
    <div className="rw-segment">
      <header className="rw-segment-header">
        <h2 className="rw-heading rw-heading-secondary">New ShopNote</h2>
      </header>
      <div className="rw-segment-main">
        <ShopNoteForm onSave={onSave} loading={loading} error={error} />
      </div>
    </div>
  )
}

export default NewShopNote
