Commit bed69344 authored by Andrey Krylov's avatar Andrey Krylov
Browse files

add-url-params

parent fd628462
Showing with 25 additions and 4 deletions
+25 -4
......@@ -14,12 +14,13 @@ import { createDaoFormValidation } from "@/views/CreateDao/schema";
import { useCreateTokenDialog } from "@/store";
import { useContractApi } from "@/hooks";
import { CreateDaoForm } from "@/hooks/useContractApi/types";
import { Network } from "@cryptodo/contracts";
import Store, { ActionsObject as LocalActionsObject, useLocalStore, } from './context'
import * as S from './style';
const Page = () => {
const { push } = useRouter();
const { push, query } = useRouter();
const [ postingToTestnet, setPostingToTestnet ] = useState<boolean>(false);
const [ allFieldsDisabled, disableAllFields ] = useState<boolean>(false);
const [ deployConfirmationOpen, toggleDeployConfirmationDialog ] =
......@@ -31,7 +32,7 @@ const Page = () => {
} = localActions as LocalActionsObject;
const {
data: { selectedBlockchain },
data: { selectedBlockchain }, actions: { selectBlockchain }
} = useCreateTokenDialog();
const { register, reset, formState: { errors, isValid }, control, watch, getValues, setValue } = useForm({
......@@ -183,6 +184,10 @@ const Page = () => {
setValue('quorum', localData.quorum);
}, [localData.quorum]);
useEffect(() => {
selectBlockchain(query?.network as Network)
}, []);
return (
<S.Wrapper>
<S.Content>
......
import { FC } from 'react';
import { FC, useEffect } from 'react';
import useTranslation from 'next-translate/useTranslation';
import { useRouter } from 'next/router';
......@@ -10,7 +10,7 @@ import { Space, Text, Tooltip, Dialog, Button } from '@/components';
import * as S from './style';
export const CreateTokenDialog: FC = () => {
const { push } = useRouter();
const { push, query, isReady } = useRouter();
const { t } = useTranslation('SmartContracts');
const {
......@@ -19,6 +19,13 @@ export const CreateTokenDialog: FC = () => {
} = useUI();
const { toggleCreateTokenDialog } = uiActions as ActionsObject['ui'];
const toggleBlockchain = (network: string) => {
push({
query: { 'network': network }
});
};
const {
data: { selectedBlockchain },
actions: createTokenActions,
......@@ -37,6 +44,13 @@ export const CreateTokenDialog: FC = () => {
toggleCreateTokenDialog(false);
};
useEffect(() => {
if (!query?.network && isReady) {
toggleBlockchain("BSC")
}
}, []);
return (
<Dialog
open={createTokenDialogOpen}
......@@ -49,6 +63,7 @@ export const CreateTokenDialog: FC = () => {
onClick={() =>
push({
pathname: '/createDao',
query: { 'network': query?.network }
})
}
>
......@@ -82,6 +97,7 @@ export const CreateTokenDialog: FC = () => {
type="button"
disabled={item.disabled}
onClick={() => {
toggleBlockchain(network)
selectBlockchain(network);
}}
>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment