import { FaEdit } from "react-icons/fa";
import { useState } from "react";
import styles from "./MitgliederItemEdit.module.css";
import EditPopUp from "./EditPopUp";

type MitgliederItemEditProps = {
  user: {
    id: string;
    name: string;
    email: string;
    role: string;
    position: string;
    azure_id: string;
  };
  refetchUsers: () => Promise<void>;
};

const MitgliederItemEdit = ({ user, refetchUsers }: MitgliederItemEditProps) => {
  const [editWindow, setEditWindow] = useState(false);

  return (
    <div>
      <button
        onClick={() => setEditWindow(true)}
        className={styles.editBtn}
        title="Edit user"
      >
        <FaEdit />
      </button>

      {editWindow && (
        <EditPopUp
          user={user}
          closePopup={() => setEditWindow(false)}
          refetchUsers={refetchUsers}
        />
      )}
    </div>
  );
};

export default MitgliederItemEdit; 