Skip to content

Commit

Permalink
More data, some debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-yakubiv committed May 22, 2020
1 parent 860ab88 commit c003a15
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions modules/billing/payment-required/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import Markdown from 'components/markdown'
import Form from 'components/forms/request-premium'
import { withGlobalStore } from 'store'

const PRODUCT_SCOPE = 'ENTERPRISE'

const FormController = (formProps) => {
// editing, sending, success, failure
const [status, changeStatus] = useState('editing')
Expand All @@ -22,15 +24,24 @@ const FormController = (formProps) => {
const handleSubmit = useCallback(
(event) => {
event.preventDefault()
const rawDataInput = new FormData(event.target)
const dataInput = Object.fromEntries(rawDataInput.entries())
const rawUserInput = new FormData(event.target)
const { body, ...metadata } = Object.fromEntries(rawUserInput.entries())
const message = {
product: PRODUCT_SCOPE,
message: body,
...metadata,
}

/* eslint-disable no-console */
changeStatus('sending')
send(dataInput).then(
console.log('sending')
send(message).then(
(success) => {
changeStatus(success ? 'success' : 'failure')
console.log(success ? 'success' : 'failure')
},
() => {
console.log('failure')
changeStatus('failure')
}
)
Expand All @@ -53,7 +64,9 @@ const FormController = (formProps) => {
onSubmit={handleSubmit}
onBlur={handleChange}
{...formProps}
/>
>
<input type="hidden" name="product" value={PRODUCT_SCOPE} />
</Form>
)
}

Expand Down

0 comments on commit c003a15

Please sign in to comment.