diff --git a/backend/src/usecases/documents/new_contracts/delete-document-contract.usecase.ts b/backend/src/usecases/documents/new_contracts/delete-document-contract.usecase.ts index 87b10198..90fe20e5 100644 --- a/backend/src/usecases/documents/new_contracts/delete-document-contract.usecase.ts +++ b/backend/src/usecases/documents/new_contracts/delete-document-contract.usecase.ts @@ -47,7 +47,11 @@ export class DeleteDocumentContractUsecase implements IUseCaseService { ); } - await this.documentContractFacade.delete(id); + const deleted = await this.documentContractFacade.delete(id); + + if (!deleted) { + throw new Error('Could not delete contract from DB'); + } // 10. Track event this.actionsArchiveFacade.trackEvent( @@ -55,7 +59,7 @@ export class DeleteDocumentContractUsecase implements IUseCaseService { { organizationId: contract.organizationId, volunteerId: contract.volunteerId, - volunteerName: contract.volunteer.user.name, + volunteerName: contract.volunteerData.name, documentContractId: contract.id, documentContractNumber: contract.documentNumber, }, diff --git a/frontend/src/components/DocumentContractsTable.tsx b/frontend/src/components/DocumentContractsTable.tsx index c41a8254..bd8cedaf 100644 --- a/frontend/src/components/DocumentContractsTable.tsx +++ b/frontend/src/components/DocumentContractsTable.tsx @@ -31,12 +31,13 @@ import { useGetContractsStatisticsQuery, useGetDocumentsContractsQuery, } from '../services/document-contracts/document-contracts.service'; -import { - DocumentContractStatusForFilter, -} from '../common/enums/document-contract-status.enum'; +import { DocumentContractStatusForFilter } from '../common/enums/document-contract-status.enum'; import { IPaginationQueryParams } from '../common/constants/pagination'; -import { IDocumentContract, IDocumentContractsStatistics } from '../common/interfaces/document-contract.interface'; +import { + IDocumentContract, + IDocumentContractsStatistics, +} from '../common/interfaces/document-contract.interface'; import DocumentsContractSidePanel from './DocumentsContractSidePanel'; import VolunteerSelect from '../containers/VolunteerSelect'; import { ListItem } from '../common/interfaces/list-item.interface'; @@ -146,7 +147,9 @@ const DocumentContractsTable = ({ query, setQuery }: DocumentContractsTableBasic orderDirection: query?.orderDirection as OrderDirection, volunteerId: query?.volunteerId as string, status: query?.status as DocumentContractStatusForFilter, - ...(query.startDate ? { documentStartDate: formatDate(query?.startDate as Date, 'yyyy-MM-dd') } : {}), + ...(query.startDate + ? { documentStartDate: formatDate(query?.startDate as Date, 'yyyy-MM-dd') } + : {}), ...(query.endDate ? { documentEndDate: formatDate(query?.endDate as Date, 'yyyy-MM-dd') } : {}), }); @@ -183,6 +186,7 @@ const DocumentContractsTable = ({ query, setQuery }: DocumentContractsTableBasic deleteContract(contractId, { onSuccess: () => { useSuccessToast(t('contract.submit.delete')); + setSelectedDeleteContract(null); refetch(); }, // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -334,7 +338,11 @@ const DocumentContractsTable = ({ query, setQuery }: DocumentContractsTableBasic return ( <> - +