|
1 | | -import React from 'react'; |
2 | | -import * as typeformEmbed from '@typeform/embed'; |
3 | 1 | import hash from '@codesandbox/common/lib/utils/hash'; |
4 | | -import { inject, hooksObserver } from 'app/componentConnectors'; |
| 2 | +import * as typeformEmbed from '@typeform/embed'; |
| 3 | +import React, { FunctionComponent } from 'react'; |
| 4 | + |
| 5 | +import { useOvermind } from 'app/overmind'; |
5 | 6 |
|
6 | 7 | import { Container } from './elements'; |
7 | 8 |
|
8 | | -export const SurveyModal = inject('store', 'signals')( |
9 | | - hooksObserver(({ store, signals }) => { |
10 | | - const initializeTypeform = (el: HTMLDivElement) => { |
11 | | - if (el) { |
12 | | - typeformEmbed.makeWidget( |
13 | | - el, |
14 | | - `https://codesandbox.typeform.com/to/LYbjII?userid=${hash( |
15 | | - store.user.id |
16 | | - )}&ispatron=${store.isPatron}`, |
17 | | - { |
18 | | - opacity: 0, |
19 | | - hideScrollbars: true, |
20 | | - hideFooter: true, |
21 | | - hideHeaders: true, |
22 | | - onSubmit: () => { |
23 | | - setTimeout(() => { |
24 | | - signals.modalClosed(); |
25 | | - }, 3000); |
26 | | - }, |
27 | | - } |
28 | | - ); |
29 | | - } |
30 | | - }; |
| 9 | +export const SurveyModal: FunctionComponent = () => { |
| 10 | + const { |
| 11 | + actions: { modalClosed }, |
| 12 | + state: { isPatron, user }, |
| 13 | + } = useOvermind(); |
| 14 | + |
| 15 | + const initializeTypeform = (el?: HTMLDivElement) => { |
| 16 | + if (el) { |
| 17 | + typeformEmbed.makeWidget( |
| 18 | + el, |
| 19 | + `https://codesandbox.typeform.com/to/LYbjII?userid=${hash( |
| 20 | + user.id |
| 21 | + )}&ispatron=${isPatron}`, |
| 22 | + { |
| 23 | + opacity: 0, |
| 24 | + hideScrollbars: true, |
| 25 | + hideFooter: true, |
| 26 | + hideHeaders: true, |
| 27 | + onSubmit: () => { |
| 28 | + setTimeout(() => { |
| 29 | + modalClosed(); |
| 30 | + }, 3000); |
| 31 | + }, |
| 32 | + } |
| 33 | + ); |
| 34 | + } |
| 35 | + }; |
31 | 36 |
|
32 | | - return ( |
33 | | - <Container> |
34 | | - <div style={{ width: '100%', height: 500 }} ref={initializeTypeform} /> |
35 | | - </Container> |
36 | | - ); |
37 | | - }) |
38 | | -); |
| 37 | + return ( |
| 38 | + <Container> |
| 39 | + <div style={{ width: '100%', height: 500 }} ref={initializeTypeform} /> |
| 40 | + </Container> |
| 41 | + ); |
| 42 | +}; |
0 commit comments