windows is not defined for a react client component in nextjs

I’m getting windows is not defined and can’t remove the error by checking windows type or usestate and useeffect to know if it is in client.
Please help me spot the root of the issue.

Here’s the code:

'use client';
import { Metadata } from "next";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Overview } from "./components/overview";
import { RecentSales } from "./components/recent-sales";
import ProfileWallet from "../profile-wallet";
import { useAccount } from 'wagmi';
import { useMutation } from '@tanstack/react-query';
import { useEffect, useState } from "react";
import { getWalletSummary } from "@/services/http/wallets.http";
import clsx from "clsx";
import { Button } from "@/components/ui/button";
import { useWeb3Modal } from "@web3modal/wagmi/react";

export const metadata: Metadata = {
  title: "Dashboard",
  description: "Example dashboard app built using the components.",
};

export default function ProfileDashboard() {
  const { isConnected, address } = useAccount();
  const { mutate: fetchWalletSummary, data: walletSummary } = useMutation(

    {
      mutationKey: ['userWallet', address],
      mutationFn: (walletAddress: string) => getWalletSummary(walletAddress),
    }
  );

  useEffect(() => {
    if (isConnected && address) {
      fetchWalletSummary(address);
    }
  }, [isConnected, address, fetchWalletSummary]);


  return (
    <>
      <div className="flex-col md:flex">
        <div className="flex-1 space-y-4 pt-6">
          <div className="flex items-center justify-between space-y-2">
            <h2 className="text-3xl font-bold tracking-tight">Dashboard</h2>
          </div>
          <Tabs defaultValue="overview" className="space-y-4">
            <TabsList className="w-full md:w-auto">
              <TabsTrigger value="overview">Overview</TabsTrigger>
              <TabsTrigger value="wallets">Wallets</TabsTrigger>
              <TabsTrigger value="analytics" disabled>Reports</TabsTrigger>
              <TabsTrigger value="notifications" disabled>Notifications</TabsTrigger>
            </TabsList>
            <TabsContent value="overview">
                {isConnected ? (
                  <div className="space-y-4">
                    <div className="grid gap-4 grid-cols-1 w-full md:grid-cols-2 lg:grid-cols-4">
                      <DashboardCard
                        title="Net Profit"
                        iconPath="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"
                      >
                        {walletSummary?.netProfit !== undefined ? (
                          <div className="text-2xl font-bold">${walletSummary.netProfit}</div>
                        ) : (
                          <ConnectWalletMessage />
                        )}
                      </DashboardCard>
                      {walletSummary?.transactionMetrics?.totalTransactions !== undefined && (
                        <DashboardCard
                          title="Total Transactions"
                          iconPath="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 7a4 4 0 1 1 0 7.75M22 21v-2a4 4 0 0 0-3-3.87"
                        >
                          <div className="text-2xl font-bold">{walletSummary.transactionMetrics.totalTransactions}</div>
                        </DashboardCard>
                      )}
                      <DashboardCard
                        title="Highest Profitable Trade"
                        iconPath="M2 10h20"
                      >
                        {walletSummary?.highestProfit !== undefined ? (
                          <div className="text-2xl font-bold">{walletSummary.highestProfit[0]}</div>
                        ) : (
                          <ConnectWalletMessage />
                        )}
                      </DashboardCard>
                      <DashboardCard
                        title="Money Flow"
                        iconPath="M22 12h-4l-3 9L9 3l-3 9H2"
                      >
                        {walletSummary?.totalDeposit !== undefined && walletSummary?.totalWithdraw !== undefined ? (
                          <div className="text-2xl font-bold">
                            <div className="text-sm text-muted-foreground">Inflow: {walletSummary.totalDeposit}</div>
                            <div className="text-sm text-muted-foreground">Outflow: {walletSummary.totalWithdraw}</div>
                          </div>
                        ) : (
                          <ConnectWalletMessage />
                        )}
                      </DashboardCard>
                    </div>
                    <div className="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-7">
                      <DashboardCard
                        title="Overview"
                        iconPath="M22 12h-4l-3 9L9 3l-3 9H2"
                        classNames="col-span-3 md:col-span-4">
                        {walletSummary && <Overview walletInfo={walletSummary} />}
                      </DashboardCard>
                      <DashboardCard
                        title="Watchlist"
                        iconPath="M22 12h-4l-3 9L9 3l-3 9H2"
                        classNames="col-span-3">
                        <RecentSales />
                      </DashboardCard>
                    </div>
                  </div>
                ) : (
                  <ConnectWalletGrid />
                )}
            </TabsContent>
            <TabsContent value="wallets" className="space-y-4">
              {/* {isConnected ? <ProfileWallet /> : <ConnectWalletGrid />} */}
            </TabsContent>
          </Tabs>
        </div>
      </div>
    </>
  );
}

interface DashboardCardProps {
  title: string;
  iconPath: string;
  children: React.ReactNode;
  classNames?: string;
}

function DashboardCard({ title, iconPath, children, classNames }: DashboardCardProps) {
  return (
    <Card className={clsx('w-full', classNames)}>
      <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
        <CardTitle className="text-sm font-medium">{title}</CardTitle>
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
          className="h-4 w-4 text-muted-foreground"
        >
          <path d={iconPath} />
        </svg>
      </CardHeader>
      <CardContent>
        {children}
      </CardContent>
    </Card>
  );
}

function ConnectWalletGrid() {
  return (
    <div className="space-y-4">
      <div className="grid gap-4 grid-cols-1 w-full md:grid-cols-2 lg:grid-cols-4">
        <DashboardCard
          title="Net Profit"
          iconPath="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"
        >
          <ConnectWalletMessage />
        </DashboardCard>
        <DashboardCard
          title="Total Transactions"
          iconPath="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 7a4 4 0 1 1 0 7.75M22 21v-2a4 4 0 0 0-3-3.87"
        >
          <ConnectWalletMessage />
        </DashboardCard>
        <DashboardCard
          title="Highest Profitable Trade"
          iconPath="M2 10h20"
        >
          <ConnectWalletMessage />
        </DashboardCard>
        <DashboardCard
          title="Money Flow"
          iconPath="M22 12h-4l-3 9L9 3l-3 9H2"
        >
          <ConnectWalletMessage />
        </DashboardCard>
      </div>
      <div className="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-7">
        <DashboardCard
          title="Overview"
          iconPath="M22 12h-4l-3 9L9 3l-3 9H2"
          classNames="col-span-3 md:col-span-4">
          <ConnectWalletMessage />
        </DashboardCard>
        <DashboardCard
          title="Watchlist"
          iconPath="M22 12h-4l-3 9L9 3l-3 9H2"
          classNames="col-span-3">
          <RecentSales />
        </DashboardCard>
      </div>
    </div>
  );
}

function ConnectWalletMessage() {
  const { open } = useWeb3Modal();

  return (
    <div className="flex flex-col items-center justify-center gap-2 my-5">
      <Button variant="outline" onClick={() => open()}>
        Connect with wallet to see info
      </Button>
    </div>
  );
}

I tried checking the type of windows and useeffect alongside usestate to flip usestates value to know if things are happening in the client.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật