diff --git a/apps/web/src/components/Thread/CommentInput.tsx b/apps/web/src/components/Thread/CommentInput.tsx
index 900a5a29..732a19df 100644
--- a/apps/web/src/components/Thread/CommentInput.tsx
+++ b/apps/web/src/components/Thread/CommentInput.tsx
@@ -5,6 +5,7 @@ import { DIDSession } from "did-session";
import { trpc } from "../../utils/trpc";
import { ComposeClient } from "@composedb/client";
import { definition } from "@devnode/composedb";
+import { toast } from 'react-toastify';
export const compose = new ComposeClient({
ceramic: String(process.env.NEXT_PUBLIC_CERAMIC_NODE),
@@ -36,6 +37,12 @@ const CommentInput = (props: { threadId: string; refresh: () => void }) => {
const discordUserName = authorDiscord.data?.discordUsername ?? "Anonymous";
const onCommentSubmit = async () => {
+
+ if(comment.length === 0){
+ toast.error("Empty comment");
+ return;
+ }
+
const session = await DIDSession.fromSession(didSession);
compose.setDID(session.did);
@@ -53,7 +60,10 @@ const CommentInput = (props: { threadId: string; refresh: () => void }) => {
"Content-Type": "application/json",
},
}
- ).then(() => {
+ ).then((response) => {
+ if(!response.ok){
+ toast.error("Invalid thread or Api failed");
+ }
setComment("");
props.refresh();
});
diff --git a/apps/web/src/components/Thread/NewThread.tsx b/apps/web/src/components/Thread/NewThread.tsx
index 400b842f..bd1f7d0c 100644
--- a/apps/web/src/components/Thread/NewThread.tsx
+++ b/apps/web/src/components/Thread/NewThread.tsx
@@ -30,6 +30,10 @@ const NewThread = (props) => {
const discordUserName = authorDiscord.data?.discordUsername ?? "Anonymous";
const onThreadSumbit = async () => {
+ if(thread.length === 0){
+ toast.error("Empty thread");
+ return;
+ }
await fetch(`${String(process.env.NEXT_PUBLIC_DISCORD_BOT_URL)}webthread`, {
body: JSON.stringify({
threadTitle: thread,
@@ -41,7 +45,7 @@ const NewThread = (props) => {
headers: {
"Content-Type": "application/json",
},
- }).then(async (response) => {
+ }).then((response) => {
if(!response.ok){
toast.error("Community missing or Api failed");
}
@@ -81,6 +85,7 @@ const NewThread = (props) => {
className="form-control m-0 block w-full rounded border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-1.5 text-base font-normal text-gray-700 focus:border-blue-600 focus:bg-white focus:text-gray-700 focus:outline-none"
id="exampleFormControlTextarea13"
placeholder="Thread title"
+ value={thread}
onChange={(e) => setThread(e.target.value)}
/>
diff --git a/apps/web/src/pages/index.tsx b/apps/web/src/pages/index.tsx
index 2f2600c2..6787880a 100644
--- a/apps/web/src/pages/index.tsx
+++ b/apps/web/src/pages/index.tsx
@@ -7,6 +7,7 @@ import { useAccount } from "wagmi";
import useLocalStorage from "../hooks/useLocalStorage";
import { trpc } from "../utils/trpc";
+import Modal from "../components/Modal/Modal";
const Home: NextPage = () => {
const threads = trpc.public.getAllThreads.useQuery();
@@ -14,6 +15,7 @@ const Home: NextPage = () => {
const { isConnected } = useAccount();
const [isDidSession, setDidSession] = useState(didSession?true:false);
const [isDiscordUser, setDiscordUser] = useState(false);
+ const [isOpen, setOpen] = useState(false);
if (!threads.data) return
Loading...
;
@@ -24,6 +26,10 @@ const Home: NextPage = () => {
setDiscordUser(value)
}
+ const handleClick = () => {
+ setOpen((state) => !state);
+ };
+
const checkConnected = () =>{
if (!isConnected)
return (
@@ -46,12 +52,13 @@ const Home: NextPage = () => {
if (!isDiscordUser)
return (
-
+
Please connect to Discord
);
}
+
return (
{
}
);
};
diff --git a/apps/web/src/server/trpc/router/public.ts b/apps/web/src/server/trpc/router/public.ts
index 685da77f..7ad17dea 100644
--- a/apps/web/src/server/trpc/router/public.ts
+++ b/apps/web/src/server/trpc/router/public.ts
@@ -58,6 +58,9 @@ export const publicRouter = router({
getAuthor: publicProcedure
.input(z.object({ pkh: z.string() }))
.query(async ({ input }) => {
+ if(!input.pkh || input.pkh === ""){
+ return null;
+ }
let user = await prisma.user.findFirstOrThrow({
where: {
didpkh: input.pkh,
@@ -70,6 +73,9 @@ export const publicRouter = router({
getDiscordUser: publicProcedure
.input(z.object({ didSession: z.string() }))
.query(async ({ input }) => {
+ if(!input.didSession || input.didSession === ""){
+ return null;
+ }
let discordUsername = await prisma.user.findFirstOrThrow({
where: {
didSession: input.didSession,
diff --git a/yarn.lock b/yarn.lock
index e24e03ab..e2cc431e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5665,7 +5665,7 @@ clone@^2.1.1:
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==
-clsx@^1.1.0:
+clsx@^1.1.0, clsx@^1.1.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12"
integrity sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==
@@ -12290,6 +12290,13 @@ react-ssr-prepass@^1.5.0:
resolved "https://registry.yarnpkg.com/react-ssr-prepass/-/react-ssr-prepass-1.5.0.tgz#bc4ca7fcb52365e6aea11cc254a3d1bdcbd030c5"
integrity sha512-yFNHrlVEReVYKsLI5lF05tZoHveA5pGzjFbFJY/3pOqqjGOmMmqx83N4hIjN2n6E1AOa+eQEUxs3CgRnPmT0RQ==
+react-toastify@^9.1.1:
+ version "9.1.1"
+ resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-9.1.1.tgz#9280caea4a13dc1739c350d90660a630807bf10b"
+ integrity sha512-pkFCla1z3ve045qvjEmn2xOJOy4ZciwRXm1oMPULVkELi5aJdHCN/FHnuqXq8IwGDLB7PPk2/J6uP9D8ejuiRw==
+ dependencies:
+ clsx "^1.1.1"
+
react@18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"