import React from "react";
import styles from "@/app/(Admin)/dashboard/(Users)/users-login/userslogin.module.css";
import Link from "next/link";
import { BsArrowLeft } from "react-icons/bs";
import { getAllToken, getTokenBy } from "@/models/users";
import UsersLoginData from "@/components/administrator/UsersLogin/user.online.data";
import { decodeRefreshToken } from "@/utils/cookie";

const UsersLogin = async () => {
  const uid = (await decodeRefreshToken()).data?.uid;
  const allToken = await getAllToken();
  const activeUsers = allToken.filter((item) => item.uid !== uid);

  return (
    <div className={styles.container}>
      <div className={styles.header}>
        <Link
          className={styles.back}
          href="/dashboard">
          <BsArrowLeft /> back
        </Link>
      </div>
      <div className={styles.body}>
        <UsersLoginData initialData={activeUsers} />
      </div>
    </div>
  );
};

export default UsersLogin;
