Skip to content

Commit 2a9297d

Browse files
committed
fix form submit; update Sub onSubmit
1 parent 3ac04a6 commit 2a9297d

File tree

2 files changed

+25
-29
lines changed

2 files changed

+25
-29
lines changed

components/territory-domains.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { useState } from 'react'
21
import { Badge } from 'react-bootstrap'
32
import { Form, Input, SubmitButton } from './form'
43
import { gql, useMutation } from '@apollo/client'
54
import Info from './info'
65
import { customDomainSchema } from '@/lib/validate'
76
import ActionTooltip from './action-tooltip'
7+
import { useToast } from '@/components/toast'
88

99
const UPDATE_CUSTOM_DOMAIN = gql`
1010
mutation UpdateCustomDomain($subName: String!, $domain: String!) {
@@ -17,23 +17,19 @@ const UPDATE_CUSTOM_DOMAIN = gql`
1717

1818
// TODO: verification states should refresh
1919
export default function CustomDomainForm ({ sub }) {
20-
const [updateCustomDomain] = useMutation(UPDATE_CUSTOM_DOMAIN)
21-
const [error, setError] = useState(null)
22-
const [success, setSuccess] = useState(false)
20+
const [updateCustomDomain] = useMutation(UPDATE_CUSTOM_DOMAIN, {
21+
refetchQueries: ['Sub']
22+
})
23+
const toaster = useToast()
2324

2425
const onSubmit = async ({ domain }) => {
25-
setError(null)
26-
setSuccess(false)
27-
console.log('domain', domain)
28-
29-
const { data } = await updateCustomDomain({
26+
await updateCustomDomain({
3027
variables: {
3128
subName: sub.name,
3229
domain
3330
}
3431
})
35-
console.log('success', data)
36-
setSuccess(true)
32+
toaster.success('domain updated successfully')
3733
}
3834

3935
const getStatusBadge = (status) => {
@@ -70,9 +66,7 @@ export default function CustomDomainForm ({ sub }) {
7066
<Input
7167
label={
7268
<div className='d-flex align-items-center gap-2'>
73-
<span>domain</span>
74-
{error && <Info variant='danger'>error</Info>}
75-
{success && <Info variant='success'>Domain settings updated successfully!</Info>}
69+
<span>custom domain</span>
7670
{sub?.customDomain && (
7771
<>
7872
<div className='d-flex align-items-center gap-2'>

components/territory-form.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,23 @@ export default function TerritoryForm ({ sub }) {
288288
/>
289289
</div>
290290
</Form>
291-
<AccordianItem
292-
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>personalization</div>}
293-
body={
294-
<>
295-
<TerritoryDomains sub={sub} />
296-
{sub?.customDomain?.verificationState === 'VERIFIED' &&
297-
<>
298-
<BootstrapForm.Label>[NOT IMPLEMENTED] branding</BootstrapForm.Label>
299-
<div className='mb-3'>WIP</div>
300-
<BootstrapForm.Label>[NOT IMPLEMENTED] color scheme</BootstrapForm.Label>
301-
<div className='mb-3'>WIP</div>
302-
</>}
303-
</>
304-
}
305-
/>
291+
<div className='w-100'>
292+
<AccordianItem
293+
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>advanced</div>}
294+
body={
295+
<>
296+
<TerritoryDomains sub={sub} />
297+
{sub?.customDomain?.verificationState === 'VERIFIED' &&
298+
<>
299+
<BootstrapForm.Label>[NOT IMPLEMENTED] branding</BootstrapForm.Label>
300+
<div className='mb-3'>WIP</div>
301+
<BootstrapForm.Label>[NOT IMPLEMENTED] color scheme</BootstrapForm.Label>
302+
<div className='mb-3'>WIP</div>
303+
</>}
304+
</>
305+
}
306+
/>
307+
</div>
306308
</FeeButtonProvider>
307309
)
308310
}

0 commit comments

Comments
 (0)