dfghgfhplkjbv

src/components/Jobs/Jobs.js

Feb 26th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import classNames from 'classnames'
  3. import { Link } from 'gatsby'
  4. import posed, { PoseGroup } from 'react-pose'
  5. import shuffle from 'src/shuffle'
  6. import styles from './Jobs.module.scss'
  7. // import vector from 'src/img/Vector.png'
  8. import { formatMessage } from 'src/translations'
  9. import { getLink } from 'src/utils'
  10.  
  11. const Item = posed.div({
  12. flip: {
  13. scale: 1,
  14. transition: {
  15. scale: {
  16. type: 'spring',
  17. velocity: 3,
  18. },
  19. default: {
  20. type: 'spring',
  21. },
  22. },
  23. // transition: { type: 'spring', stiffness: 100 },
  24. },
  25. })
  26.  
  27. class Jobs extends Component {
  28. state = {
  29. preparedOffers: this.props.offers.filter(({ node: slug }) => slug !== '_').slice(0, 4),
  30. }
  31.  
  32. handleTagClick = (tagTitle) => {
  33. this.setState(
  34. {
  35. preparedOffers: this.props.offers
  36. .filter(
  37. ({
  38. node: {
  39. tag: { title },
  40. },
  41. }) => title === tagTitle,
  42. )
  43. .slice(0, 4),
  44. },
  45. () =>
  46. this.setState({
  47. preparedOffers: shuffle(
  48. this.props.offers
  49. .filter(
  50. ({
  51. node: {
  52. tag: { title },
  53. },
  54. }) => title === tagTitle,
  55. )
  56. .slice(0, 4),
  57. ),
  58. }),
  59. )
  60. }
  61.  
  62. render() {
  63. const { preparedOffers } = this.state
  64. const { className, jobTags, locale } = this.props
  65.  
  66. return (
  67. <div className={classNames(className, styles.root)}>
  68. <section className={styles.container}>
  69. <header className={styles.header}>
  70. <h1>{formatMessage(locale, 'jobs')}</h1>
  71. </header>
  72. <div className={styles.blocksContainer}>
  73. <div className={styles.tagsContainer}>
  74. <div className={styles.jobsTitle}>
  75. <h2>{formatMessage(locale, 'tags')}</h2>
  76. </div>
  77. <div className={styles.buttonsContainer}>
  78. {jobTags.map(({ node }) => (
  79. <button className={styles.button} key={node.id} onClick={() => this.handleTagClick(node.title)}>
  80. {node.title}
  81. </button>
  82. ))}
  83. </div>
  84. <div className={styles.gemsContainer}>
  85. <div className={styles.innerContainer}>
  86. <p className={styles.gems}>{formatMessage(locale, 'gems')}</p>
  87. <Link to={getLink(locale, 'jobs')} className={styles.allJobs}>
  88. {formatMessage(locale, 'viewAllJobs')}
  89. </Link>
  90. </div>
  91. </div>
  92. </div>
  93. <div className={styles.vacanciesContainer}>
  94. <PoseGroup>
  95. {preparedOffers.map(
  96. ({
  97. node: {
  98. id,
  99. slug,
  100. description,
  101. tag: { title },
  102. companyLogo: { url },
  103. companyName,
  104. },
  105. }) => (
  106. <Item className={styles.vacanciesItem} key={id}>
  107. <Link to={getLink(locale, `job/${slug}`)} className={styles.jobOffer} key={id}>
  108. <div className={styles.headerVacancy}>
  109. <p>{title}</p>
  110. <div className={styles.box}>
  111. <img src={url} alt="" />
  112. </div>
  113. <div className={styles.description}>
  114. <p>{description.length >= 70 ? `${description.substring(0, 70)}...` : description}</p>
  115. </div>
  116. <div className={styles.bottomLine}>
  117. <p>{companyName}</p>
  118. {/* <img src={vector} className={styles.vector} alt="" ></img> */}
  119. </div>
  120. </div>
  121. </Link>
  122. </Item>
  123. ),
  124. )}
  125. </PoseGroup>
  126. </div>
  127. </div>
  128. </section>
  129. </div>
  130. )
  131. }
  132. }
  133.  
  134. export default Jobs
Advertisement
Add Comment
Please, Sign In to add comment