mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-23 05:29:56 +05:30
Fix type and lint errors after upgrading corresponding dependencies
This commit is contained in:
parent
404fcb804a
commit
12f5e711c4
@ -41,11 +41,11 @@ export function authenticate(
|
||||
}
|
||||
|
||||
try {
|
||||
const { token: newToken, refreshToken: newRefreshToken, user } = await validateToken(
|
||||
accountId,
|
||||
token,
|
||||
refreshToken,
|
||||
);
|
||||
const {
|
||||
token: newToken,
|
||||
refreshToken: newRefreshToken,
|
||||
user,
|
||||
} = await validateToken(accountId, token, refreshToken);
|
||||
const newAccount: Account = {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
|
@ -405,7 +405,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
|
||||
|
||||
getHeader({ key, style, data }: TransitionPlainStyle): ReactElement {
|
||||
const { Title } = data as AnimationData;
|
||||
const { transformSpring } = (style as unknown) as AnimationStyle;
|
||||
const { transformSpring } = style as unknown as AnimationStyle;
|
||||
|
||||
let { hasBackButton } = data;
|
||||
|
||||
@ -414,7 +414,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
const transitionStyle = {
|
||||
...this.getDefaultTransitionStyles(key, (style as unknown) as AnimationStyle),
|
||||
...this.getDefaultTransitionStyles(key, style as unknown as AnimationStyle),
|
||||
opacity: 1, // reset default
|
||||
};
|
||||
|
||||
@ -448,7 +448,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
|
||||
|
||||
getBody({ key, style, data }: TransitionPlainStyle): ReactElement {
|
||||
const { Body } = data as AnimationData;
|
||||
const { transformSpring } = (style as unknown) as AnimationStyle;
|
||||
const { transformSpring } = style as unknown as AnimationStyle;
|
||||
const { direction } = this.state;
|
||||
|
||||
let transform = this.translate(transformSpring, direction);
|
||||
@ -460,7 +460,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
const transitionStyle: CSSProperties = {
|
||||
...this.getDefaultTransitionStyles(key, (style as unknown) as AnimationStyle),
|
||||
...this.getDefaultTransitionStyles(key, style as unknown as AnimationStyle),
|
||||
top: 'auto', // reset default
|
||||
[verticalOrigin]: 0,
|
||||
...transform,
|
||||
@ -486,7 +486,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
|
||||
getFooter({ key, style, data }: TransitionPlainStyle): ReactElement {
|
||||
const { Footer } = data as AnimationData;
|
||||
|
||||
const transitionStyle = this.getDefaultTransitionStyles(key, (style as unknown) as AnimationStyle);
|
||||
const transitionStyle = this.getDefaultTransitionStyles(key, style as unknown as AnimationStyle);
|
||||
|
||||
return (
|
||||
<div key={`footer/${key}`} style={transitionStyle}>
|
||||
@ -498,7 +498,7 @@ class PanelTransition extends React.PureComponent<Props, State> {
|
||||
getLinks({ key, style, data }: TransitionPlainStyle): ReactElement {
|
||||
const { Links } = data as AnimationData;
|
||||
|
||||
const transitionStyle = this.getDefaultTransitionStyles(key, (style as unknown) as AnimationStyle);
|
||||
const transitionStyle = this.getDefaultTransitionStyles(key, style as unknown as AnimationStyle);
|
||||
|
||||
return (
|
||||
<div key={`links/${key}`} style={transitionStyle}>
|
||||
|
@ -15,18 +15,19 @@ interface Props {
|
||||
const AccountSwitcher: ComponentType<Props> = ({ accounts, onAccountClick }) => {
|
||||
const [selectedAccount, setSelectedAccount] = useState<number>();
|
||||
const onAccountClickCallback = useCallback(
|
||||
(account: Account): MouseEventHandler => async (event) => {
|
||||
event.stopPropagation();
|
||||
(account: Account): MouseEventHandler =>
|
||||
async (event) => {
|
||||
event.stopPropagation();
|
||||
|
||||
setSelectedAccount(account.id);
|
||||
try {
|
||||
if (onAccountClick) {
|
||||
await onAccountClick(account);
|
||||
setSelectedAccount(account.id);
|
||||
try {
|
||||
if (onAccountClick) {
|
||||
await onAccountClick(account);
|
||||
}
|
||||
} finally {
|
||||
setSelectedAccount(undefined);
|
||||
}
|
||||
} finally {
|
||||
setSelectedAccount(undefined);
|
||||
}
|
||||
},
|
||||
},
|
||||
[onAccountClick],
|
||||
);
|
||||
|
||||
|
@ -44,7 +44,7 @@ const typeToForm: TypeToForm = {
|
||||
|
||||
type TypeToLabel = Record<ApplicationType, MessageDescriptor>;
|
||||
|
||||
const typeToLabel: TypeToLabel = ((Object.keys(typeToForm) as unknown) as Array<ApplicationType>).reduce(
|
||||
const typeToLabel: TypeToLabel = (Object.keys(typeToForm) as unknown as Array<ApplicationType>).reduce(
|
||||
(result, key) => {
|
||||
result[key] = typeToForm[key].label;
|
||||
|
||||
|
@ -14,7 +14,7 @@ interface Props {
|
||||
|
||||
const ApplicationTypeSwitcher: ComponentType<Props> = ({ appTypes, selectedType, setType }) => (
|
||||
<div>
|
||||
{((Object.keys(appTypes) as unknown) as Array<ApplicationType>).map((type) => (
|
||||
{(Object.keys(appTypes) as unknown as Array<ApplicationType>).map((type) => (
|
||||
<div className={styles.radioContainer} key={type}>
|
||||
<Radio
|
||||
onChange={() => setType(type)}
|
||||
|
@ -14,10 +14,11 @@ const FooterMenu: ComponentType = () => {
|
||||
const dispatch = useReduxDispatch();
|
||||
|
||||
const createPopupHandler = useCallback(
|
||||
(popup: ComponentType): MouseEventHandler<HTMLAnchorElement> => (event) => {
|
||||
event.preventDefault();
|
||||
dispatch(createPopup({ Popup: popup }));
|
||||
},
|
||||
(popup: ComponentType): MouseEventHandler<HTMLAnchorElement> =>
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
dispatch(createPopup({ Popup: popup }));
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
|
@ -11,7 +11,7 @@ import FormInputComponent from './FormInputComponent';
|
||||
type I18nString = string | MessageDescriptor;
|
||||
type ItemLabel = I18nString | React.ReactElement;
|
||||
|
||||
interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
||||
interface Props extends InputHTMLAttributes<HTMLDivElement> {
|
||||
label: I18nString;
|
||||
items: Record<string, ItemLabel>;
|
||||
block?: boolean;
|
||||
|
@ -39,9 +39,7 @@ export default class FormModel {
|
||||
*
|
||||
* @returns {object} - ref and name props for component
|
||||
*/
|
||||
bindField(
|
||||
name: string,
|
||||
): {
|
||||
bindField(name: string): {
|
||||
name: string;
|
||||
ref: (el: any) => void;
|
||||
error?: ValidationError;
|
||||
|
@ -27,19 +27,21 @@ const AccountSwitcher: ComponentType<Props> = ({
|
||||
}) => {
|
||||
const available = accounts.filter((account) => account.id !== activeAccount.id);
|
||||
const onAccountClickCallback = useCallback(
|
||||
(account: Account): MouseEventHandler => (event) => {
|
||||
event.preventDefault();
|
||||
onAccountClick(account);
|
||||
},
|
||||
(account: Account): MouseEventHandler =>
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
onAccountClick(account);
|
||||
},
|
||||
[onAccountClick],
|
||||
);
|
||||
const onAccountRemoveCallback = useCallback(
|
||||
(account: Account): MouseEventHandler => (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
(account: Account): MouseEventHandler =>
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
onRemoveClick(account);
|
||||
},
|
||||
onRemoveClick(account);
|
||||
},
|
||||
[onRemoveClick],
|
||||
);
|
||||
|
||||
|
@ -88,9 +88,7 @@ export { default as debounce } from 'debounce';
|
||||
*
|
||||
* @returns {object} - decoded jwt payload
|
||||
*/
|
||||
export function getJwtPayloads(
|
||||
jwt: string,
|
||||
): {
|
||||
export function getJwtPayloads(jwt: string): {
|
||||
sub: string;
|
||||
jti: number;
|
||||
exp: number;
|
||||
|
@ -78,94 +78,96 @@ export default connect(
|
||||
}),
|
||||
{
|
||||
refreshUserData,
|
||||
onSubmit: ({ form, sendData }: { form: FormModel; sendData: () => Promise<any> }) => (dispatch: Dispatch) => {
|
||||
form.beginLoading();
|
||||
onSubmit:
|
||||
({ form, sendData }: { form: FormModel; sendData: () => Promise<any> }) =>
|
||||
(dispatch: Dispatch) => {
|
||||
form.beginLoading();
|
||||
|
||||
return sendData()
|
||||
.catch((resp) => {
|
||||
const requirePassword = resp.errors && !!resp.errors.password;
|
||||
return sendData()
|
||||
.catch((resp) => {
|
||||
const requirePassword = resp.errors && !!resp.errors.password;
|
||||
|
||||
// prevalidate user input, because requestPassword popup will block the
|
||||
// entire form from input, so it must be valid
|
||||
if (resp.errors) {
|
||||
delete resp.errors.password;
|
||||
// prevalidate user input, because requestPassword popup will block the
|
||||
// entire form from input, so it must be valid
|
||||
if (resp.errors) {
|
||||
delete resp.errors.password;
|
||||
|
||||
if (resp.errors.email && resp.data && resp.data.canRepeatIn) {
|
||||
resp.errors.email = {
|
||||
type: resp.errors.email,
|
||||
payload: {
|
||||
msLeft: resp.data.canRepeatIn * 1000,
|
||||
},
|
||||
};
|
||||
if (resp.errors.email && resp.data && resp.data.canRepeatIn) {
|
||||
resp.errors.email = {
|
||||
type: resp.errors.email,
|
||||
payload: {
|
||||
msLeft: resp.data.canRepeatIn * 1000,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (Object.keys(resp.errors).length) {
|
||||
form.setErrors(resp.errors);
|
||||
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
|
||||
if (requirePassword) {
|
||||
return requestPassword(form);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(resp.errors).length) {
|
||||
form.setErrors(resp.errors);
|
||||
|
||||
return Promise.reject(resp);
|
||||
})
|
||||
.catch((resp) => {
|
||||
if (!resp || !resp.errors) {
|
||||
logger.warn('Unexpected profile editing error', {
|
||||
resp,
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
})
|
||||
.finally(() => form.endLoading());
|
||||
|
||||
if (requirePassword) {
|
||||
return requestPassword(form);
|
||||
}
|
||||
}
|
||||
function requestPassword(form: FormModel) {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch(
|
||||
createPopup({
|
||||
Popup(props: { onClose: () => Promise<any> }) {
|
||||
const onSubmit = () => {
|
||||
form.beginLoading();
|
||||
|
||||
return Promise.reject(resp);
|
||||
})
|
||||
.catch((resp) => {
|
||||
if (!resp || !resp.errors) {
|
||||
logger.warn('Unexpected profile editing error', {
|
||||
resp,
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
})
|
||||
.finally(() => form.endLoading());
|
||||
sendData()
|
||||
.then(resolve)
|
||||
.then(props.onClose)
|
||||
.catch((resp) => {
|
||||
if (resp.errors) {
|
||||
form.setErrors(resp.errors);
|
||||
|
||||
function requestPassword(form: FormModel) {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch(
|
||||
createPopup({
|
||||
Popup(props: { onClose: () => Promise<any> }) {
|
||||
const onSubmit = () => {
|
||||
form.beginLoading();
|
||||
const parentFormHasErrors =
|
||||
Object.keys(resp.errors).filter((name) => name !== 'password')
|
||||
.length > 0;
|
||||
|
||||
sendData()
|
||||
.then(resolve)
|
||||
.then(props.onClose)
|
||||
.catch((resp) => {
|
||||
if (resp.errors) {
|
||||
form.setErrors(resp.errors);
|
||||
|
||||
const parentFormHasErrors =
|
||||
Object.keys(resp.errors).filter((name) => name !== 'password')
|
||||
.length > 0;
|
||||
|
||||
if (parentFormHasErrors) {
|
||||
// something wrong with parent form, hiding popup and show that form
|
||||
props.onClose();
|
||||
reject(resp);
|
||||
logger.warn(
|
||||
'Profile: can not submit password popup due to errors in source form',
|
||||
{ resp },
|
||||
);
|
||||
if (parentFormHasErrors) {
|
||||
// something wrong with parent form, hiding popup and show that form
|
||||
props.onClose();
|
||||
reject(resp);
|
||||
logger.warn(
|
||||
'Profile: can not submit password popup due to errors in source form',
|
||||
{ resp },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
} else {
|
||||
return Promise.reject(resp);
|
||||
}
|
||||
})
|
||||
.finally(() => form.endLoading());
|
||||
};
|
||||
})
|
||||
.finally(() => form.endLoading());
|
||||
};
|
||||
|
||||
return <PasswordRequestForm form={form} onSubmit={onSubmit} />;
|
||||
},
|
||||
// TODO: this property should be automatically extracted from the popup's isClosable prop
|
||||
disableOverlayClose: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
return <PasswordRequestForm form={form} onSubmit={onSubmit} />;
|
||||
},
|
||||
// TODO: this property should be automatically extracted from the popup's isClosable prop
|
||||
disableOverlayClose: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
)(ProfileController);
|
||||
|
@ -1,8 +1,6 @@
|
||||
import request, { Resp } from 'app/services/request';
|
||||
|
||||
export function getSecret(
|
||||
id: number,
|
||||
): Promise<
|
||||
export function getSecret(id: number): Promise<
|
||||
Resp<{
|
||||
qr: string;
|
||||
secret: string;
|
||||
|
@ -66,9 +66,7 @@ class I18N {
|
||||
await intlPolyfill('en');
|
||||
}
|
||||
|
||||
async require(
|
||||
locale: string,
|
||||
): Promise<{
|
||||
async require(locale: string): Promise<{
|
||||
locale: string;
|
||||
messages: Record<string, string>;
|
||||
}> {
|
||||
|
@ -267,25 +267,23 @@ async function pull(): Promise<void> {
|
||||
});
|
||||
let downloadingReady = 0;
|
||||
|
||||
const promises = localesToPull.map(
|
||||
async (languageId): Promise<void> => {
|
||||
const {
|
||||
data: { url },
|
||||
} = await crowdin.translationsApi.buildProjectFileTranslation(PROJECT_ID, fileId, {
|
||||
targetLanguageId: languageId,
|
||||
});
|
||||
const promises = localesToPull.map(async (languageId): Promise<void> => {
|
||||
const {
|
||||
data: { url },
|
||||
} = await crowdin.translationsApi.buildProjectFileTranslation(PROJECT_ID, fileId, {
|
||||
targetLanguageId: languageId,
|
||||
});
|
||||
|
||||
const { data: fileContents } = await axios.get(url, {
|
||||
// Disable response parsing
|
||||
transformResponse: [],
|
||||
});
|
||||
fs.writeFileSync(getLocaleFilePath(languageId), fileContents);
|
||||
const { data: fileContents } = await axios.get(url, {
|
||||
// Disable response parsing
|
||||
transformResponse: [],
|
||||
});
|
||||
fs.writeFileSync(getLocaleFilePath(languageId), fileContents);
|
||||
|
||||
downloadingProgressBar.update(++downloadingReady / localesToPull.length, {
|
||||
cCurrent: downloadingReady,
|
||||
});
|
||||
},
|
||||
);
|
||||
downloadingProgressBar.update(++downloadingReady / localesToPull.length, {
|
||||
cCurrent: downloadingReady,
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
|
@ -12,13 +12,15 @@ module.exports = ({ webpackLoaderContext: loader }) => ({
|
||||
'postcss-import': {
|
||||
addModulesDirectories: ['./src'],
|
||||
|
||||
resolve: ((defaultResolve) => (url, basedir, importOptions) =>
|
||||
defaultResolve(
|
||||
// mainly to remove '~' from request
|
||||
loaderUtils.urlToRequest(url),
|
||||
basedir,
|
||||
importOptions,
|
||||
))(require('postcss-import/lib/resolve-id')),
|
||||
resolve: (
|
||||
(defaultResolve) => (url, basedir, importOptions) =>
|
||||
defaultResolve(
|
||||
// mainly to remove '~' from request
|
||||
loaderUtils.urlToRequest(url),
|
||||
basedir,
|
||||
importOptions,
|
||||
)
|
||||
)(require('postcss-import/lib/resolve-id')),
|
||||
|
||||
load: ((defaultLoad) => (filename, importOptions) => {
|
||||
if (/\.font.(js|json)$/.test(filename)) {
|
||||
|
@ -240,8 +240,7 @@ function createState() {
|
||||
id: 7,
|
||||
username: 'SleepWalker',
|
||||
email: 'danilenkos@auroraglobal.com',
|
||||
token:
|
||||
'eyJhbGciOiJIUzI1NiJ9.eyJlbHktc2NvcGVzIjoiYWNjb3VudHNfd2ViX3VzZXIiLCJpYXQiOjE1MTgzNzM4MDksImV4cCI6MTUxODM3NzQwOSwic3ViIjoiZWx5fDciLCJqdGkiOjM1NDh9.Fv4AbJ0iDbrH3bhbgF0ViJLfYYiwH78deR4fMlMhKrQ',
|
||||
token: 'eyJhbGciOiJIUzI1NiJ9.eyJlbHktc2NvcGVzIjoiYWNjb3VudHNfd2ViX3VzZXIiLCJpYXQiOjE1MTgzNzM4MDksImV4cCI6MTUxODM3NzQwOSwic3ViIjoiZWx5fDciLCJqdGkiOjM1NDh9.Fv4AbJ0iDbrH3bhbgF0ViJLfYYiwH78deR4fMlMhKrQ',
|
||||
refreshToken:
|
||||
'3gh6ZZ3R9jGeFdp0TmlY7sd0zBxH6Zfq48M86eUAv952RcAKx32RAnjlKkgd6i-MV-RKbjtADIdoRwMUWOYQjEYtwwXPjcQJ',
|
||||
},
|
||||
@ -249,8 +248,7 @@ function createState() {
|
||||
id: 102,
|
||||
username: 'test',
|
||||
email: 'admin@udf.su',
|
||||
token:
|
||||
'eyJhbGciOiJIUzI1NiJ9.eyJlbHktc2NvcGVzIjoiYWNjb3VudHNfd2ViX3VzZXIiLCJpYXQiOjE1MTgzNzM4NjUsImV4cCI6MTUxODM3NzQ2NSwic3ViIjoiZWx5fDEwMiIsImp0aSI6MzU0OX0.eJEgvXT3leGqBe3tYNGZb0E4WEvWfrLPjcD7eNjyQYO',
|
||||
token: 'eyJhbGciOiJIUzI1NiJ9.eyJlbHktc2NvcGVzIjoiYWNjb3VudHNfd2ViX3VzZXIiLCJpYXQiOjE1MTgzNzM4NjUsImV4cCI6MTUxODM3NzQ2NSwic3ViIjoiZWx5fDEwMiIsImp0aSI6MzU0OX0.eJEgvXT3leGqBe3tYNGZb0E4WEvWfrLPjcD7eNjyQYO',
|
||||
refreshToken:
|
||||
'Al75SIx-LFOCP7kaqZBVqMVmSljJw9_bdFQGyuM64c6ShP7YsXbkCD8vPOundAwUDfRZqsIbOHUROmAHPB0VBfjLfw96yqxx',
|
||||
},
|
||||
|
@ -6,7 +6,7 @@ describe('Applications', () => {
|
||||
|
||||
// remove all previously added apps
|
||||
cy.window().then(async (win) => {
|
||||
const { oauthApi } = (win as any) as {
|
||||
const { oauthApi } = win as any as {
|
||||
oauthApi: typeof import('app/services/api/oauth').default;
|
||||
};
|
||||
const apps = await oauthApi.getAppsByUser(user.id);
|
||||
|
6
tests-e2e/cypress/support/index.d.ts
vendored
6
tests-e2e/cypress/support/index.d.ts
vendored
@ -32,11 +32,7 @@ declare namespace Cypress {
|
||||
*/
|
||||
rawApiResp?: false;
|
||||
}): Promise<{ accounts: TAccount[] }>;
|
||||
login(options: {
|
||||
accounts: AccountAlias[];
|
||||
updateState?: boolean;
|
||||
rawApiResp: true;
|
||||
}): Promise<{
|
||||
login(options: { accounts: AccountAlias[]; updateState?: boolean; rawApiResp: true }): Promise<{
|
||||
accounts: {
|
||||
success: true;
|
||||
access_token: string;
|
||||
|
Loading…
Reference in New Issue
Block a user