Skip to content

Commit

Permalink
fix: [Contracts] #425 - Cannot delete contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
radulescuandrew committed Oct 1, 2024
1 parent 2e984a2 commit 2b4d21e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,19 @@ export class DeleteDocumentContractUsecase implements IUseCaseService<string> {
);
}

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(
TrackedEventName.DELETE_DOCUMENT_CONTRACT,
{
organizationId: contract.organizationId,
volunteerId: contract.volunteerId,
volunteerName: contract.volunteer.user.name,
volunteerName: contract.volunteerData.name,
documentContractId: contract.id,
documentContractNumber: contract.documentNumber,
},
Expand Down
20 changes: 14 additions & 6 deletions frontend/src/components/DocumentContractsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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') } : {}),
});

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -334,7 +338,11 @@ const DocumentContractsTable = ({ query, setQuery }: DocumentContractsTableBasic

return (
<>
<ContractsStatistics statistics={statistics as IDocumentContractsStatistics} isLoading={isLoadingStatistics} setQuery={setQuery} />
<ContractsStatistics
statistics={statistics as IDocumentContractsStatistics}
isLoading={isLoadingStatistics}
setQuery={setQuery}
/>
<DataTableFilters
onSearch={onSearch}
searchValue={query?.search}
Expand Down

0 comments on commit 2b4d21e

Please sign in to comment.