[AURORA-1970] - добавлена передача requestId
This commit is contained in:
parent
1a3fed537f
commit
2f8f4138af
@ -10,6 +10,7 @@ const initialState: CatalogueJurSliceType = {
|
||||
total_groups: 0,
|
||||
loading: false,
|
||||
error: null,
|
||||
currentRequestId: null,
|
||||
isGettingArchive: false,
|
||||
relatedGroupFilter: null,
|
||||
activeCompanyGroup: null,
|
||||
@ -32,22 +33,30 @@ const catalogueJurSlice = createSlice({
|
||||
resetRows(state) {
|
||||
state.raw_rows = [];
|
||||
state.total_groups = 0;
|
||||
// Запрос, начатый до сброса, больше не нужен: его ответ отбросится в fulfilled/rejected
|
||||
state.currentRequestId = null;
|
||||
state.loading = false;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(getCatalogueJurThunk.pending, (state, _) => {
|
||||
.addCase(getCatalogueJurThunk.pending, (state, action) => {
|
||||
state.currentRequestId = action.meta.requestId;
|
||||
state.loading = true;
|
||||
state.error = null;
|
||||
})
|
||||
.addCase(getCatalogueJurThunk.fulfilled, (state, action) => {
|
||||
if (action.meta.requestId !== state.currentRequestId) return;
|
||||
state.raw_rows = action.payload.items;
|
||||
state.total_groups = action.payload.total;
|
||||
state.loading = false;
|
||||
state.currentRequestId = null;
|
||||
})
|
||||
.addCase(getCatalogueJurThunk.rejected, (state, action) => {
|
||||
if (action.meta.requestId !== state.currentRequestId) return;
|
||||
state.error = action.payload ?? 'Неизвестная ошибка';
|
||||
state.loading = false;
|
||||
state.currentRequestId = null;
|
||||
})
|
||||
// Выбранная ГК — копия строки списка ГК: после перезагрузки списка берём свежую (счётчик ЮЛ в шапке и вкладке)
|
||||
.addCase(getCompanyGroupsThunk.fulfilled, (state, action) => {
|
||||
|
||||
@ -7,6 +7,7 @@ export interface CatalogueJurSliceType {
|
||||
raw_rows: ICatalogueJur[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
currentRequestId: string | null;
|
||||
isGettingArchive: boolean;
|
||||
relatedGroupFilter?: RelatedGroupOut | null;
|
||||
activeCompanyGroup?: ICompanyGroup | null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user