Skip to content

Commit

Permalink
fix: remove rerouting to spaces, show password entry in spaces
Browse files Browse the repository at this point in the history
removing spaces since if you wanna go to the last page youre getting rerouted
  • Loading branch information
ReddixT committed Jan 4, 2023
1 parent 913747a commit cc9e303
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 85 deletions.
117 changes: 59 additions & 58 deletions lumium-space/pages/[workspaceId]/[[...pageId]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,64 +70,65 @@ const Workspace: React.FC = () => {
<NavBar onOpen={onOpen} userInfo={userInfo} workspace={workspace} />
<Box p="4">
{
(workspace?.name && userInfo?.nickName && !pageId) &&
<Heading>
Welcome to the <em>{workspace?.name}</em> workspace, {userInfo?.nickName}!
</Heading> ||
!passwordEntered &&
<Flex
align={'center'}
justify={'center'}
>
<Stack
spacing={4}
w={'full'}
maxW={'md'}
rounded={'xl'}
boxShadow={'lg'}
p={6}
my={12}>
<Heading lineHeight={1.1} fontSize={{ base: '2xl', md: '3xl' }}>
Enter the password for <em>{workspace?.name}</em>
</Heading>
<form onSubmit={formik.handleSubmit} data-cy={"form"}>
<FormControl id="password" isRequired>
<FormLabel>Password</FormLabel>
<InputGroup>
<Input
name={"password"}
type={showPassword ? 'text' : 'password'}
onChange={formik.handleChange}
value={formik.values.password}
data-cy="passwordInput"
/>
<InputRightElement h={'full'}>
<Button
variant={'ghost'}
onClick={() =>
setShowPassword((showPassword) => !showPassword)
}>
{showPassword ? <ViewIcon /> : <ViewOffIcon />}
</Button>
</InputRightElement>
</InputGroup>
<FormErrorMessage data-cy="credentialError"></FormErrorMessage>
</FormControl>
<Stack spacing={6}>
<Button
bg={'blue.400'}
color={'white'}
_hover={{
bg: 'blue.500',
}}
type="submit"
>
Submit
</Button>
</Stack>
</form>
</Stack>
</Flex>
(workspace?.name && userInfo?.nickName && !pageId && !passwordEntered) &&
<>
<Heading>
Welcome to the <em>{workspace?.name}</em> workspace, {userInfo?.nickName}!
</Heading>
<Flex
align={'center'}
justify={'center'}
>
<Stack
spacing={4}
w={'full'}
maxW={'md'}
rounded={'xl'}
boxShadow={'lg'}
p={6}
my={12}>
<Heading lineHeight={1.1} fontSize={{ base: '2xl', md: '3xl' }}>
Enter the password for <em>{workspace?.name}</em>
</Heading>
<form onSubmit={formik.handleSubmit} data-cy={"form"}>
<FormControl id="password" isRequired>
<FormLabel>Password</FormLabel>
<InputGroup>
<Input
name={"password"}
type={showPassword ? 'text' : 'password'}
onChange={formik.handleChange}
value={formik.values.password}
data-cy="passwordInput"
/>
<InputRightElement h={'full'}>
<Button
variant={'ghost'}
onClick={() =>
setShowPassword((showPassword) => !showPassword)
}>
{showPassword ? <ViewIcon /> : <ViewOffIcon />}
</Button>
</InputRightElement>
</InputGroup>
<FormErrorMessage data-cy="credentialError"></FormErrorMessage>
</FormControl>
<Stack spacing={6} mt={"2%"}>
<Button
bg={'blue.400'}
color={'white'}
_hover={{
bg: 'blue.500',
}}
type="submit"
>
Submit
</Button>
</Stack>
</form>
</Stack>
</Flex>
</>
|| pageId &&
<Flex flexDir="row">
<Textarea />
Expand Down
23 changes: 0 additions & 23 deletions lumium-space/pages/spaces/[[...path]].tsx

This file was deleted.

8 changes: 6 additions & 2 deletions lumium-space/src/components/other/CreateWorkspace.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ViewIcon, ViewOffIcon } from "@chakra-ui/icons";
import { Flex, Text, Heading, FormControl, FormLabel, Input, InputGroup, InputRightElement, Button, FormErrorMessage, ButtonGroup } from "@chakra-ui/react";
import { SPACES } from "@routes/space";
import { useUserInfo } from "@hooks/api";
import { ROOT, SPACES } from "@routes/space";
import { useFormik } from 'formik';
import { create_workspace } from "lumium-renderer";
import Router from "next/router";
Expand All @@ -15,6 +16,7 @@ export const CreateWorkspace = ({ disclaimerButtonColor }: createWorkspaceProps)
const [credentialsMatchError, setCredentialsMatchError] = useState(false);
const [step, setStep] = useState(1);
const [progress, setProgress] = useState(50);
const { refetchUserInfo } = useUserInfo();

const nextStep = () => {
if (formik.values.password == formik.values.passwordConfirm) {
Expand All @@ -37,7 +39,9 @@ export const CreateWorkspace = ({ disclaimerButtonColor }: createWorkspaceProps)

const handleDownloadKeys = () => {
create_workspace(formik.values.password, formik.values.name).then(() => {
Router.push(SPACES);
refetchUserInfo().then((info) => {
Router.push(ROOT + info?.recentWorkspace.id);
});
});
};

Expand Down
24 changes: 22 additions & 2 deletions lumium-space/src/sections/landing/CallToAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,30 @@ import {
Icon,
IconProps,
} from '@chakra-ui/react';
import { SPACES, AUTH_SIGNUP } from '@routes/space';
import { useApi, useUserInfo } from '@hooks/api';
import { SECURE_PONG } from '@routes/api/v1';
import { AUTH_SIGNUP, AUTH_SIGNIN, SPACES_CREATE, ROOT } from '@routes/space';
import Router from 'next/router';

export const CallToAction = () => {
const [api] = useApi();
const { refetchUserInfo } = useUserInfo();

const handleContinue = () => {
api.get(SECURE_PONG).then((res) => {
if (res.status == 200) {
refetchUserInfo().then((info) => {
if (info?.recentWorkspace) {
Router.push(ROOT + info?.recentWorkspace.id);
} else {
Router.push(SPACES_CREATE);
};
});
} else {
Router.push(AUTH_SIGNIN);
}
});
}
return (
<Container maxW={'5xl'}>
<Stack
Expand All @@ -36,7 +56,7 @@ export const CallToAction = () => {
rounded={'full'}
px={6}
bg={'blue.400'}
onClick={() => Router.push(SPACES)}
onClick={handleContinue}
>
Continue
</Button>
Expand Down

0 comments on commit cc9e303

Please sign in to comment.