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 { isServer } from 'tools';
|
||||
|
||||
function isSovkom(account) {
|
||||
return account.label.toLowerCase().includes('совком');
|
||||
}
|
||||
|
||||
export function createLink(headers) {
|
||||
const { URL_CRM_GRAPHQL } = getUrls();
|
||||
|
||||
@ -44,7 +48,15 @@ export function createLink(headers) {
|
||||
}
|
||||
|
||||
if (operation.operationName === 'GetInsuranceCompanies') {
|
||||
response.data.accounts = response.data.accounts.map((account) => {
|
||||
response.data.accounts = response.data.accounts
|
||||
.sort((a, b) => {
|
||||
if (isSovkom(a)) return -1;
|
||||
|
||||
if (isSovkom(b)) return 1;
|
||||
|
||||
return 0;
|
||||
})
|
||||
.map((account) => {
|
||||
const substring = account.label.match(/"(.+)"/u);
|
||||
if (substring)
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user