Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4599 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4599 Rev 5374
Línea 1... Línea 1...
1
/* eslint-disable react/prop-types */
1
/* eslint-disable react/prop-types */
2
import React from "react";
2
import React from 'react'
3
import { useState, } from "react";
3
import { useState } from 'react'
4
import { profileTypes } from "../../../Profile.types";
4
import { profileTypes } from '../../../Profile.types'
5
import ImageModal from './ImageModal'
5
import ImageModal from './ImageModal'
Línea 6... Línea -...
6
 
-
 
7
 
6
 
8
const ProfileImg = ({
7
const ProfileImg = ({
9
  entityId = '',
8
  entityId = '',
10
  profileId = '',
9
  profileId = '',
11
  image = '',
10
  image = '',
12
  imageProfileCover = '',
11
  imageProfileCover = '',
13
  profileType = ''
12
  profileType = ''
14
}) => {
-
 
15
 
-
 
16
 
-
 
17
 
13
}) => {
18
  // states
14
  // states
Línea 19... Línea 15...
19
  const [isModalOpen, setIsModalOpen] = useState(false);
15
  const [isModalOpen, setIsModalOpen] = useState(false)
20
 
16
 
21
  const [profileImg, setProfileImg] = useState(() => {
17
  const [profileImg, setProfileImg] = useState(() => {
22
    switch (profileType) {
18
    switch (profileType) {
23
      case profileTypes.USER:
19
      case profileTypes.USER:
24
        return {
20
        return {
25
          path: `/storage/type/user-profile/code/${entityId}/${image ? `filename/${image}` : ''}`,
21
          path: `/storage/type/user-profile/code/${entityId}/${image ? `filename/${image}` : ''}`,
26
          uid: Date.now(),
22
          uid: Date.now()
27
        };
23
        }
28
      case profileTypes.COMPANY:
24
      case profileTypes.COMPANY:
29
        return {
25
        return {
30
          path: `/storage/type/company/code/${entityId}/${image ? `filename/${image}` : ''}`,
26
          path: `/storage/type/company/code/${entityId}/${image ? `filename/${image}` : ''}`,
31
          uid: Date.now(),
27
          uid: Date.now()
32
        }
28
        }
-
 
29
      default:
-
 
30
        return {
-
 
31
          path: image,
33
      default:
32
          uid: Date.now()
34
        break;
33
        }
Línea 35... Línea 34...
35
    }
34
    }
36
  });
35
  })
37
 
36
 
38
  const handleModalOpen = (event) => {
37
  const handleModalOpen = (event) => {
Línea 39... Línea 38...
39
    event && event.preventDefault();
38
    event && event.preventDefault()
40
    setIsModalOpen(!isModalOpen);
39
    setIsModalOpen(!isModalOpen)
41
  };
40
  }
42
 
41
 
43
  return (
42
  return (
44
    <>
43
    <>
45
      <div className="user-pro-img">
44
      <div className="user-pro-img">
46
        <img
45
        <img
-
 
46
          id="user-profile-img"
47
          id="user-profile-img"
47
          src={`${profileImg.path}?${profileImg.uid}`}
48
          src={`${profileImg.path}?${profileImg.uid}`}
48
          alt=""
49
          alt=""
49
        />
50
        />
50
        {profileId &&
51
        <div className="add-dp" id="OpenImgUpload">
51
          <div className="add-dp" id="OpenImgUpload">
52
          <a href="#" className="btn-image-open" onClick={handleModalOpen}>
52
            <a href="#" className="btn-image-open" onClick={handleModalOpen}>
53
            <i className="fas fa-camera"></i>
53
              <i className="fas fa-camera"></i>
54
          </a>
54
            </a>
55
        </div>
55
          </div>}
56
      </div>
56
      </div>
57
      <ImageModal
57
      <ImageModal
58
        isModalOpen={isModalOpen}
58
        isModalOpen={isModalOpen}
59
        profileId={profileId}
59
        profileId={profileId}
60
        setProfileImg={(newImage) => setProfileImg(newImage)}
60
        setProfileImg={(newImage) => setProfileImg(newImage)}
61
        imageProfileCover={imageProfileCover}
61
        imageProfileCover={imageProfileCover}
62
        handleModalOpen={handleModalOpen}
62
        handleModalOpen={handleModalOpen}
63
        profileType={profileType}
63
        profileType={profileType}
Línea 64... Línea 64...
64
      />
64
      />