Skip to content

Commit

Permalink
front: get all secondary codes when selecting an operational point in…
Browse files Browse the repository at this point in the history
… stdcm

Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Feb 13, 2025
1 parent a6ec296 commit 17c9ac7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
const { t } = useTranslation('stdcm');
const dispatch = useAppDispatch();

const { searchTerm, setSearchTerm, searchResults, setSearchResults } = useSearchOperationalPoint({
const {
searchTerm,
setSearchTerm,
searchResults,
setSearchResults,
searchOperationalPointsByTrigram,
} = useSearchOperationalPoint({
initialSearchTerm: location?.name,
initialChCodeFilter: location?.secondary_code,
isStdcm: true,
Expand Down Expand Up @@ -98,14 +104,17 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
[searchResults]
);

const handleCiSelect = (selectedSuggestion?: CIOption) => {
const handleCiSelect = async (selectedSuggestion?: CIOption) => {
dispatch(updateStdcmPathStep({ id: pathStepId, updates: { location: selectedSuggestion } }));
if (selectedSuggestion) {
const newChSuggestions = extractChCodes(searchResults, selectedSuggestion);
const operationalPointParts = await searchOperationalPointsByTrigram(
selectedSuggestion.trigram
);
const newChSuggestions = extractChCodes(operationalPointParts, selectedSuggestion);
setChSuggestions(newChSuggestions);
} else {
setChSuggestions([]);
}
dispatch(updateStdcmPathStep({ id: pathStepId, updates: { location: selectedSuggestion } }));
};

const handleChSelect = (selectedChCode?: CHOption) => {
Expand Down
1 change: 1 addition & 0 deletions front/src/common/Map/Search/useSearchOperationalPoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default function useSearchOperationalPoint({
mainOperationalPointsOnly,
searchResults,
searchOperationalPoints,
searchOperationalPointsByTrigram,
setSearchTerm,
setChCodeFilter,
setSearchResults,
Expand Down

0 comments on commit 17c9ac7

Please sign in to comment.