Pull request #352: Bugfix/TEAMMSBMOB-16830 add header organizationId
Merge in MCB_FE/mcb-platform-monorepo from bugfix/TEAMMSBMOB-16830_add-header-organizationId to develop
Squashed commit of the following:
commit 5a44dee61855ff9f74909cf6f1443b831d142d99
Author: Juraldinio <Juraldinio@gmail.com>
Date: Fri Sep 5 17:02:12 2025 +0300
bugfix:(TEAMMSBMOB-16830) - ESLint warnings
commit 1bc71c9461824d0de27908b4e42300699f1e92c2
Author: Juraldinio <Juraldinio@gmail.com>
Date: Fri Sep 5 16:59:23 2025 +0300
bugfix:(TEAMMSBMOB-16830) - add header organizationId to request
commit f8ff9fbdef4baeb307350957751e4df281c8bb41
Merge: ccd5d5e7 eaccd862
Author: Juraldinio <Juraldinio@gmail.com>
Date: Fri Sep 5 16:54:46 2025 +0300
Merge branch 'develop' into bugfix/TEAMMSBMOB-16830_add-header-organizationId
commit ccd5d5e7015b7f9a1c0d0d67c8642315cde91c1a
Author: Juraldinio <Juraldinio@gmail.com>
Date: Fri Sep 5 16:20:25 2025 +0300
bugfix(TEAMMSBMOB-16830) - add header to request
This commit is contained in:
@@ -4,6 +4,7 @@ import { DEFAULT_LIMIT, DEFAULT_OFFSET } from './constants';
|
||||
|
||||
const fetchSuggestionPage = async (
|
||||
value: string,
|
||||
organizationId: string,
|
||||
offset: number = DEFAULT_OFFSET,
|
||||
limit: number = DEFAULT_LIMIT
|
||||
): Promise<Suggestion[]> => {
|
||||
@@ -23,7 +24,11 @@ const fetchSuggestionPage = async (
|
||||
},
|
||||
};
|
||||
|
||||
const response = await network.client.post<GetSuggestionPageResponseDto>(GET_SUGGESTION_PAGE_ENDPOINT, data);
|
||||
const response = await network.client.post<GetSuggestionPageResponseDto>(GET_SUGGESTION_PAGE_ENDPOINT, data, {
|
||||
headers: {
|
||||
OrganizationId: organizationId,
|
||||
},
|
||||
});
|
||||
|
||||
return response.data.page;
|
||||
};
|
||||
|
||||
@@ -3,10 +3,10 @@ import { fetchSuggestionPage, GET_SUGGESTION_PAGE_QUERY } from '../../api/getSug
|
||||
import type { Suggestion } from '../../endpoints';
|
||||
import { DEFAULT_LIMIT, DEFAULT_OFFSET } from './constants';
|
||||
|
||||
const useSuggestionPage = (value: string, offset: number = DEFAULT_OFFSET, limit: number = DEFAULT_LIMIT) =>
|
||||
const useSuggestionPage = (value: string, organizationId: string, offset: number = DEFAULT_OFFSET, limit: number = DEFAULT_LIMIT) =>
|
||||
useQuery<Suggestion[], Error | undefined>({
|
||||
queryKey: [GET_SUGGESTION_PAGE_QUERY, value, offset, limit],
|
||||
queryFn: () => fetchSuggestionPage(value, offset, limit),
|
||||
queryFn: () => fetchSuggestionPage(value, organizationId, offset, limit),
|
||||
});
|
||||
|
||||
export { useSuggestionPage };
|
||||
|
||||
+6
-3
@@ -1,21 +1,24 @@
|
||||
import { useReducer, useRef } from 'react';
|
||||
import { usePageWithIndicators, useSuggestionPage } from '@msb/http';
|
||||
import { useDebounce } from '@msb/shared';
|
||||
import { useAppContext, useDebounce } from '@msb/shared';
|
||||
import type { PayeeAccountIdentification } from '../constants';
|
||||
import { PayeeFieldsBankStore } from './PayeeFieldsBankStore';
|
||||
import { PayeeFieldsForm } from './PayeeFieldsForm';
|
||||
import { findClientsWithPermissions } from '@/shared/lib';
|
||||
|
||||
const reducerIncrement = 1;
|
||||
const requiredCharactersCount = 2;
|
||||
const debounceDelay = 3000;
|
||||
const reducerIncrement = 3000;
|
||||
|
||||
const usePayeeForm = () => {
|
||||
const { userAuthorities } = useAppContext();
|
||||
const [, forceUpdate] = useReducer(x => x + reducerIncrement, 0);
|
||||
const payeeFields = useRef(new PayeeFieldsForm(forceUpdate, new PayeeFieldsBankStore()));
|
||||
const name = payeeFields.current.organization;
|
||||
const debounceNameInnField = useDebounce(name.length > requiredCharactersCount ? name : '', debounceDelay);
|
||||
const organizationId = userAuthorities ? findClientsWithPermissions(userAuthorities, 'RUBLE_PAYMENT_ORDER.VIEW')[0] : '';
|
||||
const { data: mySuggestions = [] } = usePageWithIndicators(debounceNameInnField);
|
||||
const { data: globalSuggestions = [] } = useSuggestionPage(debounceNameInnField);
|
||||
const { data: globalSuggestions = [] } = useSuggestionPage(debounceNameInnField, organizationId);
|
||||
|
||||
const globalSuggest: PayeeAccountIdentification[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user