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}
|
||||
aria-describedby={departementDescribedBy}
|
||||
placeholder={placeholderDepartement}
|
||||
addForeignDepartement={false}
|
||||
required={params.mandatory}
|
||||
onChange={(value, result) => {
|
||||
setDepartementCode(result?.code);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { QueryClientProvider } from 'react-query';
|
||||
import { matchSorter } from 'match-sorter';
|
||||
|
||||
|
@ -16,14 +17,19 @@ function expandResultsWithForeignDepartement(term, results) {
|
|||
];
|
||||
}
|
||||
|
||||
export function ComboDepartementsSearch(params) {
|
||||
export function ComboDepartementsSearch({
|
||||
addForeignDepartement = true,
|
||||
...params
|
||||
}) {
|
||||
return (
|
||||
<ComboSearch
|
||||
{...params}
|
||||
scope="departements"
|
||||
minimumInputLength={1}
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue