Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: solve ESLint and Sonar issues #998

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
import { Link } from 'react-router-dom';
import D from '../../../deprecated-locales';

const mapping = {
sourceItemLabelLg1: D.sourceItemTitle,
targetItemLabelLg1: D.targetItemTitle,
};

type SourceItemLabelTypes = {
label: string;
classId: string;
itemId: string;
itemLabelLg1: string;
itemLabelLg2: string;
secondLang: boolean;
classAltLabelLg1: string;
classAltLabelLg2: string;
};
const SourceItemLabel = ({
label,
classId,
itemId,
itemLabelLg1,
itemLabelLg2,
secondLang,
classAltLabelLg1,
classAltLabelLg2,
}: Readonly<SourceItemLabelTypes>) => {
return (
<li>
{label} :{' '}
<Link to={`/classifications/classification/${classId}/item/${itemId}`}>
{`${itemId} - `}
{!secondLang ? itemLabelLg1 : itemLabelLg2}
</Link>
<Link to={`/classifications/classification/${classId}`}>
{!secondLang
? classAltLabelLg1 && ` (${classAltLabelLg1})`
: classAltLabelLg2 && ` (${classAltLabelLg2})`}
</Link>
</li>
);
};
export const generalFields = (association: any, secondLang: boolean) => {
const mapping = {
sourceItemLabelLg1: D.sourceItemTitle,
targetItemLabelLg1: D.targetItemTitle,
};
const {
sourceClassId,
targetClassId,
Expand All @@ -23,40 +59,36 @@ export const generalFields = (association: any, secondLang: boolean) => {
const content = Object.keys(mapping).map((fieldName) => {
if (fieldName === 'sourceItemLabelLg1' && association[fieldName]) {
return (
<li key={fieldName}>
{mapping[fieldName]} :{' '}
<Link
to={`/classifications/classification/${sourceClassId}/item/${sourceItemId}`}
>
{`${sourceItemId} - `}
{!secondLang ? sourceItemLabelLg1 : sourceItemLabelLg2}
</Link>
<Link to={`/classifications/classification/${sourceClassId}`}>
{!secondLang
? sourceClassAltLabelLg1 && ` (${sourceClassAltLabelLg1})`
: sourceClassAltLabelLg2 && ` (${sourceClassAltLabelLg2})`}
</Link>
</li>
<SourceItemLabel
key="sourceItemLabelLg1"
label={mapping[fieldName]}
secondLang={secondLang}
classId={sourceClassId}
itemId={sourceItemId}
classAltLabelLg1={sourceClassAltLabelLg1}
classAltLabelLg2={sourceClassAltLabelLg2}
itemLabelLg1={sourceItemLabelLg1}
itemLabelLg2={sourceItemLabelLg2}
/>
);
}
if (fieldName === 'targetItemLabelLg1' && association[fieldName]) {
return (
<li key={fieldName}>
{mapping[fieldName]} :{' '}
<Link
to={`/classifications/classification/${targetClassId}/item/${targetItemId}`}
>
{`${targetItemId} - `}
{!secondLang ? targetItemLabelLg1 : targetItemLabelLg2}
</Link>
<Link to={`/classifications/classification/${targetClassId}`}>
{!secondLang
? targetClassAltLabelLg1 && ` (${targetClassAltLabelLg1})`
: targetClassAltLabelLg2 && ` (${targetClassAltLabelLg2})`}
</Link>
</li>
<SourceItemLabel
key="sourceItemLabelLg2"
label={mapping[fieldName]}
secondLang={secondLang}
classId={targetClassId}
itemId={targetItemId}
classAltLabelLg1={targetClassAltLabelLg1}
classAltLabelLg2={targetClassAltLabelLg2}
itemLabelLg1={targetItemLabelLg1}
itemLabelLg2={targetItemLabelLg2}
/>
);
} else return null;
}

return null;
});

return <ul>{content}</ul>;
Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/actions/classifications/level/general.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Dispatch } from 'redux';
import * as A from '../../../../redux/actions/constants';
import { ClassificationsApi } from '../../../../sdk/classification';

const fetchClassificationLevelGeneral =
(classificationId: string, levelId: string) => (dispatch: any) => {
(classificationId: string, levelId: string) => (dispatch: Dispatch) => {
dispatch({
type: A.LOAD_CLASSIFICATION_LEVEL_GENERAL,
payload: {
Expand Down
7 changes: 4 additions & 3 deletions src/packages/redux/actions/operations/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Dispatch } from 'redux';
import { sortArrayByLabel } from '../../../../utils/array-utils';

const call =
(remoteCall: any, LOADING: any, SUCCESS: any, FAILURE: any) =>
(dispatch: any) => {
(dispatch: Dispatch) => {
dispatch({
type: LOADING,
payload: {},
Expand Down Expand Up @@ -37,7 +38,7 @@ export const getPublishFactory = (
FAILURE: any,
) => {
return (object: any, callback = () => {}) =>
(dispatch: any) => {
(dispatch: Dispatch) => {
dispatch({
type: LOADING,
payload: {},
Expand Down Expand Up @@ -65,7 +66,7 @@ export const getPublishFactory = (
export const getItemFactory =
(remoteCall: any, LOADING: any, SUCCESS: any, FAILURE: any) =>
(id: string) =>
(dispatch: any, getState: any) => {
(dispatch: Dispatch, getState: any) => {
if (getState().operationsOperationCurrentStatus === LOADING) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/geographies.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GeographieApi } from '../sdk/geographie';
import { ERROR, LOADED, LOADING } from '../sdk/constants';
import { ReduxModel } from './model';
import { createAllDictionary } from '../utils/dictionnary';
import { Dispatch } from 'redux';

// Constants
const LOAD_GEOGRAPHIES = 'LOAD_GEOGRAPHIES';
Expand Down Expand Up @@ -69,7 +70,7 @@ export const reducer = (
};

// loader
export const loadGeographies = () => (dispatch: any) => {
export const loadGeographies = () => (dispatch: Dispatch) => {
dispatch(loadGeographiesPending());
return GeographieApi.getAll().then(
(results) => {
Expand Down
3 changes: 2 additions & 1 deletion src/packages/redux/operations/metadatastructure/list.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Dispatch } from 'redux';
import { getTree } from '../../../modules-operations/utils/msd';
import { OperationsApi } from '../../../sdk/operations-api';
import { loadCodesList } from '../../actions/operations/utils/setup';
Expand All @@ -9,7 +10,7 @@ export const LOAD_OPERATIONS_METADATASTRUCTURE_LIST_SUCCESS =
export const LOAD_OPERATIONS_METADATASTRUCTURE_LIST_FAILURE =
'LOAD_OPERATIONS_METADATASTRUCTURE_LIST_FAILURE';

const fetchMsd = () => (dispatch: any, getState: any) => {
const fetchMsd = () => (dispatch: Dispatch, getState: any) => {
dispatch({
type: LOAD_OPERATIONS_METADATASTRUCTURE_LIST,
payload: {},
Expand Down