Skip to content

Commit 908380e

Browse files
committed
fix(api, layout): update messages endpoint to prevent multiple submissions, and update toast provider to ensure it works and is positioned correctly
1 parent 58cecac commit 908380e

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/app/api/messages/route.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
import "@/lib/observer-setup";
12
import { NextResponse } from "next/server";
23
import { messageNotifier } from "@/lib/observer";
3-
import { DiscordObserver } from "@/lib/dicord";
44

55
export async function POST(req: Request) {
66
try {
7-
messageNotifier.subscribe(DiscordObserver);
8-
97
const data = await req.json();
108
await messageNotifier.notify(data);
119

src/app/providers.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import { HeroUIProvider, ToastProvider } from "@heroui/react";
44
import { ThemeProvider as NextThemesProvider } from "next-themes";
55
import Favicon from "./favicon";
6-
import { ModalLoginContext } from "@/components/auth";
7-
import { ModalFeedbackContext } from "@/components/feedback";
86

97
type Props = {
108
children: React.ReactNode;
@@ -15,20 +13,23 @@ export default function Providers({ children }: Props) {
1513
<HeroUIProvider>
1614
<NextThemesProvider attribute="class" defaultTheme="system" enableSystem>
1715
<ToastProvider
18-
placement="bottom-center"
16+
placement="bottom-right"
1917
maxVisibleToasts={1}
2018
toastProps={{
21-
size: "lg",
22-
radius: "lg",
23-
variant: "solid",
24-
color: "primary",
19+
classNames: {
20+
motionDiv: "flex justify-end items-center pb-10",
21+
base: "w-72 rounded-xl shadow-xl bg-neutral-950 dark:bg-white border-2 border-neutral-800 dark:border-neutral-200",
22+
wrapper: "pl-2",
23+
title: "text-white dark:text-neutral-950 font-medium",
24+
description: "text-neutral-500",
25+
},
26+
size: "sm",
2527
timeout: 5000,
2628
}}
29+
regionProps={{ classNames: { base: "z-[50]" } }}
2730
/>
31+
{children}
2832
<Favicon />
29-
<ModalLoginContext>
30-
<ModalFeedbackContext>{children}</ModalFeedbackContext>
31-
</ModalLoginContext>
3233
</NextThemesProvider>
3334
</HeroUIProvider>
3435
);

src/lib/observer-setup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { messageNotifier } from "@/lib/observer";
2+
import { DiscordObserver } from "@/lib/dicord";
3+
4+
messageNotifier.subscribe(DiscordObserver);

0 commit comments

Comments
 (0)