Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
razvantomegea committed Aug 5, 2024
1 parent 4f68b08 commit 5aa39f2
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 115 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ yarn-debug.log*
yarn-error.log*

.yalc
yalc.lock
yalc.lock
version.json
22 changes: 0 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@multiversx/sdk-network-providers": "2.2.1",
"@multiversx/sdk-wallet": "4.2.0",
"@reduxjs/toolkit": "1.9.1",
"add": "^2.0.6",
"axios": "1.6.5",
"bignumber.js": "9.0.2",
"classnames": "2.3.2",
Expand All @@ -63,7 +62,6 @@
"react-router-dom": "6.16.0",
"react-select": "5.8.0",
"redux-persist": "6.0.0",
"yarn": "^1.22.22",
"yup": "1.4.0"
},
"devDependencies": {
Expand Down
41 changes: 0 additions & 41 deletions src/components/Copy/helpers/copyToClipboard.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Copy/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './copyToClipboard';
export * from './readFromClipboard';
21 changes: 8 additions & 13 deletions src/pages/CreateRecover/CreateRecover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,16 @@ export const CreateRecover = () => {
<CreateRecoverDownload
createdAddress={createdAddress}
keystoreString={keystoreString}
/>
/>,
...(isCreateRoute
? [
<CreateDisclaimer onNext={onNext} setMnemonic={setMnemonic} />,
<CreateMnemonics onNext={onNext} mnemonic={mnemonic} />,
<CreateQuiz mnemonic={mnemonic} onBack={onBack} onNext={onNext} />
]
: [<RecoverMnemonics onNext={onNext} setMnemonic={setMnemonic} />])
];

if (isCreateRoute) {
stepComponents.unshift(
<CreateDisclaimer onNext={onNext} setMnemonic={setMnemonic} />,
<CreateMnemonics onNext={onNext} mnemonic={mnemonic} />,
<CreateQuiz mnemonic={mnemonic} onBack={onBack} onNext={onNext} />
);
} else {
stepComponents.unshift(
<RecoverMnemonics onNext={onNext} setMnemonic={setMnemonic} />
);
}

return (
<ModalContainer
className='login-modal'
Expand Down
46 changes: 24 additions & 22 deletions src/pages/CreateRecover/helpers/downloadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,33 @@ interface DownloadFileType {
}

export const downloadFile = ({ data, name, fileType }: DownloadFileType) => {
if (data && name) {
const type =
fileType === 'csv'
? 'data:text/csv;charset=utf-8'
: 'application/json; charset=utf-8';
if (!data || !name) {
return;
}

const type =
fileType === 'csv'
? 'data:text/csv;charset=utf-8'
: 'application/json; charset=utf-8';

const blob = new Blob([data], { type });
const blob = new Blob([data], { type });

if (!isChromeIOS()) {
FileSaver.saveAs(blob, name + '.' + fileType);
} else {
const reader = new FileReader();
reader.onload = () => {
window.location.href = reader.result as any;
};
if (!isChromeIOS()) {
FileSaver.saveAs(blob, name + '.' + fileType);
} else {
const reader = new FileReader();
reader.onload = () => {
window.location.href = reader.result as any;
};

reader.readAsDataURL(blob);
reader.readAsDataURL(blob);

const fileURL = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = fileURL;
a.target = '_blank';
a.download = name + '.' + fileType;
document.body.appendChild(a);
a.click();
}
const fileURL = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = fileURL;
a.target = '_blank';
a.download = name + '.' + fileType;
document.body.appendChild(a);
a.click();
}
};
6 changes: 3 additions & 3 deletions src/pages/CreateRecover/hooks/useCreateRecoverState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MouseEvent, useState } from 'react';
import { matchPath } from 'react-router-dom';
import { matchPath, useLocation } from 'react-router-dom';
import { CreateRecoverProviderTypeEnum } from '../types';

interface CreateRecoverState {
Expand Down Expand Up @@ -29,14 +29,14 @@ const createRecoverDetails: Record<
};

export const useCreateRecoverState = () => {
const { pathname } = useLocation();
const [mnemonic, setMnemonic] = useState('');
const [createdAddress, setCreatedAddress] = useState('');
const [keystoreString, setKeystoreString] = useState('');

const [currentStep, setCurrentStep] = useState(0);
const isCreateRoute = matchPath(
CreateRecoverProviderTypeEnum.create,
window.location.pathname
pathname
);

const providerType = isCreateRoute
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3560,11 +3560,6 @@ acorn@^8.1.0, acorn@^8.11.0, acorn@^8.11.3, acorn@^8.4.1, acorn@^8.8.1, acorn@^8
resolved "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz"
integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==

add@^2.0.6:
version "2.0.6"
resolved "https://registry.npmjs.org/add/-/add-2.0.6.tgz"
integrity sha512-j5QzrmsokwWWp6kUcJQySpbG+xfOBqqKnup3OIk1pz+kB/80SLorZ9V8zHFLO92Lcd+hbvq8bT+zOGoPkmBV0Q==

agent-base@^7.0.2, agent-base@^7.1.0, agent-base@^7.1.1:
version "7.1.1"
resolved "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz"
Expand Down Expand Up @@ -10842,11 +10837,6 @@ yargs@^17.2.1, yargs@^17.3.1, yargs@^17.7.2, [email protected]:
y18n "^5.0.5"
yargs-parser "^21.1.1"

yarn@^1.22.22:
version "1.22.22"
resolved "https://registry.npmjs.org/yarn/-/yarn-1.22.22.tgz"
integrity sha512-prL3kGtyG7o9Z9Sv8IPfBNrWTDmXB4Qbes8A9rEzt6wkJV8mUvoirjU0Mp3GGAU06Y0XQyA3/2/RQFVuK7MTfg==

yauzl@^2.10.0:
version "2.10.0"
resolved "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz"
Expand Down

0 comments on commit 5aa39f2

Please sign in to comment.