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

Filter TowedRollingStocks to include only allowed values #10227

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions front/src/applications/stdcm/consts.ts
SharglutDev marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@ export const COMPOSITION_CODES_MAX_SPEEDS: Record<string, number | undefined> =
HLP: 100,
MVGV: 200,
};

export const ALLOWED_TOWED_ROLLING_STOCKS = [
'AFAMOD',
'AFAMOD2',
'MA',
'MAL100',
'MALOUR',
'MAVIDE',
'ME100',
'ME120',
'ME140',
'ME200SER',
'MEPA',
'TRAINLOC',
];
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';

import { isEqual } from 'lodash';

import { ALLOWED_TOWED_ROLLING_STOCKS } from 'applications/stdcm/consts';
import { osrdEditoastApi, type TowedRollingStock } from 'common/api/osrdEditoastApi';
import { setFailure } from 'reducers/main';
import { useAppDispatch } from 'store';
Expand Down Expand Up @@ -40,14 +41,22 @@ const useFilterTowedRollingStock = () => {
>([]);

const {
data: { results: allTowedRollingStocks } = { results: [] },
data: { results: fetchedTowedRollingStocks } = { results: [] },
isSuccess,
isError,
error,
} = osrdEditoastApi.endpoints.getTowedRollingStock.useQuery({
pageSize: 50,
});

const allTowedRollingStocks = useMemo(
() =>
fetchedTowedRollingStocks.filter((stock) =>
ALLOWED_TOWED_ROLLING_STOCKS.includes(stock.name)
),
[fetchedTowedRollingStocks]
);

SharglutDev marked this conversation as resolved.
Show resolved Hide resolved
const searchTowedRollingStock = (value: string) => {
setFilters({ id: undefined, text: value });
};
Expand Down
Loading