Skip to content

Commit

Permalink
fix: depencency bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Molaryy committed Aug 29, 2023
1 parent 0238060 commit acb4ee7
Showing 9 changed files with 961 additions and 857 deletions.
19 changes: 10 additions & 9 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {Metadata} from "next";
'use client';

import Provider from "./provider";


export const metadata: Metadata = {
title: 'InterPlanetaryCloud',
description: 'A distributed cloud built on top of Aleph, the next generation network of distributed big data applications.',
icons: {
icon: '/ipc-logo.svg'
},
viewport: "width=device-width, initial-scale=1",
}
// export const metadata: Metadata = {
// title: 'InterPlanetaryCloud',
// description: 'A distributed cloud built on top of Aleph, the next generation network of distributed big data applications.',
// icons: {
// icon: '/ipc-logo.svg'
// },
// viewport: "width=device-width, initial-scale=1",
// }

export default function RootLayout({children}: { children: React.ReactNode }) {

27 changes: 2 additions & 25 deletions app/login/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client'

import {Text, Textarea, useColorModeValue, useToast, VStack} from '@chakra-ui/react';
import Link from 'next/link';
import {Text, useColorModeValue, useToast, VStack} from '@chakra-ui/react';
import {useRouter} from 'next/navigation';
import {useState} from 'react';

@@ -15,7 +14,6 @@ import Button from 'components/Button';
import {ResponseType} from 'types/types';

import {textColorMode} from 'config/colorMode';
import colors from 'theme/foundations/colors';


const AuthProvider = () => {
@@ -59,12 +57,6 @@ const AuthProvider = () => {
<VStack w="100%" spacing="64px">
<VStack w="100%" spacing="32px">
<VStack spacing="16px" w="100%">
<Textarea
_focus={{boxShadow: `0px 0px 0px 2px ${colors.red[300]}`}}
cursor="text"
onChange={(e) => setMnemonics(e.target.value)}
id="ipc-login-text-area"
/>
<Button
variant="primary"
size="lg"
@@ -97,22 +89,7 @@ const AuthProvider = () => {
</Text>
</VStack>
</VStack>
<VStack w="100%">
<Text size="lg" color={textColor}>
You don't have an account?
</Text>
<Link href="/signup">
<Button
variant="secondary"
size="lg"
w="100%"
onClick={() => router.push('/signup')}
id="ipc-login-signup-button"
>
Create an account
</Button>
</Link>
</VStack>

</VStack>
</AuthPage>
);
1 change: 0 additions & 1 deletion app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -5,5 +5,4 @@ import AuthProvider from "./auth";
const Login = (): JSX.Element => (
<AuthProvider/>
);

export default Login;
1 change: 0 additions & 1 deletion app/provider.tsx
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import ConfigContext from "../src/contexts/config";
import {IPCConfig, IPCContact, IPCFile, IPCFolder, IPCProgram} from "../src/types/types";
import DriveContext from "../src/contexts/drive";
import Auth from "../src/lib/auth";
import '../src/theme/index.css'

const Provider = ({children}: { children: React.ReactNode }) => {
const [auth, setAuth] = useState<Auth>(new Auth());
200 changes: 100 additions & 100 deletions app/signup/page.tsx
Original file line number Diff line number Diff line change
@@ -1,115 +1,115 @@
'use client';

import { useRouter } from 'next/router';
import { useState } from 'react';
import {useRouter} from 'next/navigation';
import {useState} from 'react';

import { Text, Textarea, useColorModeValue, useToast, VStack } from '@chakra-ui/react';
import {Text, Textarea, useColorModeValue, useToast, VStack} from '@chakra-ui/react';

import { useAuthContext } from 'contexts/auth';
import { useConfigContext } from 'contexts/config';
import { useUserContext } from 'contexts/user';
import {useAuthContext} from 'contexts/auth';
import {useConfigContext} from 'contexts/config';
import {useUserContext} from 'contexts/user';

import AuthPage from 'components/AuthPage';
import Button from 'components/Button';

import { ResponseType } from 'types/types';
import {ResponseType} from 'types/types';

import { textColorMode } from 'config/colorMode';
import {textColorMode} from 'config/colorMode';
import colors from 'theme/foundations/colors';

const Signup = (): JSX.Element => {
const auth = useAuthContext();
const { setUser } = useUserContext();
const { setConfig } = useConfigContext();
const router = useRouter();

const [isLoadingCredentials, setIsLoadingCredentials] = useState(false);
const [mnemonics, setMnemonics] = useState('');

const toast = useToast({ duration: 2000, isClosable: true });
const textColor = useColorModeValue(textColorMode.light, textColorMode.dark);

const signupWithMnemonics = async (): Promise<ResponseType> => {
setIsLoadingCredentials(true);

const signup = await auth.signup();

setIsLoadingCredentials(false);
if (!signup.user || !signup.user.account) return { success: false, message: signup.message };
if (!signup.mnemonic)
return {
success: false,
message: 'We could not generate your mnemonics. Please try again.',
};
setMnemonics(signup.mnemonic);
setUser(signup.user);
setConfig(signup.user.config);
return { success: true, message: signup.message };
};

const onClick = () => {
if (!mnemonics)
signupWithMnemonics().then((res) => toast({ title: res.message, status: res.success ? 'success' : 'error' }));
else {
navigator.clipboard.writeText(mnemonics);
toast({ title: 'Copy to clipboard !', status: 'success' });
}
};

return (
<AuthPage>
<VStack w="100%">
<VStack spacing="16px" w="100%">
<Textarea
value={mnemonics}
_focus={{ boxShadow: `0px 0px 0px 2px ${colors.red[300]}` }}
cursor="text"
readOnly
id="ipc-signup-text-area"
/>
<VStack w="100%" spacing="64px">
<VStack w="100%" spacing="32px">
<Button
variant={mnemonics ? 'primary' : 'special'}
size="lg"
w="100%"
onClick={onClick}
id="ipc-signup-create-copy-mnemonics-button"
isLoading={isLoadingCredentials}
>
{mnemonics ? 'Copy my mnemonics' : 'Create my account'}
</Button>

<Button
variant="secondary"
size="lg"
w="100%"
onClick={() => router.push('/drive')}
disabled={!mnemonics}
id="ipc-signup-go-to-dashboard-button"
>
Go to my dashboard
</Button>
</VStack>
<VStack w="100%">
<Text size="lg" color={textColor}>
Already got an account?
</Text>
<Button
variant="secondary"
size="lg"
onClick={() => router.push('/login')}
w="100%"
id="ipc-signup-login-button"
>
Login with my account
</Button>
</VStack>
</VStack>
</VStack>
</VStack>
</AuthPage>
);
const auth = useAuthContext();
const {setUser} = useUserContext();
const {setConfig} = useConfigContext();
const router = useRouter();

const [isLoadingCredentials, setIsLoadingCredentials] = useState(false);
const [mnemonics, setMnemonics] = useState('');

const toast = useToast({duration: 2000, isClosable: true});
const textColor = useColorModeValue(textColorMode.light, textColorMode.dark);

const signupWithMnemonics = async (): Promise<ResponseType> => {
setIsLoadingCredentials(true);

const signup = await auth.signup();

setIsLoadingCredentials(false);
if (!signup.user || !signup.user.account) return {success: false, message: signup.message};
if (!signup.mnemonic)
return {
success: false,
message: 'We could not generate your mnemonics. Please try again.',
};
setMnemonics(signup.mnemonic);
setUser(signup.user);
setConfig(signup.user.config);
return {success: true, message: signup.message};
};

const onClick = () => {
if (!mnemonics)
signupWithMnemonics().then((res) => toast({title: res.message, status: res.success ? 'success' : 'error'}));
else {
navigator.clipboard.writeText(mnemonics);
toast({title: 'Copy to clipboard !', status: 'success'});
}
};

return (
<AuthPage>
<VStack w="100%">
<VStack spacing="16px" w="100%">
<Textarea
value={mnemonics}
_focus={{boxShadow: `0px 0px 0px 2px ${colors.red[300]}`}}
cursor="text"
readOnly
id="ipc-signup-text-area"
/>
<VStack w="100%" spacing="64px">
<VStack w="100%" spacing="32px">
<Button
variant={mnemonics ? 'primary' : 'special'}
size="lg"
w="100%"
onClick={onClick}
id="ipc-signup-create-copy-mnemonics-button"
isLoading={isLoadingCredentials}
>
{mnemonics ? 'Copy my mnemonics' : 'Create my account'}
</Button>

<Button
variant="secondary"
size="lg"
w="100%"
onClick={() => router.push('/drive')}
disabled={!mnemonics}
id="ipc-signup-go-to-dashboard-button"
>
Go to my dashboard
</Button>
</VStack>
<VStack w="100%">
<Text size="lg" color={textColor}>
Already got an account?
</Text>
<Button
variant="secondary"
size="lg"
onClick={() => router.push('/login')}
w="100%"
id="ipc-signup-login-button"
>
Login with my account
</Button>
</VStack>
</VStack>
</VStack>
</VStack>
</AuthPage>
);
};

export default Signup;
4 changes: 2 additions & 2 deletions login.mo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
>Mohammed:
Mohammed:
drastic various soon remain sand glimpse fox more fit dolphin taxi gift

Test:
paddle globe seminar sadness rescue sure destroy screen mother fury swallow juice
paddle globe seminar sadness rescue sure destroy screen mother fury swallow juice
13 changes: 7 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
},
output: 'standalone',
reactStrictMode: true,
webpack: (config) => {
config.resolve.fallback = {fs: false};
return config;
},
output: 'standalone',
experimental: {appDir: true}
}

module.exports = nextConfig;
Loading

0 comments on commit acb4ee7

Please sign in to comment.