diff --git a/app/caseflow_core/microservices/lob/src/caseflow_contacts/resolvers/caseflow_contacts.resolver.ts b/app/caseflow_core/microservices/lob/src/caseflow_contacts/resolvers/caseflow_contacts.resolver.ts index 544514854..d83111abc 100644 --- a/app/caseflow_core/microservices/lob/src/caseflow_contacts/resolvers/caseflow_contacts.resolver.ts +++ b/app/caseflow_core/microservices/lob/src/caseflow_contacts/resolvers/caseflow_contacts.resolver.ts @@ -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 { - const output = this.caseflowContactsService.findAll(args); + getContactsList(): Promise { + const output = this.caseflowContactsService.findAll(); return output; } diff --git a/app/caseflow_core/microservices/lob/src/caseflow_contacts/services/caseflow_contacts.service.ts b/app/caseflow_core/microservices/lob/src/caseflow_contacts/services/caseflow_contacts.service.ts index 4d037cd38..75e20ecef 100644 --- a/app/caseflow_core/microservices/lob/src/caseflow_contacts/services/caseflow_contacts.service.ts +++ b/app/caseflow_core/microservices/lob/src/caseflow_contacts/services/caseflow_contacts.service.ts @@ -39,14 +39,26 @@ export class CaseflowContactsService { } } - async findAll( - args: FetchArgs = { skip: 0, take: 5 }, - ): Promise { + async findByIds(id: number): Promise { + 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 { try { const [CaseflowContacts, totalCount] = await Promise.all([ this.caseflowContactsRepository.find({ - take: args.take, - skip: args.skip, order: { id: 'DESC', }, @@ -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) diff --git a/app/caseflow_core/microservices/lob/src/caseflow_individuals/resolvers/caseflow_individuals.resolver.ts b/app/caseflow_core/microservices/lob/src/caseflow_individuals/resolvers/caseflow_individuals.resolver.ts index 228762b47..609445717 100644 --- a/app/caseflow_core/microservices/lob/src/caseflow_individuals/resolvers/caseflow_individuals.resolver.ts +++ b/app/caseflow_core/microservices/lob/src/caseflow_individuals/resolvers/caseflow_individuals.resolver.ts @@ -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 { - const output = this.caseflowIndividualsService.findAll(args); + getIndividualsList(): Promise { + const output = this.caseflowIndividualsService.findAll(); return output; } diff --git a/app/caseflow_core/microservices/lob/src/caseflow_individuals/services/caseflow_individuals.service.ts b/app/caseflow_core/microservices/lob/src/caseflow_individuals/services/caseflow_individuals.service.ts index 952274f88..c6710a595 100644 --- a/app/caseflow_core/microservices/lob/src/caseflow_individuals/services/caseflow_individuals.service.ts +++ b/app/caseflow_core/microservices/lob/src/caseflow_individuals/services/caseflow_individuals.service.ts @@ -39,14 +39,26 @@ export class CaseflowIndividualsService { } } - async findAll( - args: FetchArgs = { skip: 0, take: 5 }, - ): Promise { + async findByIds(id: number): Promise { + 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 { try { const [CaseflowIndividuals, totalCount] = await Promise.all([ this.caseflowIndividualsRepository.find({ - take: args.take, - skip: args.skip, order: { id: 'DESC', }, @@ -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) diff --git a/app/caseflow_core/microservices/lob/src/schema.gql b/app/caseflow_core/microservices/lob/src/schema.gql index 0edad62e4..25587cf5b 100644 --- a/app/caseflow_core/microservices/lob/src/schema.gql +++ b/app/caseflow_core/microservices/lob/src/schema.gql @@ -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! } diff --git a/app/caseflow_core/microservices/server/src/cases/services/cases.service.ts b/app/caseflow_core/microservices/server/src/cases/services/cases.service.ts index d5ee6f020..315cc1b75 100644 --- a/app/caseflow_core/microservices/server/src/cases/services/cases.service.ts +++ b/app/caseflow_core/microservices/server/src/cases/services/cases.service.ts @@ -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() }%` }) @@ -214,6 +235,7 @@ export class CasesService { } catch(err){ + console.log(err); throw new HttpException("something went wrong", HttpStatus.INTERNAL_SERVER_ERROR) } diff --git a/app/caseflow_web/src/components/AdvanedSearch/advancedSearch.tsx b/app/caseflow_web/src/components/AdvanedSearch/advancedSearch.tsx index 331fedb1f..243dfd7a6 100644 --- a/app/caseflow_web/src/components/AdvanedSearch/advancedSearch.tsx +++ b/app/caseflow_web/src/components/AdvanedSearch/advancedSearch.tsx @@ -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"), @@ -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, @@ -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, @@ -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, @@ -164,7 +164,6 @@ export default function AdvancedSearch() { useEffect(() => { searchDetails(); - console.log(searchresults); }, [ searchField, fromDateForSearch, diff --git a/app/caseflow_web/src/components/CaseDetails/CaseDetails.tsx b/app/caseflow_web/src/components/CaseDetails/CaseDetails.tsx index 2cef960d7..eb8fad954 100644 --- a/app/caseflow_web/src/components/CaseDetails/CaseDetails.tsx +++ b/app/caseflow_web/src/components/CaseDetails/CaseDetails.tsx @@ -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"); @@ -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 ); @@ -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); @@ -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) { @@ -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) } } @@ -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]); @@ -633,8 +648,8 @@ const CaseDetails = () => { {selectedCase && selectedCase.id ? ( <> { - const dispatch = useDispatch(); - const navigate = useNavigate(); - 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 lobData = selectedCase.lobDetails; - useEffect(() => { - if (selectedCase.contactid) { - getCaseContactDetails(selectedCase.contactid); - } - }, [selectedCase.contactid]); - useEffect(() => { - if (selectedCase.individualid) { - getCaseIndividualDetails(selectedCase.individualid); - } - }, [selectedCase.individualid]); - const getCaseContactDetails = async (contact) => { - let searchContacts = await getContactsData(1, contact.split(" ")[0]); - let contactDetails = searchContacts?.CaseflowContacts?.map((element) => { - if(element.firstname+" "+element.lastname === contact) { - return element - } else return {} - }); - dispatch(setSelectedContact(contactDetails)); - }; - const getCaseIndividualDetails = async (individual) => { - let searchIndividuals = await getIndividualsData(1, individual.split(" ")[0]); - let individualDetails = searchIndividuals?.CaseflowIndividuals?.map((element) => { - if(element.firstname+" "+element.lastname === individual) { - return element - } else return {} - }); - dispatch(setSelectedIndividual(individualDetails)); - }; - // const navigateToLob = () => { - // navigate("/private/lob/" + lobData.id + "/details"); - // }; - return ( <> <> @@ -69,35 +27,35 @@ const LobCustom = () => {
Id - {selectedContact[0]?.id} + {selectedContact?.id}
Name - {selectedContact[0]?.firstname} {selectedContact[0]?.lastname} + {selectedContact?.firstname} {selectedContact?.lastname}
Phone No - {selectedContact[0]?.phonenumber} + {selectedContact?.phonenumber}
Email - {selectedContact[0]?.email} + {selectedContact?.email}
Address - {selectedContact[0]?.address} + {selectedContact?.address} @@ -136,35 +94,35 @@ const LobCustom = () => {
Id - {selectedIndividual[0]?.id} + {selectedIndividual?.id}
Name - {selectedIndividual[0]?.firstname} {selectedIndividual[0]?.lastname} + {selectedIndividual?.firstname} {selectedIndividual?.lastname}
Phone No - {selectedIndividual[0]?.phonenumber} + {selectedIndividual?.phonenumber}
Email - {selectedIndividual[0]?.email} + {selectedIndividual?.email}
Address - {selectedIndividual[0]?.address} + {selectedIndividual?.address} diff --git a/app/caseflow_web/src/components/Cases/Cases.tsx b/app/caseflow_web/src/components/Cases/Cases.tsx index 2411cece1..23acc1cbb 100644 --- a/app/caseflow_web/src/components/Cases/Cases.tsx +++ b/app/caseflow_web/src/components/Cases/Cases.tsx @@ -12,6 +12,8 @@ import { } from "../../reducers/newCaseReducer"; import { Typography } from "@mui/material"; import { GENERIC_NAME } from "../../apiManager/endpoints/config"; +import { getContactDetailsByIds } from "../../services/ContactService"; +import { getIndividualDetailsByIds } from "../../services/IndividualService"; const caseListProps = { title: GENERIC_NAME, count: 5, @@ -23,7 +25,7 @@ const caseListProps = { const Cases = () => { const [filteredCaseDetails, setFilteredCaseDetails] = useState([]); const [searchField, setSearchField] = useState(""); - const [searchColumn, setSearchColumn] = useState("individualid"); + const [searchColumn, setSearchColumn] = useState("other"); const [dropDownArray, setdropDownArray] = useState(["Name", "Description"]); const [sortSetting, setSortSetting] = useState({ orderBy: "id", @@ -47,10 +49,37 @@ const Cases = () => { null, null ); + let searchResultCases = searchResult.Cases?.map((element) => { return { ...element, status: "Open" }; }); + let contacts = await searchResultCases.reduce(function(pV, cV){ + pV.push(parseInt(cV.contactid)); + return pV; + }, []); + let individuals = await searchResultCases.reduce(function(pV, cV){ + pV.push(parseInt(cV.individualid)); + return pV; + }, []); + let contactList = await getContactDetailsByIds(contacts); + let individualList = await getIndividualDetailsByIds(individuals); + + let contactsKey = new Map(); + contactList.map(contact=>{ + contactsKey.set(contact.id, contact.firstname+' '+contact.lastname); + }) + + let individualsKey = new Map(); + individualList.map(individual=>{ + individualsKey.set(individual.id, individual.firstname+' '+individual.lastname); + }) + searchResultCases = searchResultCases.map((element) => { + element.contactname=contactsKey.get(element.contactid); + element.individualname=individualsKey.get(element.individualid); + return element; + }); + if (searchResultCases) setFilteredCaseDetails(searchResultCases); dispatch(setTotalCaseCount(searchResult.totalCount)); }; @@ -69,7 +98,7 @@ const Cases = () => { let searchResultCases = searchResult.Cases?.map((element) => { return { 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"), diff --git a/app/caseflow_web/src/components/ContactDetails/ContactDetails.tsx b/app/caseflow_web/src/components/ContactDetails/ContactDetails.tsx index 411c2f010..2ff98786d 100644 --- a/app/caseflow_web/src/components/ContactDetails/ContactDetails.tsx +++ b/app/caseflow_web/src/components/ContactDetails/ContactDetails.tsx @@ -4,16 +4,65 @@ import { useSelector } from "react-redux"; import { State } from "../../interfaces/stateInterface"; import "./ContactDetails.scss"; import moment from "moment"; -import { getContactDetails } from "../../services/ContactService"; +import { getContactDetails, getContactDetailsByIds } from "../../services/ContactService"; import { useDispatch } from "react-redux"; import { setSelectedContact } from "../../reducers/newContactReducer"; import { Typography } from "@mui/material"; +import CaseList from "../CaseList/CaseList"; +import { fetchRecentCaseList, searchCases } from "../../services/CaseService"; +import { GENERIC_NAME } from "../../apiManager/endpoints/config"; +import { setsearchCaseResult } from "../../reducers/newCaseReducer"; +import { getIndividualDetailsByIds } from "../../services/IndividualService"; + +const caseListProps = { + title: "Related Cases", +}; const ContactDetail = () => { const [dataForBreadCrumbs, setDataForBreadCrumbs] = useState([ { text: "Home", link: "/private" }, ]); const contact = useSelector((state: State) => state.contacts.selectedContact); + const [recentCases, setrecentCases] = useState([]); + + const [searchColumn] = useState("contactid"); + + const relatedCaseList = async (output) => { + let recentCases = await searchCases( + output.id, + searchColumn, + 1, + "id", + true, + true, + null, + null + ); + let searchResultCases = recentCases.Cases?.map((element) => { + return { ...element, status: "Open" }; + }); + let individuals = await searchResultCases?.reduce(function(pV, cV){ + pV.push(parseInt(cV.individualid)); + return pV; + }, []); + let individualList = individuals ? await getIndividualDetailsByIds(individuals):[]; + + + let individualsKey = new Map(); + individualList.map(individual=>{ + individualsKey.set(individual.id, individual.firstname+' '+individual.lastname); + }) + + + searchResultCases = searchResultCases.map((element) => { + element.contactname=output.firstname+' '+output.lastname; + element.individualname=individualsKey.get(element.individualid); + return element; + }); + + setrecentCases(searchResultCases); + }; + const location = useLocation(); const dispatch = useDispatch(); async function fetchContactDetails() { @@ -21,6 +70,7 @@ const ContactDetail = () => { if (matches && matches[0]) { let output = await getContactDetails(matches[0]); dispatch(setSelectedContact(output)); + relatedCaseList(output); } } @@ -38,7 +88,6 @@ const ContactDetail = () => { }, ]); }, [contact]); - return ( <>
@@ -105,6 +154,12 @@ const ContactDetail = () => {
+
+ +
); }; diff --git a/app/caseflow_web/src/components/Dashboard/Dashboard.tsx b/app/caseflow_web/src/components/Dashboard/Dashboard.tsx index 1a9d9013f..6ab45b358 100644 --- a/app/caseflow_web/src/components/Dashboard/Dashboard.tsx +++ b/app/caseflow_web/src/components/Dashboard/Dashboard.tsx @@ -9,6 +9,8 @@ import { GENERIC_NAME } from "../../apiManager/endpoints/config"; import { useDispatch, useSelector } from "react-redux"; import { setsearchCaseResult } from "../../reducers/newCaseReducer"; import { State } from "../../interfaces/stateInterface"; +import { getContactDetailsByIds } from "../../services/ContactService"; +import { getIndividualDetailsByIds } from "../../services/IndividualService"; const caseListProps = { title: "Recent " + GENERIC_NAME, @@ -42,7 +44,7 @@ const Dashboard = () => { let searchResultCases = searchResult.Cases?.map((element) => { return { 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"), @@ -61,9 +63,32 @@ const Dashboard = () => { const recentCaseList = async () => { let recentCases = await fetchRecentCaseList(); + let contacts = await recentCases.reduce(function(pV, cV){ + pV.push(parseInt(cV.contactid)); + return pV; + }, []); + let individuals = await recentCases.reduce(function(pV, cV){ + pV.push(parseInt(cV.individualid)); + return pV; + }, []); + let contactList = await getContactDetailsByIds(contacts); + let individualList = await getIndividualDetailsByIds(individuals); + + let contactsKey = new Map(); + contactList.map(contact=>{ + contactsKey.set(contact.id, contact.firstname+' '+contact.lastname); + }) + + let individualsKey = new Map(); + individualList.map(individual=>{ + individualsKey.set(individual.id, individual.firstname+' '+individual.lastname); + }) recentCases = recentCases.filter((element, index) => { + element.contactname=contactsKey.get(element.contactid); + element.individualname=individualsKey.get(element.individualid); return index < 5; }); + setrecentCases(recentCases); }; diff --git a/app/caseflow_web/src/components/IndividualDetails/IndividualDetails.tsx b/app/caseflow_web/src/components/IndividualDetails/IndividualDetails.tsx index b8ce8833d..a814b4cd9 100644 --- a/app/caseflow_web/src/components/IndividualDetails/IndividualDetails.tsx +++ b/app/caseflow_web/src/components/IndividualDetails/IndividualDetails.tsx @@ -8,12 +8,60 @@ import { getIndividualDetails } from "../../services/IndividualService"; import { useDispatch } from "react-redux"; import { setSelectedIndividual } from "../../reducers/newIndividualReducer"; import { Typography } from "@mui/material"; +import CaseList from "../CaseList/CaseList"; +import { searchCases } from "../../services/CaseService"; +import { getContactDetailsByIds } from "../../services/ContactService"; + +const caseListProps = { + title: "Related Cases", +}; const IndividualDetail = () => { const [dataForBreadCrumbs, setDataForBreadCrumbs] = useState([ { text: "Home", link: "/private" }, ]); const individual = useSelector((state: State) => state.individuals.selectedIndividual); + const [recentCases, setrecentCases] = useState([]); + + const [searchColumn] = useState("individualid"); + + + const relatedCaseList = async (output) => { + let recentCases = await searchCases( + output.id, + searchColumn, + 1, + "id", + true, + true, + null, + null + ); + let searchResultCases = recentCases.Cases?.map((element) => { + return { ...element, status: "Open" }; + }); + let contacts = await searchResultCases?.reduce(function(pV, cV){ + pV.push(parseInt(cV.contactid)); + return pV; + }, []); + let contactList = contacts ? await getContactDetailsByIds(contacts):[]; + + + let contactsKey = new Map(); + contactList.map(contact=>{ + contactsKey.set(contact.id, contact.firstname+' '+contact.lastname); + }) + + + searchResultCases = searchResultCases.map((element) => { + element.individualname=output.firstname+' '+output.lastname; + element.contactname=contactsKey.get(element.contactid); + return element; + }); + + setrecentCases(searchResultCases); + }; + const location = useLocation(); const dispatch = useDispatch(); async function fetchIndividualDetails() { @@ -21,6 +69,7 @@ const IndividualDetail = () => { if (matches && matches[0]) { let output = await getIndividualDetails(matches[0]); dispatch(setSelectedIndividual(output)); + relatedCaseList(output); } } @@ -105,6 +154,13 @@ const IndividualDetail = () => {
+ +
+ +
); }; diff --git a/app/caseflow_web/src/components/NewCase/NewCase.tsx b/app/caseflow_web/src/components/NewCase/NewCase.tsx index 0a21a5bbe..be5c77619 100644 --- a/app/caseflow_web/src/components/NewCase/NewCase.tsx +++ b/app/caseflow_web/src/components/NewCase/NewCase.tsx @@ -20,6 +20,7 @@ import { } from "../../reducers/newCaseReducer"; import "./NewCaseComponent.scss"; import { + Autocomplete, FormControl, InputLabel, MenuItem, @@ -47,6 +48,8 @@ import { FORMSFLOW_APPLICATION_URL, FORMSFLOW_WEB_APPLICATION_URL } from "../../ import { Form as FormIOForm, saveSubmission, Formio } from "react-formio"; import CustomizedDialog from "../Dialog/Dialog"; import { GENERIC_NAME } from "../../apiManager/endpoints/config"; +import { getAllContactsData } from "../../services/ContactService"; +import { getAllIndividualData } from "../../services/IndividualService"; const NewCase = () => { const dispatch = useDispatch(); const navigate = useNavigate(); @@ -80,6 +83,8 @@ const NewCase = () => { ); const [values, setValues] = useState(initialFieldValues); const [isEdit, setIsEdit] = useState(false); + const [contactList, setContactList]: any = useState(); + const [individualList, setIndividualList]: any = useState(); const { handleSubmit, control, register } = useForm(); // const [caseList.isEdit,setIsCaseEdit] = useState(Boolean); const [selectedForm, setselectedForm]: any = useState(""); @@ -172,6 +177,8 @@ const NewCase = () => { lobcaseid:data.lobcaseid, }; setValues(InitialSelectedCaseDetails); + await getContacts(); + await getIndividuals(); setIsEdit(true); } }; @@ -181,6 +188,25 @@ const NewCase = () => { dispatch(setCaseTypes(caseTypes)); }; + const getContacts = async () => { + const contacts = await getAllContactsData(); + let values:any = []; + contacts.forEach(function (contact){ + values.push({'id': contact.id,'label': contact.firstname+' '+contact.lastname }) + }) + setContactList(values); + }; + + const getIndividuals = async () => { + const individials = await getAllIndividualData(); + const values = [{}]; + individials.forEach(function (individual){ + values.push({id: individual.id,label: individual.firstname+' '+individual.lastname }) + }) + setIndividualList(values); + }; + + const refreshCases = () => { dispatch(resetSelectedCase()); setValues(initialFieldValues); @@ -285,7 +311,6 @@ const NewCase = () => { } }, [selectedFormDetails]); - return ( <>
{ name={"contactid"} control={control} render={({ field: { onChange, value } }) => ( - { - setValues({ ...values, contactid: e.target.value }); - }} - /> + setValues({ ...values, contactid: e.target.value }); + }} + > + {contactList.map(contact => ( + {contact.label} + ))} + )} /> @@ -349,19 +376,21 @@ const NewCase = () => { name={"individualid"} control={control} render={({ field: { onChange, value } }) => ( - { - setValues({ ...values, individualid: e.target.value }); - }} - /> + setValues({ ...values, individualid: e.target.value }); + }} + > + {individualList.map(individual => ( + {individual.label} + ))} + )} /> diff --git a/app/caseflow_web/src/components/RecentCaseCard/RecentCaseCard.tsx b/app/caseflow_web/src/components/RecentCaseCard/RecentCaseCard.tsx index 8e6d8eaa8..91623d633 100644 --- a/app/caseflow_web/src/components/RecentCaseCard/RecentCaseCard.tsx +++ b/app/caseflow_web/src/components/RecentCaseCard/RecentCaseCard.tsx @@ -14,7 +14,6 @@ const RecentCaseCard = (props) => { const [CaseDetails, setcaseDetails] = useState(props.case); const dispatch = useDispatch(); const navigate = useNavigate(); - const viewCaseDetails = async (CaseDetails) => { navigate("/private/cases/" + CaseDetails.id + "/details"); }; @@ -63,13 +62,13 @@ const RecentCaseCard = (props) => { whiteSpace: "nowrap", }} > - {CaseDetails.contactid}{" "} + {CaseDetails.contactname} } /> - { whiteSpace: "nowrap", }} > - {CaseDetails.individualid}{" "} + {CaseDetails.individualname}{" "} } /> diff --git a/app/caseflow_web/src/graphql/contactRequest.ts b/app/caseflow_web/src/graphql/contactRequest.ts index cde6e99fc..cb67f4a36 100644 --- a/app/caseflow_web/src/graphql/contactRequest.ts +++ b/app/caseflow_web/src/graphql/contactRequest.ts @@ -15,16 +15,26 @@ export const FETCH_DATA = gql` } `; - +export const FETCH_ALL_BY_IDS = gql` + query getContactsByIds($Id: [Int!]!) { + getContactsByIds(id: $Id) { + totalCount + CaseflowContacts { + id + firstname + lastname + phonenumber + email + dateofbirth + address + createdat + } + } + } +`; export const FETCH_ALL = gql` - query getAll( - $Skip: Int - $Take: Int - ) { - getContactsList( - skip: $Skip - take: $Take - ) { + query getAll { + getContactsList { totalCount CaseflowContacts { id diff --git a/app/caseflow_web/src/graphql/individualRequest.ts b/app/caseflow_web/src/graphql/individualRequest.ts index 100800fee..da36509d2 100644 --- a/app/caseflow_web/src/graphql/individualRequest.ts +++ b/app/caseflow_web/src/graphql/individualRequest.ts @@ -15,16 +15,27 @@ export const FETCH_DATA = gql` } `; +export const FETCH_ALL_BY_IDS = gql` + query getIndividualsByIds($Id: [Int!]!) { + getIndividualsByIds(id: $Id) { + totalCount + CaseflowIndividuals { + id + firstname + lastname + phonenumber + email + dateofbirth + address + createdat + } + } + } +`; export const FETCH_ALL = gql` - query getAll( - $Skip: Int - $Take: Int - ) { - getIndividualsList( - skip: $Skip - take: $Take - ) { + query getAll { + getIndividualsList { totalCount CaseflowIndividuals { id diff --git a/app/caseflow_web/src/services/ContactService.ts b/app/caseflow_web/src/services/ContactService.ts index a80c3ad7e..95a59c064 100644 --- a/app/caseflow_web/src/services/ContactService.ts +++ b/app/caseflow_web/src/services/ContactService.ts @@ -2,6 +2,8 @@ import { httpPOSTRequest } from "../apiManager/httpRequestHandler"; import { LOBURL } from "../apiManager/endpoints"; import { CREATE_NEW_CASEFLOW_CONTACT, + FETCH_ALL, + FETCH_ALL_BY_IDS, FETCH_ALL_CONTACTS_DATA, FETCH_DATA, UPDATE_NEW_CASEFLOW_CONTACT, @@ -32,6 +34,50 @@ export const getContactDetails = async (id) => { return output; }; +export const getContactDetailsByIds = async (ids) => { + const url = LOBURL; + const output = await httpPOSTRequest( + url, + { + query: print(FETCH_ALL_BY_IDS), + variables: { + Id: ids, + }, + }, + null + ) + .then((res) => { + return res.data.data.getContactsByIds.CaseflowContacts; + }) + .catch((error) => { + console.log({ error: error }); + return {}; + }); + return output; +}; + +export const getAllContactsData = async () => { + const url = LOBURL; + const output = await httpPOSTRequest( + url, + { + query: print(FETCH_ALL), + variables: { + Take: Number(PAGINATION_TAKE), + }, + }, + null + ) + .then((res) => { + return res.data.data; + }) + .catch((err) => { + console.log(err); + return {}; + }); + return output?.getContactsList?.CaseflowContacts; +}; + export const getContactsData = async ( number, searchField, diff --git a/app/caseflow_web/src/services/IndividualService.ts b/app/caseflow_web/src/services/IndividualService.ts index 86c571230..07f4c7dd7 100644 --- a/app/caseflow_web/src/services/IndividualService.ts +++ b/app/caseflow_web/src/services/IndividualService.ts @@ -2,6 +2,8 @@ import { httpPOSTRequest } from "../apiManager/httpRequestHandler"; import { LOBURL } from "../apiManager/endpoints"; import { CREATE_NEW_CASEFLOW_INDIVIDUAL, + FETCH_ALL, + FETCH_ALL_BY_IDS, FETCH_ALL_INDIVIDUALS_DATA, FETCH_DATA, UPDATE_NEW_CASEFLOW_INDIVIDUAL, @@ -32,6 +34,52 @@ export const getIndividualDetails = async (id) => { return output; }; +export const getIndividualDetailsByIds = async (ids) => { + const url = LOBURL; + const output = await httpPOSTRequest( + url, + { + query: print(FETCH_ALL_BY_IDS), + variables: { + Id: ids, + }, + }, + null + ) + .then((res) => { + return res.data.data.getIndividualsByIds.CaseflowIndividuals; + }) + .catch((error) => { + console.log({ error: error }); + return {}; + }); + return output; +}; + + +export const getAllIndividualData = async () => { + const url = LOBURL; + const output = await httpPOSTRequest( + url, + { + query: print(FETCH_ALL), + variables: { + Take: Number(PAGINATION_TAKE), + }, + }, + null + ) + .then((res) => { + return res.data.data; + }) + .catch((err) => { + console.log(err); + return {}; + }); + return output?.getIndividualsList?.CaseflowIndividuals; +}; + + export const getIndividualsData = async ( number, searchField,