import React from "react";
import {AppState} from "../../Store/RootReducer";
import {useTranslation} from "react-i18next";
import {useAppSelector} from "../../Hook/useAppSelector";
import Mdicon from "../../Components/Misc/Mdicon";

const HeaderStats: React.FC = () => {
    const {t} = useTranslation();
    const headerStatsReducer = useAppSelector((state: AppState) => state.headerStats);

    return (
        <div className="header-stats-flex">
            <div className="header-stats">
                <div className="header-stats-card online">
                    <div className="stat-flex">
                        <div className="stat-icon">
                            <Mdicon name="phone_iphone" />
                        </div>
                        <div className="stat-content">
                            <div className="stat-count">{headerStatsReducer.online}</div>
                            <div className="stat-value-name">{t("STATS_ONLINE")}</div>
                        </div>
                    </div>
                </div>
                <div className="header-stats-card offline">
                    <div className="stat-flex">
                        <div className="stat-icon">
                            <Mdicon name="phone_iphone" />
                        </div>
                        <div className="stat-content">
                            <div className="stat-count">{headerStatsReducer.offline}</div>
                            <div className="stat-value-name">{t("STATS_OFFLINE")}</div>
                        </div>
                    </div>
                </div>
                <div className="header-stats-card new">
                    <div className="stat-flex">
                        <div className="stat-icon">
                            <Mdicon name="phone_iphone" />
                        </div>
                        <div className="stat-content">
                            <div className="stat-count">
                                {headerStatsReducer.lastHour > 0 ? `+${headerStatsReducer.lastHour}` : headerStatsReducer.lastHour}
                            </div>
                            <div className="stat-value-name">{t("STATS_NEW_LAST_HOUR")}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    );
};

export default HeaderStats;
