Skip to content

Commit

Permalink
hot fix for CodeEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Cali93 committed May 9, 2022
1 parent 4a53866 commit 41cd84e
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 56 deletions.
2 changes: 1 addition & 1 deletion packages/dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"react-icons": "^4.3.1",
"react-markdown": "^7.0.0",
"react-parallax-tilt": "^1.5.73",
"siwe": "^2.0.1",
"siwe": "^1.1.6",
"states-cities-db": "^1.4.1",
"tiny-invariant": "^1.2.0",
"uint8arrays": "^3.0.0",
Expand Down
28 changes: 21 additions & 7 deletions packages/dapp/src/components/projects/CreateProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {
InputGroup,
InputLeftAddon,
Text,
Textarea,
} from "@chakra-ui/react";
import CodeEditorPreview from "components/custom/CodeEditorPreview";
import useCustomColor from "core/hooks/useCustomColor";
import dynamic from "next/dynamic";
// import useCustomColor from "core/hooks/useCustomColor";
// import dynamic from "next/dynamic";
import { useEffect, useState } from "react";
import { useFormContext } from "react-hook-form";

Expand All @@ -29,12 +30,12 @@ import ControlledSelect from "../Inputs/ControlledSelect";

import LogoDropzone from "./LogoDropzone";

const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
ssr: false,
});
// const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
// ssr: false,
// });
const CreateProjectForm = () => {
const [code, setCode] = useState<string>();
const { codeEditorScheme } = useCustomColor();
// const { codeEditorScheme } = useCustomColor();
const { data, loading, error } = useQuery(ALL_TAGS_QUERY);
const {
register,
Expand Down Expand Up @@ -106,7 +107,8 @@ const CreateProjectForm = () => {

<FormControl isInvalid={errors.description}>
<FormLabel htmlFor="description">Markdown Description</FormLabel>
<CodeEditor
{/* TODO: fix types for CodeEditor
<CodeEditor
value={code}
language="markdown"
placeholder="Project description"
Expand All @@ -123,6 +125,18 @@ const CreateProjectForm = () => {
}}
className={codeEditorScheme}
padding={15}
/>
*/}
<Textarea
placeholder="Project description"
{...register("description", {
required: REQUIRED_FIELD_LABEL,
})}
onChange={(e) => {
const { name } = e.target;
setCode(e.target.value);
setValue(name, e.target.value);
}}
/>
<FormErrorMessage>
{errors.description && errors.description.message}
Expand Down
26 changes: 18 additions & 8 deletions packages/dapp/src/components/projects/EditProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@ import {
AlertIcon,
AlertTitle,
Spinner,
Textarea,
} from "@chakra-ui/react";
import { useFormContext } from "react-hook-form";
import dynamic from "next/dynamic";
// import dynamic from "next/dynamic";
// import useCustomColor from "core/hooks/useCustomColor";
import { useState, useEffect } from "react";

import CodeEditorPreview from "components/custom/CodeEditorPreview";
import useCustomColor from "core/hooks/useCustomColor";
import { Tag } from "../../core/types";
import { ALL_TAGS_QUERY } from "../../graphql/tags";
import IconWithState from "../custom/IconWithState";
import ControlledSelect from "../Inputs/ControlledSelect";

import LogoDropzone from "./LogoDropzone";

const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
ssr: false,
});
// const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
// ssr: false,
// });
const EditProjectForm: React.FunctionComponent = () => {
const [code, setCode] = useState<string>();
const { codeEditorScheme } = useCustomColor();
// const { codeEditorScheme } = useCustomColor();
const {
register,
setValue,
Expand Down Expand Up @@ -83,7 +84,16 @@ const EditProjectForm: React.FunctionComponent = () => {

<FormControl isInvalid={errors.description}>
<FormLabel htmlFor="description">Description</FormLabel>
<CodeEditor
<Textarea
placeholder="Project description"
{...register("description")}
onChange={(e) => {
const { name } = e.target;
setCode(e.target.value);
setValue(name, e.target.value);
}}
/>
{/* <CodeEditor
value={code}
language="markdown"
placeholder="Project description"
Expand All @@ -103,7 +113,7 @@ const EditProjectForm: React.FunctionComponent = () => {
}}
className={codeEditorScheme}
padding={15}
/>
/> */}
<FormErrorMessage>
{errors.description && errors.description.message}
</FormErrorMessage>
Expand Down
28 changes: 20 additions & 8 deletions packages/dapp/src/components/projects/pathways/PathwayForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import {
NumberInputStepper,
Tag,
Text,
Textarea,
VStack,
} from "@chakra-ui/react";
import { useWeb3React } from "@web3-react/core";
import CodeEditorPreview from "components/custom/CodeEditorPreview";
import useCustomColor from "core/hooks/useCustomColor";
import dynamic from "next/dynamic";
// import useCustomColor from "core/hooks/useCustomColor";
// import dynamic from "next/dynamic";
import { useEffect, useMemo, useState } from "react";
import { useFormContext } from "react-hook-form";
import {
Expand All @@ -34,13 +35,13 @@ import useTokenList from "../../../core/hooks/useTokenList";
import ImageDropzone from "../../custom/ImageDropzone";
import ControlledSelect from "../../Inputs/ControlledSelect";

const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
ssr: false,
});
// const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
// ssr: false,
// });

export default function PathwayForm({ isWithRewards, withRewards }: any) {
const [code, setCode] = useState<string>();
const { codeEditorScheme } = useCustomColor();
// const { codeEditorScheme } = useCustomColor();

const { chainId } = useWeb3React();
const { tokens } = useTokenList();
Expand Down Expand Up @@ -161,7 +162,18 @@ export default function PathwayForm({ isWithRewards, withRewards }: any) {

<FormControl isInvalid={errors.description}>
<FormLabel htmlFor="description">Description</FormLabel>
<CodeEditor
<Textarea
placeholder="Pathway description"
{...register("description", {
required: REQUIRED_FIELD_LABEL,
})}
onChange={(e) => {
const { name } = e.target;
setCode(e.target.value);
setValue(name, e.target.value);
}}
/>
{/* <CodeEditor
value={code}
language="markdown"
placeholder="Pathway description (markdown)"
Expand All @@ -178,7 +190,7 @@ export default function PathwayForm({ isWithRewards, withRewards }: any) {
}}
className={codeEditorScheme}
padding={15}
/>
/> */}
<FormErrorMessage>
{errors.description && errors.description.message}
</FormErrorMessage>
Expand Down
28 changes: 20 additions & 8 deletions packages/dapp/src/components/projects/quests/QuestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import {
useToast,
VStack,
Checkbox,
Textarea,
} from "@chakra-ui/react";
import { useWeb3React } from "@web3-react/core";
import CodeEditorPreview from "components/custom/CodeEditorPreview";
import useCustomColor from "core/hooks/useCustomColor";
import { Contract, ethers } from "ethers";
import dynamic from "next/dynamic";
// import useCustomColor from "core/hooks/useCustomColor";
// import dynamic from "next/dynamic";
import { useRouter } from "next/router";
import { ChangeEvent, useContext, useEffect, useMemo, useState } from "react";
import { useFormContext } from "react-hook-form";
Expand Down Expand Up @@ -92,17 +93,17 @@ const questTypeOptions = [
},
];

const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
ssr: false,
});
// const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
// ssr: false,
// });

const CreateQuestForm: React.FunctionComponent = () => {
const router = useRouter();
const toast = useToast();
const [code, setCode] = useState<string>();
const [isWithRewards, setIsWithRewards] = useState<boolean>();
const [submitStatus, setSubmitStatus] = useState<string>("Creating quest");
const { codeEditorScheme } = useCustomColor();
// const { codeEditorScheme } = useCustomColor();
const { tokens } = useTokenList();
const { library, chainId } = useWeb3React();
const { self, account, contracts } = useContext(Web3Context);
Expand Down Expand Up @@ -498,7 +499,18 @@ const CreateQuestForm: React.FunctionComponent = () => {

<FormControl isInvalid={errors.description}>
<FormLabel htmlFor="description">Description</FormLabel>
<CodeEditor
<Textarea
placeholder="Quest description"
{...register("description", {
required: REQUIRED_FIELD_LABEL,
})}
onChange={(e) => {
const { name } = e.target;
setCode(e.target.value);
setValue(name, e.target.value);
}}
/>
{/* <CodeEditor
value={code}
language="markdown"
placeholder="Quest description (markdown)"
Expand All @@ -515,7 +527,7 @@ const CreateQuestForm: React.FunctionComponent = () => {
}}
className={codeEditorScheme}
padding={15}
/>
/> */}
<FormErrorMessage>
{errors.description && errors.description.message}
</FormErrorMessage>
Expand Down
28 changes: 20 additions & 8 deletions packages/dapp/src/components/projects/quests/bounty/BountyForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import {
Progress,
Stack,
Text,
Textarea,
useToast,
VStack,
} from "@chakra-ui/react";
import { useWeb3React } from "@web3-react/core";

import CodeEditorPreview from "components/custom/CodeEditorPreview";
import ImageDropzone from "components/custom/ImageDropzone";
import { REQUIRED_FIELD_LABEL } from "core/constants";
import { blobToDataURL } from "core/helpers";
import useCustomColor from "core/hooks/useCustomColor";
import { GET_APP_DID } from "graphql/app";
import dynamic from "next/dynamic";
// import dynamic from "next/dynamic";
import { useContext, useState } from "react";
import { useForm } from "react-hook-form";
import { Web3Context } from "../../../../contexts/Web3Context";
Expand All @@ -31,9 +32,9 @@ import {
SUBMIT_QUEST_SOLUTION_MUTATION,
} from "../../../../graphql/quests";

const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
ssr: false,
});
// const CodeEditor = dynamic(() => import("@uiw/react-textarea-code-editor"), {
// ssr: false,
// });

function BountyForm({ questId, pathwayId, successCallback }: any) {
const toast = useToast();
Expand All @@ -46,7 +47,7 @@ function BountyForm({ questId, pathwayId, successCallback }: any) {
const { self } = useContext(Web3Context);

const [code, setCode] = useState<string>();
const { codeEditorScheme } = useCustomColor();
// const { codeEditorScheme } = useCustomColor();

const [isLoading, setIsLoading] = useState(false);

Expand Down Expand Up @@ -179,7 +180,18 @@ function BountyForm({ questId, pathwayId, successCallback }: any) {
<VStack as="form">
<FormControl isInvalid={errors.solution}>
<FormLabel htmlFor="solution">Your Solution</FormLabel>
<CodeEditor
<Textarea
placeholder="Quest solution"
{...register("solution", {
required: REQUIRED_FIELD_LABEL,
})}
onChange={(e) => {
const { name } = e.target;
setCode(e.target.value);
setValue(name, e.target.value);
}}
/>
{/* <CodeEditor
value={code}
language="markdown"
placeholder="Quest solution (markdown)"
Expand All @@ -196,7 +208,7 @@ function BountyForm({ questId, pathwayId, successCallback }: any) {
}}
className={codeEditorScheme}
padding={15}
/>
/> */}
<FormErrorMessage>
{errors.solution && errors.solution.message}
</FormErrorMessage>
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/pages/projects/create-project/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function CreateProjectStepper() {
{activeStep === 2 && (
<Button
ml="0.5rem"
// colorScheme="accent"
// colorScheme="accentDark"
isLoading={methods.formState.isSubmitting}
type="submit"
px="1.25rem"
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"siwe": "^2.0.1",
"siwe": "^1.1.6",
"subscriptions-transport-ws": "^0.9.19",
"swagger-ui-express": "^4.1.6",
"uint8arrays": "^2.1.10",
Expand Down
25 changes: 11 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6494,14 +6494,12 @@
dependencies:
antlr4ts "^0.5.0-alpha.4"

"@spruceid/siwe-parser@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@spruceid/siwe-parser/-/siwe-parser-2.0.0.tgz#fb316b9115e9116bac528c5cbfed18787119bede"
integrity sha512-zXlPBRKaT9ecxhhLQqn/StAWlXvQBlFDFnIAlM7ceMVx/1NVZZ65GdW9A28tYGbhpesYxNYpsqegGsBcrWuASg==
"@spruceid/siwe-parser@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@spruceid/siwe-parser/-/siwe-parser-1.1.3.tgz#0eebe8bbd63c6de89cb44c06b6329b00b305df65"
integrity sha512-oQ8PcwDqjGWJvLmvAF2yzd6iniiWxK0Qtz+Dw+gLD/W5zOQJiKIUXwslHOm8VB8OOOKW9vfR3dnPBhHaZDvRsw==
dependencies:
apg-js "^4.1.1"
uri-js "^4.4.1"
valid-url "^1.0.9"

"@stablelib/aead@^1.0.1":
version "1.0.1"
Expand Down Expand Up @@ -31238,15 +31236,14 @@ sisteransi@^1.0.5:
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==

siwe@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/siwe/-/siwe-2.0.1.tgz#4c1c6762bf39a3100fee882c59a2114c525adc47"
integrity sha512-4zMQZSR9pp3BR7w8c8N/ofGI71QIVK2a1+cyBzkPNWr0/DV9APmRFdZtg0lkiEemGCFtFyTy/h6f90tG/GFH5w==
siwe@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/siwe/-/siwe-1.1.6.tgz#b4b4fe7814654d5ea529171b2ede15f7ef7ef1ae"
integrity sha512-3WRdEil32Tc2vuNzqJ2/Z/MIvsvy0Nkzc2ov+QujmpHO7tM83dgcb47z0Pu236T4JQkOQCqQkq3AJ/rVIezniA==
dependencies:
"@spruceid/siwe-parser" "2.0.0"
"@spruceid/siwe-parser" "^1.1.3"
"@stablelib/random" "^1.0.1"
uri-js "^4.4.1"
valid-url "^1.0.9"
apg-js "^4.1.1"

size-limit@^6.0.1:
version "6.0.4"
Expand Down Expand Up @@ -34218,7 +34215,7 @@ upper-case@^2.0.2:
dependencies:
tslib "^2.0.3"

uri-js@^4.2.2, uri-js@^4.4.1:
uri-js@^4.2.2:
version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==
Expand Down

0 comments on commit 41cd84e

Please sign in to comment.