Skip to content

Commit

Permalink
Adding delete functionality and missing packages
Browse files Browse the repository at this point in the history
  • Loading branch information
midhun-aot committed Feb 9, 2025
1 parent f59e347 commit a3688ed
Show file tree
Hide file tree
Showing 8 changed files with 10,984 additions and 93 deletions.
10,965 changes: 10,899 additions & 66 deletions backend/users/package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion backend/users/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"@nestjs/platform-express": "^9.0.0",
"@nestjs/typeorm": "^9.0.1",
"apollo-server-express": "^3.10.2",
"axios": "^1.7.9",
"class-transformer": "^0.5.1",
"cls-rtracer": "^2.6.3",
"graphql": "^16.6.0",
"keycloak-connect": "^18.0.2",
"nest-keycloak-connect": "^1.9.0",
Expand All @@ -44,7 +46,8 @@
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"typeorm": "^0.3.10",
"cls-rtracer": "^2.6.3"
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
Expand Down
3 changes: 3 additions & 0 deletions backend/users/src/app/dto/createPersonInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ export class CreatePersonInput {

@Field(() => Date)
updatedDatetime: Date;

@Field(() => Boolean, { nullable: true })
isDeleted?: boolean;
}
11 changes: 8 additions & 3 deletions backend/users/src/app/entities/person.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class Person {
@Column('boolean', { name: 'is_active' })
isActive: boolean;

@Field(() => String)
@Column('boolean', { name: 'is_deleted', nullable: true })
isDeleted?: boolean;

@Field(() => String)
@Column('integer', { name: 'row_version_count' })
rowVersionCount: number;
Expand All @@ -120,9 +124,10 @@ export class Person {
@Column('timestamp without time zone', { name: 'updated_datetime' })
updatedDatetime: Date;

@Field(() => String)
@Column('bytea', { name: 'ts' })
ts: Buffer;
// Comment out for now, not sure if we need this
// @Field(() => String)
// @Column('bytea', { name: 'ts', nullable: true })
// ts?: Buffer;

@OneToMany(() => AppParticipant, (appParticipant) => appParticipant.person)
appParticipants: AppParticipant[];
Expand Down
2 changes: 1 addition & 1 deletion backend/users/src/app/services/people.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class PersonService {
try {
const response = new SearchPersonResponse();
const query = this.personRepository.createQueryBuilder('person');

query.andWhere('is_deleted is not true');
query.andWhere(
new Brackets((qb) => {
qb.where('CAST(person.id AS TEXT) LIKE :searchParam', {
Expand Down
18 changes: 18 additions & 0 deletions backend/users/src/migrations/1739126886945-master-script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class masterScript1739126886945 implements MigrationInterface {
name = 'masterScript1739126886945'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "cats"."person" RENAME COLUMN "ts" TO "is_deleted"`);
await queryRunner.query(`ALTER TABLE "cats"."person" DROP COLUMN "is_deleted"`);
await queryRunner.query(`ALTER TABLE "cats"."person" ADD "is_deleted" boolean`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "cats"."person" DROP COLUMN "is_deleted"`);
await queryRunner.query(`ALTER TABLE "cats"."person" ADD "is_deleted" bytea`);
await queryRunner.query(`ALTER TABLE "cats"."person" RENAME COLUMN "is_deleted" TO "ts"`);
}

}
4 changes: 2 additions & 2 deletions cats-frontend/src/app/features/people/dto/Columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ const getPeopleSearchResultsColumns = () => {
7,
"Address",
true,
"addressLine1",
"address_1,address_2",
2,
false,
true,
1,
true,
getColumnType("Address", "addressLine1", "")
getColumnType("Address", "address_1,address_2", "")
),
new TableColumn(
2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDispatch } from "react-redux";
import { AppDispatch } from "../../../Store";
import { Button } from "../../../components/button/Button";
import { getUser, isUserOfType, UserRoleType } from "../../../helpers/utility";
// import AddToFolio from '../../folios/AddToFolio';

import {
FileExportIcon,
PlainTrashIcon,
Expand All @@ -15,10 +15,8 @@ import {
import { downloadCSV } from "../../../helpers/csvExport/csvExport";
import Actions from "../../../components/action/Actions";
import { updatePeople } from "../dto/PeopleSlice";
// import { addCartItem, resetCartItemAddedStatus } from '../../cart/CartSlice';

interface SearchResultsActionsProps {
selectedRows: any[]; // TODO: type this properly, should be Site
selectedRows: any[];
}
export const SearchResultsActions: FC<SearchResultsActionsProps> = ({
selectedRows,
Expand All @@ -28,7 +26,40 @@ export const SearchResultsActions: FC<SearchResultsActionsProps> = ({

const handleExport = () => {
if (selectedRows.length > 0) {
downloadCSV(selectedRows);
const loggedInUser = getUser();
if (loggedInUser === null) {
auth.signinRedirect({ extraQueryParams: { kc_idp_hint: "idir" } });
} else {
const updatePeopleInput = selectedRows.map((row) => {
return {
id: row.id,
middleName: "",
firstName: row.firstName,
lastName: row.lastName,
isTaxExempt: row.isTaxExempt,
isEnvConsultant: row.isEnvConsultant,
loginUserName: row.loginUserName,
address_1: row.address_1,
address_2: row.address_2,
city: row.city,
prov: row.prov,
country: row.country,
postal: row.postal,
phone: row.phone,
mobile: row.mobile,
fax: row.fax,
email: row.email,
isActive: false,
rowVersionCount: 1,
createdBy: "",
updatedBy: "",
createdDatetime: new Date(),
updatedDatetime: new Date(),
isDeleted: true,
};
});
dispatch(updatePeople(updatePeopleInput)).unwrap();
}
}
};

Expand All @@ -41,33 +72,31 @@ export const SearchResultsActions: FC<SearchResultsActionsProps> = ({
const updatePeopleInput = selectedRows.map((row) => {
return {
id: row.id,
middleName: "",
firstName: row.firstName,
lastName: row.lastName,
isTaxExempt: row.isTaxExempt,
isEnvConsultant: row.isEnvConsultant,
loginUserName: row.loginUserName,
addressLine1: row.addressLine1,
addressLine2: row.addressLine2,
address_1: row.address_1,
address_2: row.address_2,
city: row.city,
province: row.province,
prov: row.prov,
country: row.country,
postalCode: row.postalCode,
phone: null,
mobile: null,
fax: null,
postal: row.postal,
phone: row.phone,
mobile: row.mobile,
fax: row.fax,
email: row.email,
isActive: event === "Active" ? true : false,
rowVersionCount: 1,
createdBy: "",
updatedBy: "",
createdDatetime: new Date(),
updatedDatetime: new Date(),
};
});
dispatch(updatePeople(updatePeopleInput)).unwrap();
// const cartItems = selectedRows.map((row) => {
// return {
// siteId: row.id,
// price: 200.11,
// };
// });
// dispatch(resetCartItemAddedStatus(null));
// dispatch(addCartItem(cartItems)).unwrap();
}
};

Expand Down

0 comments on commit a3688ed

Please sign in to comment.