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

fix: room creation process #160

Merged
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
83 changes: 67 additions & 16 deletions packages/react-app/src/routes/create/Create.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@ import {
TagLabel,
Tooltip,
} from "@chakra-ui/react";
import {
useDisclosure,
AlertDialog,
AlertDialogBody,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogContent,
AlertDialogOverlay,
AlertDialogCloseButton,
} from '@chakra-ui/react';
import { ArrowBackIcon, EditIcon, QuestionOutlineIcon, WarningIcon } from "@chakra-ui/icons";
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useRef } from "react";
import { useHistory } from "react-router-dom";
import { default as MultiAddressInput } from "./components/MultiAddressInput";
import { useColorModeValue } from "@chakra-ui/color-mode";
import Blockie from "../../components/Blockie";



const Create = ({
address,
mainnetProvider,
Expand All @@ -38,6 +50,8 @@ const Create = ({
const [loadingText, setLoadingText] = useState("Loading...");
const [isConfirmDisabled, setIsConfirmDisabled] = useState(true);
const [isInvalidName, setIsInvalidName] = useState(false);
const { isOpen, onOpen, onClose } = useDisclosure();
const cancelRef = React.useRef();
const [partyObj, setPartyObj] = useState({
name: "",
description: "",
Expand Down Expand Up @@ -80,7 +94,7 @@ const Create = ({
const [candidates, setCandidates] = useState([]);
const [description, setDescription] = useState("");
const [name, setName] = useState(partyName);

useEffect(_ => {
if (!partyJson) {
(async _ => {
Expand Down Expand Up @@ -211,17 +225,6 @@ const Create = ({
<Center p="5">
<Text fontSize="xl">Review</Text>
</Center>
<Center>
<Button
variant="link"
onClick={() => {
setIsReview(false);
}}
rightIcon={<EditIcon />}
>
Edit
</Button>
</Center>
<form onSubmit={onSubmit}>
<FormControl id="Review">
<FormLabel pt="3">Name:</FormLabel>
Expand Down Expand Up @@ -282,18 +285,66 @@ const Create = ({
</Box>
);

const goHomeAlert = (
<AlertDialog
motionPreset='slideInBottom'
leastDestructiveRef={cancelRef}
onClose={onClose}
isOpen={isOpen}
isCentered
>
<AlertDialogOverlay />

<AlertDialogContent>
<AlertDialogHeader>Go to home page?</AlertDialogHeader>
<AlertDialogCloseButton />
<AlertDialogBody>
Are you sure? All the details entered will be deleted.
</AlertDialogBody>
<AlertDialogFooter>
<Button ref={cancelRef} onClick={onClose}>
No
</Button>
<Button
colorScheme='red'
ml={3}
onClick={() => {
routeHistory.push("/");
}}
>
Yes
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);


return (
<Box>
{isReview ? (
<Button
size="lg"
variant="ghost"
onClick={() => {
routeHistory.push("/");
}}
setIsReview(false);
}}
leftIcon={<ArrowBackIcon />}
>
Back
Edit
</Button>
) : (
<Button
size="lg"
variant="ghost"
onClick={onOpen}
leftIcon={<ArrowBackIcon />}
>
Home
</Button>
)
}
{goHomeAlert}
<Center p="5">{isReview ? reviewForm : createForm}</Center>
</Box>
);
Expand Down