diff --git a/src/features/common/components/add-issue-modal.tsx b/src/features/common/components/add-issue-modal.tsx
index 020cdd5..1f4a441 100644
--- a/src/features/common/components/add-issue-modal.tsx
+++ b/src/features/common/components/add-issue-modal.tsx
@@ -1,91 +1,60 @@
-import FormInput from "./form-input"
-
-
-import { AiOutlineClose } from "react-icons/ai"
import { useState } from "react";
-import Button from "./button";
-
-import { useWalletSignedInAccountQuery } from "../hooks/useWalletQueries";
-
-import { useUser } from '@auth0/nextjs-auth0'
-
-import { useAccount } from 'wagmi'
-import axios from "axios";
-
-type AddIssueModalProps = {
- setIsModalOpen: (value: boolean) => void
+import Modal from "./modal";
+import { useCreateSuggestion } from "../hooks/useGuildQueries";
+
+export default function AddIssueModal({
+ isOpen,
+ setIsOpen,
+}: {
+ isOpen: boolean;
+ setIsOpen: (isOpen: boolean) => void;
+}) {
+ const [value, setValue] = useState("");
+ const { mutate: createSuggestion, isLoading } = useCreateSuggestion();
+
+ const handleSubmit = () => {
+ if (!value.trim()) return;
+ createSuggestion(
+ { suggestion: value },
+ {
+ onSuccess: () => {
+ setValue("");
+ setIsOpen(false);
+ },
+ }
+ );
+ };
+
+ return (
+ setIsOpen(false)} title="Suggest a feature">
+
+
+ Feature Request
+
+
+ Describe the feature you would like to see.
+
+
+
+ );
}
-
-const AddIssueModal = ({ setIsModalOpen }: AddIssueModalProps) => {
- const [value, setValue] = useState("");
- const [title, setTitle] = useState("")
- const walletId = useWalletSignedInAccountQuery()
- const { user, error, isLoading } = useUser();
- const { address } = useAccount()
- const [isSubmitLoading, setIsLoading] = useState(false)
-
-
- const getWalletId = () => {
- const walletChain = localStorage.getItem("wallet-chain")
-
- let connectedWalletId;
-
- if (walletChain === "near") {
- connectedWalletId = walletId
- } else if (walletChain === "polygon") {
- connectedWalletId = address
- } else {
- connectedWalletId = "Unknown"
- }
-
- return connectedWalletId
- }
-
- const submitIssue = async () => {
- if (title.length === 0 || value.length == 0 || isSubmitLoading) return
- setIsLoading(true);
- try {
- let isGithubAuth = user != undefined
- let userId = user ? user?.sub : getWalletId()
-
- const result = await axios.post("/api/issues/addIssue", {
- userId,
- title,
- body: value, isGithubAuth
- }) as any
-
- const url = await result?.data?.message?.html_url
-
- window.open(url, "_blank")
- setIsLoading(false);
- setIsModalOpen(false)
- } catch (e) {
- setIsLoading(false);
-
- console.log(e)
- }
-
- }
-
- return
setIsModalOpen(false)} className="w-screen h-screen bg-black/50 top-0 left-0 absolute z-10 flex items-center justify-center">
-
{
- e.stopPropagation()
- }} className="rounded-md p-4 bg-white dark:bg-zinc-900 flex flex-col dark:text-white w-[90vw] h-[80vh] lg:w-[50vw] ">
-
-
-
Add Issue
-
setIsModalOpen(false)} />
-
-
setTitle(e.target?.value)} placeholder="Issue Title" />
-
-
-
-}
-
-
-export default AddIssueModal
diff --git a/src/features/common/components/button.tsx b/src/features/common/components/button.tsx
index c9760cd..c5f5c87 100644
--- a/src/features/common/components/button.tsx
+++ b/src/features/common/components/button.tsx
@@ -1,33 +1,33 @@
-import React from "react";
+import { ReactNode } from "react";
-const typeToClass: Record = {
+const variants = {
primary:
- "px-4 py-2 bg-pink-500 text-white shadow-lg shadow-pink-500/40 hover:brightness-150",
+ "flex flex-row items-center px-4 py-2 border-0 border-lime-500 dark:border-lime-600 bg-transparent text-lime-600 dark:text-lime-600 dark:hover:bg-zinc-800 hover:bg-gray-200 text-sm space-x-2",
secondary:
- "px-4 py-2 border-2 border-pink-500 bg-transparent text-pink-500 hover:brightness-150",
+ "flex flex-row items-center px-4 py-2 border-0 border-gray-200 dark:border-stone-500 bg-transparent text-gray-600 dark:text-gray-300 dark:hover:bg-zinc-800 hover:bg-gray-200 text-sm space-x-2",
iconConnect:
- "flex flex-row items-center px-4 py-2 border-0 border-lime-500 dark:border-lime-600 bg-transparent text-lime-500 dark:text-lime-600 dark:hover:bg-zinc-800 hover:bg-gray-200 text-sm space-x-2",
+ "flex flex-row items-center px-4 py-2 border-0 border-lime-500 dark:border-lime-600 bg-transparent text-lime-600 dark:text-lime-600 dark:hover:bg-zinc-800 hover:bg-gray-200 text-sm space-x-2",
iconDisconnect:
- "flex flex-row items-center px-4 py-2 border-0 border-gray-200 dark:border-stone-500 bg-transparent text-gray-500 dark:text-gray-300 dark:hover:bg-zinc-800 hover:bg-gray-200 text-sm space-x-2",
- icon:
- "flex flex-row items-center space-x-2 px-4 py-2 bg-pink-500 text-white shadow-lg shadow-pink-500/40 hover:brightness-150",
+ "flex flex-row items-center px-4 py-2 border-0 border-gray-300 dark:border-stone-500 bg-transparent text-gray-600 dark:text-gray-300 dark:hover:bg-zinc-800 hover:bg-gray-200 text-sm space-x-2",
};
-export default function Button(
- props: {
- type?: "primary" | "secondary" | "inverse" | "iconConnect" | "iconDisconnect" | "icon";
- } & React.HTMLProps
-) {
- const { type = "primary", className = "", ...restProps } = props;
-
- const baseClassName =
- "rounded-md cursor-pointer disabled:brightness-50 hover:disabled:cursor-not-allowed";
- const typeClassName = typeToClass[type];
-
+export default function Button({
+ children,
+ type,
+ onClick,
+ className = "",
+}: {
+ children: ReactNode;
+ type: keyof typeof variants;
+ onClick?: () => void;
+ className?: string;
+}) {
return (
+ className={`${variants[type]} ${className}`}
+ onClick={onClick}
+ >
+ {children}
+
);
}
diff --git a/src/features/common/components/chain-list-item.tsx b/src/features/common/components/chain-list-item.tsx
index 7fd96aa..fc8f72b 100644
--- a/src/features/common/components/chain-list-item.tsx
+++ b/src/features/common/components/chain-list-item.tsx
@@ -1,21 +1,19 @@
-import Image from "next/image";
-
-import ChainIcon from "./chain-icon";
-
-export default function ChainListItem(props: {
- chainName: string;
- onClick: (chainName: string) => void;
+export default function ChainListItem({
+ name,
+ icon,
+ onClick,
+}: {
+ name: string;
+ icon: JSX.Element;
+ onClick: () => void;
}) {
return (
- props.onClick(props.chainName)}
+
-
-
{props.chainName.toUpperCase()}
-
+
{icon}
+ {name}
+
);
}
diff --git a/src/features/common/components/connect-wallet-button.tsx b/src/features/common/components/connect-wallet-button.tsx
index d632bd5..06857ca 100644
--- a/src/features/common/components/connect-wallet-button.tsx
+++ b/src/features/common/components/connect-wallet-button.tsx
@@ -1,78 +1,28 @@
-import React from "react";
-import { useRouter } from "next/router";
-import Button from "./button";
-import SelectChainModal from "./select-chain-modal";
+import { useWalletChainQuery } from "../hooks/useWalletQueries";
import ChainIcon from "./chain-icon";
-import {
- useWalletChainQuery,
- useWalletSignedInAccountQuery,
- useWalletSignInMutation,
- useWalletSignOutMutation,
-} from "../hooks/useWalletQueries";
-import config from "config";
-
export default function ConnectWalletButton() {
- const router = useRouter();
-
- const [isSelectChainModalOpen, setIsSelectChainModalOpen] =
- React.useState(false);
-
- const walletChainQuery = useWalletChainQuery();
- const signedInAccountQuery = useWalletSignedInAccountQuery();
- const signInMutation = useWalletSignInMutation();
- const signOutMutation = useWalletSignOutMutation();
-
- async function handleSelectChain(chain: string) {
- signInMutation.mutate(chain);
- }
-
- async function handleDisconnectWallet() {
- let path = window.location.pathname;
- if (path.includes("add-bounty")) {
- router.replace(`/issues/${path.split("/")[2]}`);
- }
-
- setTimeout(() => {
- signOutMutation.mutate();
- }, 1000);
- }
-
- if (walletChainQuery.data && signedInAccountQuery.data) {
- return (
-
-
-
- );
- }
+ const { data: walletChain, isLoading } = useWalletChainQuery();
return (
- <>
-
- setIsSelectChainModalOpen(false)}
- onSelectChain={handleSelectChain}
- enabledChains={config.site.enabledChains}
+
);
}
diff --git a/src/features/common/components/form-input.tsx b/src/features/common/components/form-input.tsx
index 8ccec20..e88540d 100644
--- a/src/features/common/components/form-input.tsx
+++ b/src/features/common/components/form-input.tsx
@@ -1,12 +1,11 @@
-import React from "react";
-
-export default function FormInput(props: React.HTMLProps) {
- const { className = "", ...restProps } = props;
-
+export default function FormInput({
+ className = "",
+ ...props
+}: React.InputHTMLAttributes) {
return (
);
}
diff --git a/src/features/common/components/header-nav.tsx b/src/features/common/components/header-nav.tsx
index 82b24a6..4c3f2ed 100644
--- a/src/features/common/components/header-nav.tsx
+++ b/src/features/common/components/header-nav.tsx
@@ -2,76 +2,88 @@ import Link from "next/link";
import ConnectWalletButton from "./connect-wallet-button";
import config from "config";
-import { ConnectButton } from '@rainbow-me/rainbowkit';
+import { ConnectButton } from "@rainbow-me/rainbowkit";
import Button from "./button";
+import { ThemeToggle } from "./theme-toggle";
-import { useAccount } from 'wagmi'
+import { useAccount } from "wagmi";
import { useEffect } from "react";
-import { useUser } from '@auth0/nextjs-auth0'
+import { useUser } from "@auth0/nextjs-auth0";
import { useWalletChainQuery } from "../hooks/useWalletQueries";
import { AiFillGithub } from "react-icons/ai";
export default function HeaderNav() {
-
- const { isDisconnected } = useAccount()
+ const { isDisconnected } = useAccount();
const { data: walletChain = "" } = useWalletChainQuery();
const { user, error, isLoading } = useUser();
-
// Removing the wallet from local storage when the user disconnects it (Polygon only)
useEffect(() => {
- const localStorageWallet = localStorage.getItem("wallet-chain")
+ const localStorageWallet = localStorage.getItem("wallet-chain");
if (isDisconnected && localStorageWallet === "polygon") {
- localStorage.removeItem('wallet-chain')
+ localStorage.removeItem("wallet-chain");
}
- }, [isDisconnected])
-
-
+ }, [isDisconnected]);
return (
-
+
);
diff --git a/src/features/common/components/layout.tsx b/src/features/common/components/layout.tsx
index 94519d3..18dc86e 100644
--- a/src/features/common/components/layout.tsx
+++ b/src/features/common/components/layout.tsx
@@ -1,25 +1,12 @@
-import Head from "./head";
import HeaderNav from "./header-nav";
import Footer from "./footer";
-import type { ReactElement } from "react";
-type Props = {
- children: ReactElement;
- title?: string;
- metaDescription?: string;
-};
-
-export function Layout(props: Props) {
+export default function Layout({ children }: { children: React.ReactNode }) {
return (
-
-
+
-
- {props.children}
-
+
{children}
);
}
-
-export default Layout;
diff --git a/src/features/common/components/modal.tsx b/src/features/common/components/modal.tsx
index 574407d..3811466 100644
--- a/src/features/common/components/modal.tsx
+++ b/src/features/common/components/modal.tsx
@@ -1,33 +1,34 @@
+import { Fragment, ReactNode } from "react";
import { Dialog, Transition } from "@headlessui/react";
-import React, { Fragment } from "react";
-import { FiX } from "react-icons/fi";
-import Button from "./button";
-
-export default function Modal(props: {
- title: string;
+export default function Modal({
+ isOpen,
+ onClose,
+ title,
+ children,
+}: {
isOpen: boolean;
onClose: () => void;
- children: React.ReactNode;
+ title: string;
+ children: ReactNode;
}) {
return (
- <>
-
-