Skip to content

Commit

Permalink
Merge pull request #46 from AOT-Technologies/feature/update-lob
Browse files Browse the repository at this point in the history
making changes for Contacts and individual data to dropdown
  • Loading branch information
nagarajaPC-AOT authored Apr 8, 2024
2 parents 1dba341 + 5d3df93 commit 9de79df
Show file tree
Hide file tree
Showing 19 changed files with 503 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ export class CaseflowContactsResolver {
return this.caseflowContactsService.findById(id);
}

@Query(() => CaseflowContactsResponse, { name: 'getContactsByIds' })
findAllByIds(@Args('id', { type: () => [Int] }) id: number) {
return this.caseflowContactsService.findByIds(id);
}

@Query((returns) => CaseflowContactsResponse, { name: 'getContactsList' })
getContactsList(@Args() args: FetchArgs): Promise<CaseflowContactsResponse> {
const output = this.caseflowContactsService.findAll(args);
getContactsList(): Promise<CaseflowContactsResponse> {
const output = this.caseflowContactsService.findAll();
return output;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,26 @@ export class CaseflowContactsService {
}
}

async findAll(
args: FetchArgs = { skip: 0, take: 5 },
): Promise<CaseflowContactsResponse> {
async findByIds(id: number): Promise<CaseflowContactsResponse> {
try {
if (id) {
const [CaseflowContacts, totalCount] = await this.caseflowContactsRepository
.createQueryBuilder('table')
.where('table.id IN(:...ids)', { ids: id })
.orderBy({ 'table.id': 'DESC' })
.getManyAndCount();
return { CaseflowContacts, totalCount };
}
throw new BadRequestException("request doesn't have any id");
} catch (err) {
return err;
}
}

async findAll(): Promise<CaseflowContactsResponse> {
try {
const [CaseflowContacts, totalCount] = await Promise.all([
this.caseflowContactsRepository.find({
take: args.take,
skip: args.skip,
order: {
id: 'DESC',
},
Expand Down Expand Up @@ -74,9 +86,12 @@ export class CaseflowContactsService {
firstname: `%${searchField}%` ,
}).orWhere('table.lastname ilike :lastname', {
lastname: `%${searchField}%` ,
}).orWhere('table.firstname || \' \' || table.lastname ilike :fullname', {
fullname: `%${searchField}%` ,
}).orWhere('table.phonenumber ilike :phonenumber', {
phonenumber: `%${searchField}%` ,
})
}).orWhere("table.id = :id", { id: isNaN(parseInt(searchField))?0:parseInt(searchField)})

.orderBy({ 'table.id': 'DESC' })
.take(take)
.skip(skip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ export class CaseflowIndividualsResolver {
return this.caseflowIndividualsService.findById(id);
}

@Query(() => CaseflowIndividualsResponse, { name: 'getIndividualsByIds' })
findAllByIds(@Args('id', { type: () => [Int] }) id: number) {
return this.caseflowIndividualsService.findByIds(id);
}

@Query((returns) => CaseflowIndividualsResponse, { name: 'getIndividualsList' })
getIndividualsList(@Args() args: FetchArgs): Promise<CaseflowIndividualsResponse> {
const output = this.caseflowIndividualsService.findAll(args);
getIndividualsList(): Promise<CaseflowIndividualsResponse> {
const output = this.caseflowIndividualsService.findAll();
return output;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,26 @@ export class CaseflowIndividualsService {
}
}

async findAll(
args: FetchArgs = { skip: 0, take: 5 },
): Promise<CaseflowIndividualsResponse> {
async findByIds(id: number): Promise<CaseflowIndividualsResponse> {
try {
if (id) {
const [CaseflowIndividuals, totalCount] = await this.caseflowIndividualsRepository
.createQueryBuilder('table')
.where('table.id IN(:...ids)', { ids: id })
.orderBy({ 'table.id': 'DESC' })
.getManyAndCount();
return { CaseflowIndividuals, totalCount };
}
throw new BadRequestException("request doesn't have any id");
} catch (err) {
return err;
}
}

async findAll(): Promise<CaseflowIndividualsResponse> {
try {
const [CaseflowIndividuals, totalCount] = await Promise.all([
this.caseflowIndividualsRepository.find({
take: args.take,
skip: args.skip,
order: {
id: 'DESC',
},
Expand Down Expand Up @@ -74,9 +86,12 @@ export class CaseflowIndividualsService {
firstname: `%${searchField}%` ,
}).orWhere('table.lastname ilike :lastname', {
lastname: `%${searchField}%` ,
}).orWhere('table.firstname || \' \' || table.lastname ilike :fullname', {
fullname: `%${searchField}%` ,
}).orWhere('table.phonenumber ilike :phonenumber', {
phonenumber: `%${searchField}%` ,
})
}).orWhere("table.id = :id", { id: isNaN(parseInt(searchField))?0:parseInt(searchField)})

.orderBy({ 'table.id': 'DESC' })
.take(take)
.skip(skip)
Expand Down
6 changes: 4 additions & 2 deletions app/caseflow_core/microservices/lob/src/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ type Query {
getLobList(skip: Int! = 0, take: Int! = 25): CaseflowLobResponse!
searchCaseflowLob(searchField: String!, searchColumn: String!, fromDate: String!, toDate: String!, skip: Int! = 0, take: Int! = 25): CaseflowLobResponse!
getContactsById(id: Int!): CaseflowContacts!
getContactsList(skip: Int! = 0, take: Int! = 25): CaseflowContactsResponse!
getContactsByIds(id: [Int!]!): CaseflowContactsResponse!
getContactsList: CaseflowContactsResponse!
searchCaseflowContacts(searchField: String!, skip: Int! = 0, take: Int! = 25): CaseflowContactsResponse!
getIndividualsById(id: Int!): CaseflowIndividuals!
getIndividualsList(skip: Int! = 0, take: Int! = 25): CaseflowIndividualsResponse!
getIndividualsByIds(id: [Int!]!): CaseflowIndividualsResponse!
getIndividualsList: CaseflowIndividualsResponse!
searchCaseflowIndividuals(searchField: String!, skip: Int! = 0, take: Int! = 25): CaseflowIndividualsResponse!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,31 @@ export class CasesService {
.getManyAndCount()
return {Cases,totalCount};
}
case 'contactid': {
const [Cases,totalCount] =await this.caseRepository.createQueryBuilder("table")
.where("table.contactid = :contactid", { contactid: isNaN(parseInt(searchField))?0:parseInt(searchField)})
.andWhere('table.isdeleted = :status', {status:false})
.orderBy({[orderBy]: orderType})
.leftJoinAndSelect('table.casestatus', 'status')
.leftJoinAndSelect('table.casestype', 'type')
.getManyAndCount()
return {Cases,totalCount};
}
case 'individualid': {
const [Cases,totalCount] =await this.caseRepository.createQueryBuilder("table")
.where("table.individualid = :individualid", { individualid: isNaN(parseInt(searchField))?0:parseInt(searchField)})
.andWhere('table.isdeleted = :status', {status:false})
.orderBy({[orderBy]: orderType})
.leftJoinAndSelect('table.casestatus', 'status')
.leftJoinAndSelect('table.casestype', 'type')
.getManyAndCount()
return {Cases,totalCount};
}
default :
const [Cases,totalCount] = await (this.caseRepository.createQueryBuilder("table")
.where(new Brackets((qb) => {
qb.where("LOWER(table.issuetype) LIKE :issuetype", { issuetype: `%${ searchField.toLowerCase() }%` })
.orWhere("table.id = :id", { id: isNaN(parseInt(searchField))?0:parseInt(searchField)})
.orWhere("LOWER(table.contactid) LIKE :contactid", { contactid: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.individualid) LIKE :individualid", { individualid: `%${ searchField.toLowerCase() }%` })
.orWhere("LOWER(table.caseowner) LIKE :caseowner", { caseowner: `%${ searchField.toLowerCase() }%` })
Expand All @@ -214,6 +235,7 @@ export class CasesService {

}
catch(err){
console.log(err);
throw new HttpException("something went wrong", HttpStatus.INTERNAL_SERVER_ERROR)
}

Expand Down
47 changes: 23 additions & 24 deletions app/caseflow_web/src/components/AdvanedSearch/advancedSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export default function AdvancedSearch() {
fromDateForSearch,
toDateForSearch
).then((searchCaseResult) => {
totalCount = totalCount + searchCaseResult.totalCount;
totalCount = totalCount + searchCaseResult?.totalCount;
searchCaseResult?.Cases.map((element) => {
result.push({
title: element.id + " - " + element.issuetype,
content: element.individualid,
content: 'Owner: '+element.caseowner,
subtitle: GENERIC_NAME,
link: "/private/cases/" + element.id + "/details",
imgIcon: require("../../assets/CasesIcon.png"),
Expand All @@ -81,7 +81,7 @@ export default function AdvancedSearch() {
fromDateForSearch,
toDateForSearch
).then((searchDocumentResult) => {
totalCount = totalCount + searchDocumentResult.totalCount;
totalCount = totalCount + searchDocumentResult?.totalCount;
searchDocumentResult?.CaseDocuments.map((element) => {
result.push({
title: element.id + " - " + element.name,
Expand All @@ -92,25 +92,25 @@ export default function AdvancedSearch() {
});
});
}),
(allSearch || lobSearch) &&
getLobData(
1,
searchField,
"policyNumber",
fromDateForSearch,
toDateForSearch
).then((searchLobResult) => {
totalCount = totalCount + searchLobResult?.totalCount;
searchLobResult?.CaseflowLob.map((element) => {
result.push({
title: element.id + " - " + element.policyNumber,
content: moment(element.createdDate).format("MMMM Do, YYYY"),
subtitle: "Policy",
link: "/private/lob/" + element.id + "/details",
imgIcon: require("../../assets/LOBIcon.png"),
});
});
}),
// (allSearch || lobSearch) &&
// getLobData(
// 1,
// searchField,
// "policyNumber",
// fromDateForSearch,
// toDateForSearch
// ).then((searchLobResult) => {
// totalCount = totalCount + searchLobResult?.totalCount;
// searchLobResult?.CaseflowLob.map((element) => {
// result.push({
// title: element.id + " - " + element.policyNumber,
// content: moment(element.createdDate).format("MMMM Do, YYYY"),
// subtitle: "Policy",
// link: "/private/lob/" + element.id + "/details",
// imgIcon: require("../../assets/LOBIcon.png"),
// });
// });
// }),
(allSearch || contactSearch) &&
getContactsData(
1,
Expand All @@ -132,7 +132,7 @@ export default function AdvancedSearch() {
1,
searchField
).then((individuals) => {
totalCount = totalCount + individuals?.CaseflowIndividuals?.totalCount;
totalCount = totalCount + individuals?.totalCount;
individuals?.CaseflowIndividuals?.map((element) => {
result.push({
title: element.id + " - " + element.firstname +" "+element.lastname,
Expand Down Expand Up @@ -164,7 +164,6 @@ export default function AdvancedSearch() {

useEffect(() => {
searchDetails();
console.log(searchresults);
}, [
searchField,
fromDateForSearch,
Expand Down
47 changes: 31 additions & 16 deletions app/caseflow_web/src/components/CaseDetails/CaseDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ import { publishMessage } from "../../services/NatsServices";
import { v4 as uuidv4 } from "uuid";
import { GENERIC_NAME } from "../../apiManager/endpoints/config";
import { createNewNote, getCaseNotes } from "../../services/caseNotesService";
import { getContactDetails, getContactsData } from "../../services/ContactService";
import { setSelectedContact } from "../../reducers/newContactReducer";
import { getIndividualDetails } from "../../services/IndividualService";
import { setSelectedIndividual } from "../../reducers/newIndividualReducer";

// Formio.setProjectUrl("https://app2.aot-technologies.com/formio");
// Formio.setBaseUrl("https://app2.aot-technologies.com/formio");
Expand All @@ -86,6 +90,8 @@ const CaseDetails = () => {
const caseTypes = useSelector((state: State) => state.constants.caseTypes);
const tasks = useSelector((state: State) => state.cases.selectedCase.tasks);
const selectedCase = useSelector((state: State) => state.cases.selectedCase);
const selectedContact = useSelector((state: State) => state.contacts.selectedContact);
const selectedIndividual = useSelector((state: State) => state.individuals.selectedIndividual);
const userName = useSelector(
(state: State) => state.auth.userDetails.userName
);
Expand All @@ -102,18 +108,18 @@ const CaseDetails = () => {
dueDate: "2022-11-01",
};
const optionsForAction = [
{ id: 11, code: 11, text: "Edit" },
{ id: 9, code: 9, text: "Edit" },
{ id: 1, code: "1", text: "Start Workflow" },
{ id: 2, code: 2, text: "Wake" },
{ id: 3, code: 3, text: "Pending" },
// { id: 4, code: 4, text: "Complete" },
{ id: 4, code: 4, text: "Merge" },
{ id: 5, code: 5, text: "Archive" },
{ id: 6, code: 6, text: "Upload Document" },
{ id: 7, code: 7, text: "Add Note" },
{ id: 8, code: 8, text: "Delete" },
{ id: 9, code: 9, text: "Add Communication" },
{ id: 10, code: 10, text: "Close" },
// { id: 4, code: 4, text: "Merge" },
// { id: 5, code: 5, text: "Archive" },
{ id: 4, code: 4, text: "Upload Document" },
{ id: 5, code: 5, text: "Add Note" },
{ id: 6, code: 6, text: "Delete" },
{ id: 7, code: 7, text: "Add Communication" },
{ id: 8, code: 8, text: "Close" },
];
const [isDeleteConfirmationUpOpen, setDeleteConfirmation] = useState(false);
const [isNoteOpen, setIsNoteOpen] = useState(false);
Expand Down Expand Up @@ -163,6 +169,8 @@ const CaseDetails = () => {
let output = await getCaseDetails(matches[0]);
dispatch(setSelectedCase({ ...output, isEdit: false }));
await fetchCaseHistory(matches[0]);
findContact(output.contactid);
findIndividual(output.individualid);
}
}
async function fetchCaseHistory(id) {
Expand Down Expand Up @@ -275,22 +283,22 @@ const CaseDetails = () => {
// case optionsForAction[4].text: {
// return changeStatus(3); // Complete
// }
case optionsForAction[6].text: {
case optionsForAction[4].text: {
return setOpenPopup(true);
}
case optionsForAction[0].text: {
return editCaseDetails(selectedCase);
}
case optionsForAction[8].text: {
case optionsForAction[6].text: {
return setDeleteConfirmation(true)
}
case optionsForAction[7].text: {
case optionsForAction[5].text: {
return setIsNoteOpen(true)
}
case optionsForAction[9].text: {
case optionsForAction[7].text: {
return setIsCommunicationOpen(true)
}
case optionsForAction[10].text: {
case optionsForAction[8].text: {
return setIsRecordOutputOpen(true)
}
}
Expand Down Expand Up @@ -323,7 +331,14 @@ const CaseDetails = () => {
fetchCaseDetails();
fetchAllCaseStatuses();
}, []);

async function findContact (contactid){
const selectedContact = await getContactDetails([contactid]);
dispatch(setSelectedContact(selectedContact));
};
async function findIndividual (individualid) {
const selectedIndividual = await getIndividualDetails(individualid);
dispatch(setSelectedIndividual(selectedIndividual));
};
useEffect(() => {
if (selectedCase && selectedCase.id) fetchRealtedTasks();
}, [selectedCase.id]);
Expand Down Expand Up @@ -633,8 +648,8 @@ const CaseDetails = () => {
{selectedCase && selectedCase.id ? (
<>
<CaseDetailData
contactid={selectedCase.contactid}
individualid={selectedCase.individualid}
contactid={selectedContact.firstname+' '+selectedContact.lastname}
individualid={selectedIndividual.firstname+" "+selectedIndividual.lastname}
startDate={caseDetail.startDate}
owner={caseDetail.owner}
tasks={tasks}
Expand Down
Loading

0 comments on commit 9de79df

Please sign in to comment.