import { getStats } from "../../common/ajax/Messages";

import { Credentials } from "../../common/global/Credentials";
import log from "loglevel";

export async function stats(): Promise<void> {
  const stats = await getStats(Credentials.authToken);
  setTimeout(() => {
    $(".admin-stats-spinner").hide();

    $("#totalMessages").text(stats.totalMessages).removeAttr("hidden");
    $("#totalUsers").text(stats.totalUsers).removeAttr("hidden");
    $("#totalOnlineUsers").text(stats.totalOnlineUsers).removeAttr("hidden");
    $("#numMessagesToday").text(stats.numMessagesToday).removeAttr("hidden");
  }, 1000);

  log.debug(stats);
}
