Skip to content

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Sep 18, 2022
1 parent 92e6d9b commit 68635de
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/features/files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ describe('Upload a file modal in Dashboard', () => {
cy.get('#ipc-dashboard-upload-file').attachFile(fixtureFile);
cy.get('#ipc-dashboard-upload-file-modal-button').click();
cy.wait(20000);
cy.get('button').should('have.length', 18);
cy.get('button').should('have.length', 19);
});

it('Good number of buttons after failed upload', () => {
cy.get('#ipc-dashboard-upload-file').attachFile(emptyFixtureFile, { allowEmpty: true });
cy.get('#ipc-dashboard-upload-file-modal-button').click();
cy.wait(20000);
cy.get('button').should('have.length', 20);
cy.get('button').should('have.length', 21);
});
});

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/features/programs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe('Deploy a program modal for Dashboard', () => {
cy.get('#ipc-dashboard-deploy-program').attachFile(fixtureFile);
cy.get('#ipc-dashboard-deploy-program-modal-button').click();
cy.wait(20000);
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of buttons after closing modal', () => {
cy.get('#ipc-modal-close-button').click();
cy.get('button').should('have.length', 11);
cy.get('button').should('have.length', 12);
});
});
6 changes: 3 additions & 3 deletions cypress/e2e/front/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Good Upload file modal front in Dashboard', () => {
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of input', () => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('Good Deploy program modal front in Dashboard', () => {
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of input', () => {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Good Create folder modal front in Dashboard', () => {
});

it('Good number of buttons', () => {
cy.get('button').should('have.length', 13);
cy.get('button').should('have.length', 14);
});

it('Good number of input', () => {
Expand Down
24 changes: 15 additions & 9 deletions src/components/ConfigPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Text, Input, Button, useToast, Box, HStack, useColorMode, useColorModeValue } from '@chakra-ui/react';
import { Box, Button, HStack, Input, Text, useColorMode, useColorModeValue, useToast } from '@chakra-ui/react';
import { ChangeEvent, useState } from 'react';

import { useConfigContext } from 'contexts/config';
import { useUserContext } from 'contexts/user';
Expand All @@ -14,31 +14,30 @@ const ConfigPage = (): JSX.Element => {
const { toggleColorMode } = useColorMode();
const color = useColorModeValue('white', 'gray.800');
const colorText = useColorModeValue('gray.800', 'white');
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
console.log(user.config?.theme);
}, []);

const Theme = (e: React.ChangeEvent<HTMLInputElement>) => {
const Theme = (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.value.toLowerCase() === 'dark') setColorTheme('gray.800');
else if (e.target.value.toLowerCase() === 'light') setColorTheme('white');
else setColorTheme('undefined');
};

const configUser = async () => {
setIsLoading(true);
try {
if (ColorTheme === 'undefined') {
toast({ title: "This color doesn't exist", status: 'error' });
return;
}
const config1 = await user.contact.configFile(ColorTheme);
setConfig({ theme: ColorTheme });
setConfig({ ...user.config!, theme: ColorTheme });
toggleColorMode();
toast({ title: config1.message, status: config1.success ? 'success' : 'error' });
} catch (error) {
toast({ title: 'Fail change theme', status: 'error' });
console.error(error);
}
setIsLoading(false);
};

return (
Expand All @@ -56,7 +55,14 @@ const ConfigPage = (): JSX.Element => {
</HStack>
<BsCodeSlash size="25" color={colorText}></BsCodeSlash>
</Box>
<Button onClick={configUser} w="90%" backgroundColor={color} textColor={colorText} justifyContent="center">
<Button
onClick={configUser}
w="90%"
backgroundColor={color}
textColor={colorText}
justifyContent="center"
isLoading={isLoading}
>
Save
</Button>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/components/OutlineButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Button, ButtonProps, Flex, Text } from '@chakra-ui/react';

import colors from 'theme/foundations/colors';

type OutlineButtonProps = { text: string; configTheme: string } & ButtonProps;
type OutlineButtonProps = { text: string; configTheme?: string } & ButtonProps;

const OutlineButton = ({ text, configTheme, ...rest }: OutlineButtonProps): JSX.Element => (
<Button variant="inline" {...rest} p="4px" _hover={{ opacity: 0.8 }}>
<Flex w="100%" bg={configTheme ?? 'white'} h="100%" borderRadius="base" justify="center" align="center">
<Flex w="100%" h="100%" bg={configTheme ?? 'white'} borderRadius="base" justify="center" align="center">
<Text bgGradient={`linear-gradient(90deg, ${colors.blue[700]} 0%, ${colors.red[700]} 100%)`} bgClip="text">
{text}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/components/computing/CustomProgram.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeEvent } from 'react';
import { Input } from '@chakra-ui/react';
import { ChangeEvent } from 'react';

type CustomProgramParams = {
customName: string;
Expand Down
1 change: 1 addition & 0 deletions src/components/contact/AddContact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const AddContact = (): JSX.Element => {
publicKey: contactPublicKey,
files: [],
folders: [],
config: undefined,
});

toast({ title: add.message, status: add.success ? 'success' : 'error' });
Expand Down
2 changes: 1 addition & 1 deletion src/lib/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class Contact {
if (this.account) {
const contact = this.contacts.find((c) => c.address === this.account?.address);
if (contact) {
contact.config.theme = newTheme;
contact.config!.theme = newTheme;
await this.publishAggregate();
return { success: true, message: 'Theme change' };
}
Expand Down
3 changes: 1 addition & 2 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type IPCContact = {
publicKey: string;
files: IPCFile[];
folders: IPCFolder[];
config: IPCConfig;
config: IPCConfig | undefined;
};

export type IPCPermission = 'owner' | 'viewer' | 'editor';
Expand All @@ -58,7 +58,6 @@ export type UploadResponse = ResponseType & {
export type AggregateContentType = {
programs: IPCProgram[];
contacts: IPCContact[];
config: IPCConfig;
};

export type AggregateType = {
Expand Down

0 comments on commit 68635de

Please sign in to comment.