diff --git a/apps/condo/domains/marketplace/components/Invoice/InvoiceRowsTable.tsx b/apps/condo/domains/marketplace/components/Invoice/InvoiceRowsTable.tsx index a22faf806e8..4e48a9dc1d3 100644 --- a/apps/condo/domains/marketplace/components/Invoice/InvoiceRowsTable.tsx +++ b/apps/condo/domains/marketplace/components/Invoice/InvoiceRowsTable.tsx @@ -1,6 +1,7 @@ import { Invoice } from '@app/condo/schema' import { Table as AntdTable } from 'antd' import get from 'lodash/get' +import isEmpty from 'lodash/isEmpty' import React, { useCallback, useMemo } from 'react' import { useIntl } from '@open-condo/next/intl' @@ -113,7 +114,7 @@ export const InvoiceRowsTable: React.FC = ({ invoice }) = const ContractPriceMessage = intl.formatMessage({ id: 'pages.condo.marketplace.invoice.form.contractPrice' }).toLowerCase() const currencyCode = get(invoice, 'currencyCode') || DEFAULT_INVOICE_CURRENCY_CODE - const rows = useMemo(() => get(invoice, 'rows'), [invoice]) + const rows = useMemo(() => get(invoice, 'rows') || [], [invoice]) const organizationId = get(invoice, 'organization.id') || get(invoice, 'organization') const skuItems = rows.map(({ sku }) => sku).filter(Boolean) @@ -122,7 +123,7 @@ export const InvoiceRowsTable: React.FC = ({ invoice }) = sku_in: skuItems, organization: { id: organizationId }, }, - }) + }, { skip: isEmpty(skuItems) || !organizationId }) const orderColumns = useInvoiceRowsTableColumns(currencyCode, marketItems) diff --git a/apps/condo/domains/marketplace/components/Invoice/UpdateInvoiceForm.tsx b/apps/condo/domains/marketplace/components/Invoice/UpdateInvoiceForm.tsx index 07be3c22526..70fb622ec4a 100644 --- a/apps/condo/domains/marketplace/components/Invoice/UpdateInvoiceForm.tsx +++ b/apps/condo/domains/marketplace/components/Invoice/UpdateInvoiceForm.tsx @@ -58,9 +58,6 @@ export const UpdateInvoiceForm: React.FC = ({ const handleUpdateInvoice = useCallback(async (values) => { setSubmitLoading(true) let valuesFromForm = { ...values } - if (isModalForm) { - valuesFromForm = omit(values, ['clientName', 'clientPhone', 'contact', 'property', 'unitName', 'unitType']) - } if (!values.payerData) { valuesFromForm = { ...valuesFromForm, @@ -73,6 +70,9 @@ export const UpdateInvoiceForm: React.FC = ({ client: null, } } + if (isModalForm) { + valuesFromForm = omit(values, ['clientName', 'clientPhone', 'contact', 'property', 'unitName', 'unitType']) + } const formattedValues = Invoice.formValuesProcessor(valuesFromForm, intl) const updatedInvoice = await updateInvoiceAction(formattedValues, invoice) diff --git a/apps/condo/domains/marketplace/queries/Invoice.graphql b/apps/condo/domains/marketplace/queries/Invoice.graphql index 2c63c009815..cb8aa84fdaf 100644 --- a/apps/condo/domains/marketplace/queries/Invoice.graphql +++ b/apps/condo/domains/marketplace/queries/Invoice.graphql @@ -39,5 +39,27 @@ query getInvoicesByIds ($ids: [ID!]!) { ) { id status + number + paymentType + status + currencyCode + rows { + name + toPay + isMin + count + sku + } + organization { + id + } + createdBy { + id + name + type + } + ticket { + id + } } } \ No newline at end of file diff --git a/apps/condo/domains/ticket/components/TicketForm/UpdateTicketForm.tsx b/apps/condo/domains/ticket/components/TicketForm/UpdateTicketForm.tsx index 95f3ae56ae8..53a0cf4b3d4 100644 --- a/apps/condo/domains/ticket/components/TicketForm/UpdateTicketForm.tsx +++ b/apps/condo/domains/ticket/components/TicketForm/UpdateTicketForm.tsx @@ -135,7 +135,7 @@ export const UpdateTicketForm: React.FC = ({ id }) => { } if (!isEmpty(existedInvoices)) { - const notUpdatableFields = ['property', 'unitName', 'unitType', 'contact', 'clientName', 'clientPhone', 'client'] + const notUpdatableFields = ['ticket', 'property', 'unitName', 'unitType', 'contact', 'clientName', 'clientPhone', 'client'] for (const existedInvoice of existedInvoices) { const initialInvoice = invoices.find(invoice => invoice.id === existedInvoice.id) diff --git a/apps/condo/gql/index.ts b/apps/condo/gql/index.ts index bf6ecdafdf4..f525058109c 100644 --- a/apps/condo/gql/index.ts +++ b/apps/condo/gql/index.ts @@ -1018,6 +1018,28 @@ export const GetInvoicesByIdsDocument = gql` invoices: allInvoices(where: {id_in: $ids}, sortBy: [createdAt_DESC]) { id status + number + paymentType + status + currencyCode + rows { + name + toPay + isMin + count + sku + } + organization { + id + } + createdBy { + id + name + type + } + ticket { + id + } } } ` diff --git a/apps/condo/gql/operation.types.ts b/apps/condo/gql/operation.types.ts index 6231c2cb276..eb4c1d3fbf2 100644 --- a/apps/condo/gql/operation.types.ts +++ b/apps/condo/gql/operation.types.ts @@ -142,7 +142,7 @@ export type GetInvoicesByIdsQueryVariables = Types.Exact<{ }> -export type GetInvoicesByIdsQuery = { __typename?: 'Query', invoices?: Array<{ __typename?: 'Invoice', id: string, status?: Types.InvoiceStatusType | null } | null> | null } +export type GetInvoicesByIdsQuery = { __typename?: 'Query', invoices?: Array<{ __typename?: 'Invoice', id: string, status?: Types.InvoiceStatusType | null, number?: number | null, paymentType?: Types.InvoicePaymentTypeType | null, currencyCode?: string | null, rows: Array<{ __typename?: 'InvoiceRowSchemaField', name: string, toPay: string, isMin: boolean, count: number, sku?: string | null }>, organization?: { __typename?: 'Organization', id: string } | null, createdBy?: { __typename?: 'User', id: string, name?: string | null, type?: Types.UserTypeType | null } | null, ticket?: { __typename?: 'Ticket', id: string } | null } | null> | null } export type GetMeterReadingExportTasksQueryVariables = Types.Exact<{ where: Types.MeterReadingExportTaskWhereInput