diff --git a/.env.tpl b/.env.tpl index b4e11dd..76b73d2 100644 --- a/.env.tpl +++ b/.env.tpl @@ -1,4 +1,4 @@ -SENTRY_DSN=https://@sentry.io/ +SENTRY_DSN= CROWDIN_API_KEY=abc diff --git a/packages/app/components/auth/actions.ts b/packages/app/components/auth/actions.ts index a2ae2c5..339133d 100644 --- a/packages/app/components/auth/actions.ts +++ b/packages/app/components/auth/actions.ts @@ -21,7 +21,7 @@ import { } from 'app/services/api/signup'; import dispatchBsod from 'app/components/ui/bsod/dispatchBsod'; import { create as createPopup } from 'app/components/ui/popup/actions'; -import ContactForm from 'app/components/contact/ContactForm'; +import ContactForm from 'app/components/contact'; import { Account } from 'app/components/accounts/reducer'; import { ThunkAction, Dispatch } from 'app/reducers'; import { Resp } from 'app/services/request'; diff --git a/packages/app/components/contact/ContactForm.test.tsx b/packages/app/components/contact/ContactForm.test.tsx index 6fe4ebe..cdab5d2 100644 --- a/packages/app/components/contact/ContactForm.test.tsx +++ b/packages/app/components/contact/ContactForm.test.tsx @@ -2,11 +2,11 @@ import React from 'react'; import expect from 'app/test/unexpected'; import sinon from 'sinon'; import { render, fireEvent, waitFor, screen } from '@testing-library/react'; -import feedback from 'app/services/api/feedback'; +import * as feedback from 'app/services/api/feedback'; import { User } from 'app/components/user'; import { TestContextProvider } from 'app/shell'; -import { ContactForm } from './ContactForm'; +import ContactForm from './ContactForm'; beforeEach(() => { sinon.stub(feedback, 'send').returns(Promise.resolve() as any); @@ -18,11 +18,9 @@ afterEach(() => { describe('ContactForm', () => { it('should contain Form', () => { - const user = {} as User; - render( - + , ); @@ -49,14 +47,14 @@ describe('ContactForm', () => { }); describe('when rendered with user', () => { - const user = { + const user: Pick = { email: 'foo@bar.com', - } as User; + }; it('should render email field with user email', () => { render( - - + + , ); @@ -65,13 +63,13 @@ describe('ContactForm', () => { }); it('should submit and then hide form and display success message', async () => { - const user = { + const user: Pick = { email: 'foo@bar.com', - } as User; + }; render( - - + + , ); @@ -113,9 +111,9 @@ describe('ContactForm', () => { }); it('should show validation messages', async () => { - const user = { + const user: Pick = { email: 'foo@bar.com', - } as User; + }; (feedback.send as any).callsFake(() => Promise.reject({ @@ -125,8 +123,8 @@ describe('ContactForm', () => { ); render( - - + + , ); diff --git a/packages/app/components/contact/ContactForm.tsx b/packages/app/components/contact/ContactForm.tsx index 0fff30d..938b764 100644 --- a/packages/app/components/contact/ContactForm.tsx +++ b/packages/app/components/contact/ContactForm.tsx @@ -1,202 +1,43 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import clsx from 'clsx'; -import { FormattedMessage as Message, defineMessages } from 'react-intl'; -import { Input, TextArea, Button, Form, FormModel, Dropdown } from 'app/components/ui/form'; -import feedback from 'app/services/api/feedback'; -import icons from 'app/components/ui/icons.scss'; -import popupStyles from 'app/components/ui/popup/popup.scss'; +import React, { ComponentType, useCallback, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; + +import { send as sendFeedback } from 'app/services/api/feedback'; import { RootState } from 'app/reducers'; import logger from 'app/services/logger'; -import { User } from 'app/components/user'; -import styles from './contactForm.scss'; +import ContactFormPopup from './ContactFormPopup'; +import SuccessContactFormPopup from './SuccessContactFormPopup'; -const CONTACT_CATEGORIES = { - // TODO: сюда позже проставить реальные id категорий с backend - 0: , - 1: , - 2: , - 3: , - 4: , -}; - -const labels = defineMessages({ - subject: 'Subject', - email: 'E‑mail', - message: 'Message', - whichQuestion: 'What are you interested in?', - - send: 'Send', - - close: 'Close', -}); - -export class ContactForm extends React.Component< - { - onClose: () => void; - user: User; - }, - { - isLoading: boolean; - isSuccessfullySent: boolean; - lastEmail: string | null; - } -> { - static defaultProps = { - onClose() {}, - }; - - state = { - isLoading: false, - isSuccessfullySent: false, - lastEmail: null, - }; - - form = new FormModel(); - - render() { - const { isSuccessfullySent } = this.state || {}; - const { onClose } = this.props; - - return ( -
-
-
-

- -

- -
- - {isSuccessfullySent ? this.renderSuccess() : this.renderForm()} -
-
- ); - } - - renderForm() { - const { form } = this; - const { user } = this.props; - const { isLoading } = this.state; - - return ( -
-
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
- -
- -