File size: 1,540 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
import { forwardRef, useState } from "react";
import { GroupResultsProps } from "./GroupResultsProps";
import "../searchResultsItem/SearchResultsItem.scss";
import "./GroupResults.scss";

const GroupResults = forwardRef<HTMLDivElement, GroupResultsProps>(({ group, index }, ref) => {
  const [opened, setOpened] = useState<boolean>(false);

  return (
    <div className="search_result_item" ref={ref}>
      <div className="document">
        <p className="link_button">
          {index + 1}. {group.group_name}
        </p>
      </div>
      {opened && (
        <div className="group_info" style={{ marginLeft: "10px" }}>
          <table>
            <thead>
              <tr>
                <th>ФИО</th>
                <th>Должность внутри группы</th>
              </tr>
            </thead>
            <tbody>
              {group.group_composition.map((person, index) => {
                return (
                  <tr key={person?.person_name + index}>
                    <td>{person?.person_name}</td>
                    <td>{person?.position_in_group.replace("Члены", "Член")}</td>
                  </tr>
                );
              })}
            </tbody>
          </table>
        </div>
      )}
      <div className="actions">
        <button className="link_button" onClick={() => setOpened(!opened)}>
          {opened ? "Свернуть состав" : "Развернуть состав"}
        </button>
      </div>
    </div>
  );
});

export default GroupResults;