feat: initial editor files, add toast

This commit is contained in:
2024-02-24 00:30:24 +00:00
parent 8bb3d2bd84
commit 49b80a2f4c
11 changed files with 108 additions and 22 deletions
+18 -2
View File
@@ -1,14 +1,27 @@
import React, { useState } from "react";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
import trpc, { getBaseUrl } from "~/lib/trpc";
import { toast } from "~/lib/utils";
import { httpBatchLink } from "@trpc/react-query";
import { Toaster } from "~/components/ui/sonner";
type Props = {
children: React.ReactNode;
};
const Providers = ({ children }: Props) => {
const [queryClient] = useState(() => new QueryClient());
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
mutations: {
onError(err) {
toast.error(err.message);
},
},
},
})
);
const [trpcClient] = useState(() =>
trpc.createClient({
links: [
@@ -24,7 +37,10 @@ const Providers = ({ children }: Props) => {
return (
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
<QueryClientProvider client={queryClient}>
{children}
<Toaster />
</QueryClientProvider>
</trpc.Provider>
);
};