Skip to content

Commit 1c43304

Browse files
authored
perf(condo): DOMA-11056 use new hooks (#5793)
* perf(condo): DOMA-11056 first save commit * perf(condo): DOMA-11056 update incident form * perf(condo): DOMA-11056 update callcenter * perf(condo): DOMA-11056 some changes * perf(condo): DOMA-11056 change TicketStatus * perf(condo): DOMA-11056 more changes * perf(condo): DOMA-11056 remaining requests * perf(condo): DOMA-11056 update other query * perf(condo): DOMA-11056 cleaning extra lines * perf(condo): DOMA-11056 clean copy * perf(condo): DOMA-11056 fix errors * perf(condo): DOMA-11056 refactor old code * perf(condo): DOMA-11056 corrections to comments * fix(condo): DOMA-11056 adding a temporary reading function * perf(condo): DOMA-11056 removing unnecessary parameters in queries * perf(condo): DOMA-11056 update global b2b query * perf(condo): DOMA-11056 rename returning incident value * perf(condo): DOMA-11056 add dv and sender * perf(condo): DOMA-11056 add dv and sender * perf(condo): DOMA-11056 add dv and sender #2 * perf(condo): DOMA-11056 first part of corrections after review @Alllex202 * perf(condo): DOMA-11056 second part of corrections after review @Alllex202 * perf(condo): DOMA-11056 add type for statusUpdatedAt in TicketStatusSelect.tsx * perf(condo): DOMA-11055 optional chain for employee.role * perf(condo): DOMA-11055 fix sonarCloud issue * perf(condo): DOMA-11056 remove type overrides * perf(condo): DOMA-11056 add type for IncidentForm * perf(condo): DOMA-11056 add gql types * perf(condo): DOMA-11056 fix after last review * perf(condo): DOMA-11056 {`/property/${property?.id || ''}`} * perf(condo): DOMA-11056 fix lint * feat(condo): DOMA-5258 add first to BillingIntegrationOrganizationContext.graphql * feat(condo): DOMA-11056 add first to BillingReceipt.graphql * perf(condo): DOMA-11056 add "first" to all queries * perf(condo): DOMA-11056 add new queries in incident/[id] page * perf(condo): DOMA-11056 rewrite addressRender utils * perf(condo): DOMA-11056 some fix * perf(condo): DOMA-11056 fix lint * perf(condo): DOMA-11056 remove insurance pointer * perf(condo): DOMA-11056 add callcenter pointer * perf(condo): DOMA-11056 fix error after rebase * perf(condo): DOMA-11056 fix last comments after review * perf(condo): DOMA-11056 update pointer callcenter * perf(condo): DOMA-11056 fix build errors
1 parent 8433dec commit 1c43304

File tree

65 files changed

+3124
-803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3124
-803
lines changed

apps/callcenter

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
query getBillingIntegrationOrganizationContexts ($integration: BillingIntegrationWhereInput!, $organization: OrganizationWhereInput!) {
2+
contexts: allBillingIntegrationOrganizationContexts(
3+
where: {
4+
integration: $integration,
5+
organization: $organization,
6+
},
7+
first: 1,
8+
) {
9+
id
10+
lastReport
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
query getBillingReceiptsByPropertyCount ($context: BillingIntegrationOrganizationContextWhereInput!, $property: BillingPropertyWhereInput!, $period_gte: String!) {
2+
count: _allBillingReceiptsMeta (
3+
where: {
4+
context: $context,
5+
property: $property,
6+
period_gte: $period_gte
7+
},
8+
) {
9+
count
10+
}
11+
}

apps/condo/domains/common/utils/helpers.ts

+23-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { ParsedUrlQuery } from 'querystring'
22

3-
import { Property } from '@app/condo/schema'
3+
import {
4+
AddressMetaForTableAddressFragment,
5+
} from '@app/condo/gql'
46
import { FilterValue } from 'antd/es/table/interface'
57
import get from 'lodash/get'
68
import isArray from 'lodash/isArray'
@@ -10,8 +12,6 @@ import isObject from 'lodash/isObject'
1012
import { NextRouter } from 'next/router'
1113
import qs from 'qs'
1214

13-
import { IRecordWithId } from '../types'
14-
1515
const DEFAULT_WIDTH_PRECISION = 2
1616
const RUSSIAN_PHONE_FORMAT_REGEXP = /(\d)(\d{3})(\d{3})(\d{2})(\d{2})/
1717
const SPANISH_PHONE_FORMAT_REGEXP = /(\d{2})(\d{3})(\d{3})(\d{3})/
@@ -48,43 +48,47 @@ export const preciseFloor = (x: number, precision: number = DEFAULT_WIDTH_PRECIS
4848
return Math.floor(x * Math.pow(10, precision)) / 100
4949
}
5050

51-
type ObjectWithAddressInfo = Pick<Property, 'address' | 'addressMeta'>
51+
export type ObjectWithAddressInfo = {
52+
address?: string
53+
addressMeta?: AddressMetaForTableAddressFragment
54+
deletedAt?: string
55+
}
5256
/**
5357
* Tries to extract address details from a property (or any object, containing address and addressMeta, like ticket)
5458
* @param property
5559
*/
5660
export const getAddressDetails = (property: ObjectWithAddressInfo) => {
57-
const addressMeta = get(property, ['addressMeta', 'data'])
61+
const addressMeta = property?.addressMeta?.data
5862

59-
const streetWithType = get(addressMeta, 'street_with_type')
63+
const streetWithType = addressMeta?.street_with_type
6064

61-
const houseType = get(addressMeta, 'house_type')
62-
const houseName = get(addressMeta, 'house')
65+
const houseType = addressMeta?.house_type
66+
const houseName = addressMeta?.house
6367
const houseNamePrefix = (houseType) ? `${houseType} ` : ''
64-
const blockType = get(addressMeta, 'block_type')
65-
const blockName = get(addressMeta, 'block')
68+
const blockType = addressMeta?.block_type
69+
const blockName = addressMeta?.block
6670
const houseNameSuffix = blockType ? ` ${blockType} ${blockName}` : ''
67-
const flatType = get(addressMeta, 'flat_type')
68-
const flatName = get(addressMeta, 'flat')
71+
const flatType = addressMeta?.flat_type
72+
const flatName = addressMeta?.flat
6973
const flatPart = flatType ? `${flatType} ${flatName}` : ''
7074

71-
const regionType = get(addressMeta, 'region_type_full')
72-
const regionName = get(addressMeta, 'region')
73-
const regionWithType = get(addressMeta, 'region_with_type')
75+
const regionType = addressMeta?.region_type_full
76+
const regionName = addressMeta?.region
77+
const regionWithType = addressMeta?.region_with_type
7478
const regionNamePosition = regionWithType && regionWithType.split(' ')[0] === regionName ? 0 : 1
7579
const regionWithFullType = (regionType) ? (regionNamePosition === 0 ? `${regionName} ${regionType}` : `${regionType} ${regionName}`) : `${regionName}`
7680

77-
const cityPart = get(addressMeta, 'city_with_type')
78-
const cityName = get(addressMeta, 'city')
81+
const cityPart = addressMeta?.city_with_type
82+
const cityName = addressMeta?.city
7983

80-
const settlementPart = get(addressMeta, 'settlement_with_type')
84+
const settlementPart = addressMeta?.settlement_with_type
8185

8286
const settlement = streetWithType ? streetWithType : settlementPart
8387
const settlementWithComma = settlement ? `${settlement}, ` : ''
8488
const streetPart = `${settlementWithComma}${houseNamePrefix}${houseName}${houseNameSuffix}`
8589
const regionPart = regionName && regionName !== cityName && regionWithFullType
8690

87-
const areaWithType = get(addressMeta, 'area_with_type')
91+
const areaWithType = addressMeta?.area_with_type
8892
const areaPart = areaWithType && areaWithType !== cityPart && areaWithType
8993

9094
const regionLine = regionPart ? `\n${regionPart}` : ''
@@ -96,12 +100,6 @@ export const getAddressDetails = (property: ObjectWithAddressInfo) => {
96100
return { flatPart, streetPart, areaPart, settlementPart, regionPart, cityPart, renderPostfix }
97101
}
98102

99-
/**
100-
* Tries to get id of string type from any record that might contain such
101-
* @param record
102-
*/
103-
export const getId = (record: IRecordWithId): string | null => get(record, 'id', null)
104-
105103
/**
106104
* Generic function for extracting value from filters
107105
* @param filters

apps/condo/domains/common/utils/next/apollo.ts

+109
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,106 @@ const cacheConfig: InitCacheConfig = (cacheOptions) => {
2626
read: listHelper.getReadFunction('paginate'),
2727
merge: listHelper.mergeLists,
2828
},
29+
allPropertyScopeProperties: {
30+
keyArgs: ['where'],
31+
read: listHelper.getReadFunction('paginate'),
32+
merge: listHelper.mergeLists,
33+
},
34+
allPropertyScopeOrganizationEmployees: {
35+
keyArgs: ['where'],
36+
read: listHelper.getReadFunction('paginate'),
37+
merge: listHelper.mergeLists,
38+
},
39+
allPropertyScopes: {
40+
keyArgs: ['where'],
41+
read: listHelper.getReadFunction(),
42+
merge: listHelper.mergeLists,
43+
},
44+
allIncidents: {
45+
keyArgs: ['where'],
46+
read: listHelper.getReadFunction('paginate'),
47+
merge: listHelper.mergeLists,
48+
},
49+
allIncidentChanges: {
50+
keyArgs: ['where'],
51+
read: listHelper.getReadFunction('paginate'),
52+
merge: listHelper.mergeLists,
53+
},
54+
allIncidentProperties: {
55+
keyArgs: ['where'],
56+
read: listHelper.getReadFunction('paginate'),
57+
merge: listHelper.mergeLists,
58+
},
59+
allIncidentClassifierIncidents: {
60+
keyArgs: ['where'],
61+
read: listHelper.getReadFunction('paginate'),
62+
merge: listHelper.mergeLists,
63+
},
64+
allBillingIntegrationOrganizationContexts: {
65+
keyArgs: ['where'],
66+
read: listHelper.getReadFunction(),
67+
merge: listHelper.mergeLists,
68+
},
69+
allTickets: {
70+
keyArgs: ['where'],
71+
read: listHelper.getReadFunction(),
72+
merge: listHelper.mergeLists,
73+
},
74+
allTicketChanges: {
75+
keyArgs: ['where'],
76+
read: listHelper.getReadFunction(),
77+
merge: listHelper.mergeLists,
78+
},
79+
allTicketComments: {
80+
keyArgs: ['where'],
81+
read: listHelper.getReadFunction(),
82+
merge: listHelper.mergeLists,
83+
},
84+
allTicketCommentFile: {
85+
keyArgs: ['where'],
86+
read: listHelper.getReadFunction(),
87+
merge: listHelper.mergeLists,
88+
},
89+
allTicketStatuses: {
90+
keyArgs: ['where'],
91+
read: listHelper.getReadFunction(),
92+
merge: listHelper.mergeLists,
93+
},
94+
allTicketFiles: {
95+
keyArgs: ['where'],
96+
read: listHelper.getReadFunction(),
97+
merge: listHelper.mergeLists,
98+
},
99+
allInvoices: {
100+
keyArgs: ['where'],
101+
read: listHelper.getReadFunction(),
102+
merge: listHelper.mergeLists,
103+
},
104+
allProperties: {
105+
keyArgs: ['where'],
106+
read: listHelper.getReadFunction(),
107+
merge: listHelper.mergeLists,
108+
},
109+
allTourStep: {
110+
keyArgs: ['where'],
111+
read: listHelper.getReadFunction(),
112+
merge: listHelper.mergeLists,
113+
},
114+
allMiniApps: {
115+
keyArgs: ['where'],
116+
read: listHelper.getReadFunction(),
117+
merge: listHelper.mergeLists,
118+
},
119+
allB2BApps: {
120+
keyArgs: ['where'],
121+
read: listHelper.getReadFunction(),
122+
merge: listHelper.mergeLists,
123+
},
124+
allOrganizationEmployeeSpecializations: {
125+
keyArgs: ['where'],
126+
read: listHelper.getReadFunction(),
127+
merge: listHelper.mergeLists,
128+
},
29129
},
30130
},
31131

@@ -91,6 +191,15 @@ const cacheConfig: InitCacheConfig = (cacheOptions) => {
91191
Invoice: {
92192
timeToLive: 60 * 1000, // 1 minute in milliseconds
93193
},
194+
Incident: {
195+
timeToLive: 60 * 1000, // 1 minute in milliseconds
196+
},
197+
IncidentProperty: {
198+
timeToLive: 60 * 1000, // 1 minute in milliseconds
199+
},
200+
IncidentClassifierIncident: {
201+
timeToLive: 60 * 1000, // 1 minute in milliseconds
202+
},
94203
},
95204
},
96205
}

apps/condo/domains/marketplace/queries/Invoice.graphql

+20-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ query getTicketInvoices ($ticketId: ID!) {
33
where: {
44
ticket: { id: $ticketId }
55
},
6-
sortBy: [createdAt_DESC]
6+
sortBy: [createdAt_DESC],
7+
first: 100,
78
) {
89
id
910
status
@@ -32,6 +33,18 @@ query getTicketInvoices ($ticketId: ID!) {
3233
}
3334
}
3435

36+
query getPublishTicketInvoices ($ticketId: ID!, $first: Int!) {
37+
publishInvoices: allInvoices (
38+
where: {
39+
ticket: { id: $ticketId },
40+
status: published,
41+
},
42+
first: $first,
43+
) {
44+
id
45+
}
46+
}
47+
3548
query getInvoicesByIds ($ids: [ID!]!) {
3649
invoices: allInvoices (
3750
where: { id_in: $ids },
@@ -62,4 +75,10 @@ query getInvoicesByIds ($ids: [ID!]!) {
6275
id
6376
}
6477
}
78+
}
79+
80+
mutation createInvoice ($data: InvoiceCreateInput!) {
81+
invoice: createInvoice (data: $data) {
82+
id
83+
}
6584
}

apps/condo/domains/miniapp/components/ConnectedAppsWithIconsProvider.tsx

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1+
import { useGetAllMiniAppsQuery } from '@app/condo/gql'
12
import { SortAllMiniAppsBy } from '@app/condo/schema'
2-
import get from 'lodash/get'
3-
import React, { createContext, useCallback, useContext, useState } from 'react'
3+
import React, { createContext, useContext, useState } from 'react'
44

5-
import { useQuery } from '@open-condo/next/apollo'
5+
import { useCachePersistor } from '@open-condo/apollo'
66
import { useAuth } from '@open-condo/next/auth'
77
import { useOrganization } from '@open-condo/next/organization'
88

99
import { ALL_MENU_CATEGORIES, DEFAULT_MENU_CATEGORY } from '@condo/domains/common/constants/menuCategories'
1010
import { getClientSideSenderInfo } from '@condo/domains/common/utils/userid.utils'
11-
import { ALL_MINI_APPS_QUERY } from '@condo/domains/miniapp/gql'
12-
1311

1412
import type { MiniAppOutput } from '@app/condo/schema'
1513

@@ -31,11 +29,12 @@ export const ConnectedWithIconsContext = createContext<IConnectedAppsWithIconsCo
3129
export const ConnectedAppsWithIconsContextProvider: React.FC = ({ children }) => {
3230
const { isAuthenticated, isLoading: isUserLoading } = useAuth()
3331
const { organization } = useOrganization()
34-
const orgId = get(organization, 'id', null)
32+
const orgId = organization?.id || null
3533
const [appsByCategories, setAppsByCategories] = useState<AppsByCategories>({})
3634
const [connectedApps, setConnectedApps] = useState<Array<string>>([])
35+
const { persistor } = useCachePersistor()
3736

38-
const { refetch } = useQuery(ALL_MINI_APPS_QUERY, {
37+
const { refetch } = useGetAllMiniAppsQuery({
3938
variables: {
4039
data: {
4140
dv: 1,
@@ -49,12 +48,12 @@ export const ConnectedAppsWithIconsContextProvider: React.FC = ({ children }) =>
4948
sortBy: SortAllMiniAppsBy.ConnectedAtAsc,
5049
},
5150
},
52-
skip: isUserLoading || !isAuthenticated || !orgId,
53-
onCompleted: (data) => {
54-
const apps = get(data, 'objs', [])
51+
skip: isUserLoading || !isAuthenticated || !orgId || !persistor,
52+
onCompleted: (allMiniAppsData) => {
53+
const apps = allMiniAppsData?.allMiniApps.filter(Boolean) || []
5554
const appsByCategories: AppsByCategories = Object.assign({}, ...ALL_MENU_CATEGORIES.map(category =>({ [category]: [] })))
5655
for (const app of apps) {
57-
const menuCategory = get(app, 'menuCategory', DEFAULT_MENU_CATEGORY) || DEFAULT_MENU_CATEGORY
56+
const menuCategory = app?.menuCategory || DEFAULT_MENU_CATEGORY
5857
appsByCategories[menuCategory].push(app)
5958
}
6059
setConnectedApps(apps.map(app => app.id))
@@ -66,12 +65,8 @@ export const ConnectedAppsWithIconsContextProvider: React.FC = ({ children }) =>
6665
},
6766
})
6867

69-
const refetchAuth = useCallback(async () => {
70-
await refetch()
71-
}, [refetch])
72-
7368
return (
74-
<ConnectedWithIconsContext.Provider value={{ appsByCategories: appsByCategories, refetch: refetchAuth, connectedAppsIds: connectedApps }}>
69+
<ConnectedWithIconsContext.Provider value={{ appsByCategories: appsByCategories, refetch, connectedAppsIds: connectedApps }}>
7570
{children}
7671
</ConnectedWithIconsContext.Provider>
7772
)

0 commit comments

Comments
 (0)