Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. import * as React from 'react'
  2. import { action } from 'mobx'
  3. import { observer, inject } from 'mobx-react'
  4. import styled from 'styled-components'
  5. import { observable } from 'mobx'
  6.  
  7. import { StaticPlaceholderInput } from '~/components/common'
  8. // import { Field, Input, StaticPlaceholderInput } from '~/components/common'
  9. import { PrimaryBtn, PrimaryBtnSize, ArrowLink } from '~/components/pru'
  10. import { STORE_AUTH, STORE_ENTITIES } from '~/constants/stores'
  11. // import { building } from '~/types'
  12. import { MEDIA } from '~/constants/media-queries'
  13. import {
  14. MAIN_TEXT,
  15. // BLUE,
  16. // PLACEHOLDER,
  17. // DARK_LINES,
  18. EXTRA_TEXT,
  19. PAGE_BG
  20. } from '~/components/pru/ui-colors'
  21. import { IAccountProps } from './account.d'
  22. import { SELECT_ACCOUNT } from '~/constants/links'
  23.  
  24. const Wrapper = styled.section`
  25. width: 476px;
  26. /* margin-top: -48px; */
  27. /* text-align: center; */
  28. /* display: flex;
  29. flex: 1; */
  30. /* margin-top: -70px; */
  31. padding-top: 24px;
  32. padding-bottom: 50px;
  33.  
  34. @media ${MEDIA.untilTablet} {
  35. width: 100%;
  36. /* padding-left: 20px;
  37. padding-right: 20px; */
  38. margin-top: 0;
  39. background-color: #fff;
  40. padding-bottom: 0;
  41. display: flex;
  42. flex-direction: column;
  43. flex: 1;
  44. }
  45. `
  46.  
  47. // const Content = styled.div`
  48.  
  49. // @media ${MEDIA.untilTablet} {
  50. // /* margin-top: 0;
  51. // text-align: left;
  52. // margin-bottom: 14px; */
  53. // }
  54. // `
  55.  
  56. const Heading = styled.h1`
  57. color: ${MAIN_TEXT};
  58. font-size: 30px;
  59. font-weight: normal;
  60. margin: 0;
  61. margin-bottom: 3px;
  62. text-align: center;
  63.  
  64. @media ${MEDIA.untilTablet} {
  65. margin-top: 0;
  66. text-align: left;
  67. margin-bottom: 4px;
  68. font-size: 26px;
  69. }
  70. `
  71.  
  72. const Description = styled.p`
  73. color: ${EXTRA_TEXT};
  74. text-align: center;
  75. margin-bottom: 20px;
  76. font-size: 16px;
  77. color: #6c6c6c;
  78.  
  79. @media ${MEDIA.untilTablet} {
  80. margin-top: 0;
  81. text-align: left;
  82. margin-bottom: 30px;
  83. }
  84. `
  85.  
  86. const Form = styled.form`
  87. background-color: #fff;
  88. padding: 39px 52px 25px 52px;
  89. border-radius: 4px;
  90. box-shadow: 2px 2px 6px 0 rgba(0, 0, 0, 0.04);
  91. padding-bottom: ${(props: IAccountProps) => (props.firstAccount ?
  92. `40px` : ``)};
  93.  
  94. @media ${MEDIA.untilTablet} {
  95. padding: 0;
  96. display: flex;
  97. flex-direction: column;
  98. flex: 1;
  99. }
  100. `
  101.  
  102. const Field = styled.div`
  103. text-transform: uppercase;
  104. font-size: 9px;
  105. font-weight: 500;
  106. font-style: normal;
  107. line-height: 1;
  108. letter-spacing: 0.8px;
  109. position: relative;
  110. color: ${EXTRA_TEXT};
  111.  
  112. &:not(:last-child) {
  113. margin-bottom: 27px;
  114. }
  115.  
  116. @media ${MEDIA.untilTablet} {
  117. &:not(:last-child) {
  118. margin-bottom: 25px;
  119. }
  120. }
  121. `
  122.  
  123. const SendBtn = styled(PrimaryBtn)`
  124. width: 100%;
  125. max-width: none;
  126. `
  127.  
  128. const FormContent = styled.div`
  129. margin-bottom: 29px;
  130.  
  131. @media ${MEDIA.untilTablet} {
  132. padding-left: 20px;
  133. padding-right: 20px;
  134. display: flex;
  135. flex-direction: column;
  136. flex: 1;
  137. }
  138. `
  139.  
  140. const FormFooter = styled.footer`
  141. width: 100%;
  142. text-align: center;
  143.  
  144. @media ${MEDIA.untilTablet} {
  145. padding-left: 20px;
  146. padding-right: 20px;
  147. padding-top: 24px;
  148. background-color: ${PAGE_BG};
  149. padding-bottom: 28px;
  150. }
  151. `
  152.  
  153. const PageHeader = styled.div`
  154. padding-left: 20px;
  155. padding-right: 20px;
  156. `
  157.  
  158. const ReverseArrowLink = styled(ArrowLink)`
  159. margin-top: 17px;
  160. margin-left: -21px;
  161.  
  162. @media ${MEDIA.untilTablet} {
  163. font-size: 16px;
  164. }
  165. `
  166.  
  167. @inject(STORE_AUTH, STORE_ENTITIES)
  168. @observer
  169. export default class PageAddAccount extends React.Component<IAccountProps> {
  170. building = ''
  171. premise = ''
  172. number = ''
  173. @observable value = ''
  174.  
  175. static defaultProps = {
  176. firstAccount: false
  177. }
  178.  
  179. constructor(props: React.Props<{}>) {
  180. super(props)
  181.  
  182. this.handleSubmit = this.handleSubmit.bind(this)
  183. this.handleAutocompleteClick = this.handleAutocompleteClick.bind(this)
  184. this.handleInputChange = this.handleInputChange.bind(this)
  185. }
  186.  
  187. handleSubmit(e: React.FormEvent<{}>) {
  188. e.preventDefault()
  189. const store = this.props[STORE_ENTITIES]
  190.  
  191. if (!store) return
  192.  
  193. const newAccount = {
  194. _type: 'account',
  195. _uid: 'fake',
  196. _fake: true,
  197. building: this.building,
  198. premise: this.premise,
  199. number: this.number
  200. }
  201.  
  202. store.createEntity(newAccount, { sync: true, log: true })
  203. }
  204.  
  205. @action
  206. handleAutocompleteClick({ target }: React.ChangeEvent<HTMLSelectElement>) {
  207. this.building = target.value
  208. }
  209.  
  210. @action.bound
  211. handleInputChange(event: React.ChangeEvent<HTMLInputElement>) {
  212. this.value = event.target.value
  213. }
  214.  
  215. render() {
  216. // const { [STORE_ENTITIES]: store } = this.props
  217. // if (!store) return
  218. const { firstAccount } = this.props
  219. console.log('323', firstAccount)
  220.  
  221. return (
  222. <Wrapper>
  223. <PageHeader>
  224. { firstAccount ? <Heading>Личный кабинет</Heading> : <Heading>Добавление адреса</Heading>}
  225. <Description>
  226. Добавьте адрес помещения (квартиры, офиса, паркинга) обслуживаемого
  227. УК&nbsp;&laquo;ПИК&ndash;Комфорт&raquo;.
  228. </Description>
  229. </PageHeader>
  230. <Form onSubmit={this.handleSubmit} firstAccount={firstAccount}>
  231. <FormContent>
  232. <Field>
  233. Адрес
  234. <StaticPlaceholderInput
  235. placeholder="Найти адрес"
  236. name="address"
  237. onChange={this.handleInputChange}
  238. value={this.value}
  239. />
  240. </Field>
  241. <Field>
  242. Номер квартиры
  243. <StaticPlaceholderInput
  244. placeholder="Введите номер квартиры"
  245. name="number"
  246. type="number"
  247. />
  248. </Field>
  249. <Field>
  250. Номер Лицевого счета
  251. <StaticPlaceholderInput
  252. placeholder="9 или 12 цифр, указан в квитанции"
  253. name="accountNumber"
  254. type="number"
  255. />
  256. </Field>
  257. </FormContent>
  258. <FormFooter>
  259. <SendBtn size={PrimaryBtnSize.LARGE}>Подтвердить</SendBtn>
  260. { !firstAccount && <ReverseArrowLink reverse={true} link={SELECT_ACCOUNT}>
  261. Вернуться назад
  262. </ReverseArrowLink> }
  263. </FormFooter>
  264. </Form>
  265. </Wrapper>
  266. )
  267. }
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement