Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.60 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { AUTH_TOKEN, USER_DATA } from '../utils/constants';
  3. // import Navigation from '../components/Navigation';
  4. import Header from '../components/Header';
  5. import Kanban from '../components/Kanban';
  6. import { Row, Col, Button, Modal, ModalBody, Form, FormGroup, Label, Input } from 'reactstrap';
  7.  
  8. import { Mutation } from 'react-apollo';
  9. import gql from 'graphql-tag';
  10.  
  11.  
  12. const BRIEF_MUTATION = gql`
  13. mutation($title: String!, $content: String!, $appId: Int!, $musicLink: String!, $footageLink: String!, $duration: String!, $ratioSquare: Boolean!, $ratioStory: Boolean!, $ratioFiveFour: Boolean!, $ratioSixteenNine: Boolean!, $variations: Int!, $referenceLink: String! ) {
  14. addBrief(title: $title, content: $content, appId: $appId, musicLink: $musicLink, footageLink: $footageLink, duration: $duration, ratioSquare: $ratioSquare, ratioStory: $ratioStory, ratioFiveFour: $ratioFiveFour, ratioSixteenNine: $ratioSixteenNine, variations: $variations, referenceLink: $referenceLink ) {
  15. title
  16. content
  17. appId
  18. musicLink
  19. footageLink
  20. ratioSquare
  21. ratioStory
  22. ratioFiveFour
  23. ratioSixteenNine
  24. duration
  25. referenceLink
  26. variations
  27. }
  28. }
  29. `;
  30.  
  31.  
  32. class Dashboard extends Component {
  33. constructor(props) {
  34. super(props);
  35.  
  36.  
  37. this.state = {
  38. title: '',
  39. content: '',
  40. appId: '',
  41. musicLink: '',
  42. footageLink: '',
  43. duration: '',
  44. ratioSquare: false,
  45. ratioStory: false,
  46. ratioFiveFour: false,
  47. ratioSixteenNine: false,
  48. variations: '',
  49. referenceLink: '',
  50.  
  51. };
  52.  
  53. this.toggleSquare = this.toggleSquare.bind(this);
  54. this.toggleStory = this.toggleStory.bind(this);
  55. this.toggleFiveFour = this.toggleFiveFour.bind(this);
  56. this.toggleSixteenNine = this.toggleSixteenNine.bind(this);
  57. }
  58.  
  59.  
  60. toggleSquare() {
  61. this.setState(prevState => ({
  62. ratioSquare: !prevState.ratioSquare
  63. }));
  64. }
  65.  
  66. toggleStory() {
  67. this.setState(prevState => ({
  68. ratioStory: !prevState.ratioStory
  69. }));
  70. }
  71.  
  72. toggleFiveFour() {
  73. this.setState(prevState => ({
  74. ratioFiveFour: !prevState.ratioFiveFour
  75. }));
  76. }
  77.  
  78. toggleSixteenNine() {
  79. this.setState(prevState => ({
  80. ratioSixteenNine: !prevState.ratioSixteenNine
  81. }));
  82. }
  83.  
  84.  
  85. render() {
  86.  
  87. const userData = JSON.parse(localStorage.getItem(USER_DATA));
  88. const { title, content, appId, musicLink, footageLink, duration, ratioSquare, ratioStory, ratioFiveFour, ratioSixteenNine, variations, referenceLink } = this.state;
  89.  
  90. return (
  91. <>
  92. <Header title="Новая задача" />
  93. <div className="new-task-body">
  94. <Form>
  95. <Row className="alone">
  96. <Col xs="6"> <FormGroup>
  97.  
  98. <Input type="text" value={title} onChange={e => this.setState({ title: e.target.value })} name="appName" id="appName" placeholder="Введите название задачи" />
  99. </FormGroup></Col>
  100. <Col xs="4"> <FormGroup>
  101.  
  102. <Input type="select" value={appId} onChange={e => this.setState({ appId: parseInt(e.target.value) })} name="select" id="exampleSelect">
  103. <option value="0">Без приложения</option>
  104. { userData ? userData.apps.map(app => <option value={ app.id }>{ app.title }</option> ) : <option>Нет приложений</option>}
  105.  
  106. </Input>
  107. </FormGroup></Col>
  108. <Col xs="2"><Button outline className="cancel">Отмена</Button></Col>
  109. </Row>
  110. <div className="task-box">
  111. <FormGroup>
  112. <Label for="references">Референсы</Label>
  113. <Input type="text" value={referenceLink} onChange={e => this.setState({ referenceLink: e.target.value })} name="references" id="references" placeholder="Вставьте ссылку на референсы" />
  114. </FormGroup>
  115. <FormGroup>
  116. <Label for="content">Задача</Label>
  117. <Input type="textarea" value={content} onChange={e => this.setState({ content: e.target.value })} rows={4} name="content" id="content" placeholder="Распишите подробно задачу ролика" />
  118. </FormGroup>
  119.  
  120. <FormGroup >
  121. <Label for="music">Музыка</Label>
  122. </FormGroup>
  123.  
  124.  
  125. <FormGroup row>
  126. <Col xs={6}>
  127. <Input type="text" value={musicLink} onChange={e => this.setState({ musicLink: e.target.value })} name="music" id="music" placeholder="Вставьте ссылку на облако " />
  128. </Col>
  129. <Col className="reference-list" xs={3}>
  130. <a><strike>Или выберете из списка</strike></a>
  131. </Col>
  132. <Col xs={3}>
  133.  
  134. <Input type="text" disabled name="music_name" id="music_name" placeholder="И введите название файла" />
  135. </Col>
  136. </FormGroup>
  137.  
  138. <FormGroup >
  139. <Label for="footages">Футажи</Label>
  140. </FormGroup>
  141.  
  142.  
  143. <FormGroup row>
  144. <Col xs={6}>
  145. <Input type="text" value={footageLink} onChange={e => this.setState({ footageLink: e.target.value })} name="footages" id="footages" placeholder="Вставьте ссылку на облако " />
  146. </Col>
  147. <Col className="reference-list" xs={3}>
  148. <a ><strike>Или выберете из списка</strike></a>
  149. </Col>
  150. <Col xs={3}>
  151.  
  152. <Input type="text" disabled name="footages_name" id="footage_name" placeholder="И введите название файла" />
  153. </Col>
  154. </FormGroup>
  155.  
  156.  
  157. <FormGroup row>
  158. <Col xs={4}>
  159. <FormGroup>
  160. <Label for="checkbox2" >Разрешение</Label><br></br>
  161.  
  162. <FormGroup check inline>
  163.  
  164.  
  165. <Input type="checkbox" name="ratio" value={ratioSquare} onChange={this.toggleSquare} id="checkbox2" />
  166. Квадрат
  167.  
  168. <Input type="checkbox" name="ratio" value={ratioStory} onChange={this.toggleStory} id="checkbox2" />
  169. Сторис
  170.  
  171. <Input type="checkbox" name="ratio" value={ratioFiveFour} onChange={this.toggleFiveFour} id="checkbox2" />
  172. 5:4
  173. <Input type="checkbox" name="ratio" value={ratioSixteenNine} onChange={this.toggleSixteenNine} id="checkbox2" />
  174. 16:9
  175.  
  176. </FormGroup>
  177. </FormGroup>
  178. </Col>
  179.  
  180. <Col xs={4}>
  181. <FormGroup>
  182. <Label for="duration" >Длительность</Label>
  183.  
  184. <Input type="select" value={duration} onChange={e => this.setState({ duration: e.target.value })} name="duration" id="duration">
  185. <option>до 10 секунд</option>
  186. <option>до 15 секунд</option>
  187. <option>до 20 секунд</option>
  188. <option>до 25 секунд</option>
  189. <option>до 30 секунд</option>
  190. </Input>
  191. </FormGroup>
  192. </Col>
  193.  
  194. <Col xs={4}>
  195. <FormGroup>
  196. <Label for="variants" >Количество вариантов</Label>
  197.  
  198. <Input type="select" value={variations} onChange={e => this.setState({ variations: parseInt(e.target.value) })} name="variants" id="variants">
  199. <option>1</option>
  200. <option>2</option>
  201. <option>3</option>
  202. <option>4</option>
  203. </Input>
  204. </FormGroup>
  205. </Col>
  206. </FormGroup>
  207.  
  208. </div>
  209.  
  210. <FormGroup className="save-btn">
  211. <Mutation
  212. mutation={BRIEF_MUTATION}
  213. variables={{ title, content, appId, musicLink, footageLink, duration, ratioSquare, ratioStory, ratioFiveFour, ratioSixteenNine, variations, referenceLink }}
  214. onCompleted={() => this.props.history.push('/')}>
  215. {
  216. addBrief =>
  217. <Button color="primary " className="save" onClick={addBrief}>Готово</Button>
  218. }
  219. </Mutation>
  220. </FormGroup>
  221.  
  222.  
  223.  
  224.  
  225. </Form>
  226. </div>
  227. </>
  228. )
  229. }
  230. };
  231.  
  232. export default Dashboard;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement