@chakra-ui/core#Avatar JavaScript Examples

The following examples show how to use @chakra-ui/core#Avatar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmailRow.js    From CubeMail with MIT License 5 votes vote down vote up
EmailRow = ({ message, handleMessageClick }) => {
  // Get name of email sender
  const name = removeQuote(
    getHeader(message.payload.headers, "From").split("<")[0]
  );

  // Get subject of email
  const subject = getHeader(message.payload.headers, "Subject");

  // Get part of email snippet
  const msg = decodeHtml(message.snippet.substr(0, 75));

  // Set backgroundColor to white if the mail is not yet opened
  const backgroundColor =
    message.labelIds.indexOf("UNREAD") > -1 ? "#fff" : "#E2E8F0";

  return (
    <Flex
      key={message.id}
      id={message.id}
      onClick={handleMessageClick}
      wrap='no-wrap'
      justify='space-around'
      py={2}
      bg={backgroundColor}
      borderTop='1px'
      borderBottom='1px'
      borderColor='gray.300'
      cursor='pointer'
    >
      <Avatar name={name} src='https://bit.ly/tioluwani-kolawole' />
      <Box w='80%'>
        <Text fontSize='sm' color='gray.700' isTruncated>
          {name}
        </Text>
        <Text fontSize='md' fontWeight='bold' color='#3182ce' isTruncated>
          {subject}
        </Text>
        <Text fontSize='xs' color='gray.500'>
          {msg}
        </Text>
      </Box>
    </Flex>
  );
}
Example #2
Source File: CompanyReviewForm.js    From allay-fe with MIT License 4 votes vote down vote up
ReviewForm2 = ({
  history,
  loadingCompanies,
  companies,
  getCompanies,
  postReview,
}) => {
  //initialize animations
  AOS.init()
  const { register, handleSubmit, formState } = useForm()

  // thinking state
  const [thinking, setThinking] = useState(false)
  const dots = () => {
    setThinking(true)
  }

  // search state
  const [searchTerm, setSearchTerm] = useState('')
  const [searchResults, setSearchResults] = useState([])

  // no company state
  const [noCompany, setNoCompany] = useState(false)

  // location "state"
  const [location, setLocation] = useState({})
  const [newLocation, setNewLocation] = useState({})
  const stateSelectorHelper = (value) => {
    setLocation(value)
  }

  // star rating
  const [starState, setStarState] = useState(0)

  //progress bar
  const [progress, setProgress] = useState({
    prec: 99,
    time: 8,
    prog: 2,
  })

  // state for visibility
  const [Tag2, setTag2] = useState(false)
  const [Tag3, setTag3] = useState(false)
  const [Tag4, setTag4] = useState(false)
  const [Tag5, setTag5] = useState(false)
  const [Tag6, setTag6] = useState(false)

  // brings to top on render
  useEffect(() => {
    getCompanies()
    setProgress({
      prec: 95,
      time: 7,
      prog: 5,
    })
    const element = document.getElementById('Tag1')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    })
  }, [getCompanies])

  // company search function
  useEffect(() => {
    if (searchTerm.length >= 3) {
      const results = companies.filter((company) =>
        company.company_name.toLowerCase().startsWith(searchTerm.toLowerCase())
      )
      setSearchResults(results)
      if (results.length === 0) {
        setNoCompany(true)
      } else {
        setNoCompany(false)
      }
    }
  }, [searchTerm, companies])

  // state confirmation search function
  useEffect(() => {
    if (location.myState) {
      const stateId = states.filter((i) =>
        i.state_name.toLowerCase().startsWith(location.myState.toLowerCase())
      )
      setNewLocation({ ...location, myState: stateId[0].id })
    }
  }, [location])

  // timers for moves
  let timer = null
  let dotTimer = null

  // 2nd tag
  const time1 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo2, 1000)
  }
  const routeTo2 = () => {
    setTag2(true)
    setProgress({
      prec: 70,
      time: 6,
      prog: 20,
    })
    const element = document.getElementById('Tag2')
    element.scrollIntoView({ behavior: 'smooth', block: 'start' })
    setThinking(false)
  }

  // 3rd tag
  const time2 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo3, 1000)
  }
  const routeTo3 = () => {
    setTag3(true)
    setProgress({
      prec: 65,
      time: 4,
      prog: 35,
    })
    const element = document.getElementById('Tag3')
    element.scrollIntoView({ behavior: 'smooth', block: 'start' })
    setThinking(false)
  }

  //4th tag
  const time3 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo4, 1000)
  }
  const routeTo4 = () => {
    setTag4(true)
    setProgress({
      prec: 45,
      time: 2,
      prog: 65,
    })
    const element = document.getElementById('Tag4')
    element.scrollIntoView({ behavior: 'smooth', block: 'start' })
    setThinking(false)
  }

  // 5th tag
  const time4 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo5, 1000)
  }
  const routeTo5 = () => {
    setTag5(true)
    setProgress({
      prec: 20,
      time: 1,
      prog: 80,
    })
    const element = document.getElementById('Tag5')
    element.scrollIntoView({ behavior: 'smooth', block: 'center' })
    setThinking(false)
  }

  // 6th tag
  const time5 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo6, 1000)
  }
  const routeTo6 = () => {
    setTag6(true)
    setProgress({
      prec: 100,
      time: 0,
      prog: 100,
    })
    const element = document.getElementById('Tag6')
    element.scrollIntoView({ behavior: 'smooth', block: 'center' })
    setThinking(false)
  }

  //push to dashboard and send info to DS for review
  const sendInfoToDS = (data) => {
    var dataForDS = JSON.stringify(data)
    axiosToDS()
      .post('/check_review', dataForDS)
      .then((res) => {
        console.log(res)
      })
      .catch((err) => {
        console.log(err)
      })
    history.push('/dashboard')
  }

  //submit handler
  const submitForm = (data) => {
    postReview(localStorage.getItem('userId'), {
      ...data,
      review_type_id: 1,
      overall_rating: starState,
      city: newLocation.myCity,
      state_id: newLocation.myState,
    }).then(() => sendInfoToDS(data))
    ReactGA.event({
      category: 'Review',
      action: `Submit review`,
    })
  }

  return (
    // main container

    <>
      <Flex justify="center">
        <ProgressHeader progress={progress} />
      </Flex>

      <Flex w="100%" margin="0 auto" minH="100vh">
        {thinking ? (
          <>
            <Flex
              bottom="0"
              position="fixed"
              overflow="hidden"
              zIndex="999"
              pt="5%"
              pl="15%"
            >
              <ThinkingDots />
            </Flex>
          </>
        ) : null}
        {/* form container */}
        <Flex
          w="100%"
          bg="#FFF"
          flexDir="column"
          px="2%"
          pt="5%"
          margin="0 auto"
        >
          {/*--------------- start of form ---------------  */}
          <form onSubmit={handleSubmit(submitForm)}>
            <FormControl isRequired>
              {/* first prompt */}
              <Flex
                id="Tag1"
                align="center"
                h="5%"
                p="1%"
                w="416px"
                mb="8%"
                mt="5%"
                bg="#F2F6FE"
                rounded="20px"
                data-aos="fade-right"
                data-aos-offset="200"
                data-aos-delay="50"
                data-aos-duration="1000"
                data-aos-easing="ease-in-out"
                data-aos-mirror="true"
                data-aos-once="true"
              >
                <p>Tell me some details so we can get started</p>
              </Flex>
              {/* form container  */}
              <Flex w="100%" justify="flex-end">
                {/* company box */}
                <Flex
                  w="459px"
                  h="700px"
                  px="6"
                  py="8"
                  border="1px solid #BBBDC6"
                  rounded="6px"
                  flexDir="column"
                  justify="space-evenly"
                  data-aos="fade-in"
                  data-aos-offset="200"
                  data-aos-delay="1000"
                  data-aos-duration="1500"
                  data-aos-easing="ease-in-out"
                  data-aos-mirror="true"
                  data-aos-once="true"
                  data-aos-anchor="Tag1"
                >
                  <FormLabel>1. Company name</FormLabel>
                  {loadingCompanies ? (
                    <>
                      <Flex justify="center" w="100%">
                        <CustomSpinner />
                      </Flex>
                    </>
                  ) : (
                    <>
                      {' '}
                      <Input
                        h="56px"
                        variant="filled"
                        rounded="6px"
                        textTransform="capitalize"
                        type="text"
                        label="company_name"
                        name="company_name"
                        list="company_name"
                        ref={register}
                        onChange={(e) => setSearchTerm(e.target.value)}
                      />
                      <datalist id="company_name">
                        {searchResults.map((company) => (
                          <option value={company.company_name} key={company.id}>
                            {company.company_name}
                          </option>
                        ))}
                      </datalist>
                      {noCompany ? (
                        <>
                          <Link mb="3" color="grey" href="/add-company">
                            Oops, you need to add that company!
                          </Link>
                        </>
                      ) : (
                        <Flex mb="6" />
                      )}
                    </>
                  )}
                  <FormLabel>2. Status at the company</FormLabel>
                  <Select
                    h="56px"
                    mb="6"
                    rounded="6px"
                    variant="filled"
                    label="work_status_id"
                    name="work_status_id"
                    placeholder="Select one"
                    ref={register}
                  >
                    <option value={1}>Current Employee</option>
                    <option value={2}>Former Employee</option>
                    <option value={3}>Full Time</option>
                    <option value={4}>Part Time</option>
                    <option value={5}>Intern</option>
                  </Select>
                  <FormLabel>3. Job Title</FormLabel>
                  <Input
                    h="56px"
                    mb="6"
                    variant="filled"
                    rounded="6px"
                    autoCapitalize="none"
                    type="text"
                    label="job_title"
                    name="job_title"
                    list="job_title"
                    ref={register}
                  />
                  <FormLabel>3. Location of company</FormLabel>
                  <CustomAutoComplete
                    stateHelper={stateSelectorHelper}
                    id="Company Headquarters"
                    name="Company Headquarters"
                    label="Company Headquarters"
                    placeholder="e.g. Los Angeles, CA"
                  />
                  <FormLabel mt="6">5. Length of position</FormLabel>
                  <Flex w="100%" justify="space-between">
                    <Input
                      type="number"
                      min="1970"
                      max="2030"
                      h="56px"
                      variant="filled"
                      rounded="6px"
                      w="45%"
                      mr="2%"
                      label="start_date"
                      name="start_date"
                      placeholder="YYYY"
                      ref={register}
                    />

                    <Input
                      h="56px"
                      variant="filled"
                      rounded="6px"
                      autoCapitalize="none"
                      type="number"
                      min="1970"
                      max="2030"
                      w="45%"
                      label="end_date"
                      name="end_date"
                      placeholder="YYYY"
                      ref={register}
                    />
                  </Flex>
                </Flex>
                {/* avatar */}
                <Flex
                  h="700px"
                  align="flex-end"
                  ml="1%"
                  data-aos="fade-in"
                  data-aos-offset="200"
                  data-aos-delay="1000"
                  data-aos-duration="1500"
                  data-aos-easing="ease-in-out"
                  data-aos-mirror="true"
                  data-aos-once="true"
                  data-aos-anchor="Tag1"
                >
                  <Avatar size="md" src="https://bit.ly/broken-link" />
                </Flex>
              </Flex>
              <Flex
                justify="flex-end"
                mb="5%"
                data-aos="fade-in"
                data-aos-offset="120"
                data-aos-delay="1000"
                data-aos-duration="1500"
                data-aos-easing="ease-in-out"
                data-aos-mirror="true"
                data-aos-once="true"
                data-aos-anchor="Tag1"
              >
                <Button
                  data-cy="companyReviewFormButton"
                  h="56px"
                  w="17%"
                  mt="2%"
                  rounded="35px"
                  border="1px solid #344CD0"
                  color="#344CD0"
                  backgroundColor="#FFF"
                  _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                  onClick={time1}
                >
                  Next
                </Button>
              </Flex>
              {/* Second prompt */}
              {Tag2 ? (
                <>
                  <Flex
                    id="Tag2"
                    align="center"
                    p="1%"
                    mb="2%"
                    h="5%"
                    w="45%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Thank you for that information.</p>
                  </Flex>
                  <Flex
                    id="Tag2"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="800"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Please add some comments below. Helpful comments include
                      information about company culture, work environment,
                      career growth, salary, etc.
                    </p>
                  </Flex>
                  <Flex w="100%" justify="flex-end">
                    {/* long hand interview box */}
                    <Flex
                      w="459px"
                      h="350px"
                      px="6"
                      py="8"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="2400"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag2"
                    >
                      <FormLabel>Comments</FormLabel>
                      <Textarea
                        variant="filled"
                        resize="none"
                        h="250px"
                        rowsMax={6}
                        type="text"
                        name="comment"
                        rounded="6px"
                        ref={register}
                        data-cy="companyComment"
                      />
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="350px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="2400"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag2"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="120"
                    data-aos-delay="2400"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="Tag2"
                  >
                    <Button
                      data-cy="companyReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time2}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* 3rd prompt */}
              {Tag3 ? (
                <>
                  <Flex
                    id="Tag3"
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="2%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Thank you for sharing that.</p>
                  </Flex>
                  <Flex
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="1500"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      To better understand company culture, would you please add
                      a few more details?
                    </p>
                  </Flex>
                  {/* hours container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* hours box */}
                    <Flex
                      w="459px"
                      h="136px"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="2800"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag3"
                    >
                      <FormLabel>Working hours</FormLabel>
                      <Select
                        h="56px"
                        rounded="6px"
                        variant="filled"
                        label="typical_hours"
                        name="typical_hours"
                        placeholder="Select one"
                        ref={register}
                      >
                        <option value={29}>Less than 30 hours</option>
                        <option value={30}>30 hours+</option>
                        <option value={40}>40 hours+</option>
                        <option value={50}>50 hours+</option>
                        <option value={60}>60 hours+</option>
                      </Select>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="136px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="2800"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag3"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="120"
                    data-aos-delay="2800"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="Tag3"
                  >
                    <Button
                      data-cy="companyReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time3}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* 4th prompt */}
              {Tag4 ? (
                <>
                  <Flex
                    id="Tag4"
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Posting your hiring salary helps many job-seekers
                      negotiate fair salaries.
                    </p>
                  </Flex>
                  {/* salary container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* salary box */}
                    <Flex
                      w="459px"
                      h="150px"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="1000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag4"
                    >
                      <FormLabel>Hiring salary</FormLabel>
                      <InputGroup>
                        <InputLeftElement
                          mb="4"
                          py="28px"
                          color="gray.300"
                          fontSize="1.2em"
                          children="$"
                        />
                        <Input
                          h="56px"
                          mb="6"
                          variant="filled"
                          rounded="6px"
                          autoCapitalize="none"
                          type="number"
                          label="salary"
                          name="salary"
                          ref={register}
                        />
                      </InputGroup>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="150px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag4"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="120"
                    data-aos-delay="1000"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="Tag4"
                  >
                    <Button
                      data-cy="companyReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time4}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* 5th prompt */}
              {Tag5 ? (
                <>
                  <Flex
                    id="Tag5"
                    align="center"
                    h="5%"
                    w="416px"
                    p="1%"
                    mb="2%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Awesome! Thank you for sharing that.</p>
                  </Flex>
                  <Flex
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="1000"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>One last question.</p>
                  </Flex>
                  {/* overall container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* overall box */}
                    <Flex
                      w="459px"
                      h="136px"
                      mb="8%"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <FormLabel mb="4">
                        Please rate your overall experience.
                      </FormLabel>
                      <Flex justify="center" w="100%">
                        <BeautyStars
                          name="companyOverall"
                          value={starState}
                          activeColor="#344CD0"
                          onChange={(value) => {
                            setStarState(value)
                            time5()
                          }}
                        />
                      </Flex>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="136px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag5"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                </>
              ) : null}
              {/* 6th prompt */}
              {Tag6 ? (
                <>
                  <Flex
                    id="Tag6"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="#ratingTag"
                  >
                    <p>Thank you! Don’t forget to hit submit. </p>
                  </Flex>
                  {/* submit container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* submit box */}
                    <Flex
                      w="459px"
                      h="136px"
                      mb="8%"
                      p="6"
                      justify="center"
                      align="center"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Button
                        bg="#344CD0"
                        color="white"
                        type="submit"
                        isLoading={formState.isSubmitting}
                        rounded="6px"
                        border="none"
                        data-cy="companyReviewSubmit"
                      >
                        Submit
                      </Button>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="136px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                </>
              ) : null}
            </FormControl>
          </form>
        </Flex>
      </Flex>
    </>
  )
}
Example #3
Source File: FormController.js    From allay-fe with MIT License 4 votes vote down vote up
FormController = ({ history }) => {
  // initialize AOS
  AOS.init()
  // state to show interview review
  const [showInterview, setShowInterview] = useState(false)
  // state to show company review
  const [showCompanyReview, setShowCompanyReview] = useState(false)
  //progress bar
  const [progress] = useState({
    prec: 99,
    prog: 0,
  })

  return (
    // main container
    <>
      <ProgressHeader progress={progress} />


      {/* Start of messenger  */}
      {/* form container */}
      <Flex margin="0 auto" width="80%">
        <Flex flexDir="column" pt="5%" width="100%">

          <Flex
            align="center"
            p="1%"
            ml="2%"
            w="45%"
            mt="20%"
            mb="2%"
            bg="#F2F6FE"
            position="relative"
            right="0"
            bottom=" 0"
            left="0"
            rounded="20px"
            data-aos="fade-right"
            data-aos-offset="200"
            data-aos-delay="50"
            data-aos-duration="1000"
            data-aos-easing="ease-in-out"
            data-aos-mirror="false"
            data-aos-once="false"
          >
            <p>
              Hi {localStorage.getItem('username')},{' '}
              <span role="img" aria-label="smile">
                ?
              </span>{' '}
              Thank you for choosing to post.
            </p>
          </Flex>
          <Flex
            align="center"
            p="1%"
            ml="2%"
            w="50%"
            mb="2%"
            bg="#F2F6FE"
            rounded="20px"
            data-aos="fade-right"
            data-aos-offset="200"
            data-aos-delay="1000"
            data-aos-duration="1000"
            data-aos-easing="ease-in-out"
            data-aos-mirror="true"
            data-aos-once="false"
          >
            <p>
              Sharing your experience through your posts encourages others to do
              the same and promotes the exchange of helpful information
            </p>
          </Flex>
          <Flex
            align="center"
            p="1%"
            ml="2%"
            w="45%"
            mb="8%"
            bg="#F2F6FE"
            rounded="20px"
            data-aos="fade-right"
            data-aos-offset="200"
            data-aos-delay="2500"
            data-aos-duration="1000"
            data-aos-easing="ease-in-out"
            data-aos-mirror="true"
            data-aos-once="false"
          >
            <p>What do you want to post about?</p>
          </Flex>
          {/* company container  */}

          <Flex w="100%" justify="flex-end" pb="5%">
            {/* company box */}
            <Flex
              w="36%"
              px="6%"
              py="5%"

              border="1px solid #EAF0FE"
              rounded="6px"
              flexDir="column"
              data-aos="fade-in"
              data-aos-offset="200"

              data-aos-delay="1500"

              data-aos-duration="2000"
              data-aos-easing="ease-in-out"
              data-aos-mirror="true"
              data-aos-once="false"
              align="center"
            >
              <Flex w="100%" color="#494B5B" fontSize="20px" fontWeight="light">
                Choose a topic
              </Flex>
              <Flex justify="space-between" mt="3%" align="center" width="60%">
                <Flex
                  justify="center"
                  align="center"
                  w="100px"
                  h="100px"
                  onClick={() => {
                    setShowInterview(true)
                    setShowCompanyReview(false)
                  }}
                  data-cy="interviewReviewButton"
                >
                  <Image src={interviewIcon} alt="Interview Review Icon" />
                </Flex>
                <Flex
                  justify="center"
                  ml="40%"
                  w="100px"
                  h="100px"
                  mb="10%"
                  onClick={() => {
                    setShowInterview(false)
                    setShowCompanyReview(true)
                  }}
                  data-cy="companyReviewButton"
                >
                  <Image src={companyIcon} alt="Company Review Icon" />
                </Flex>
              </Flex>

              <Flex w="100%" mt="1%" justify="space-evenly">
                <Flex
                  as="h4"
                  w="96px"
                  h="44px"
                  textAlign="center"
                  color="#494B5B"
                  fontWeight="light"
                  fontSize="16px"
                >
                  Interview Review
                </Flex>
                <Flex
                  as="h4"
                  w="96px"
                  h="44px"
                  textAlign="center"
                  color="#494B5B"
                  fontWeight="light"
                  fontSize="16px"
                >
                  Company Review
                </Flex>
              </Flex>
            </Flex>
            {/* avatar */}
            <Flex
              align="flex-end"
              ml="1%"
              mr="2%"
              data-aos="fade-in"
              data-aos-offset="200"
              data-aos-delay="3000"
              data-aos-duration="2000"
              data-aos-easing="ease-in-out"
              data-aos-mirror="true"
              data-aos-once="false"
              justify="flex-end"
            >
              <Flex align="center" justify="space-evenly" width="40%" mt="3%">
                <Avatar size="md" src="https://bit.ly/broken-link" />
              </Flex>
            </Flex>
          </Flex>
          {showInterview ? <InterviewForm history={history} /> : null}
          {showCompanyReview ? <CompanyReviewForm history={history} /> : null}
        </Flex>
      </Flex>
    </>
  )
}
Example #4
Source File: InterviewForm.js    From allay-fe with MIT License 4 votes vote down vote up
InterviewForm = ({
  loadingCompanies,
  getCompanies,
  companies,
  postReview,
  history,
}) => {
  //initialize animations
  AOS.init()
  const { register, handleSubmit, formState } = useForm()

  // state "state"
  const [location, setLocation] = useState({})
  const [newLocation, setNewLocation] = useState({})
  const stateSelectorHelper = (value) => {
    setLocation(value)
  }

  // thinking state
  const [thinking, setThinking] = useState(false)
  const dots = () => {
    setThinking(true)
  }

  // search state
  const [searchTerm, setSearchTerm] = useState('')
  const [searchResults, setSearchResults] = useState([])

  // no company state
  const [noCompany, setNoCompany] = useState(false)

  // star rating
  const [starState, setStarState] = useState(0)

  // custom radio button state offer status
  const [offer, setOffer] = useState(1)

  //progress bar
  const [progress, setProgress] = useState({
    prec: 99,
    time: 8,
    prog: 2,
  })
  // company search function

  useEffect(() => {
    if (searchTerm.length >= 3) {
      const results = companies.filter((company) =>
        company.company_name.toLowerCase().startsWith(searchTerm.toLowerCase())
      )
      setSearchResults(results)
      if (results.length === 0) {
        setNoCompany(true)
      } else {
        setNoCompany(false)
      }
    }
  }, [searchTerm, companies])

  // state confirmation search function
  useEffect(() => {
    if (location.myState) {
      const stateId = states.filter((i) =>
        i.state_name.toLowerCase().startsWith(location.myState.toLowerCase())
      )
      setNewLocation({ ...location, myState: stateId[0].id })
    }
  }, [location])

  // state for visibility
  const [Tag2, setTag2] = useState(false)
  const [Tag3, setTag3] = useState(false)
  const [Tag4, setTag4] = useState(false)
  const [Tag5, setTag5] = useState(false)
  const [Tag6, setTag6] = useState(false)
  const [Tag7, setTag7] = useState(false)
  const [Tag8, setTag8] = useState(false)
  const [Tag9, setTag9] = useState(false)

  // brings to top on render
  useEffect(() => {
    getCompanies()
    setProgress({
      prec: 95,
      time: 7,
      prog: 5,
    })
    const element = document.getElementById('Tag1')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'start',
    })
  }, [getCompanies])

  // timers for moves
  let timer = null
  let dotTimer = null

  // 2nd tag
  const time1 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo2, 1000)
  }
  const routeTo2 = () => {
    setTag2(true)
    setProgress({
      prec: 80,
      time: 6,
      prog: 20,
    })
    const element = document.getElementById('Tag2')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'start',
    })
    setThinking(false)
  }

  // 3rd tag
  const time2 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo3, 1000)
  }

  const routeTo3 = () => {
    setTag3(true)
    setProgress({
      prec: 70,
      time: 5,
      prog: 30,
    })
    const element = document.getElementById('Tag3')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    })
    setThinking(false)
  }

  //4th tag
  const time3 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo4, 1000)
  }

  const routeTo4 = () => {
    setTag4(true)
    setProgress({
      prec: 60,
      time: 4,
      prog: 40,
    })
    const element = document.getElementById('Tag4')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'start',
    })
    setThinking(false)
  }

  // 5th tag
  const time4 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo5, 1000)
  }

  const routeTo5 = () => {
    setTag5(true)
    setProgress({
      prec: 50,
      time: 3,
      prog: 50,
    })
    const element = document.getElementById('Tag5')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    })
    setThinking(false)
  }

  // 6th tag
  const time5 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo6, 1000)
  }
  const routeTo6 = () => {
    setTag6(true)
    setProgress({
      prec: 40,
      time: 2,
      prog: 60,
    })
    const element = document.getElementById('Tag6')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    })
    setThinking(false)
  }

  // 7th tag
  const time6 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo7, 1000)
  }
  const routeTo7 = () => {
    setTag7(true)
    setProgress({
      prec: 30,
      time: 1,
      prog: 70,
    })
    const element = document.getElementById('Tag7')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    })
    setThinking(false)
  }

  // 8th tag
  const time7 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo8, 1000)
  }
  const routeTo8 = () => {
    setTag8(true)
    setProgress({
      prec: 20,
      time: 1,
      prog: 85,
    })
    const element = document.getElementById('Tag8')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    })
    setThinking(false)
  }

  // 9th tag
  const time8 = () => {
    clearTimeout(timer)
    clearTimeout(dotTimer)
    dotTimer = setTimeout(dots, 300)
    timer = setTimeout(routeTo9, 1000)
  }
  const routeTo9 = () => {
    setTag9(true)
    setProgress({
      prec: 100,
      time: 0,
      prog: 100,
    })
    const element = document.getElementById('Tag9')
    element.scrollIntoView({
      behavior: 'smooth',
      block: 'start',
    })
    setThinking(false)
  }

  // custom select for offer accepted
  const CustomRadio = React.forwardRef((props, ref) => {
    const { isChecked, isDisabled, value, ...rest } = props
    return (
      <Button
        ref={ref}
        variantColor={isChecked ? 'blue' : 'gray'}
        aria-checked={isChecked}
        role="radio"
        isDisabled={isDisabled}
        {...rest}
      />
    )
  })
  //push to dashboard and send info to DS for review
  const sendInfoToDS = (data) => {
    var dataForDS = JSON.stringify(data)
    axiosToDS()
      .post('/check_review', dataForDS)
      .then((res) => {
        console.log(res)
      })
      .catch((err) => {
        console.log(err)
      })
    history.push('/dashboard')
  }

  //submit handler
  const submitForm = (data) => {
    postReview(localStorage.getItem('userId'), {
      ...data,
      review_type_id: 2,
      overall_rating: starState,
      offer_status_id: offer,
      city: newLocation.myCity,
      state_id: newLocation.myState,
    }).then(() => sendInfoToDS(data))
    ReactGA.event({
      category: 'Review',
      action: `Submit review`,
    })
  }

  return (
    // main container
    <div>
      <Flex justify="center">
        <ProgressHeader progress={progress} />
      </Flex>
      <Flex w="100%" margin="0 auto" minH="100vh">
        {thinking ? (
          <>
            <Flex
              bottom="0"
              position="fixed"
              overflow="hidden"
              zIndex="999"
              pt="5%"
              pl="15%"
            >
              <ThinkingDots />
            </Flex>
          </>
        ) : null}

        {/* form container */}
        <Flex
          w="100%"
          bg="#FFF"
          flexDir="column"
          px="2%"
          pt="10%"
          margin="0 auto"
        >
          {/*--------------- start of form ---------------  */}
          <form onSubmit={handleSubmit(submitForm)}>
            <FormControl isRequired>
              {/* first prompt */}
              <Flex
                id="Tag1"
                align="center"
                h="5%"
                p="1%"
                w="416px"
                mb="8%"
                bg="#F2F6FE"
                rounded="20px"
                data-aos="fade-up"
                data-aos-offset="200"
                data-aos-delay="50"
                data-aos-duration="1000"
                data-aos-easing="ease-in-out"
                data-aos-mirror="true"
                data-aos-once="true"
              >
                <p>Great! I will need some general details to get started.</p>
              </Flex>
              {/* company container  */}
              <Flex w="100%" justify="flex-end">
                {/* company box */}
                <Flex
                  w="459px"
                  h="379px"
                  px="6"
                  py="10"
                  border="1px solid #BBBDC6"
                  rounded="6px"
                  flexDir="column"
                  data-aos="fade-in"
                  data-aos-offset="200"
                  data-aos-delay="1000"
                  data-aos-duration="1500"
                  data-aos-easing="ease-in-out"
                  data-aos-mirror="true"
                  data-aos-once="true"
                  data-aos-anchor="Tag1"
                >
                  <FormLabel>1. Company name</FormLabel>
                  {loadingCompanies ? (
                    <>
                      <Flex justify="center" w="100%">
                        <CustomSpinner />
                      </Flex>
                    </>
                  ) : (
                    <>
                      <Input
                        h="56px"
                        variant="filled"
                        rounded="6px"
                        textTransform="capitalize"
                        type="text"
                        label="company_name"
                        name="company_name"
                        list="company_name"
                        ref={register}
                        onChange={(e) => setSearchTerm(e.target.value)}
                      />
                      <datalist id="company_name">
                        {searchResults.map((company) => (
                          <option value={company.company_name} key={company.id}>
                            {company.company_name}
                          </option>
                        ))}
                      </datalist>
                      {noCompany ? (
                        <>
                          <Link mb="3" color="grey" href="/add-company">
                            Oops, you need to add that company!
                          </Link>
                        </>
                      ) : (
                        <Flex mb="6" />
                      )}
                    </>
                  )}
                  <FormLabel>2. Job title</FormLabel>
                  <Input
                    h="56px"
                    mb="6"
                    rounded="6px"
                    type="text"
                    variant="filled"
                    label="job_title"
                    name="job_title"
                    autoCapitalize="none"
                    ref={register}
                  />
                  <FormLabel>3. Place of interview</FormLabel>
                  <CustomAutoComplete
                    stateHelper={stateSelectorHelper}
                    id="Company Headquarters"
                    name="Company Headquarters"
                    label="Company Headquarters"
                    placeholder="e.g. Los Angeles, CA"
                    textTransform="capitalize"
                    h="56px"
                    mb="6"
                  />
                </Flex>

                {/* avatar */}
                <Flex
                  h="379px"
                  mt="5px"
                  align="flex-end"
                  ml="1%"
                  data-aos="fade-in"
                  data-aos-offset="200"
                  data-aos-delay="1000"
                  data-aos-duration="1500"
                  data-aos-easing="ease-in-out"
                  data-aos-mirror="true"
                  data-aos-once="true"
                  data-aos-anchor="Tag1"
                >
                  <Avatar size="md" src="https://bit.ly/broken-link" />
                </Flex>
              </Flex>
              <Flex
                justify="flex-end"
                mb="5%"
                data-aos="fade-in"
                data-aos-offset="200"
                data-aos-delay="1000"
                data-aos-duration="1500"
                data-aos-easing="ease-in-out"
                data-aos-mirror="true"
                data-aos-once="true"
                data-aos-anchor="Tag1"
              >
                <Button
                  data-cy="interviewReviewFormButton"
                  h="56px"
                  w="17%"
                  mt="2%"
                  rounded="35px"
                  border="1px solid #344CD0"
                  color="#344CD0"
                  backgroundColor="#FFF"
                  _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                  onClick={time1}
                >
                  Next
                </Button>
              </Flex>

              {/* second prompt */}
              {Tag2 ? (
                <>
                  <Flex
                    id="Tag2"
                    align="center"
                    h="5%"
                    w="416px"
                    py="1%"
                    px="1%"
                    mb="2%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Thank you for that information.</p>
                  </Flex>
                  <Flex
                    id="roundsTag"
                    justify="center"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="1000"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      For the quality of this review I will ask some in depth
                      questions. Let’s begin with how many rounds of interviews
                      you had? Please include phone interviews and onsite
                      interviews.
                    </p>
                  </Flex>
                  {/* rounds container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* rounds box */}
                    <Flex
                      w="459px"
                      h="150px"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="2000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="roundsTag"
                    >
                      <FormLabel>Select rounds of interviews</FormLabel>
                      <Select
                        h="56px"
                        mb="6"
                        rounded="6px"
                        variant="filled"
                        label="interview_rounds"
                        name="interview_rounds"
                        placeholder="Select one"
                      >
                        <option value={1}>1</option>
                        <option value={2}>2</option>
                        <option value={3}>3</option>
                        <option value={4}>4</option>
                        <option value={5}>5</option>
                        <option value={6}>6</option>
                        <option value={7}>7</option>
                        <option value={8}>8</option>
                        <option value={9}>9</option>
                        <option value={10}>10</option>
                      </Select>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="150px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="2000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="roundsTag"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="200"
                    data-aos-delay="2000"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="roundsTag"
                  >
                    <Button
                      data-cy="interviewReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time2}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* third prompt */}
              {Tag3 ? (
                <>
                  <Flex
                    id="Tag3"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      To better assist you I have included several different
                      interview types to choose from. Please select all types
                      that best describes the interview process you went
                      through.
                    </p>
                  </Flex>
                  <Flex w="100%" justify="flex-end">
                    {/* types of interview box */}
                    <Flex
                      w="459px"
                      h="220px"
                      px="6"
                      py="8"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="1000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag3"
                    >
                      <FormLabel>Select types of interviews</FormLabel>
                      <CheckboxGroup>
                        <Flex>
                          <Flex direction="column" pr="0.5%">
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="phone_interview"
                              ref={register}
                            >
                              Phone interview
                            </Checkbox>
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="resume_review"
                              ref={register}
                            >
                              Resume review
                            </Checkbox>
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="take_home_assignments"
                              ref={register}
                            >
                              Take home assignments
                            </Checkbox>
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="online_coding_assignments"
                              ref={register}
                            >
                              Online coding tests
                            </Checkbox>
                          </Flex>
                          <Flex direction="column">
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="portfolio_review"
                              ref={register}
                            >
                              Portfolio review
                            </Checkbox>
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="screen_share"
                              ref={register}
                            >
                              Screen share
                            </Checkbox>
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="open_source_contribution"
                              ref={register}
                            >
                              Open source contribution
                            </Checkbox>
                            <Checkbox
                              size="md"
                              border="rgba(72, 72, 72, 0.1)"
                              name="side_projects"
                              ref={register}
                            >
                              Side projects
                            </Checkbox>
                          </Flex>
                        </Flex>
                      </CheckboxGroup>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="220px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="0"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      id="Tag3"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="120"
                    data-aos-delay="0"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    id="Tag3"
                  >
                    <Button
                      data-cy="interviewReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time3}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* fourth prompt */}
              {Tag4 ? (
                <>
                  <Flex
                    id="Tag4"
                    align="center"
                    p="1%"
                    mb="2%"
                    h="5%"
                    w="416px"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Great!</p>
                  </Flex>
                  <Flex
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="1200"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Use this section to describe your interview experience
                      using the options selected above for reference.
                    </p>
                  </Flex>
                  <Flex w="100%" justify="flex-end">
                    {/* long hand interview box */}
                    <Flex
                      w="459px"
                      h="242px"
                      px="6"
                      py="8"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="2600"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag4"
                    >
                      <FormLabel>Describe the interview process</FormLabel>
                      <Textarea
                        variant="filled"
                        h="144px"
                        rowsMax={6}
                        type="text"
                        name="comment"
                        placeholder="What questions came up? What did you discuss? What did you come away with from this interview? "
                        rounded="6px"
                        resize="none"
                        ref={register}
                        data-cy="interviewComment"
                      />
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="242px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="2600"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag4"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="120"
                    data-aos-delay="2600"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="Tag4"
                  >
                    <Button
                      data-cy="interviewReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time4}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* 5th prompt */}
              {Tag5 ? (
                <>
                  <Flex
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="2%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Thanks! Your opinion is very valuable and helps Lambda
                      job-seekers be better prepared.
                    </p>
                  </Flex>
                  <Flex
                    id="Tag5"
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="1000"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Please provide a difficulty rating for your interview. How
                      easy or hard was the interview?
                    </p>
                  </Flex>
                  {/* diff container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* diff box */}
                    <Flex
                      w="459px"
                      h="150px"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="120"
                      data-aos-delay="3000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag5"
                    >
                      <FormLabel>Rate the difficulty</FormLabel>
                      <Select
                        h="56px"
                        mb="6"
                        rounded="6px"
                        variant="filled"
                        label="difficulty_rating"
                        name="difficulty_rating"
                        placeholder="Select one"
                        ref={register}
                      >
                        <option value={5}>Very difficult</option>
                        <option value={4}>Difficult</option>
                        <option value={3}>Average</option>
                        <option value={2}>Easy</option>
                        <option value={1}>Very easy</option>
                      </Select>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="150px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="3000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="Tag5"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="8%"
                    data-aos="fade-in"
                    data-aos-offset="200"
                    data-aos-delay="2700"
                    data-aos-duration="1500"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="Tag5"
                  >
                    <Button
                      data-cy="interviewReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time5}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* 6th prompt */}
              {Tag6 ? (
                <>
                  <Flex
                    id="Tag6"
                    justify="center"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Your review is almost complete. Tell me how your interview
                      process ended. Did you recieve an offer?
                    </p>
                  </Flex>
                  {/* offer container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* diff box */}
                    <Flex
                      w="459px"
                      h="176px"
                      mb="8%"
                      py="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Flex w="100%" justify="center">
                        <RadioButtonGroup
                          display="flex"
                          flexDir="column"
                          spacing={0}
                          label="offer_status_id"
                          name="offer_status_id"
                          defaultValue="1"
                          onChange={(val) => {
                            setOffer(val)
                            time6()
                          }}
                        >
                          <CustomRadio value="1" w="100%">
                            No offer
                          </CustomRadio>
                          <CustomRadio value="2" w="100%" data-cy="accepted">
                            Accepted
                          </CustomRadio>
                          <CustomRadio value="3" w="100%">
                            Declined
                          </CustomRadio>
                        </RadioButtonGroup>
                      </Flex>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="176px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1000"
                      data-aos-duration="1500"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                </>
              ) : null}
              {/* 7th prompt */}
              {Tag7 ? (
                <>
                  <Flex
                    id="Tag7"
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="2%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Thank you for that information.</p>
                  </Flex>
                  <Flex
                    id="salaryTag"
                    align="center"
                    h="5%"
                    p="1%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="1500"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      If you were offered, asked, or negotiated a salary,
                      including it in your review increases the helpfulness of
                      this post.
                    </p>
                  </Flex>
                  {/* salary container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* salary box */}
                    <Flex
                      w="459px"
                      h="150px"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      justify="space-evenly"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1000"
                      data-aos-duration="3000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="salaryTag"
                    >
                      <FormLabel>Salary</FormLabel>
                      <InputGroup>
                        <InputLeftElement
                          mb="4"
                          py="28px"
                          color="gray.300"
                          fontSize="1.2em"
                          children="$"
                        />
                        <Input
                          h="56px"
                          rounded="6px"
                          type="number"
                          variant="filled"
                          label="salary"
                          name="salary"
                          autoCapitalize="none"
                          ref={register}
                        />
                      </InputGroup>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="150px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1000"
                      data-aos-duration="3000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                      data-aos-anchor="salaryTag"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                  <Flex
                    justify="flex-end"
                    mb="5%"
                    data-aos="fade-in"
                    data-aos-offset="200"
                    data-aos-delay="1000"
                    data-aos-duration="3000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="salaryTag"
                  >
                    <Button
                      data-cy="interviewReviewFormButton"
                      h="56px"
                      w="17%"
                      mt="2%"
                      rounded="35px"
                      border="1px solid #344CD0"
                      color="#344CD0"
                      backgroundColor="#FFF"
                      _hover={{ backgroundColor: '#F2F6FE', cursor: 'pointer' }}
                      onClick={time7}
                    >
                      Next
                    </Button>
                  </Flex>
                </>
              ) : null}
              {/* 8th prompt */}
              {Tag8 ? (
                <>
                  <Flex
                    id="Tag8"
                    align="center"
                    h="5%"
                    w="416px"
                    p="1%"
                    mb="2%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>Thanks!</p>
                  </Flex>
                  <Flex
                    id="ratingTag"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="900"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                  >
                    <p>
                      Last question. How would you rate your overall interview
                      experience?
                    </p>
                  </Flex>
                  {/* overall container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* overall box */}
                    <Flex
                      w="459px"
                      h="136px"
                      mb="8%"
                      p="6"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <FormLabel mb="4">Rate overall experience</FormLabel>
                      <Flex justify="center" w="100%">
                        <BeautyStars
                          name="interviewRating"
                          value={starState}
                          activeColor="#344CD0"
                          onChange={(value) => {
                            setStarState(value)
                            time8()
                          }}
                        />
                      </Flex>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="136px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                </>
              ) : null}
              {Tag9 ? (
                <>
                  <Flex
                    id="Tag9"
                    align="center"
                    p="1%"
                    h="5%"
                    w="416px"
                    mb="8%"
                    bg="#F2F6FE"
                    rounded="20px"
                    data-aos="fade-right"
                    data-aos-offset="200"
                    data-aos-delay="50"
                    data-aos-duration="1000"
                    data-aos-easing="ease-in-out"
                    data-aos-mirror="true"
                    data-aos-once="true"
                    data-aos-anchor="#ratingTag"
                  >
                    <p>Thank you! Don’t forget to hit submit.</p>
                  </Flex>
                  {/* submit container  */}
                  <Flex w="100%" justify="flex-end">
                    {/* submit box */}
                    <Flex
                      w="459px"
                      h="136px"
                      mb="8%"
                      p="6"
                      justify="center"
                      align="center"
                      border="1px solid #BBBDC6"
                      rounded="6px"
                      flexDir="column"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Button
                        bg="#344CD0"
                        color="white"
                        type="submit"
                        isLoading={formState.isSubmitting}
                        rounded="6px"
                        border="none"
                        data-cy="interviewReviewSubmit"
                      >
                        Submit
                      </Button>
                    </Flex>
                    {/* avatar */}
                    <Flex
                      h="136px"
                      align="flex-end"
                      ml="1%"
                      data-aos="fade-in"
                      data-aos-offset="200"
                      data-aos-delay="1500"
                      data-aos-duration="1000"
                      data-aos-easing="ease-in-out"
                      data-aos-mirror="true"
                      data-aos-once="true"
                    >
                      <Avatar size="md" src="https://bit.ly/broken-link" />
                    </Flex>
                  </Flex>
                </>
              ) : null}
            </FormControl>
          </form>
        </Flex>
      </Flex>
    </div>
  )
}
Example #5
Source File: ReviewCard.js    From allay-fe with MIT License 4 votes vote down vote up
ReviewCard = ({ review, history, deleteReview, isAdmin }) => {
  const singleReview = review

  //deletes the review in question
  const submitDelete = (user_id, review_id) => {
    if (review.user_id && review.review_id) {
      deleteReview(review.user_id, review.review_id).then(() => {
        // window.location.reload();
        history.push('/dashboard')
      })
    } else {
      deleteReview(user_id, review_id).then(() => {
        // window.location.reload();
        history.push('/dashboard')
      })
    }

    ReactGA.event({
      category: 'Review Delete',
      action: `Submit delete`,
    })
  }
  // useEffect(() => {}, [submitDelete])
  // basic usage for the SingleReview modal
  const { isOpen, onOpen, onClose } = useDisclosure()
  const loginId = localStorage.getItem('userId')

  // specifically for the cancel review delete button functionality
  const [isOpen2, setIsOpen2] = useState()
  const onClose2 = () => setIsOpen2(false)
  const cancelRef = useRef()

  //routes to single review
  const navToEditRoute = () =>
    review.review_type === 'Company'
      ? history.push({
          pathname: `/dashboard/review/${review.review_id}`,
          state: singleReview,
        })
      : history.push(`/dashboard/interview/${review.review_id}`)

  //routes to user's profile page
  const navToProfile = (e) => {
    e.preventDefault()
    history.push(`/profile/${review.user_id}`)
  }

  // adjust logo for api call
  // const adjustedName = review.company_name.replace(' ', '+')

  // adjust date of posting
  let tempDate = new Date(review.created_at).toUTCString()
  const tempDay = tempDate.split(' ').slice(1, 2)
  const tempMonth = tempDate.split(' ').slice(2, 3)
  const tempYear = tempDate.split(' ').slice(3, 4)
  const adjustedDate = `${tempMonth} ${tempDay}, ${tempYear}`

  //track name font color picker
  const trackFontColor = (trackName) => {
    switch (trackName) {
      case 'DS':
        return '#35694F'
        break
      case 'WEB':
        return '#474EA7'
        break
      case 'iOS' || 'IOS':
        return '#8E3D19'
        break
      case 'Android':
        return '#4B3569'
        break
      case 'UX':
        return '#9F3A5A'
        break
      default:
        return
    }
  }
  //track name background color picker
  const trackColorPicker = (trackName) => {
    switch (trackName) {
      case 'DS':
        return '#D3F2CD'
        break
      case 'WEB':
        return '#DBEBFD'
        break
      case 'iOS' || 'IOS':
        return '#F4E6BE'
        break
      case 'Android':
        return '#E9D9FF'
        break
      case 'UX':
        return '#F9E3DE'
        break
      default:
        return
    }
  }

  //remove white space from company name for logo usage
  let stripped = review.company_name.replace(/ /g, '')
  let com = '.com'
  const logo = stripped.concat(com)

  const created = moment(review.created_at).fromNow()

  return (
    <>
      {/* ------------------------------------------------------------------------------------------------ */}
      {/* ---------------------------------------Modal Cards (for edit)----------------------------------- */}
      {/* ------------------------------------------------------------------------------------------------ */}

      <Modal
        preserveScrollBarGap
        isOpen={isOpen}
        onClose={onClose}
        size="950px"
      >
        <ModalOverlay />
        <ModalContent w="100%" wrap="nowrap">
          <ModalCloseButton
            data-cy="reviewCloseButton"
            background="none"
            border="none"
          />

          {/* LEFT SIDE MODAL */}
          <Flex
            direction="column"
            justify="space-between"
            align="flex-start"
            position="relative"
            w="261px"
            height="100%"
            top="0"
            left="0"
            pb="50px"
            pt="35px"
            pl="40px"
            bg="#F2F6FE"
            borderRadius="0px 40px 40px 0px"
          >
            {/* USER AVATAR AND NAME */}
            <Flex
              justify="space-evenly"
              align="center"
              mb="30px"
              onClick={navToProfile}
              style={{ cursor: 'pointer' }}
            >
              {review.user_profile_image === 'h' ? (
                <Image
                  size="40px"
                  mr="7px"
                  style={{ opacity: '0.6' }}
                  src={require('../../icons/user.svg')}
                />
              ) : (
                <Image
                  size="40px"
                  mr="7px"
                  style={{ opacity: '0.6', borderRadius: '50%' }}
                  src={review.user_profile_image}
                />
              )}
              <Text color="#131C4D" fontSize="14px" fontFamily="Muli">
                By {review.user_first_name} {review.user_last_name}
              </Text>
            </Flex>
            {/* COMPANY LOGO AND REVIEW STARS */}
            <Flex
              direction="column"
              justify="center"
              align="flex-start"
              mb="20px"
            >
              <Image
                w="148px"
                h="70px"
                src={`https://logo.clearbit.com/${
                  review.logo !== 'unknown' ? review.logo : logo
                }`}
                fallbackSrc={`http://samscct.com/wp-content/uploads/2014/09/no-logo.png`}
              />

              <Flex mt="13px">
                {Array(5)
                  .fill('')
                  .map((_, i) => (
                    <Icon
                      name="star"
                      key={i}
                      color={i < review.overall_rating ? '#F9DC76' : '#DADADD'}
                      ml="4px"
                    />
                  ))}
              </Flex>
            </Flex>
            {/* COMPANY LOCATION AND NAME */}
            <Flex
              direction="column"
              justify="center"
              align="flex-start"
              mb="40px"
            >
              <Flex mb="5px">
                <Box as={GoLocation} size="21px" color="#BBBDC6" mr="7px" />
                <Text color="#BBBDC6" fontSize="14px" fontFamily="Muli">
                  {review.city}, {review.state_name}
                </Text>
              </Flex>
              <Flex>
                <Box as={FaRegBuilding} size="21px" color="#BBBDC6" mr="7px" />
                <Text color="#BBBDC6" fontSize="14px" fontFamily="Muli">
                  {review.company_name}
                </Text>
              </Flex>
            </Flex>
            {/* JOB/INTERVIEW INFORMATION */}
            <Flex direction="column" justify="space-between" align="flex-start">
              <Flex
                direction="column"
                justify="flex-start"
                align="flex-start"
                mb="20px"
              >
                <Text
                  color="#131C4C"
                  fontSize="18px"
                  fontFamily="Muli"
                  fontWeight="bold"
                >
                  {review.job_title}
                </Text>
                <Text
                  color="#9194A8"
                  fontSize="14px"
                  fontFamily="Muli"
                  fontWeight="bold"
                >
                  Job title
                </Text>
              </Flex>
              <Flex
                direction="column"
                justify="flex-start"
                align="flex-start"
                mb="20px"
              >
                <Text
                  color="#131C4C"
                  fontSize="18px"
                  fontFamily="Muli"
                  fontWeight="bold"
                >{`${review.salary}.00`}</Text>
                <Text
                  color="#9194A8"
                  fontSize="14px"
                  fontFamily="Muli"
                  fontWeight="bold"
                >
                  Salary
                </Text>
              </Flex>
              <Flex
                direction="column"
                justify="flex-start"
                align="flex-start"
                mb="20px"
              >
                {review.review_type === 'Company' ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    {review.work_status}
                  </Text>
                ) : review.difficulty_rating === 1 ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    Very easy
                  </Text>
                ) : review.difficulty_rating === 2 ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    Easy
                  </Text>
                ) : review.difficulty_rating === 3 ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    Somewhat easy
                  </Text>
                ) : review.difficulty_rating === 4 ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    Somewhat hard
                  </Text>
                ) : review.difficulty_rating === 5 ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    Hard
                  </Text>
                ) : (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    N/A
                  </Text>
                )}

                <Text
                  color="#9194A8"
                  fontSize="14px"
                  fontFamily="Muli"
                  fontWeight="bold"
                >
                  {review.review_type === 'Company'
                    ? 'Status'
                    : 'Interview difficulty'}
                </Text>
              </Flex>
              <Flex
                direction="column"
                justify="flex-start"
                align="flex-start"
                mb="20px"
              >
                {review.review_type === 'Company' ? (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    {review.start_date} -{' '}
                    {review.end_date ? review.end_date : 'Present'}
                  </Text>
                ) : (
                  <Text
                    color="#131C4C"
                    fontSize="18px"
                    fontFamily="Muli"
                    fontWeight="bold"
                  >
                    {review.offer_status}
                  </Text>
                )}
                <Text
                  color="#9194A8"
                  fontSize="14px"
                  fontFamily="Muli"
                  fontWeight="bold"
                >
                  {review.review_type === 'Company' ? 'Dates' : 'Job offer?'}
                </Text>
              </Flex>
            </Flex>
            <Flex>
              {Number(loginId) === Number(review.user_id) ? (
                <Image
                  src={require('../../icons/edit.png')}
                  onClick={navToEditRoute}
                  cursor="pointer"
                  size="1.5em"
                  mr="12px"
                  data-cy="editModalReview"
                />
              ) : null}
              {Number(loginId) === Number(review.user_id) ? (
                <Image
                  data-cy="deleteModalReview"
                  src={require('../../icons/trash.png')}
                  onClick={() => setIsOpen2(true)}
                  cursor="pointer"
                  size="1.5em"
                />
              ) : null}
              <AlertDialog
                isOpen={isOpen2}
                leastDestructiveRef={cancelRef}
                onClose={onClose2}
              >
                <AlertDialogOverlay />
                <AlertDialogContent>
                  <AlertDialogHeader fontSize="lg" fontWeight="bold">
                    Delete review
                  </AlertDialogHeader>

                  <AlertDialogBody>
                    Are you sure? You can't undo this action afterwards.
                  </AlertDialogBody>

                  <AlertDialogFooter>
                    <Flex
                      align="center"
                      justify="center"
                      height="56px"
                      width="30%"
                      color="#344CD0"
                      fontSize="16px"
                      fontWeight="bold"
                      ref={cancelRef}
                      onClick={onClose2}
                    >
                      Cancel
                    </Flex>
                    <Button
                      data-cy="confirmDeleteModalReview"
                      h="56px"
                      rounded="10px"
                      border="none"
                      color="white"
                      variantColor="red"
                      ml={3}
                      onClick={submitDelete}
                    >
                      Delete
                    </Button>
                  </AlertDialogFooter>
                </AlertDialogContent>
              </AlertDialog>
            </Flex>
          </Flex>
          {/* RIGHT SIDE MODAL */}
          <Flex
            direction="column"
            justify="flex-start"
            align="flex-start"
            position="absolute"
            w="575px"
            h="100%"
            ml="291px"
            mb="50px"
            mt="35px"
          >
            {/* TYPE OF REVIEW, TRACK, DATE POSTED */}
            <Flex justify="space-between" w="100%" mb="70px">
              <Flex justify="space-between">
                <Box as={MdRateReview} size="24px" color="#BBBDC6" mr="4px" />
                <Text
                  mr="40px"
                  color="#131C4D"
                  fontFamily="Muli"
                  fontSize="14px"
                >
                  {review.review_type === 'Company'
                    ? 'Company Review'
                    : 'Interview Review'}
                </Text>
                <Badge
                  backgroundColor={
                    review.track_name === 'WEB'
                      ? '#DBEBFD'
                      : review.track_name === 'iOS'
                      ? '#F4E6BE'
                      : review.track_name === 'UX'
                      ? '#F9E3DE'
                      : review.track_name === 'DS'
                      ? '#D3F2CD'
                      : review.track_name === 'Android'
                      ? '#E9D9FF'
                      : '#DBEBFD'
                  }
                  color={
                    review.track_name === 'WEB'
                      ? '#474EA7'
                      : review.track_name === 'iOS'
                      ? '#8E3D19'
                      : review.track_name === 'UX'
                      ? '#9F3A5A '
                      : review.track_name === 'DS'
                      ? '#35694F'
                      : review.track_name === 'Android'
                      ? '#4B3569'
                      : '#474EA7'
                  }
                  fontSize="16px "
                  fontWeight="light"
                  fontFamily="Muli"
                  rounded="full"
                  px="15px"
                  pt="2px"
                  overflow="hidden"
                >
                  {review.track_name}
                </Badge>
              </Flex>
              <Text color="#9194A8" fontSize="14px" fontFamily="Muli">
                {adjustedDate}
              </Text>
            </Flex>
            {/* INTERVIEW TYPES */}
            {review.review_type === 'Interview' ? (
              <Flex color="#9194A8" fontSize="14px" fontFamily="Muli">
                Interviews
              </Flex>
            ) : null}
            {review.review_type === 'Interview' ? (
              <Flex
                justify="flex-start"
                wrap="wrap"
                whiteSpace="nowrap"
                width="100%"
                mb="50px"
              >
                {review.phone_interview ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Phone screening
                  </Flex>
                ) : null}
                {review.resume_review ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Resume review
                  </Flex>
                ) : null}
                {review.take_home_assignments ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Take home assignments
                  </Flex>
                ) : null}
                {review.online_coding_assignments ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Online coding assignments
                  </Flex>
                ) : null}
                {review.portfolio_review ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Portfolio review
                  </Flex>
                ) : null}
                {review.screen_share ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Screen share
                  </Flex>
                ) : null}
                {review.open_source_contribution ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Open source contribution
                  </Flex>
                ) : null}
                {review.side_projects ? (
                  <Flex
                    as="p"
                    color="#131C4D"
                    fontSize="16px"
                    fontFamily="Muli"
                    bg="#EAF0FE"
                    px="1%"
                    mt="1.5%"
                    mr="3%"
                    rounded="3px"
                  >
                    Side projects
                  </Flex>
                ) : null}
              </Flex>
            ) : null}
            {/* DESCRIPTION */}
            <Flex direction="column">
              <Text color="#9194A8" fontSize="14px" fontFamily="Muli" mb="7px">
                Description
              </Text>
              <Text
                color="#131C4D"
                fontSize="16px"
                fontFamily="Muli"
                lineHeight="23px"
              >
                {review.comment}
              </Text>
            </Flex>
          </Flex>
          {/* ADMIN BUTTONS */}
          <ModalFooter
            w="689px"
            ml="261px"
            mb="20px"
            position="absolute"
            bottom="0"
          >
            <BlockButton user_id={review.user_id} isAdmin={isAdmin} />
            <ContentButton
              isAdmin={isAdmin}
              submitDelete={submitDelete}
              user_id={review.user_id}
              review_id={review.review_id}
            />
          </ModalFooter>
        </ModalContent>
      </Modal>

      {/* ------------------------------------------------------------------------------------------------ */}
      {/* ---------------------------------------DashBoard Cards------------------------------------------ */}
      {/* ------------------------------------------------------------------------------------------------ */}

      {/* Review container */}
      <PseudoBox
        mb="3%"
        mx="2.5%"
        px="1%"
        py="1%"
        border="1px solid #E9F0FF"
        width="408px"
        height="309px"
        borderRadius="12px"
        display="flex"
        flexDir="column"
        _hover={{ bg: '#E9F0FF' }}
        onClick={onOpen}
        data-cy="modalCard"
      >
        {/* Review content container */}
        <Flex flexDir="column">
          {/* headline container  */}
          <Flex maxW="530px">
            <Flex
              height="115px"
              justify="space-between"
              maxW="391px"
              p="2% 5%"
              wrap="wrap"
            >
              <Flex maxW="300px">
                {review.review_type === 'Company' ? (
                  <Image
                    width="106px"
                    height="40px"
                    src={`https://logo.clearbit.com/${
                      review.logo !== 'unknown' ? review.logo : logo
                    }`}
                    fallbackSrc={`http://samscct.com/wp-content/uploads/2014/09/no-logo.png`}
                  />
                ) : (
                  <Text style={{ fontSize: '22px', fontWeight: 'bold' }}>
                    {' '}
                    {review.job_title}
                  </Text>
                )}
              </Flex>
              <i
                style={{ alignSelf: 'center', fontSize: '22px', opacity: '.2' }}
                className="far fa-heart"
              ></i>
              <Flex justify="space-between" width="391px" pt="2%">
                <Flex align="center">
                  {Array(5)
                    .fill('')
                    .map((_, i) => (
                      <Icon
                        name="star"
                        key={i}
                        color={i < review.overall_rating ? '#F9DC76' : '#fff'}
                        ml="8%"
                      />
                    ))}
                </Flex>
                <Flex>
                  <Text
                    style={{
                      color: '#BBBDC6',
                      fontSize: '14px',
                      fontWeight: 'bold',
                    }}
                  >
                    {created}
                  </Text>
                  {/* )} */}
                </Flex>
              </Flex>
              <Flex width="391px" height="45px" pt="15px">
                <Box as={MdRateReview} size="24px" color="#BBBDC6" mr="4px" />
                <span style={{ paddingLeft: '5px' }}>
                  {review.review_type} review
                </span>
              </Flex>
            </Flex>
          </Flex>
        </Flex>
        {/* summary container */}
        <Flex width="100%" height="100px">
          <Flex m="10px 20px" w="348px" h="55px" overflow="hidden">
            <p style={{ fontSize: '14px', color: 'gray' }}>{review.comment}</p>
          </Flex>
        </Flex>
        <Flex
          margin="0px 12px 0px 20px"
          align="center"
          pt="5px"
          height="40px"
          justify="space-between"
        >
          <Flex alignItems="center">
            <Avatar size="md" src={review.user_profile_image} />
            <Text pl="5px" fontSize="14px">
              {review.user_first_name} {review.user_last_name}
            </Text>
          </Flex>
          <Badge
            backgroundColor={trackColorPicker(review.track_name)}
            color={trackFontColor(review.track_name)}
            fontSize="1em"
            fontWeight="light"
            rounded="full"
            textAlign="center"
            pt="5px"
            overflow="hidden"
            ml="10px"
            width="58px"
            height="36px"
          >
            <span>{review.track_name}</span>
          </Badge>
        </Flex>
      </PseudoBox>
    </>
  )
}
Example #6
Source File: EditUserProfile.js    From allay-fe with MIT License 4 votes vote down vote up
EditUserProfile = ({ match, history, userData, updateUser }) => {
  const id = match.params.id
  const userId = window.localStorage.getItem('userId')
  // creating form state, setting default values
  const { handleSubmit, errors, register, formState } = useForm({
    defaultValues: {
      firstName: userData.first_name,
      lastName: userData.last_name,
      gradMonth: userData.graduated ? userData.graduated.slice(5, 7) : null,
      gradYear: userData.graduated ? userData.graduated.slice(0, 4) : null,
      highest_ed: userData.highest_ed,
      field_of_study: userData.field_of_study,
      employed_company: userData.employed_company,
      employed_title: userData.employed_title,
      workMonth: userData.employed_start
        ? userData.employed_start.slice(5, 7)
        : null,
      workYear: userData.employed_start
        ? userData.employed_start.slice(0, 4)
        : null,
      resume: userData.resume ? userData.resume : null,
      portfolio_URL: userData.portfolio ? userData.portfolio : null,
      linked_in: userData.linked_in ? userData.linked_in : null,
      slack: userData.slack ? userData.slack : null,
      github: userData.github ? userData.github : null,
      dribble: userData.dribble ? userData.dribble : null,
      profile_image: userData.profile_image ? userData.profile_image : null,
    },
  })

  //location state/helpers
  const [location, setLocation] = useState({})
  const [newLocation, setNewLocation] = useState({})
  const stateHelper = (value) => {
    setLocation(value)
  }
  // cloudinary stuff
  const [newProfile_image, setNewProfile_Image] = useState('')
  const [newProfile_resume, setNewProfile_resume] = useState('')

  // graduated state/helpers
  const [graduated, setGraduated] = useState(userData.graduated ? true : false)
  const isGraduated = () => {
    setGraduated(true)
  }
  const notGraduated = () => {
    setGraduated(false)
  }
  // employed state/helpers
  const [employed, setEmployed] = useState(
    userData.employed_start ? true : false
  )
  const isEmployed = () => {
    setEmployed(true)
  }
  const notEmployed = () => {
    setEmployed(false)
  }

  //radio button state
  const [priorExp, setPriorExp] = useState(
    userData.prior_experience ? userData.prior_experience : false
  )
  const [tlsl, setTlsl] = useState(
    userData.tlsl_experience ? userData.tlsl_experience : false
  )
  const [remote, setRemote] = useState(
    userData.employed_remote ? userData.employed_remote : false
  )

  //location helper
  useEffect(() => {
    setNewLocation({ ...location, myState: location.myState })
    // removes numbers, commas, and whitespaces from city
    if (location.myCity) {
      if (/^[0-9]+$/.test(location.myCity) || /\s/.test(location.myCity)) {
        const tempCity = location.myCity
        setNewLocation({
          ...location,
          myCity: tempCity.replace(/^[\s,\d]+/, ''),
        })
      }
    }
  }, [location])

  ///info for slack ID
  const info = (
    <Box>
      <Image
        objectFit="fit"
        width="300px"
        height="300px"
        src={require('../../../icons/slack.gif')}
        alt="slack info"
      />
    </Box>
  )

  //validation
  function validateFirstName(value) {
    let error
    let nameRegex = /^[0-9*#+]+$/
    if (!value) {
      error = 'First Name is required'
    } else if (value.length < 2) {
      error = 'First Name must be at least 2 characters'
    } else if (nameRegex.test(value)) {
      error = 'First Name can only contain letters'
    }
    return error || true
  }

  function validateLastName(value) {
    let error
    let nameRegex = /^[0-9*#+]+$/
    if (!value) {
      error = 'Last Name is required'
    } else if (value.length < 2) {
      error = 'Last Name must be at least 2 characters'
    } else if (nameRegex.test(value)) {
      error = 'Last Name can only contain letters'
    }
    return error || true
  }

  function validateFieldOfStudy(value) {
    let error
    let nameRegex = /^[0-9*#+]+$/
    if (nameRegex.test(value)) {
      error = 'Field of study can only contain letters'
    }
    return error || true
  }
  //end validation

  //add image to cloudinary
  const updateImage = async (e) => {
    const files = e.target.files
    const data = new FormData()
    data.append('file', files[0])
    data.append('upload_preset', 'upload')
    const res = await fetch(
      '	https://api.cloudinary.com/v1_1/takija/image/upload',
      {
        method: 'POST',
        body: data,
      }
    )
    const file = await res.json()
    setNewProfile_Image(...newProfile_image, file.secure_url)
  }

  //upload resume to cloudinary
  const updateResume = async (e) => {
    const files = e.target.files
    const data = new FormData()
    data.append('file', files[0])
    data.append('upload_preset', 'upload')
    const res = await fetch(
      '	https://api.cloudinary.com/v1_1/takija/image/upload',
      {
        method: 'POST',
        body: data,
      }
    )
    const file = await res.json()
    setNewProfile_resume(...newProfile_resume, file.secure_url)
  }

  // FORM SUBMISSION
  const submitForm = (creds) => {
    // correcting grad date format
    let graduated = null
    if (creds.gradMonth && creds.gradYear) {
      graduated = `${creds.gradYear}-${creds.gradMonth}-01`
    }

    // correcting employed date format
    let employed_start = null
    if (creds.workMonth && creds.workYear) {
      employed_start = `${creds.workYear}-${creds.workMonth}-01`
    }
    // formatting the signup state to match the back end columns
    updateUser(id, {
      first_name: creds.firstName,
      last_name: creds.lastName,
      location: newLocation
        ? `${newLocation.myCity || userData.location} ${newLocation.myState}`
        : creds.location,
      graduated: graduated,
      highest_ed: creds.highest_ed || null,
      field_of_study: creds.field_of_study || null,
      prior_experience: creds.prior_experience
        ? JSON.parse(creds.prior_experience)
        : false,
      tlsl_experience: creds.tlsl_experience
        ? JSON.parse(creds.tlsl_experience)
        : false,
      employed_company: creds.employed_company || null,
      employed_title: creds.employed_title || null,
      employed_remote: creds.employed_remote
        ? JSON.parse(creds.employed_remote)
        : false,
      employed_start: employed_start,
      resume: newProfile_resume || userData.resume,
      linked_in: creds.linked_in || null,
      slack: creds.slack || null,
      github: creds.github || null,
      dribble: creds.dribble || null,
      profile_image: newProfile_image || userData.profile_image,
      portfolio: creds.portfolio_URL || null,
    }).then(() => history.push(`/profile/${id}`))

    ReactGA.event({
      category: 'User',
      action: `Button Update Profile`,
    })
  }

  const returnToProfile = (e) => {
    e.preventDefault()
    history.push(`/profile/${id}`)
  }

  //see profilePage component for details
  const lazySolution =
    userData.location != 'undefined undefined ' &&
    userData.location != 'undefined undefined'
      ? userData.location
      : 'Enter your location'

  return (
    <>
      {/* //Top Section */}

      <Flex
        maxW="1440px"
        w="100%"
        px="40px"
        py="28px"
        m="0 auto"
        justify="space-between"
        align="center"
        borderBottom="1px solid #EAF0FE"
      >
        <Flex>
          <Link
            style={{
              textDecoration: 'none',
              color: '#344CD0',
              fontFamily: 'Poppins',
              fontWeight: '600',
              fontSize: '32px',
            }}
            to="/dashboard"
          >
            <h1> Allay </h1>
          </Link>
        </Flex>

        {Number(userId) === Number(userData.id) ? (
          <Flex>
            {userData.profile_image === 'h' ? (
              <Image
                size="58px"
                style={{ opacity: '0.6' }}
                src={require('../../../icons/user.svg')}
              />
            ) : (
              <Image
                size="58px"
                style={{ opacity: '0.6', borderRadius: '50%' }}
                src={userData.profile_image}
              />
            )}
          </Flex>
        ) : null}
      </Flex>
      <Flex
        w="833px"
        mx="auto"
        justify="center"
        align="center"
        flexDir="column"
      >
        <form onSubmit={handleSubmit(submitForm)}>
          <Flex
            w="833px"
            p="6"
            flexDir="column"
            background="#FDFDFF"
            justify="center"
          >
            <Flex w="653px" justify="space-between" my="68px" mx="auto">
              <Text
                as="h2"
                fontSize="24px"
                fontWeight="600"
                fontFamily="Poppins"
              >
                Edit Profile
              </Text>
              <Flex w="150px" justify="space-between">
                <Text
                  as="h3"
                  fontFamily="Muli"
                  fontSize="22px"
                  fontWeight="normal"
                  color="#9194A8"
                  style={{ cursor: 'pointer' }}
                  onClick={returnToProfile}
                >
                  Cancel
                </Text>
                <Text
                  as="h3"
                  fontFamily="Muli"
                  fontSize="22px"
                  fontWeight="bold"
                  color="#344CD0"
                  style={{ cursor: 'pointer' }}
                  onClick={handleSubmit(submitForm)}
                >
                  Save
                </Text>
              </Flex>
            </Flex>

            {/* CLOUDINARY IMAGE UPLOAD */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb="55px"
              justify="space-evenly"
              alignItems="center"
            >
              {!newProfile_image ? (
                <Avatar
                  size="2xl"
                  name={userData.first_name}
                  style={{ borderRadius: '50%' }}
                  src={userData.profile_image}
                />
              ) : (
                <Avatar
                  size="2xl"
                  style={{ borderRadius: '50%' }}
                  src={newProfile_image}
                />
              )}

              <Flex alignItems="center">
                <input
                  type="file"
                  filename="image"
                  placeholder="Upload profile picture"
                  onChange={updateImage}
                  style={{
                    opacity: '1',
                    width: '105px',
                    color: 'transparent',
                    backgroundColor: 'transparent',
                  }}
                />
                {!newProfile_image ? (
                  <label htmlFor="files" className="btn">
                    Update profile image
                  </label>
                ) : (
                  <i
                    style={{
                      fontSize: '1.4rem',
                      color: 'green',
                      paddingLeft: '20px',
                    }}
                    className="far fa-check-circle"
                  ></i>
                )}
              </Flex>
            </Flex>

            {/* FIRST NAME, LAST NAME */}
            <Flex wrap="wrap" w="653" justify="center">
              <FormControl isRequired isInvalid={errors.username}>
                <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                  First Name
                </FormLabel>
                <SignupLoginInput
                  w="318px"
                  mb="30px"
                  mr="17px"
                  type="text"
                  name="firstName"
                  label="firstName"
                  placeholder="John"
                  autoCapitalize="none"
                  ref={register({ validate: validateFirstName })}
                />
                <FormErrorMessage>
                  {errors.firstName && errors.firstName.message}
                </FormErrorMessage>
              </FormControl>
              <FormControl isRequired isInvalid={errors.username}>
                <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                  Last Name
                </FormLabel>
                <SignupLoginInput
                  w="318px"
                  mb="30px"
                  type="text"
                  name="lastName"
                  label="lastName"
                  placeholder="Doe"
                  autoCapitalize="none"
                  ref={register({ validate: validateLastName })}
                />
                <FormErrorMessage>
                  {errors.lastName && errors.lastName.message}
                </FormErrorMessage>
              </FormControl>
            </Flex>

            {/* LOCATION OF USER */}
            <Flex wrap="wrap" w="653" justify="center">
              <FormControl>
                <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                  Location (City, State)
                </FormLabel>
                <CustomAutocomplete
                  stateHelper={stateHelper}
                  w="653px"
                  h="58px"
                  mb="30px"
                  rounded="2px"
                  variant="outline"
                  bgColor="#FDFDFF"
                  focusBorderColor="#344CD0"
                  borderColor="#EAF0FE"
                  color="#17171B"
                  _hover={{ borderColor: '#BBBDC6' }}
                  _placeholder={{ color: '#BBBDC6' }}
                  id="location"
                  name="location"
                  label="location"
                  placeholder={lazySolution}
                  ref={register}
                />
              </FormControl>
            </Flex>

            {/* GRADUATED CHECK */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb={graduated ? '20px' : '80px'}
              justify="space-between"
            >
              <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                Have you graduated from Lambda yet?
              </FormLabel>
              <Flex justify="space-between" w="131px">
                <Radio
                  name="graduated"
                  id="graduated-1"
                  value={true}
                  isChecked={graduated === true}
                  onClick={isGraduated}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  Yes
                </Radio>
                <Radio
                  name="graduated"
                  id="graduated-2"
                  value={false}
                  isChecked={graduated === false}
                  onClick={notGraduated}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  No
                </Radio>
              </Flex>
            </Flex>
            {/* GRADUATED MONTH AND YEAR */}
            {graduated ? (
              <Flex
                wrap="wrap"
                w="653px"
                mx="auto"
                mb="80px"
                justify="space-between"
                align="center"
              >
                <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                  When did you graduate?
                </FormLabel>
                <Flex align="center" alignContent="center">
                  <FormControl>
                    <Select
                      mr="17px"
                      h="68px"
                      py="16px"
                      w="155px"
                      rounded="2px"
                      variant="outline"
                      backgroundColor="#FDFDFF"
                      focusBorderColor="#344CD0"
                      borderColor="#EAF0FE"
                      color="#BBBDC6"
                      _focus={{ color: '#17171B' }}
                      _hover={{ borderColor: '#BBBDC6' }}
                      name="gradMonth"
                      label="gradMonth"
                      ref={register}
                    >
                      <option fontFamily="Muli" value="">
                        Month
                      </option>
                      <option fontFamily="Muli" value="01">
                        Jan
                      </option>
                      <option fontFamily="Muli" value="02">
                        Feb
                      </option>
                      <option fontFamily="Muli" value="03">
                        Mar
                      </option>
                      <option fontFamily="Muli" value="04">
                        Apr
                      </option>
                      <option fontFamily="Muli" value="05">
                        May
                      </option>
                      <option fontFamily="Muli" value="06">
                        Jun
                      </option>
                      <option fontFamily="Muli" value="07">
                        Jul
                      </option>
                      <option fontFamily="Muli" value="08">
                        Aug
                      </option>
                      <option fontFamily="Muli" value="09">
                        Sep
                      </option>
                      <option fontFamily="Muli" value="10">
                        Oct
                      </option>
                      <option fontFamily="Muli" value="11">
                        Nov
                      </option>
                      <option fontFamily="Muli" value="12">
                        Dec
                      </option>
                    </Select>
                  </FormControl>
                  <FormControl>
                    <Select
                      h="68px"
                      py="16px"
                      w="155px"
                      rounded="2px"
                      variant="outline"
                      backgroundColor="#FDFDFF"
                      focusBorderColor="#344CD0"
                      borderColor="#EAF0FE"
                      color="#BBBDC6"
                      _focus={{ color: '#17171B' }}
                      _hover={{ borderColor: '#BBBDC6' }}
                      name="gradYear"
                      label="gradYear"
                      ref={register}
                    >
                      <option fontFamily="Muli" value="">
                        Year
                      </option>
                      {years.map((year, index) => (
                        <option key={`year${index}`} value={year}>
                          {year}
                        </option>
                      ))}
                    </Select>
                  </FormControl>
                </Flex>
              </Flex>
            ) : null}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb="35px"
              justify="flex-start"
              borderTop="1px solid #DADADD"
            >
              <Text
                fontFamily="Poppins"
                fontWeight="600"
                fontSize="24px"
                lineHeight="36px"
                color="#BBBDC6"
              >
                Background
              </Text>
            </Flex>

            {/* HIGHEST LEVEL OF EDUCATION */}
            <Flex wrap="wrap" w="411px%" justify="center">
              <FormControl>
                <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                  Highest level of education
                </FormLabel>
                <Select
                  mb="30px"
                  mr="17px"
                  h="68px"
                  py="16px"
                  w="318px"
                  rounded="2px"
                  variant="outline"
                  backgroundColor="#FDFDFF"
                  focusBorderColor="#344CD0"
                  borderColor="#EAF0FE"
                  color="#BBBDC6"
                  _focus={{ color: '#17171B' }}
                  _hover={{ borderColor: '#BBBDC6' }}
                  name="highest_ed"
                  label="highest_ed"
                  ref={register}
                >
                  <option fontFamily="Muli" value="">
                    Select your education level
                  </option>
                  <option fontFamily="Muli" value="High school diploma">
                    High school diploma
                  </option>
                  <option fontFamily="Muli" value="Associate's degree">
                    Associate's degree
                  </option>
                  <option fontFamily="Muli" value="Bachelor's degree">
                    Bachelor's degree
                  </option>
                  <option fontFamily="Muli" value="Master's degree">
                    Master's degree
                  </option>
                  <option fontFamily="Muli" value="PhD">
                    PhD
                  </option>
                </Select>
              </FormControl>

              {/* FIELD OF STUDY */}
              <FormControl isInvalid={errors.fieldOfStudy}>
                <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                  Field of study
                </FormLabel>
                <SignupLoginInput
                  w="318px"
                  mb="30px"
                  type="text"
                  name="field_of_study"
                  label="field_of_study"
                  placeholder="Enter your field of study"
                  autoCapitalize="none"
                  ref={register({ validate: validateFieldOfStudy })}
                />
                <FormErrorMessage>
                  {errors.fieldOfStudy && errors.fieldOfStudy.message}
                </FormErrorMessage>
              </FormControl>
            </Flex>

            {/* PRIOR EXPERIENCE */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb="30px"
              justify="space-between"
            >
              <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                Prior to Lambda did you have any experience in your track?
              </FormLabel>
              <Flex justify="space-between" w="131px">
                <Radio
                  name="prior_experience"
                  id="priorExp-1"
                  ref={register}
                  value={true}
                  isChecked={priorExp === true}
                  onChange={() => setPriorExp(true)}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  Yes
                </Radio>
                <Radio
                  name="prior_experience"
                  id="priorExp-2"
                  ref={register}
                  value={false}
                  isChecked={priorExp === false}
                  onChange={() => setPriorExp(false)}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  No
                </Radio>
              </Flex>
            </Flex>

            {/* DID YOU TL/SL */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb="100px"
              justify="space-between"
            >
              <FormLabel fontSize="18px" color="#131C4D" fontFamily="Muli">
                Have you been a TL/SL while at Lambda?
              </FormLabel>
              <Flex justify="space-between" w="131px">
                <Radio
                  name="tlsl_experience"
                  id="TLSL-1"
                  value={true}
                  ref={register}
                  isChecked={tlsl === true}
                  onChange={() => setTlsl(true)}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  Yes
                </Radio>
                <Radio
                  name="tlsl_experience"
                  id="TLSL-2"
                  value={false}
                  ref={register}
                  isChecked={tlsl === false}
                  onChange={() => setTlsl(false)}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  No
                </Radio>
              </Flex>
            </Flex>

            {/* RESUME UPLOAD */}
            {/* /// */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              justify="space-between"
              align="center"
            >
              <Text
                fontSize="18px"
                color="#131C4D"
                align="center"
                fontFamily="Muli"
              >
                Resume
              </Text>
              <Flex width="270px" justify="flex-end">
                <input
                  type="file"
                  filename="image"
                  placeholder="Upload profile picture"
                  onChange={updateResume}
                  style={{
                    opacity: '1',
                    width: '105px',
                    color: 'transparent',
                    backgroundColor: 'transparent',
                  }}
                />
                <label htmlFor="files" className="btn">
                  {!newProfile_resume ? (
                    'Upload resume'
                  ) : (
                    <i
                      style={{
                        fontSize: '1.4rem',
                        color: 'green',
                        paddingLeft: '20px',
                      }}
                      className="far fa-check-circle"
                    ></i>
                  )}
                </label>
              </Flex>
            </Flex>
            <Flex w="653px" mx="auto" justify="flex-start">
              <FormHelperText w="653px" mb="30px" color="#9194A8">
                Must be a .pdf file
              </FormHelperText>
            </Flex>

            {/* //// */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb="35px"
              justify="flex-start"
              borderTop="1px solid #DADADD"
            >
              <Text
                fontFamily="Poppins"
                fontWeight="600"
                fontSize="24px"
                lineHeight="36px"
                color="#BBBDC6"
              >
                Employment
              </Text>
            </Flex>

            {/* EMPLOYED CHECK */}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb={employed ? '30px' : '80px'}
              justify="space-between"
            >
              <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                Are you currently employed in your field of study?
              </FormLabel>
              <Flex justify="space-between" w="131px">
                <Radio
                  name="employed"
                  id="employed-1"
                  value={true}
                  isChecked={employed === true}
                  onClick={isEmployed}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  Yes
                </Radio>
                <Radio
                  name="employed"
                  id="employed-2"
                  value={false}
                  isChecked={employed === false}
                  onClick={notEmployed}
                  borderRadius="md"
                  borderColor="#D9D9D9"
                  _checked={{ bg: '#344CD0' }}
                >
                  No
                </Radio>
              </Flex>
            </Flex>

            {/* EMPLOYED COMPANY NAME AND JOB TITLE */}
            {employed ? (
              <Flex wrap="wrap" w="653" justify="center">
                <FormControl>
                  <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                    Company name
                  </FormLabel>
                  <SignupLoginInput
                    w="318px"
                    mb="30px"
                    mr="17px"
                    type="text"
                    name="employed_company"
                    label="employed_company"
                    placeholder="Enter the company name"
                    autoCapitalize="none"
                    ref={register}
                  />
                </FormControl>
                <FormControl>
                  <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                    Job title
                  </FormLabel>
                  <SignupLoginInput
                    w="318px"
                    mb="30px"
                    type="text"
                    name="employed_title"
                    label="employed_title"
                    placeholder="Enter your job title"
                    autoCapitalize="none"
                    ref={register}
                  />
                </FormControl>
              </Flex>
            ) : null}

            {/* REMOTE WORK CHECK */}
            {employed ? (
              <Flex
                wrap="wrap"
                w="653px"
                mx="auto"
                mb="30px"
                justify="space-between"
              >
                <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                  Are you working remotely?
                </FormLabel>
                <Flex justify="space-between" w="131px">
                  <Radio
                    name="employed_remote"
                    id="employed_remote-1"
                    value={true}
                    ref={register}
                    isChecked={remote === true}
                    onChange={() => setRemote(true)}
                    borderRadius="md"
                    borderColor="#D9D9D9"
                    _checked={{ bg: '#344CD0' }}
                  >
                    Yes
                  </Radio>
                  <Radio
                    name="employed_remote"
                    id="employed_remote-2"
                    value={false}
                    ref={register}
                    isChecked={remote === false}
                    onChange={() => setRemote(false)}
                    borderRadius="md"
                    borderColor="#D9D9D9"
                    _checked={{ bg: '#344CD0' }}
                  >
                    No
                  </Radio>
                </Flex>
              </Flex>
            ) : null}

            {/* EMPLOYMENT START DATE */}
            {employed ? (
              <Flex
                wrap="wrap"
                w="653px"
                mx="auto"
                mb="80px"
                justify="space-between"
                align="center"
              >
                <FormLabel color="#131C4D" fontSize="18px" fontFamily="Muli">
                  When did you start?
                </FormLabel>
                <Flex align="center" alignContent="center">
                  <FormControl>
                    <Select
                      mr="17px"
                      h="68px"
                      py="16px"
                      w="159px"
                      rounded="2px"
                      variant="outline"
                      backgroundColor="#FDFDFF"
                      focusBorderColor="#344CD0"
                      borderColor="#EAF0FE"
                      color="#BBBDC6"
                      _focus={{ color: '#17171B' }}
                      _hover={{ borderColor: '#BBBDC6' }}
                      name="workMonth"
                      label="workMonth"
                      ref={register}
                    >
                      <option fontFamily="Muli" value="">
                        Month
                      </option>
                      <option fontFamily="Muli" value="01">
                        Jan
                      </option>
                      <option fontFamily="Muli" value="02">
                        Feb
                      </option>
                      <option fontFamily="Muli" value="03">
                        Mar
                      </option>
                      <option fontFamily="Muli" value="04">
                        Apr
                      </option>
                      <option fontFamily="Muli" value="05">
                        May
                      </option>
                      <option fontFamily="Muli" value="06">
                        Jun
                      </option>
                      <option fontFamily="Muli" value="07">
                        Jul
                      </option>
                      <option fontFamily="Muli" value="08">
                        Aug
                      </option>
                      <option fontFamily="Muli" value="09">
                        Sep
                      </option>
                      <option fontFamily="Muli" value="10">
                        Oct
                      </option>
                      <option fontFamily="Muli" value="11">
                        Nov
                      </option>
                      <option fontFamily="Muli" value="12">
                        Dec
                      </option>
                    </Select>
                  </FormControl>
                  <FormControl>
                    <Select
                      h="68px"
                      py="16px"
                      w="159px"
                      rounded="2px"
                      variant="outline"
                      backgroundColor="#FDFDFF"
                      focusBorderColor="#344CD0"
                      borderColor="#EAF0FE"
                      color="#BBBDC6"
                      _focus={{ color: '#17171B' }}
                      _hover={{ borderColor: '#BBBDC6' }}
                      name="workYear"
                      label="workYear"
                      ref={register}
                    >
                      <option fontFamily="Muli" value="">
                        Year
                      </option>
                      {years.map((year, index) => (
                        <option key={`year${index}`} value={year}>
                          {year}
                        </option>
                      ))}
                    </Select>
                  </FormControl>
                </Flex>
              </Flex>
            ) : null}
            <Flex
              wrap="wrap"
              w="653px"
              mx="auto"
              mb="35px"
              justify="flex-start"
              borderTop="1px solid #DADADD"
            >
              <Text
                fontFamily="Poppins"
                fontWeight="600"
                fontSize="24px"
                lineHeight="36px"
                color="#BBBDC6"
              >
                Online Presence
              </Text>
            </Flex>

            {/* PORTFOLIO URL */}
            <Flex
              wrap="wrap"
              w="653px"
              mb="15px"
              mx="auto"
              justify="space-between"
              align="center"
            >
              <Text
                color="#131C4D"
                fontSize="18px"
                align="center"
                fontFamily="Muli"
              >
                Portfolio URL
              </Text>
              <SignupLoginInput
                w="318px"
                type="text"
                name="portfolio_URL"
                label="portfolio_URL"
                placeholder="Enter your portfolio URL"
                autoCapitalize="none"
                ref={register}
              />
            </Flex>

            {/* LINKEDIN URL */}
            <Flex
              wrap="wrap"
              w="653px"
              mb="15px"
              mx="auto"
              justify="space-between"
              align="center"
            >
              <Text
                color="#131C4D"
                fontSize="18px"
                align="center"
                fontFamily="Muli"
              >
                LinkedIn URL
              </Text>
              <SignupLoginInput
                w="318px"
                type="text"
                name="linked_in"
                label="linked_in"
                placeholder="Enter your LinkedIn URL"
                autoCapitalize="none"
                ref={register}
              />
            </Flex>

            {/* SLACK USERNAME */}
            <Flex
              wrap="wrap"
              w="653px"
              mb="15px"
              mx="auto"
              justify="space-between"
              align="center"
            >
              <Text
                color="#131C4D"
                fontSize="18px"
                align="center"
                fontFamily="Muli"
              >
                Slack ID
                <Tooltip hasArrow label={info} placement="top">
                  <i
                    style={{ paddingLeft: '10px' }}
                    className="fas fa-question"
                  ></i>
                </Tooltip>
              </Text>
              <SignupLoginInput
                w="318px"
                type="text"
                name="slack"
                label="slack"
                placeholder="Enter your Slack ID"
                autoCapitalize="none"
                ref={register}
              />
            </Flex>

            {/* GITHUB USERNAME */}
            <Flex
              wrap="wrap"
              w="653px"
              mb="15px"
              mx="auto"
              justify="space-between"
              align="center"
            >
              <Text
                color="#131C4D"
                fontSize="18px"
                align="center"
                fontFamily="Muli"
              >
                Github URL
              </Text>
              <SignupLoginInput
                w="318px"
                type="text"
                name="github"
                label="github"
                placeholder="Enter your Github URL"
                autoCapitalize="none"
                ref={register}
              />
            </Flex>

            {/* DRIBBBLE URL */}
            <Flex
              wrap="wrap"
              w="653px"
              mb="15px"
              mx="auto"
              justify="space-between"
              align="center"
            >
              <Text
                color="#131C4D"
                fontSize="18px"
                align="center"
                fontFamily="Muli"
              >
                Dribbble URL
              </Text>
              <SignupLoginInput
                w="318px"
                type="text"
                name="dribble"
                label="dribble"
                placeholder="Enter your Dribbble URL"
                autoCapitalize="none"
                ref={register}
              />
            </Flex>
            <Flex
              w="100%"
              style={{ alignItems: 'center' }}
              justify="center"
              direction="column"
            >
              <Button
                border="none"
                rounded="50px"
                h="58px"
                w="653px"
                my="2%"
                size="lg"
                color="white"
                backgroundColor="#344CD0"
                _hover={{ backgroundColor: '#4254BA', cursor: 'pointer' }}
                isLoading={formState.isSubmitting}
                type="submit"
                data-cy="registerSubmit"
              >
                Save
              </Button>
              <Button
                mb="30px"
                border="none"
                rounded="50px"
                h="58px"
                w="653px"
                my="2%"
                size="lg"
                color="#9194A8"
                backgroundColor="#FDFDFF"
                _hover={{ cursor: 'pointer' }}
                onClick={returnToProfile}
                data-cy="cancelUpdate"
              >
                Cancel
              </Button>
            </Flex>
          </Flex>
        </form>
      </Flex>
    </>
  )
}
Example #7
Source File: ProfilePage.js    From allay-fe with MIT License 4 votes vote down vote up
ProfilePage = (props) => {
  const id = props.match.params.id
  const userId = window.localStorage.getItem('userId')
  //
  const dispatch = useDispatch()
  const isLoading = useSelector((state) => state.user.isLoading)
  const isUpdated = useSelector((state) => state.user.isUpdated)
  const userData = useSelector((state) => state.user.userData)
  //

  const _midSectionStyles = {
    width: '40%',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'space-between',
    padding: '0% 6% 0 3%',
    height: '40px',
  }
  const _emp = {
    padding: '0 0 0 22%',
    opacity: 0.5,
  }

  // box that shows on profile update
  let changes_div = {
    position: 'absolute',
    width: '1048px',
    marginTop: '25px',
    borderRadius: '20px 20px 0 0',
    height: '50px',
    backgroundColor: '#77E0B5',
    textAlign: 'center',
    color: '#fff',
    fontSize: '16px',
    fontFamily: 'Muli',
    fontWeight: 'bold',
  }
  //array to get the correct track name
  const track = ['arrayStartsWithZero :D', 'android', 'ds', 'web', 'ios', 'ux'][
    userData.track_id
  ]

  // formating graduated date
  let graduated = userData.graduated
  graduated = new Date(graduated).toUTCString()
  graduated = graduated.split(' ').slice(2, 4).join(' ')

  // formating employed date
  let hired = userData.employed_start
  hired = new Date(hired).toUTCString()
  hired = hired.split(' ').slice(2, 4).join(' ')

  //slack link helper
  const slackID = userData.slack
  const slackLink = `https://lambda-students.slack.com/app_redirect?channel=${slackID}`

  useEffect(() => {
    dispatch(getUser(id))
  }, [dispatch, id])

  //send location: null receive undefiend send again empty recieve the same with white space, backend fix but itll do for now

  const lazySolution =
    userData.location != 'undefined undefined ' &&
    userData.location != 'undefined undefined'
      ? userData.location
      : ''
  return (
    <>
      {/* //Top Section */}

      <Flex
        maxW="1440px"
        w="100%"
        px="40px"
        py="28px"
        m="0 auto"
        justify="space-between"
        align="center"
        borderBottom="1px solid #EAF0FE"
      >
        <Flex>
          <Link
            style={{
              textDecoration: 'none',
              color: '#344CD0',
              fontFamily: 'Poppins',
              fontWeight: '600',
              fontSize: '32px',
            }}
            to="/dashboard"
          >
            <h1> Allay </h1>
          </Link>
        </Flex>

        {Number(userId) === Number(userData.id) ? (
          <Flex>
            <Image
              size="58px"
              style={{ opacity: '0.6', borderRadius: '50%' }}
              src={userData.profile_image}
              fallbackSrc={require('../../../icons/user.svg')}
            />
          </Flex>
        ) : null}
      </Flex>

      {!isLoading ? (
        <>
          <Flex Flex w="100%" pt="3%" justify="center">
            <SimpleGrid width="1048px" columns={1}>
              <Box style={{ textAlign: 'end', paddingRight: '1%' }}>
                {Number(id) === Number(userId) && (
                  <Link
                    style={{
                      textDecoration: 'none',
                      color: 'black',
                    }}
                    to={`/profile/${id}/edit`}
                  >
                    <i
                      style={{ opacity: 0.3, paddingRight: '10px' }}
                      className="far fa-edit"
                      data-cy="editProfile"
                    ></i>
                    Edit profile
                  </Link>
                )}
              </Box>
              <div
                id="changesDiv"
                style={isUpdated ? changes_div : { display: 'none' }}
              >
                Changes successfully saved
              </div>
              <Box
                style={{
                  borderRadius: '20px 20px 0 0',
                  display: 'inline-flex',
                }}
                bg="#F7F9FF"
                height="220px"
              >
                <Flex w="20%" style={{ padding: '55px 0 0 90px' }}>
                  <Avatar
                    size="2xl"
                    name={userData.first_name}
                    src={userData.profile_image}
                  />
                </Flex>
                <Flex w="80%" pl="6%">
                  <SimpleGrid width="100%" row={2} pr="70px">
                    <Flex
                      height="113px"
                      style={{
                        display: 'flex',
                      }}
                    >
                      <Box
                        height="27px"
                        style={{
                          alignSelf: 'flex-end',
                          marginLeft: '42px',
                        }}
                      >
                        <h3
                          id="profileNames"
                          style={{
                            fontSize: '27px',
                            fontFamily: 'Poppins',
                            color: ' #131C4D',
                            width: '210px',
                          }}
                        >
                          {userData.first_name} {userData.last_name}
                        </h3>
                      </Box>
                      <Box
                        width="47%"
                        height="53px"
                        style={{
                          display: 'flex',
                          alignSelf: 'flex-end',
                          alignItems: 'baseline',
                          justifyContent: 'space-between',
                        }}
                      >
                        <span
                          style={{
                            borderRadius: '20px',
                            width: '75px',
                            height: '36px',
                            backgroundColor: '#259BF8',
                            color: '#17171b',
                            fontSize: '16px',
                            textTransform: 'uppercase',
                            textAlign: 'center',
                            marginLeft: '15%',
                            paddingTop: '6px',
                          }}
                        >
                          {track}
                        </span>

                        <h6
                          style={{
                            fontFamily: 'Muli',
                            fontWeight: 300,
                            paddingRight: '10px',
                          }}
                        >
                          {userData.graduated ? 'Alumni' : 'Student'}
                        </h6>
                      </Box>

                      <Box
                        width="120px"
                        style={{
                          alignSelf: 'flex-end',
                          textAlign: 'end',
                        }}
                        height="60px"
                      >
                        <h6
                          style={{
                            fontFamily: 'Muli',
                            fontWeight: 300,
                            paddingTop: '6px',
                          }}
                        >
                          <i
                            style={{ opacity: 0.2, paddingRight: '5px' }}
                            className="fas fa-map-marker-alt"
                          ></i>

                          {lazySolution}
                        </h6>
                      </Box>
                    </Flex>
                    <Box>
                      <SimpleGrid width="100%" columns={2}>
                        <Flex
                          width="55%"
                          justify="space-between"
                          pl="42px"
                          style={{ fontWeight: 'bold' }}
                        >
                          <a
                            style={{
                              textDecoration: 'none',
                              color: '#344CD0',
                            }}
                            target="blank"
                            href={userData.portfolio}
                          >
                            Portfolio
                          </a>

                          <a
                            style={{
                              textDecoration: 'none',
                              color: '#344CD0',
                            }}
                            target="blank"
                            href={userData.resume}
                          >
                            Resume
                          </a>
                        </Flex>
                        <Flex
                          width="62%"
                          justify="space-around"
                          justifySelf="flex-end"
                          alignItems="center"
                        >
                          {userData.linked_in ? (
                            <a target="blank" href={userData.linked_in}>
                              <Image
                                size="20px"
                                style={{ borderRadius: '60%' }}
                                src={require('../../../icons/linkedIn.png')}
                              />
                            </a>
                          ) : (
                            <Image
                              size="20px"
                              opacity=".3"
                              style={{ borderRadius: '60%' }}
                              src={require('../../../icons/linkedIn.png')}
                            />
                          )}
                          {userData.slack ? (
                            <a target="blank" href={slackLink}>
                              <Image
                                size="20px"
                                src={require('../../../icons/slack.svg')}
                              />
                            </a>
                          ) : (
                            <Image
                              opacity="0.3"
                              size="20px"
                              src={require('../../../icons/slack.svg')}
                            />
                          )}
                          {userData.github ? (
                            <a
                              style={{ height: '20px' }}
                              target="blank"
                              href={userData.github}
                            >
                              <i
                                style={{ fontSize: 'larger' }}
                                className="fab fa-github"
                              />
                            </a>
                          ) : (
                            <i
                              style={{ fontSize: 'larger', opacity: '0.3' }}
                              className="fab fa-github"
                            ></i>
                          )}

                          {userData.dribble ? (
                            <a target="blank" href={userData.dribble}>
                              <Image
                                size="20px"
                                style={{ borderRadius: '60%' }}
                                src={require('../../../icons/dribble.png')}
                              />
                            </a>
                          ) : (
                            <Image
                              size="20px"
                              opacity="0.3"
                              style={{ borderRadius: '60%' }}
                              src={require('../../../icons/dribble.png')}
                            />
                          )}
                        </Flex>
                      </SimpleGrid>
                    </Box>
                  </SimpleGrid>
                </Flex>
              </Box>
              <Box
                bg="#F7F9FF"
                pl="70px"
                height="107px"
                style={{ fontSize: '16px' }}
              >
                <h4
                  style={{
                    padding: ' 2% 0% 1% 3%',
                    fontSize: '14px',
                    color: ' #131C4D',
                  }}
                >
                  Lambda Information
                </h4>
                <Flex>
                  <Box style={_midSectionStyles}>
                    <span style={{ opacity: '.5' }}>Cohort:</span>
                    {userData.cohort}
                  </Box>
                  <Box
                    style={{
                      width: '35.5%',
                      display: ' flex',
                      alignItems: 'center',
                      justifyContent: 'space-between',
                      padding: '0% 0% 1% 11%',
                      height: '40px',
                    }}
                  >
                    <span style={{ opacity: '.5' }}>Graduated:</span>
                    {userData.graduated ? graduated : 'N/A'}
                  </Box>
                </Flex>
              </Box>
            </SimpleGrid>
          </Flex>

          <Flex
            Flex
            w="100%"
            justify="center"
            mb="3%"
            style={{ fontSize: '16px' }}
          >
            <SimpleGrid width="1048px" columns={2}>
              <Box
                bg="#F7F9FF"
                height="260px"
                pl="70px"
                style={{ borderRadius: '0 0 0 20px' }}
              >
                <h4
                  style={{
                    padding: ' 6% 2% 5% 6%',
                    fontSize: '14px',
                    color: ' #131C4D',
                  }}
                >
                  Background
                </h4>
                <SimpleGrid
                  columns={2}
                  spacing={5}
                  style={{ paddingLeft: '6%' }}
                >
                  <Box height="20px" style={{ opacity: 0.5 }}>
                    Degree:
                  </Box>
                  <Box height="20px">{userData.highest_ed || 'N/A'}</Box>
                  <Box height="20px" style={{ opacity: 0.5 }}>
                    Field of Study:
                  </Box>
                  <Box height="20px">{userData.field_of_study || 'N/A'}</Box>
                  <Box height="20px" style={{ opacity: 0.5 }}>
                    Prior web experience:
                  </Box>
                  <Box height="20px">
                    {userData.prior_experience ? 'Yes' : 'None'}
                  </Box>
                  <Box height="20px" style={{ opacity: 0.5 }}>
                    Lambda TL/SL position:
                  </Box>
                  <Box height="20px">
                    {userData.tlsl_experience ? 'Yes' : 'None'}
                  </Box>
                </SimpleGrid>
              </Box>
              <Box
                bg="#F7F9FF"
                height="260px"
                style={{ borderRadius: '0 0 20px 0' }}
              >
                <h4
                  style={{
                    padding: ' 6% 0% 4% 8%',
                    fontSize: '14px',
                    color: ' #131C4D',
                  }}
                >
                  Current employment
                </h4>
                <SimpleGrid
                  columns={2}
                  spacing={5}
                  style={{ padding: '0 20% 0 0%' }}
                >
                  <Box height="20px" style={_emp}>
                    Company:
                  </Box>
                  <Box height="20px">{userData.employed_company || 'N/A'}</Box>
                  <Box height="20px" style={_emp}>
                    Job tittle:
                  </Box>
                  <Box height="20px">{userData.employed_title || 'N/A'}</Box>
                  <Box height="20px" style={_emp}>
                    Start date:
                  </Box>
                  <Box height="20px">
                    {userData.employed_start ? hired : 'N/A'}
                  </Box>
                  <Box height="20px" style={_emp}>
                    Remote
                  </Box>
                  <Box height="20px">
                    {userData.employed_remote ? 'Yes' : 'No'}
                  </Box>
                </SimpleGrid>
              </Box>
            </SimpleGrid>
          </Flex>

          <Flex justify="center">
            <Box width="1048px">
              Reviews written by {userData.first_name} {userData.last_name}
            </Box>
          </Flex>
          <ProfilePageReview userReviews={userData.reviews} />
        </>
      ) : (
        <Flex justify="center" pt="15%">
          <GridLoader size={50} color={'#259bf8'} />
        </Flex>
      )}
    </>
  )
}
Example #8
Source File: Email.js    From CubeMail with MIT License 4 votes vote down vote up
Email = () => {
  const { message } = useContext(EmailContext);
  const headers = message ? message.payload.headers : [];
  const toast = useToast();

  React.useEffect(() => {
    if (message) {
      addToFrame(message);
    }
    // eslint-disable-next-line
  }, [message]);

  const formatReplayData = (headers) => {
    const replayTo =
      getHeader(headers, "Reply-to") !== undefined
        ? getHeader(headers, "Reply-to")
        : getHeader(headers, "From");
    const replaySubject = getHeader(headers, "Subject");
    const replayMsgId = getHeader(headers, "Message-ID");

    return {
      to: `${replayTo}`,
      subject: `Re: ${replaySubject}`,
      msgId: `${replayMsgId}`,
    };
  };

  const handleTrashBtn = (userId, messageId) => {
    return window.gapi.client.gmail.users.messages
      .trash({
        userId: userId,
        id: messageId,
      })
      .then((resp) => {
        if (resp.status === 200) {
          toast({
            title: "Message Deleted",
            status: "error",
            duration: 3000,
            isClosable: true,
          });
        }
      })
      .catch((error) => {
        console.log("error: ", error);
        toast({
          title: "An error occurred.",
          description: "Unable to Delete Message.",
          status: "warning",
          duration: 3000,
          isClosable: true,
        });
      });
  };

  const handleArchiveBtn = (ids, labelIds) => {
    return window.gapi.client.gmail.users.messages
      .batchModify({
        userId: "me",
        resource: {
          ids: ids,
          removeLabelIds: labelIds,
        },
      })
      .then((resp) => {
        if (resp.status === 204) {
          toast({
            title: "Message Archived",
            description: "The Message is now in archive category.",
            status: "success",
            duration: 3000,
            isClosable: true,
          });
        }
      })
      .catch((error) => {
        console.log("error: ", error);
        toast({
          title: "An error occurred.",
          description: "Unable to Archive Message.",
          status: "error",
          duration: 3000,
          isClosable: true,
        });
      });
  };

  const addToFrame = (message) => {
    let ifrm = document.getElementById("iframe").contentWindow.document;
    ifrm.body.innerHTML = getMessageBody(message.payload);
  };

  const getMessageBody = (message) => {
    const encodedBody =
      typeof message.parts === "undefined"
        ? message.body.data
        : getHTMLPart(message.parts);

    return Base64.decode(encodedBody);
  };

  const getHTMLPart = (arr) => {
    for (var x = 0; x <= arr.length; x++) {
      if (typeof arr[x].parts === "undefined") {
        if (arr[x].mimeType === "text/html") {
          return arr[x].body.data;
        }
      } else {
        return getHTMLPart(arr[x].parts);
      }
    }
    return "";
  };

  return (
    <Flex
      direction='column'
      wrap='no-wrap'
      w='58%'
      h='100%'
      p='0.6rem 1rem'
      bg='white'
      color='black'
      border='1px'
      borderColor='gray.200'
      borderTopRightRadius='md'
      borderBottomRightRadius='md'
    >
      {!message ? (
        <EmptyMail />
      ) : (
        <Fragment>
          {/* Header Buttons */}
          <Flex justify='space-around' wrap='no-wrap' mb={2}>
            <ReplyModel replayData={formatReplayData(headers)} />
            <ForwardModel
              forwardData={message}
              getMessageBody={getMessageBody}
            />
            <Button
              rightIcon={MdArchive}
              variantColor='blue'
              variant='outline'
              onClick={() => handleArchiveBtn([message.id], ["INBOX"])}
            >
              Archive
            </Button>
            <Button
              rightIcon='delete'
              variantColor='blue'
              variant='outline'
              onClick={() => handleTrashBtn("me", message.id)}
            >
              Delete
            </Button>
          </Flex>

          {/* Mail Container */}
          <Flex
            className='mailContainer'
            flexGrow='2'
            direction='column'
            wrap='no-wrap'
            p={2}
          >
            <Box className='mailHeader' mb={2}>
              <Text fontSize='lg' fontWeight='bold' color='gray.700' mb={1}>
                {getHeader(headers, "Subject")}
              </Text>
              <Flex wrap='no-wrap' justify='flex-start'>
                <Avatar
                  name={removeQuote(getHeader(headers, "From").split("<")[0])}
                  src='https://bit.ly/tioluwani-kolawole'
                  mr={4}
                />
                <Box w='80%'>
                  <Text fontSize='md' color='gray.700'>
                    {getHeader(headers, "From")}
                  </Text>
                  <Text fontSize='sm' color='gray.500'>
                    {formatDate(getHeader(headers, "Date"))}
                  </Text>
                </Box>
              </Flex>
              <Text fontSize='sm' color='gray.700' mt={1}>
                {`To: ${getHeader(headers, "To")}`}
              </Text>
            </Box>
            <Box className='mailBody' flexGrow='2'>
              <AspectRatioBox ratio={16 / 9} h='100%'>
                <Box as='iframe' id='iframe' title='messageBody'>
                  <p>Your browser does not support iframes.</p>
                </Box>
              </AspectRatioBox>
            </Box>
          </Flex>
        </Fragment>
      )}
    </Flex>
  );
}