Files
front-AT/app/Components/Global/visual/GlobalAlert.tsx
T

37 lines
1014 B
TypeScript
Raw Normal View History

2025-09-24 18:34:13 -06:00
"use client";
import { useEffect, useState } from "react";
2025-09-26 16:56:07 -06:00
import AlertBox from "@/app/Components/Global/AlertBox/AlertBox";
import ClearParams from "@/app/Components/Global/ClearParams/ClearParams";
2025-09-29 19:57:02 -06:00
import { useSearchParams } from "next/navigation";
2025-09-24 18:34:13 -06:00
export default function GlobalAlert() {
2025-09-29 19:57:02 -06:00
const searchParams = useSearchParams();
2025-09-24 18:34:13 -06:00
const [showSuccess, setShowSuccess] = useState<string | null>(null);
const [showError, setShowError] = useState<string | null>(null);
useEffect(() => {
2025-09-29 19:57:02 -06:00
const success = searchParams.get("success");
const error = searchParams.get("error");
2025-09-24 18:34:13 -06:00
if (success) setShowSuccess(success);
if (error) setShowError(error);
}, []);
return (
<section className="containerAlerts">
{showError && (
<>
<AlertBox key={Date.now()} message={showError} type="error" />
</>
)}
{showSuccess && (
<>
<AlertBox key={Date.now()} message={showSuccess} type="success" />
</>
)}
</section>
);
}