File size: 3,846 Bytes
79278ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { StaffResultsItemProps } from "./StaffResultsItemProps";
import "../searchResultsItem/SearchResultsItem.scss";
import "./StaffResultsItem.scss";
import { forwardRef, useState } from "react";

const StaffResultsItem = forwardRef<HTMLDivElement, StaffResultsItemProps>(({ staff, index }, ref) => {
  const [opened, setOpened] = useState<boolean>(false);
  return (
    <div className="staff_result_item" ref={ref}>
      <div className="document">
        <p className="link_button">
          {index + 1}. {staff.person_name}
        </p>
      </div>

      {!opened && (
        <div className="staff_info" style={{ marginLeft: "10px" }}>
          {staff.organizatinal_structure && (
            <div key={staff.organizatinal_structure[0].position} style={{ marginBottom: "15px" }}>
              <div style={{ marginBottom: "5px" }}>
                <strong>Должность:</strong> {staff.organizatinal_structure[0].position}
              </div>
            </div>
          )}
        </div>
      )}

      {opened && (
        <div className="staff_info" style={{ marginLeft: "10px" }}>
          {staff.organizatinal_structure?.map((element) => (
            <div key={element.position} style={{ marginBottom: "15px" }}>
              <div style={{ marginBottom: "5px" }}>
                <strong>Должность:</strong> {element.position}
              </div>
              {element.leads && (
                <div style={{ marginBottom: "5px" }}>
                  <strong>Руководит следующими сотрудниками:</strong>
                  {element.leads?.map((person, index) =>
                    person.person != "undefined" ? <div key={person.person + index}>{person.person}</div> : null
                  )}
                </div>
              )}
              <div style={{ marginBottom: "5px" }}>
                <strong>
                  Руководителем {staff.person_name} является {element?.subordinates?.person_name}
                </strong>
              </div>
            </div>
          ))}
          {staff.business_processes && (
            <div style={{ marginBottom: "10px" }}>
              <strong>Отвечает за бизнес-процессы:</strong>
              {staff.business_processes.map((process, index) => (
                <div key={process.processes_name + index}>{process.processes_name}</div>
              ))}
            </div>
          )}
          {staff.business_curator && (
            <div style={{ marginBottom: "10px" }}>
              <strong>Является бизнес-куратором (РОКС НН):</strong>
              {staff.business_curator.map((company, index) => (
                <div key={company.company_name + index}>{company.company_name}</div>
              ))}
            </div>
          )}
          {staff.groups && (
            <div>
              <strong>Входит в состав групп:</strong>
              <ul>
                {staff.groups.map((personGroup, index) => (
                  <li key={personGroup.group_name + index}>
                    <div style={{ marginBottom: "10px" }}>
                      <div>
                        <strong>{personGroup.group_name}</strong>
                      </div>
                      <strong>Должность внутри группы:</strong> {personGroup.position_in_group.replace("Члены", "Член")}
                    </div>
                  </li>
                ))}
              </ul>
            </div>
          )}
        </div>
      )}
      <div className="actions">
        <button className="link_button" onClick={() => setOpened(!opened)}>
          {opened ? "Свернуть" : "Развернуть"}
        </button>
      </div>
    </div>
  );
});

export default StaffResultsItem;