Merge pull request #30 from Hestia-Homes/toast

Toast
This commit is contained in:
KhalimCK 2024-12-04 11:36:29 +00:00 committed by GitHub
commit 580bcd6861
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 11 deletions

View file

@ -6,6 +6,7 @@ import { AuthOptions } from "@/app/api/auth/[...nextauth]/route";
import { getServerSession } from "next-auth/next";
import { cache } from "react";
import { Inter } from "next/font/google";
import { Toaster } from "@/app/shadcn_components/ui/toaster";
// If loading a variable font, you don't need to specify the font weight
const inter = Inter({
@ -51,6 +52,7 @@ export default async function RootLayout({
<ReactQueryProvider>
<Nav userImage={userImage} />
<main className="flex-grow">{children}</main>
<Toaster />
<Footer />
</ReactQueryProvider>
</Provider>

View file

@ -1,14 +1,14 @@
"use client";
import { Dialog, Transition, Menu } from "@headlessui/react";
import { useState, Fragment, useMemo, useRef } from "react";
import { Fragment, useMemo } from "react";
import { Input } from "@/app/shadcn_components/ui/input";
import { Button } from "@/app/shadcn_components/ui/button";
import { Float } from "@headlessui-float/react";
import { ChevronDownIcon } from "@heroicons/react/20/solid";
import { useMutation } from "@tanstack/react-query";
import { useSession } from "next-auth/react";
import { Form, useForm, FormProvider } from "react-hook-form";
import { useForm, FormProvider } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod";
import {
@ -18,8 +18,7 @@ import {
FormControl,
FormMessage,
} from "@/app/shadcn_components/ui/form";
import { Toast } from "@/app/shadcn_components/ui/toast";
import { FileKey } from "lucide-react";
import { useToast } from "@/app/hooks/use-toast";
type Option = {
label: string;
@ -417,12 +416,18 @@ export default function RemoteAssessmentModal({
},
});
// const [toastState, setToastState] = useState<any>([]);
const { toast } = useToast();
const onSubmit = async (data: FormValues) => {
try {
await handleSubmit(data);
form.reset();
setIsOpen(false);
toast({
title: "The Remote Assesment has been sent",
description: "",
});
} catch (error) {
console.error("Error submitting form:", error);
}
@ -631,11 +636,13 @@ export default function RemoteAssessmentModal({
<Button
type="button"
variant="outline"
onClick={() => setIsOpen(false)}
>
onClick={() => { setIsOpen(false); }}>
Cancel
</Button>
<Button type="submit" disabled={presignedUrlIsLoading}>
<Button
type="submit"
disabled={presignedUrlIsLoading}
>
{presignedUrlIsLoading ? "Submitting..." : "Submit"}
</Button>
</div>

View file

@ -5,7 +5,7 @@ import * as ToastPrimitives from "@radix-ui/react-toast"
import { cva, type VariantProps } from "class-variance-authority"
import { X } from "lucide-react"
import { cn } from "s/lib/utils"
import { cn } from "@/lib/utils"
const ToastProvider = ToastPrimitives.Provider

View file

@ -1,6 +1,6 @@
"use client"
import { useToast } from "src/app/shadcn_components/hooks/use-toast"
import { useToast } from "@/app/hooks/use-toast"
import {
Toast,
ToastClose,
@ -8,7 +8,7 @@ import {
ToastProvider,
ToastTitle,
ToastViewport,
} from "src/app/shadcn_components/ui/toast"
} from "@/app/shadcn_components/ui/toast"
export function Toaster() {
const { toasts } = useToast()

View file

@ -1,6 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
export function cn (...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}