Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditansh committed Mar 9, 2024
1 parent 465e762 commit 5db0fd3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
45 changes: 37 additions & 8 deletions devsoc24-portal-fe/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client";
import Image from "next/image";
import { useRouter } from "next/navigation";
import { Suspense, useEffect, useState } from "react";
import { useEffect } from "react";
import Logo from "@/components/logo";
import Dashtitle from "@/assets/images/titleDashboard.svg";
import CustomCard from "@/components/customCard";
import TeamCard from "@/components/teamCard";
import axios, { AxiosError, AxiosResponse } from "axios";
import axios, { type AxiosResponse } from "axios";
import {
useIdeaStore,
useTeamDataStore,
Expand All @@ -15,9 +15,18 @@ import {
} from "@/store/store";
import Loading from "./loading";
import TrackComponent from "@/components/track/TrackComponent";
import logout from "../assets/images/logout.svg";
import { ToastContainer, toast } from "react-toastify";
import { refresh, teamDataProps, userProps } from "@/interfaces";
import { refresh, type userProps } from "@/interfaces";
import { type APIResponse } from "@/schemas/api";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Button } from "@/components/ui/button";
import { User } from "lucide-react";

interface ideaProps {
message: string;
Expand Down Expand Up @@ -45,6 +54,7 @@ export default function HomePage() {
const { team, setTeam } = useTeamStore();
const { user, setUser } = useUserStore();
const { teamData, setTeamData } = useTeamDataStore();


const handleLogout = async () => {
const toastId = toast.loading("Loading...", { autoClose: false });
Expand Down Expand Up @@ -116,10 +126,10 @@ export default function HomePage() {
}
}
};

const fetchTeam = async () => {
try {
const response = await axios.get(
const response = await axios.get<APIResponse>(
`${process.env.NEXT_PUBLIC_API_URL}/team`,
{
withCredentials: true,
Expand Down Expand Up @@ -225,14 +235,33 @@ export default function HomePage() {
<Logo className="h-9/10 w-auto" />
<Image src={Dashtitle as HTMLImageElement} alt="title" />
</div>
<Image
{/* <Image
src={logout as HTMLImageElement}
alt="logout"
height={0}
width={0}
className="h-[50px] w-[50px] hover:cursor-pointer"
onClick={handleLogout}
/>
/> */}
<DropdownMenu>
<DropdownMenuTrigger className="mr-10">
<Button variant="ghost" size="icon">
<User />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel className="cursor-pointer">
Profile
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuLabel
className="cursor-pointer text-red-500"
onClick={handleLogout}
>
Logout
</DropdownMenuLabel>
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="mt-4 flex h-fit w-full flex-col justify-evenly gap-4 overflow-y-auto px-4 md:flex-row lg:h-[85%]">
{team ? (
Expand Down
3 changes: 3 additions & 0 deletions devsoc24-portal-fe/src/components/forms/create-team-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export default function CreateTeamForm() {
<p>Please choose a different name for your team.</p>
</div>
),
type: "error",
isLoading: false,
autoClose: 2000,
});
return;
}
Expand Down
6 changes: 6 additions & 0 deletions devsoc24-portal-fe/src/components/forms/join-team-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export default function JoinTeamForm() {
<p>Please check the team code and try again.</p>
</div>
),
type: "error",
isLoading: false,
autoClose: 2000,
});
return;
} else if (error.response?.status === 424) {
Expand All @@ -110,6 +113,9 @@ export default function JoinTeamForm() {
<p>Try joining another team.</p>
</div>
),
type: "error",
isLoading: false,
autoClose: 2000,
});
return;
}
Expand Down

0 comments on commit 5db0fd3

Please sign in to comment.