Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed feedbacks from radicle #5

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const Modal = ({handleClick}) => {
<li>Go to devnode server.</li>
<li>In &quot;devnode_signin&quot; channel type &quot;devnode&quot;.</li>
<li>Check your DM. You will be asked to reply with your did. It should look similar to this example: &quot;did:key:z6MkkyAkqY9bPr8gyQGuJTwQvzk8nsfywHCH4jyM1CgTq4KA&quot;. You can copy the DID by clicking on the created DID.</li>
<li>You will get a challenge link. Copy that link and paste it in your browser.</li>
<li>You will get a challenge code. Copy that URL and paste it in your browser.</li>
<li>Once you get the success message, you are good to go. Head back to the application and start exploring.</li>
</ol>
</div>
<a href={String(process.env.DISCORD_SERVER_URL)} target="_blank" rel="noreferrer" className="flex justify- items-center w-1/3 mx-auto bg-[#5A68F1] text-white p-3 border-2 rounded-lg">
<a href="https://discord.com/channels/959133142348886016/1043095213238915093" target="_blank" rel="noreferrer" className="flex justify- items-center w-1/3 mx-auto bg-[#5A68F1] text-white p-3 border-2 rounded-lg">
<div className="w-5 h-5 mr-2">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" fill="currentColor" viewBox="0 0 16 16">
<path d="M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612Zm5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612Z"/>
Expand Down
17 changes: 10 additions & 7 deletions apps/web/src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Resolver } from "did-resolver";
import { getResolver } from "pkh-did-resolver";
import { trpc } from "../../utils/trpc";
import { Modal } from "../Modal";
import Link from "next/link";

const pkhResolver = getResolver();
const resolver = new Resolver(pkhResolver);
Expand Down Expand Up @@ -90,13 +91,15 @@ const NavBar = (props) => {
<div className="mx-auto h-[100px] max-w-7xl bg-white px-5 lg:px-0">
<div className="flex h-full items-center gap-[34px] lg:gap-[50px]">
<div className="flex min-w-0 grow items-center justify-center gap-[30px] lg:max-w-[75%]">
<Image
width="44"
height="44"
className="rounded-full"
src="/logo.svg"
alt=""
/>
<Link href="/">
<Image
width="44"
height="44"
className="rounded-full"
src="/logo.svg"
alt=""
/>
</Link>

<div className="flex grow items-center lg:mx-0 lg:max-w-none xl:px-0">
<div className="w-full">
Expand Down
12 changes: 11 additions & 1 deletion apps/web/src/components/Thread/CommentInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Expand All @@ -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();
});
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/components/Thread/NewThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
}
Expand Down Expand Up @@ -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)}
/>
</div>
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ 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();
const [didSession] = useLocalStorage("didSession","");
const { isConnected } = useAccount();
const [isDidSession, setDidSession] = useState(didSession?true:false);
const [isDiscordUser, setDiscordUser] = useState(false);
const [isOpen, setOpen] = useState(false);

if (!threads.data) return <div>Loading...</div>;

Expand All @@ -24,6 +26,10 @@ const Home: NextPage = () => {
setDiscordUser(value)
}

const handleClick = () => {
setOpen((state) => !state);
};

const checkConnected = () =>{
if (!isConnected)
return (
Expand All @@ -46,12 +52,13 @@ const Home: NextPage = () => {
if (!isDiscordUser)
return (
<div className="flex w-full justify-center bg-white py-6">
<div className=" bg-white text-base font-normal text-gray-700">
<div className=" bg-white text-base font-normal text-gray-700 cursor-pointer" onClick={handleClick}>
Please connect to Discord
</div>
</div>
);
}

return (
<Layout
handleDiscordUser = {handleDiscordUser}
Expand Down Expand Up @@ -81,6 +88,7 @@ const Home: NextPage = () => {
</div>
</div>
</main>
{isOpen && <Modal handleClick={handleClick} />}
</Layout>
);
};
Expand Down
6 changes: 6 additions & 0 deletions apps/web/src/server/trpc/router/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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"

[email protected]:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
Expand Down