Guest User

Untitled

a guest
Dec 26th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. /* eslint-disable */
  2.  
  3. import React from 'react';
  4. import { Avatar, Button } from 'antd';
  5. import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
  6. import styled, { ThemeProvider } from 'styled-components';
  7.  
  8. /* utils */
  9. import { btnReboot, btnHoverTransparentToMajor } from '@/vendor/style-utils';
  10.  
  11. /* assets */
  12. import vars from '@/stylesheets/variables.runtime';
  13.  
  14. /* actions */
  15.  
  16. /* components */
  17.  
  18. /* self-defined-components */
  19.  
  20. import Style from '@/stylesheets/modules/InvitedTesterList';
  21.  
  22. const StyledInvitedTesterItem = styled.div`
  23. display: flex;
  24. align-items: center;
  25. max-height: 80px;
  26. background-color: white;
  27. padding: 30px 20px;
  28. font-size: 13px;
  29. font-weight: 500;
  30. margin-bottom: 15px;
  31. color: ${({ theme }) => theme.colors.gray800};
  32. border: 1px solid rgba(0, 0, 0, 0.125);
  33.  
  34. &:hover {
  35. border: 1px solid ${({ theme }) => theme.colors.major};
  36. box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.3);
  37. }
  38. `;
  39.  
  40. const StyledInputText = styled.input`
  41. border: 0;
  42. border-color: transparent;
  43. font-size: 13px;
  44. padding: 0;
  45. width: 100%;
  46. caret-color: ${({ theme }) => theme.colors.major};
  47.  
  48. &:hover,
  49. &:focus {
  50. outline: 0;
  51. box-shadow: none;
  52. }
  53. `
  54. const StyledSaveButton = styled(Button)`
  55. ${btnReboot}
  56. ${btnHoverTransparentToMajor}
  57. font-size: 12px !important;
  58. border-radius: 20px !important;
  59. margin-left: 10px !important;
  60. width: 44px !important;
  61. height: 20px !important;
  62. `
  63.  
  64. const IconButton = styled.button`
  65. ${btnReboot}
  66. color: #cccccc;
  67. font-size: 16px;
  68. padding: 0;
  69. `
  70.  
  71. class InvitedTesterItem extends React.Component {
  72. constructor(props) {
  73. super(props);
  74.  
  75. this.state = {
  76. isEditMode: false,
  77. }
  78.  
  79. this.inputTextRef = React.createRef();
  80. this.handleOnClick = this.handleOnClick.bind(this);
  81. this.handleOnSave = this.handleOnSave.bind(this);
  82. this.handleOnDelete = this.handleOnDelete.bind(this);
  83. }
  84.  
  85. handleOnSave() {
  86. this.props.saveNote(this.props.invitedTester.id, this.inputTextRef.current.value.trim());
  87. this.setState({
  88. isEditMode: false
  89. })
  90. }
  91.  
  92. handleOnDelete() {
  93. console.log('this.props.invitedTester.id', this.props.invitedTester.id)
  94. this.props.deleteNote(this.props.invitedTester.id)
  95. }
  96.  
  97. handleOnClick() {
  98. this.setState(prevState => {
  99. return {
  100. isEditMode: !prevState.isEditMode
  101. }
  102. })
  103. }
  104.  
  105. render() {
  106.  
  107. const { invitedTester } = this.props;
  108.  
  109. return (
  110. <ThemeProvider theme={vars}>
  111. <StyledInvitedTesterItem>
  112. <div style={{ width: 140, marginRight: 30 }}>
  113. <Avatar size={30} src={invitedTester.userAvatar} className={Style.avatar} >
  114. {invitedTester.name.slice(0, 1)}
  115. </Avatar>
  116. { invitedTester.name || 'No Personal Info' }
  117. </div>
  118.  
  119. <div style={{ width: 154, marginRight: 30 }}>
  120. { invitedTester.email }
  121. </div>
  122.  
  123. <div style={{ width: 200, marginRight: 30 }}>
  124. { invitedTester.invitedAt }
  125. </div>
  126.  
  127. <div style={{ width: 482, marginRight: 30 }}>
  128.  
  129. {
  130. this.state.isEditMode ? (
  131. <div className="d-flex align-items-center">
  132. <StyledInputText type="text" placeholder="Notes..."
  133. ref={this.inputTextRef}
  134. defaultValue={ invitedTester.note }
  135. />
  136.  
  137. <IconButton type="button" onClick={this.handleOnClick}>
  138. <FontAwesomeIcon
  139. icon={['fas', 'times']}
  140. style={{ fontSize: 12 }}
  141. />
  142. </IconButton>
  143.  
  144. <StyledSaveButton onClick={this.handleOnSave}>Save</StyledSaveButton>
  145. </div>
  146. ) : (
  147. <div className="d-flex justify-content-between">
  148. { invitedTester.note ? invitedTester.note : 'Notes...' }
  149. <IconButton type="button" onClick={this.handleOnClick}>
  150. <FontAwesomeIcon
  151. icon={['fas', 'pen']}
  152. style={{ fontSize: 14 }}
  153. />
  154. </IconButton>
  155. </div>
  156. )
  157. }
  158. </div>
  159.  
  160. <div className="text-right">
  161. <IconButton type="button" onClick={this.handleOnDelete}>
  162. <FontAwesomeIcon
  163. icon={['far', 'trash-alt']}
  164. />
  165. </IconButton>
  166. </div>
  167. </StyledInvitedTesterItem>
  168. </ThemeProvider>
  169. )
  170. }
  171. }
  172.  
  173. export default InvitedTesterItem;
Add Comment
Please, Sign In to add comment