generated from 8iq/nodejs-hackathon-boilerplate-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(condo): DOMA-8515 new Meters design (#4791)
* feat(condo): DOMA-8515 new Meters design * feat(condo): DOMA-8515 add overdue highlighting for verification date * feat(condo): DOMA-8515 request meters directly * feat(condo): DOMA-8515 adapt filters for Meters * feat(condo): DOMA-8515 change menu and title name for Meters section * feat(condo): DOMA-8515 add separate create pages * feat(condo): DOMA-8515 added meter info page and update meter page * feat(callcenter): DOMA-8515 support new meters design in callcenter * feat(condo): DOMA-8515 cast for intl * feat(condo): DOMA-8515 added archiveDate field to Meter and PropertyMeter models * feat(condo): DOMA-8515 add filters by status for Meter and PropertyMeter tables * fix(condo): DOMA-8515 update gql type to string * feat(condo): DOMA-8515 get all reporting periods and find the right one * feat(condo): DOMA-8515 change default date range value * feat(condo): DOMA-8515 regenerate migration * feat(condo): DOMA-8515 added update meter readings logic * feat(condo): DOMA-8515 added b2b logo and updated no meter tips * feat(condo): DOMA-8515 separated create and update meter forms, page naming * fix(condo): DOMA-8515 pr fixes * fix(condo): DOMA-8515 pr fix - separated useFilters * fix(condo): DOMA-8515 pr fixes * feat(condo): DOMA-8515 support changes in callcenter * feat(condo): DOMA-8515 save meter type to query * feat(condo): DOMA-8515 add checkbox selection to property meter readings table * feat(condo): DOMA-8515 added consumption column render and pr fixes * feat(callcenter): DOMA-8515 fix breaking changes in callcenter * feat(condo): DOMA-8515 small design fixes * fix(condo): DOMA-8515 trigger build * feat(condo): DOMA-8515 added remember property when adding readings and pr fixes * feat(condo): DOMA-8515 added meter step to onboarding * fix(condo): DOMA-8515 delete TourSteps on migration down * fix(condo): DOMA-8515 restrict editing readings for archived meter * fix(condo): DOMA-8515 fixed migrations
- Loading branch information
Showing
62 changed files
with
4,861 additions
and
1,057 deletions.
There are no files selected for viewing
Submodule callcenter
updated
from cafbe1 to 514cc1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
apps/condo/domains/meter/components/AddressAndUnitInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { Property as PropertyType } from '@app/condo/schema' | ||
import { Col, ColProps, Form, FormInstance, Row } from 'antd' | ||
import { Gutter } from 'antd/lib/grid/row' | ||
import { DefaultOptionType } from 'antd/lib/select' | ||
import get from 'lodash/get' | ||
import React, { Dispatch, SetStateAction } from 'react' | ||
|
||
import { useIntl } from '@open-condo/next/intl' | ||
import { Typography } from '@open-condo/ui' | ||
|
||
import { useValidations } from '@condo/domains/common/hooks/useValidations' | ||
import { MeterPageTypes, METER_TAB_TYPES } from '@condo/domains/meter/utils/clientSchema' | ||
import { usePropertyValidations } from '@condo/domains/property/components/BasePropertyForm/usePropertyValidations' | ||
import { PropertyAddressSearchInput } from '@condo/domains/property/components/PropertyAddressSearchInput' | ||
import { UnitInfo } from '@condo/domains/property/components/UnitInfo' | ||
import { PropertyFormItemTooltip } from '@condo/domains/property/PropertyFormItemTooltip' | ||
|
||
|
||
const FORM_ROW_MEDIUM_VERTICAL_GUTTER: [Gutter, Gutter] = [0, 20] | ||
const FORM_ROW_SMALL_VERTICAL_GUTTER: [Gutter, Gutter] = [0, 4] | ||
const FORM_ITEM_WRAPPER_COLUMN_STYLE: ColProps = { style: { width: '100%', padding: 0 } } | ||
|
||
type PropertyUnitInitialValues = { | ||
propertyId?: string | ||
unitName?: string | ||
unitType?: string | ||
} | ||
|
||
type AddressAndUnitInfoProps = { | ||
form?: FormInstance, | ||
organizationId: string, | ||
meterType: MeterPageTypes, | ||
getHandleSelectPropertyAddress: (form: FormInstance) => (_: unknown, option: DefaultOptionType) => void, | ||
handleDeselectPropertyAddress: () => void | ||
selectedPropertyId: string, | ||
isMatchSelectedProperty: boolean | ||
isNoMeterForAddress?: boolean, | ||
notFoundMetersForAddressTooltip?: JSX.Element, | ||
isNoMeterForUnitName?: boolean | ||
property?: PropertyType, | ||
propertyLoading?: boolean | ||
setSelectedUnitName?: Dispatch<SetStateAction<string>>, | ||
setSelectedUnitType?: Dispatch<SetStateAction<string>>, | ||
initialValues?: PropertyUnitInitialValues, | ||
} | ||
|
||
|
||
export const AddressAndUnitInfo = (props: AddressAndUnitInfoProps): JSX.Element => { | ||
const intl = useIntl() | ||
const AddressLabel = intl.formatMessage({ id: 'field.Address' }) | ||
const AddressPlaceholder = intl.formatMessage({ id: 'placeholder.Address' }) | ||
const ClientInfoMessage = intl.formatMessage({ id: 'ClientInfo' }) | ||
|
||
const { | ||
getHandleSelectPropertyAddress, | ||
handleDeselectPropertyAddress, | ||
selectedPropertyId, isMatchSelectedProperty, | ||
organizationId, | ||
isNoMeterForAddress, | ||
notFoundMetersForAddressTooltip, | ||
isNoMeterForUnitName, | ||
meterType, | ||
property, | ||
propertyLoading, | ||
setSelectedUnitName, | ||
setSelectedUnitType, | ||
form, | ||
initialValues, | ||
} = props | ||
|
||
const { requiredValidator } = useValidations() | ||
const { addressValidator } = usePropertyValidations() | ||
const validations = { | ||
property: [requiredValidator, addressValidator(selectedPropertyId, isMatchSelectedProperty)], | ||
} | ||
|
||
return ( | ||
<Row justify='space-between' gutter={FORM_ROW_MEDIUM_VERTICAL_GUTTER}> | ||
<Col span={24}> | ||
{meterType !== METER_TAB_TYPES.propertyMeter && ( | ||
<Typography.Title level={3}> | ||
{ClientInfoMessage} | ||
</Typography.Title> | ||
)} | ||
</Col> | ||
<Col span={24}> | ||
<Row gutter={FORM_ROW_SMALL_VERTICAL_GUTTER}> | ||
<Col span={24}> | ||
<Form.Item | ||
name='property' | ||
label={AddressLabel} | ||
rules={validations.property} | ||
wrapperCol={FORM_ITEM_WRAPPER_COLUMN_STYLE} | ||
shouldUpdate | ||
tooltip={<PropertyFormItemTooltip />} | ||
initialValue={initialValues && initialValues.propertyId} | ||
> | ||
<PropertyAddressSearchInput | ||
organizationId={organizationId} | ||
autoFocus={true} | ||
onSelect={getHandleSelectPropertyAddress(form)} | ||
placeholder={AddressPlaceholder} | ||
onClear={handleDeselectPropertyAddress} | ||
/> | ||
</Form.Item> | ||
</Col> | ||
{notFoundMetersForAddressTooltip && isNoMeterForAddress && ( | ||
<Col span={24}> | ||
<Typography.Text size='small' type='secondary'>{notFoundMetersForAddressTooltip}</Typography.Text> | ||
</Col> | ||
)} | ||
</Row> | ||
</Col> | ||
|
||
{!isNoMeterForAddress && ( | ||
selectedPropertyId || initialValues) && meterType === METER_TAB_TYPES.meter && (property || initialValues) && ( | ||
<Col span={24}> | ||
<Row gutter={FORM_ROW_SMALL_VERTICAL_GUTTER}> | ||
<Col span={24}> | ||
<UnitInfo | ||
property={property} | ||
loading={propertyLoading} | ||
setSelectedUnitName={setSelectedUnitName} | ||
setSelectedUnitType={setSelectedUnitType} | ||
form={form} | ||
required | ||
initialValues={{ unitName: get(initialValues, 'unitName'), unitType: get(initialValues, 'unitType') }} | ||
/> | ||
</Col> | ||
{notFoundMetersForAddressTooltip && isNoMeterForUnitName && ( | ||
<Col span={24}> | ||
<Typography.Text size='small' type='secondary'>{notFoundMetersForAddressTooltip}</Typography.Text> | ||
</Col> | ||
)} | ||
</Row> | ||
</Col>) | ||
} | ||
</Row> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.