Skip to content

Commit

Permalink
Move Toaster to layout.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
JaaskelainenL committed Jan 22, 2025
1 parent ae00f6d commit 32d085c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions apps/web/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata, Viewport } from "next";
// eslint-disable-next-line camelcase -- next/font/google
import { Inter, Roboto_Mono } from "next/font/google";
import NextTopLoader from "nextjs-toploader";
import { Toaster } from "sonner";
import { Footer } from "../../components/footer";
import { MainNav } from "../../components/main-nav";
import { MobileNav } from "../../components/mobile-nav";
Expand Down Expand Up @@ -100,6 +101,7 @@ export default async function RootLayout(
<MobileNav className="sticky top-0 z-50 lg:hidden" />
<MainNav className="sticky top-0 z-50 hidden lg:block" />
<div className="min-h-screen flex-1">{children}</div>
<Toaster richColors />
<Footer />
</div>
</body>
Expand Down
6 changes: 2 additions & 4 deletions apps/web/src/components/invoice-generator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
useState,
} from "react";
import Form from "next/form";
import { toast } from "sonner";
import {
I18nProviderClient,
useCurrentLocale,
Expand All @@ -20,7 +21,6 @@ import {
import { SaveAction } from "../../lib/api/external/laskugeneraattori/actions";
import { type InvoiceGeneratorFormState } from "../../lib/api/external/laskugeneraattori/index";

import { Toaster, toast } from "sonner";

interface GenericFieldProps extends InputHTMLAttributes<HTMLInputElement> {
label: string;
Expand Down Expand Up @@ -98,9 +98,7 @@ function SubmitButton({
<Button className="w-full max-w-sm" type="submit" disabled={pending}>
{t("Submit")}
</Button>
{formState?.success ? (
<Toaster richColors />
) : formState?.success === false && errorKeys.length === 0 ? (
{formState?.success === false && errorKeys.length === 0 ? (
<p data-form-status aria-live="polite" className="block text-red-600">
{formState.errorText}
</p>
Expand Down

0 comments on commit 32d085c

Please sign in to comment.