apps/web: graphql: GetInsuranceCompanies -> sort совком first
This commit is contained in:
parent
7014462d42
commit
09959e3ac3
@ -9,6 +9,10 @@ import { getCurrentScope } from '@sentry/nextjs';
|
|||||||
import getConfig from 'next/config';
|
import getConfig from 'next/config';
|
||||||
import { isServer } from 'tools';
|
import { isServer } from 'tools';
|
||||||
|
|
||||||
|
function isSovkom(account) {
|
||||||
|
return account.label.toLowerCase().includes('совком');
|
||||||
|
}
|
||||||
|
|
||||||
export function createLink(headers) {
|
export function createLink(headers) {
|
||||||
const { URL_CRM_GRAPHQL } = getUrls();
|
const { URL_CRM_GRAPHQL } = getUrls();
|
||||||
|
|
||||||
@ -44,16 +48,24 @@ export function createLink(headers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (operation.operationName === 'GetInsuranceCompanies') {
|
if (operation.operationName === 'GetInsuranceCompanies') {
|
||||||
response.data.accounts = response.data.accounts.map((account) => {
|
response.data.accounts = response.data.accounts
|
||||||
const substring = account.label.match(/"(.+)"/u);
|
.sort((a, b) => {
|
||||||
if (substring)
|
if (isSovkom(a)) return -1;
|
||||||
return {
|
|
||||||
...account,
|
|
||||||
label: substring ? substring[1].replaceAll('"', '').trim() : account.label,
|
|
||||||
};
|
|
||||||
|
|
||||||
return account;
|
if (isSovkom(b)) return 1;
|
||||||
});
|
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.map((account) => {
|
||||||
|
const substring = account.label.match(/"(.+)"/u);
|
||||||
|
if (substring)
|
||||||
|
return {
|
||||||
|
...account,
|
||||||
|
label: substring ? substring[1].replaceAll('"', '').trim() : account.label,
|
||||||
|
};
|
||||||
|
|
||||||
|
return account;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user