/* eslint-disable react-hooks/set-state-in-effect */ "use client"; import { Fragment, useEffect, useState } from "react"; import { Box, Button, Heading, Icon, Link, Skeleton, Text, VStack } from "@chakra-ui/react"; import { useQuery } from "@urql/next"; import lineChartArr from "@/lib/lineChartArray"; import LinksDeletedChart from "./LinksDeletedChart"; import { LineChartArr } from "@/types/LineChartStats"; import CommandResponsesChart from "./CommandResponsesChart"; import TimedTriggeredChart from "./TimesTriggeredChart"; import GetStatsRange from "@/graphql/queries/getStatsRange"; import StatsList from "./StatsList"; import GetTotalGroupsQuery from "@/graphql/queries/getTotalGroups"; import GetTotalStatsQuery from "@/graphql/queries/getTotalStats"; import GetTodaysStatsQuery from "@/graphql/queries/getTodaysStats"; import Image from "next/image"; export default function Home() { // * Total Groups * // const [ { fetching: totalGroupsFetching, data: totalGroups, error: totalGroupsError } ] = useQuery({ query: GetTotalGroupsQuery }); // * Total Stats * // const [ { fetching: totalStatsFetching, data: totalStats, error: totalStatsError } ] = useQuery({ query: GetTotalStatsQuery }); // * Today's Stats * // const [ { fetching: todaysStatsFetching, data: todayStats, error: todaysStatsError } ] = useQuery({ query: GetTodaysStatsQuery }); // * 30 Day Stats * // // Dates const [currDate, setCurrDate] = useState(); const [date30DaysAgo, setDate30DaysAgo] = useState(); useEffect(() => { setCurrDate(new Date()); setDate30DaysAgo(new Date(new Date().setDate(new Date().getDay() - 30))); }, []); const [ { fetching: thirtyDayStatsFetching, data: thirtyDayStats, error: thirtyDayStatsError } ] = useQuery({ query: GetStatsRange, variables: { stateDate: currDate, endDate: date30DaysAgo } }); // Line Chart Data const [lineChartArrState, setLineChartArrState] = useState( [] as LineChartArr ); useEffect(() => { if (!thirtyDayStatsFetching && thirtyDayStats.getStatsRange) { setLineChartArrState(lineChartArr(thirtyDayStats.getStatsRange)); } }, [ thirtyDayStats.getStatsRange, thirtyDayStatsError, thirtyDayStatsFetching ]); return ( {"Nazi Site Patrol Stats"} { "A telegram bot that removes links and embeds to sites that align with the Fascist Right political agenda." } { "The bot requires no configuration. All it needs is admin privileges to delete messages in your group." } {`30 Day Stats`} {"Updates every 24 hours"} {"Down with fascism! Fuck MAGA! Fuck Trump! Fuck Nazis!"} { "Trans rights are human rights! Trans women are women! Trans men are men! Never let them take away your happiness!" } intersex inclusive pride flag ); }