Add success toast

This commit is contained in:
Daniel Roth 2026-03-03 12:23:17 +00:00
parent 12fed5ae82
commit cbf2d1705b
4 changed files with 33 additions and 12 deletions

View file

@ -21,7 +21,7 @@ import { Button } from "@/app/shadcn_components/ui/button";
import { cva } from "class-variance-authority";
import { getUploadedFile } from "@/app/db/surveyDB/schema/surveyDB";
import BookSurveyModal from "@/app/portfolio/[slug]/components/BookSurveyModal";
import BookingSuccessToast from "@/app/portfolio/[slug]/components/BookingSuccessToast";
import SuccessToast from "@/app/portfolio/[slug]/components/SuccessToast";
import { PropertyMeta } from "@/app/db/schema/property";
interface ToolbarProps {
@ -179,8 +179,9 @@ export function Toolbar({
)}
{/* ✅ Toast */}
<BookingSuccessToast
<SuccessToast
show={showToast}
showConfetti={showToast}
onClose={() => setShowToast(false)}
message="Survey Request Recieved!"
subtext="We'll be in contact soon. 🎉"

View file

@ -34,6 +34,7 @@ export interface RecommendationsOptionsProps {
disabled?: boolean;
scenarios: ScenarioSummary[]
portfolioId: number
onSuccess: () => void;
}
interface ScenarioWithPriority {
@ -113,7 +114,8 @@ function SortableScenarioItem({
export function RecommendationsOptions({
disabled = false,
scenarios,
portfolioId
portfolioId,
onSuccess
}: RecommendationsOptionsProps) {
const [isApplying, setIsApplying] = useState(false);
const [open, setOpen] = useState(false);
@ -181,6 +183,8 @@ export function RecommendationsOptions({
body: JSON.stringify(payload)
});
onSuccess();
setIsApplying(false);
setOpen(false);
};

View file

@ -23,6 +23,7 @@ import type {
} from "./types";
import { ReportingFunctionalityButtons } from "./ReportingFunctionalityButtons";
import { RecommendationsOptions } from "./RecommendationsOptions";
import SuccessToast from "../../components/SuccessToast";
interface ReportingClientAreaProps {
baseline: BaselineMetrics;
@ -88,6 +89,7 @@ export function ReportingClientArea({
const [measuresOpen, setMeasuresOpen] = useState<boolean>(false);
const [appliedHideNonCompliant, setAppliedHideNonCompliant] =
useState<boolean>(false);
const [showToast, setShowToast] = useState(false);
const drawerOpen = Boolean(selectedScenarioId);
@ -272,6 +274,7 @@ export function ReportingClientArea({
disabled={scenarioBusy}
scenarios={scenarios}
portfolioId={portfolioId}
onSuccess={() => setShowToast(true)}
/>
}
</div>
@ -346,6 +349,15 @@ export function ReportingClientArea({
data={measuresData ?? null}
error={measuresError}
/>
<SuccessToast
show={showToast}
showConfetti={true}
onClose={() => setShowToast(true)}
message="Recommendation process triggered"
subtext="Recommendations might take a few minutes to update"
timeoutMs={6000}
/>
</>
);
}

View file

@ -5,28 +5,32 @@ import { motion, AnimatePresence } from "framer-motion";
import Confetti from "react-confetti";
import { CheckCircle } from "lucide-react";
interface BookingSuccessToastProps {
interface SuccessToastProps {
show: boolean;
showConfetti: boolean;
onClose: () => void;
message?: string;
subtext?: string;
message: string;
subtext: string;
timeoutMs?: number;
}
export default function BookingSuccessToast({
export default function SuccessToast({
show,
showConfetti,
onClose,
message = "Booking Confirmed!",
subtext = "Youre all set. 🎉",
}: BookingSuccessToastProps) {
message,
subtext,
timeoutMs = 4000
}: SuccessToastProps) {
const [confetti, setConfetti] = useState(false);
useEffect(() => {
if (show) {
setConfetti(true);
setConfetti(showConfetti);
const timer = setTimeout(() => {
setConfetti(false);
onClose();
}, 4000);
}, timeoutMs);
return () => clearTimeout(timer);
}
}, [show, onClose]);