school-dashboard-exercise/src/Components/Division/DivisionsHeaderSection.tsx
2024-06-23 12:16:01 +03:00

68 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState } from "react";
import { useModalState } from "../../zustand/Modal";
import { ModalEnum } from "../../enums/Model";
import { FaMoneyBill } from "react-icons/fa";
import { IoMdArrowDropdown, IoMdArrowDropup } from "react-icons/io";
const DivisionsHeaderSection = () => {
const [showAll, setShowAll] = useState<boolean>(false);
const toggleShowAll = () => {
setShowAll(!showAll);
};
const { isOpen, setIsOpen } = useModalState((state) => state);
const handelOpenModal = () => {
setIsOpen(ModalEnum?.DIVISION_ADD);
};
// Define the interface for your data
interface Item {
icon: JSX.Element;
name: string;
}
const data: Item[] = [
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
{ icon: <FaMoneyBill />, name: "الطالبات" },
];
return (
<div className="Divisions_header_section">
<div className="CountCards">
{data?.map((item: Item, index: number) => {
return (
<div
key={index}
className={`CountCard ${!showAll && index >= 5 ? "hidden" : ""}`}
>
<i>{item?.icon}</i>
<h4>{item?.name}</h4>
</div>
);
})}
</div>
{showAll ? (
<span className="Show_More_Button" onClick={toggleShowAll}>
<IoMdArrowDropup />
</span>
) : (
<span className="Show_More_Button" onClick={toggleShowAll}>
<IoMdArrowDropdown />
</span>
)}
<button className="Add_button" onClick={handelOpenModal}>
إضافة مادة
</button>
</div>
);
};
export default DivisionsHeaderSection;