Skip to content

Commit

Permalink
Merge pull request #28 from Octasol/hotfix2
Browse files Browse the repository at this point in the history
Refactor layout component to dispatch decrement action when counter v…
  • Loading branch information
A91y authored Nov 17, 2024
2 parents 15a9cb1 + b5120a4 commit a7279ae
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/app/(pages)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,33 @@
import Sidebar from "@/components/Sidebar";
import VerifyMail from "@/components/verifyMail";
import React, { ReactNode, useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import Image from "next/image";
import { decrement } from "../Redux/Features/loader/loaderSlice";

type Props = { children: ReactNode };
const Layout = ({ children }: Props) => {
const session = useSelector((state: any) => state.user);
const counter = useSelector((state: any) => state.counter);
const [verifiedEmail, setVerifiedEmail] = useState(true);
const dispatch = useDispatch();

const verified = async (): Promise<void> => {
console.log("session", session);

if (session && session.accessToken) {
setVerifiedEmail(session.isVerifiedEmail);
if (session) {
console.log(counter);
if (counter.value > 0) {
dispatch(decrement());
}
}
}
};
useEffect(() => {
verified();
}, [session, verifiedEmail]);
}, [session, verifiedEmail, counter]);

return (
<>
Expand Down

0 comments on commit a7279ae

Please sign in to comment.