Skip to content

Commit

Permalink
show banner idea
Browse files Browse the repository at this point in the history
  • Loading branch information
Abh1noob committed Mar 18, 2024
1 parent dadf63b commit 06e0fda
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions devsoc24-portal-fe/src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,44 @@ export default function HomePage() {
}
};

const fetchBanner = async () => {
try {
const response: AxiosResponse<ideaProps> = await axios.get(
`${process.env.NEXT_PUBLIC_API_URL}/idea`,
{
withCredentials: true,
},
);
if (response.data.status === "success") {
setShowBanner(true);
// setShowNotice(true);
setSelected(true);
SetIdea("idea found");
}
} catch (e) {
if (axios.isAxiosError(e)) {
const axiosError = e as AxiosError<APIResponse>;
switch (axiosError.response?.status) {
case 401:
router.push("/");
break;
case 404:
SetIdea("");
break;
case 417:
// console.log("team no idea");
break;
case 409:
setIdea(409);
break;
default:
// console.log(e);
break;
}
}
}
};

const fetchTeam = async () => {
try {
const response = await axios.get<APIResponse>(
Expand Down Expand Up @@ -223,6 +261,7 @@ export default function HomePage() {
} else {
void fetchIdea();
void fetchTeam();
void fetchBanner();
}
}, []);

Expand Down Expand Up @@ -376,8 +415,8 @@ export default function HomePage() {
<>
<Check className="h-8 w-8 text-white" />
<p className="pl-2 text-xl text-white">
Congratulations! Your idea has been shortlisted for round 2.
Report to Anna Auditorium before 11:45 AM.
Congratulations! Your idea has been shortlisted for
round 2. Report to Anna Auditorium before 11:45 AM.
</p>
</>
) : (
Expand Down

0 comments on commit 06e0fda

Please sign in to comment.