Skip to content
Merged
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
35 changes: 7 additions & 28 deletions src/modules/lite/explorer/pages/CreateProposal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useCallback, useEffect, useMemo, useState } from "react"
import React, { useCallback, useState } from "react"
import {
Grid,
styled,
Expand All @@ -11,10 +11,9 @@ import {
useTheme,
useMediaQuery
} from "@material-ui/core"
import { EnvKey, getEnv } from "services/config"

import { Choices } from "../../components/Choices"
import { useHistory, useParams } from "react-router-dom"
import { useHistory } from "react-router-dom"
import { Field, Form, Formik, FormikErrors, getIn } from "formik"
import { TextField as FormikTextField } from "formik-material-ui"
import { Poll } from "models/Polls"
Expand Down Expand Up @@ -198,6 +197,10 @@ const validateForm = (values: Poll) => {
errors.name = "Required"
}

if (!values.externalLink) {
errors.externalLink = "Required"
}

if (values.choices.length === 0 || values.choices.length === 1) {
errors.choices = "Two options at least are required"
}
Expand Down Expand Up @@ -297,6 +300,7 @@ export const ProposalForm = ({
</Grid>
<Grid item>
<Field name="externalLink" type="text" placeholder="External Link" component={CustomFormikTextField} />
{errors?.externalLink && touched.externalLink ? <ErrorText>{errors.externalLink}</ErrorText> : null}
</Grid>

{isMobileSmall ? (
Expand Down Expand Up @@ -519,31 +523,6 @@ export const ProposalCreator: React.FC<{ id: string }> = ({ id }) => {
const [isLoading, setIsLoading] = useState(false)
const tokenAddress = useToken(id)

// useEffect(() => {
// async function fetchData() {
// const communityId = id.toString()
// await fetch(`${getEnv(EnvKey.REACT_APP_LITE_API_URL)}/token/${communityId}`).then(async response => {
// if (!response.ok) {
// openNotification({
// message: "An error has occurred",
// autoHideDuration: 2000,
// variant: "error"
// })
// return
// }

// const record = await response.json()
// if (!record) {
// return
// }
// setTokenAddress(record.tokenAddress)
// })
// }
// fetchData()

// return
// }, [id, network])

const initialState: Poll = {
name: "",
description: "",
Expand Down