Merge pull request #6677 from tchak/fix-commune-select
fix(commune): do not display foreign departement when selecting commune
This commit is contained in:
commit
f86e202738
2 changed files with 14 additions and 2 deletions
|
@ -91,6 +91,7 @@ function ComboCommunesSearch(params) {
|
||||||
inputId={!departementCode ? inputId : null}
|
inputId={!departementCode ? inputId : null}
|
||||||
aria-describedby={departementDescribedBy}
|
aria-describedby={departementDescribedBy}
|
||||||
placeholder={placeholderDepartement}
|
placeholder={placeholderDepartement}
|
||||||
|
addForeignDepartement={false}
|
||||||
required={params.mandatory}
|
required={params.mandatory}
|
||||||
onChange={(value, result) => {
|
onChange={(value, result) => {
|
||||||
setDepartementCode(result?.code);
|
setDepartementCode(result?.code);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { QueryClientProvider } from 'react-query';
|
import { QueryClientProvider } from 'react-query';
|
||||||
import { matchSorter } from 'match-sorter';
|
import { matchSorter } from 'match-sorter';
|
||||||
|
|
||||||
|
@ -16,14 +17,19 @@ function expandResultsWithForeignDepartement(term, results) {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ComboDepartementsSearch(params) {
|
export function ComboDepartementsSearch({
|
||||||
|
addForeignDepartement = true,
|
||||||
|
...params
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<ComboSearch
|
<ComboSearch
|
||||||
{...params}
|
{...params}
|
||||||
scope="departements"
|
scope="departements"
|
||||||
minimumInputLength={1}
|
minimumInputLength={1}
|
||||||
transformResult={({ code, nom }) => [code, `${code} - ${nom}`]}
|
transformResult={({ code, nom }) => [code, `${code} - ${nom}`]}
|
||||||
transformResults={expandResultsWithForeignDepartement}
|
transformResults={
|
||||||
|
addForeignDepartement ? expandResultsWithForeignDepartement : undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -39,4 +45,9 @@ function ComboDepartementsSearchDefault(params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComboDepartementsSearch.propTypes = {
|
||||||
|
...ComboSearch.propTypes,
|
||||||
|
addForeignDepartement: PropTypes.bool
|
||||||
|
};
|
||||||
|
|
||||||
export default ComboDepartementsSearchDefault;
|
export default ComboDepartementsSearchDefault;
|
||||||
|
|
Loading…
Reference in a new issue