Skip to content

Commit

Permalink
[minor-fix] Fix language issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenduythuc committed Jul 13, 2023
1 parent 6ae3174 commit e8f65db
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 58 deletions.
15 changes: 7 additions & 8 deletions src/screens/MasterPassword/ApplyMasterPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ const removeIcon = <Icon phosphorIcon={Trash} size={'lg'} iconColor={'#737373'}

const nextIcon = <Icon phosphorIcon={ArrowCircleRight} size={'lg'} weight={'fill'} />;

const formConfig: FormControlConfig = {
password: {
name: i18n.inputLabel.currentPassword,
value: '',
validateFunc: validatePassword,
},
};

const intersectionArray = (array1: AccountJson[], array2: AccountJson[]): AccountJson[] => {
return array1.filter(account => array2.find(acc => acc.address === account.address));
};
Expand All @@ -61,6 +53,13 @@ const ApplyMasterPassword = () => {
const selectedAction = useRef<SelectedActionType>();
useHandlerHardwareBackPress(true);
const migrateAddressRef = useRef<string>('');
const formConfig: FormControlConfig = {
password: {
name: i18n.inputLabel.currentPassword,
value: '',
validateFunc: validatePassword,
},
};

const migratedRef = useRef<AccountJson[]>(
accounts.filter(acc => acc.address !== ALL_ACCOUNT_KEY && !acc.isExternal && acc.isMasterPassword),
Expand Down
45 changes: 22 additions & 23 deletions src/screens/MasterPassword/ChangeMasterPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,6 @@ import i18n from 'utils/i18n/i18n';
import AlertBox from 'components/design-system-ui/alert-box';
import { FontSemiBold } from 'styles/sharedStyles';

const formConfig = {
curPassword: {
name: i18n.inputLabel.currentPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
password: {
name: i18n.inputLabel.newPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
repeatPassword: {
name: i18n.inputLabel.confirmNewPassword,
value: '',
validateFunc: (value: string, formValue: Record<string, string>) => {
return validatePasswordMatched(value, formValue.password);
},
require: true,
},
};

function checkValidateForm(isValidated: Record<string, boolean>) {
return isValidated.password && isValidated.repeatPassword;
}
Expand All @@ -56,6 +33,28 @@ const ChangeMasterPassword = () => {
const [isBusy, setIsBusy] = useState(false);
const [errors, setErrors] = useState<string[]>([]);
const [step, setStep] = useState<PageStep>('OldPassword');
const formConfig = {
curPassword: {
name: i18n.inputLabel.currentPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
password: {
name: i18n.inputLabel.newPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
repeatPassword: {
name: i18n.inputLabel.confirmNewPassword,
value: '',
validateFunc: (value: string, formValue: Record<string, string>) => {
return validatePasswordMatched(value, formValue.password);
},
require: true,
},
};

useHandlerHardwareBackPress(isBusy);

Expand Down
33 changes: 16 additions & 17 deletions src/screens/MasterPassword/CreateMasterPassword/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ import { KeypairType } from '@polkadot/util-crypto/types';
import useHandlerHardwareBackPress from 'hooks/screen/useHandlerHardwareBackPress';
import AlertBox from 'components/design-system-ui/alert-box';

const formConfig: FormControlConfig = {
password: {
name: i18n.common.walletPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
repeatPassword: {
name: i18n.common.repeatWalletPassword,
value: '',
validateFunc: (value: string, formValue: Record<string, string>) => {
return validatePasswordMatched(value, formValue.password);
},
require: true,
},
};

function checkValidateForm(isValidated: Record<string, boolean>) {
return isValidated.password && isValidated.repeatPassword;
}
Expand All @@ -48,6 +31,22 @@ const CreateMasterPassword = ({
const [isBusy, setIsBusy] = useState(false);
const [errors, setErrors] = useState<string[]>([]);
useHandlerHardwareBackPress(true);
const formConfig: FormControlConfig = {
password: {
name: i18n.common.walletPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
repeatPassword: {
name: i18n.common.repeatWalletPassword,
value: '',
validateFunc: (value: string, formValue: Record<string, string>) => {
return validatePasswordMatched(value, formValue.password);
},
require: true,
},
};

const onComplete = async () => {
if (pathName === 'CreateAccount') {
Expand Down
18 changes: 8 additions & 10 deletions src/screens/MasterPassword/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ import { keyringUnlock } from 'messaging/index';

type Props = {};

const formConfig = {
password: {
name: i18n.common.walletPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
};
const Login: React.FC<Props> = (props: Props) => {
const {} = props;

const theme = useSubWalletTheme().swThemes;

const [loading, setLoading] = useState<boolean>(false);
const formConfig = {
password: {
name: i18n.common.walletPassword,
value: '',
validateFunc: validatePassword,
require: true,
},
};

const onSubmit = () => {
const password = formState.data.password;
Expand Down

0 comments on commit e8f65db

Please sign in to comment.