Skip to content

Commit

Permalink
Merge pull request #280 from Sid-80/fix/bugs
Browse files Browse the repository at this point in the history
fix: bugs
  • Loading branch information
subhadeeproy3902 authored Jun 13, 2024
2 parents 59c694d + 424d939 commit a0aeb42
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 39 deletions.
10 changes: 1 addition & 9 deletions src/app/dashboard/_components/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function SideNav() {
const { setFileList_ } = useContext(FileListContext);
const dispatch = useDispatch();
const { theme } = useTheme();
const [background, setBackground] = useState("dark");
const [isSidebarOpen, setIsSidebarOpen] = useState(true);

const dispatch_nav = useDispatch();
Expand Down Expand Up @@ -76,16 +75,9 @@ function SideNav() {
setTotalFiles(result?.length);
};

useEffect(() => {
setBackground(theme === "dark" ? "dark" : "light");
}, [theme]);

return (
<div
className={
`h-screen fixed md:w-72 w-60 borde-r border-[1px] p-6 flex flex-col ` +
(`${background}` === "dark" ? "bg-black" : "bg-white")
}
className={`h-screen fixed md:w-72 w-60 borde-r border-[1px] p-6 flex flex-col `}
>
<button
className="md:hidden absolute top-4 right-4 mb-2"
Expand Down
6 changes: 3 additions & 3 deletions src/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ function DashboardLayout({
const result = await convex.query(api.teams.getTeam, {
email: user?.email,
});

if (!result?.length) {
createTeam({
teamName: "My Org",
teamName: `${user.given_name} Org`,
createdBy: user?.email,
teamMembers: [user.email]
teamMembers: [user.email],
}).then((resp) => {
if (resp) {
router.push("/dashboard");
Expand Down
48 changes: 23 additions & 25 deletions src/app/invite/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function Page({ params }: any) {
const [errorMsg, setErrorMsg] = useState("");
const [isError, setIsError] = useState(false);
const [isDialogOpen, setIsDialogOpen] = useState(false);
const [isValidLink,setIsValidLink] = useState(true);
const [isValidLink, setIsValidLink] = useState(true);
const { user }: any = useKindeBrowserClient();
const { isAuthenticated } = useKindeBrowserClient();

Expand All @@ -43,48 +43,47 @@ export default function Page({ params }: any) {
_id: id,
});
if (result) {
console.log(isDialogOpen);
setErrorMsg("");
setIsError(false);
setTeamData(result);
setIsDialogOpen(true);
} else {
setIsDialogOpen(true);
setErrorMsg("Invalid Invite Link!!");
setIsError(true);
setTeamData("Invalid Link")
setTeamData("Invalid Link");
setIsValidLink(false);
}
};
if (user && isAuthenticated) {
getTeamData();
}
}, [user]);

useEffect(() => {
const timer = setTimeout(() => {
if (!user && !isAuthenticated && !isDialogOpen && !teamData) {
if(!user && !isAuthenticated){
const timer = setTimeout(()=>{
setIsDialogOpen(true);
setErrorMsg("Unauthorized Access!!");
setIsError(true);
}
}, 5000);

return () => clearTimeout(timer);
},3000)
return () => clearTimeout(timer);
}
}, [user]);

const AddUserToMember = async () => {

if (teamData.teamMembers?.includes(user.email) || teamData.createdBy == user.email) {
setErrorMsg(`Already member of ${teamData.teamName}`)
const AddUserToMember = async () => {
if (
teamData.teamMembers?.includes(user.email) ||
teamData.createdBy == user.email
) {
setErrorMsg(`Already member of ${teamData.teamName}`);
setIsError(true);
return;
}

let memberArray:string[];
let memberArray: string[];

if(teamData.teamMembers){
if (teamData.teamMembers) {
memberArray = teamData.teamMembers;
}else{
} else {
memberArray = [teamData.createdBy];
}

Expand All @@ -96,7 +95,6 @@ export default function Page({ params }: any) {
});

router.push("/dashboard");

};

if (!isDialogOpen) return <Loader />;
Expand Down Expand Up @@ -199,7 +197,9 @@ export default function Page({ params }: any) {
{!user && !isAuthenticated && (
<>
<AlertDialogHeader>
<AlertDialogTitle>Unauthorized Access or Invalid link!!</AlertDialogTitle>
<AlertDialogTitle>
Unauthorized Access or Invalid link!!
</AlertDialogTitle>
<AlertDialogDescription className="w-full">
<p>Register or Login to your account.</p>
<p>Link may be Invalid!</p>
Expand All @@ -215,9 +215,8 @@ export default function Page({ params }: any) {
</AlertDialogFooter>
</>
)}
{
user && isAuthenticated && isError && (
<>
{user && isAuthenticated && isError && (
<>
<AlertDialogHeader>
<AlertDialogTitle>{errorMsg}</AlertDialogTitle>
</AlertDialogHeader>
Expand All @@ -230,8 +229,7 @@ export default function Page({ params }: any) {
</Link>
</AlertDialogFooter>
</>
)
}
)}
</AlertDialogContent>
</AlertDialog>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/RenameFileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function RenameFileModal({ id }: Props) {
<DialogTitle>File renamed successfully!!</DialogTitle>
</DialogHeader>
<DialogFooter>
<Button onClick={() => router.refresh()}>Close</Button>
<Button onClick={() => window.location.reload()}>Close</Button>
</DialogFooter>
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/RenameTeamModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function RenameTeamModal() {
<DialogTitle>Team renamed successfully!!</DialogTitle>
</DialogHeader>
<DialogFooter>
<Button onClick={() => router.refresh()}>Close</Button>
<Button onClick={() => window.location.reload()}>Close</Button>
</DialogFooter>
</>
)}
Expand Down

0 comments on commit a0aeb42

Please sign in to comment.