From 102aa820fe81f2ca24da7d6163301050aaba7db9 Mon Sep 17 00:00:00 2001 From: Sean Sundberg Date: Wed, 20 Sep 2023 08:17:02 -0500 Subject: [PATCH] Add button to issue AI calls again (#43) Signed-off-by: Sean Sundberg --- .../kyc-case-management.api.ts | 1 + .../kyc-case-management.graphql.ts | 57 +++++++++++++++++++ .../kyc-case-management.mock.ts | 4 ++ src/services/schema.gql | 1 + .../KYCCasePending/KYCCasePending.tsx | 8 +++ vite.config.ts | 6 +- 6 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/services/kyc-case-management/kyc-case-management.api.ts b/src/services/kyc-case-management/kyc-case-management.api.ts index 41e179c..df9a886 100644 --- a/src/services/kyc-case-management/kyc-case-management.api.ts +++ b/src/services/kyc-case-management/kyc-case-management.api.ts @@ -21,6 +21,7 @@ export abstract class KycCaseManagementApi { abstract removeDocumentFromCase(id: string, documentId: string): Promise; abstract reviewCase(input: ReviewCaseModel): Promise; abstract approveCase(input: ApproveCaseModel): Promise; + abstract processCase(id: string): Promise; } export class CaseNotFound extends Error { diff --git a/src/services/kyc-case-management/kyc-case-management.graphql.ts b/src/services/kyc-case-management/kyc-case-management.graphql.ts index ebb8a01..6c33302 100644 --- a/src/services/kyc-case-management/kyc-case-management.graphql.ts +++ b/src/services/kyc-case-management/kyc-case-management.graphql.ts @@ -350,6 +350,48 @@ const REMOVE_DOCUMENT_FROM_CASE = gql` } } ` +const PROCESS_CASE = gql` + mutation ProcessCase($caseId: ID!) { + processCase(id: $caseId) { + id + status + customer { + name + countryOfResidence + entityType + industryType + } + documents { + id + name + path + } + customerOutreach + counterparty { + name + countryOfResidence + } + negativeScreening { + result + error + } + counterpartyNegativeScreening { + result + error + } + customerRiskAssessment { + score + rating + error + } + caseSummary { + summary + error + } + } + } +` + export class KycCaseManagementGraphql implements KycCaseManagementApi { client: ApolloClient; @@ -512,4 +554,19 @@ export class KycCaseManagementGraphql implements KycCaseManagementApi { async reload(): Promise { } + async processCase(caseId: string): Promise { + return this.client + .mutate<{processCase: KycCaseModel}>({ + mutation: PROCESS_CASE, + variables: {caseId}, + refetchQueries: [{query: LIST_CASES}, {query: GET_CASE, variables: {caseId}}], + awaitRefetchQueries: true + }) + .then(async (result: FetchResult<{processCase: KycCaseModel}>) => { + this.caseNotifySubject.next(result.data?.processCase.id || ''); + + return result.data?.processCase + }) as Promise + } + } \ No newline at end of file diff --git a/src/services/kyc-case-management/kyc-case-management.mock.ts b/src/services/kyc-case-management/kyc-case-management.mock.ts index f6363ab..6cd810f 100644 --- a/src/services/kyc-case-management/kyc-case-management.mock.ts +++ b/src/services/kyc-case-management/kyc-case-management.mock.ts @@ -157,4 +157,8 @@ export class KycCaseManagementMock implements KycCaseManagementApi { async reload() { } + + async processCase() { + return undefined + } } diff --git a/src/services/schema.gql b/src/services/schema.gql index a4c8021..1a5c2b9 100644 --- a/src/services/schema.gql +++ b/src/services/schema.gql @@ -101,6 +101,7 @@ type Mutation { addDocumentToCase(caseId: ID!, documentName: String!, documentUrl: String!): KycCase! approveCase(case: ApproveCaseInput!): KycCase! createCase(customer: CustomerInput!): KycCase! + processCase(id: ID!): KycCase! removeDocumentFromCase(caseId: ID!, documentId: ID!): KycCase! reviewCase(case: ReviewCaseInput!): KycCase! } diff --git a/src/views/KYC/KYCCaseDetail/KYCCasePending/KYCCasePending.tsx b/src/views/KYC/KYCCaseDetail/KYCCasePending/KYCCasePending.tsx index 3941b50..d9815f5 100644 --- a/src/views/KYC/KYCCaseDetail/KYCCasePending/KYCCasePending.tsx +++ b/src/views/KYC/KYCCaseDetail/KYCCasePending/KYCCasePending.tsx @@ -13,6 +13,7 @@ import { Stack } from "../../../../components"; import {KycCaseModel} from "../../../../models"; +import {kycCaseManagementApi} from "../../../../services"; export interface KYCCasePendingProps { currentCase: KycCaseModel; @@ -21,11 +22,17 @@ export interface KYCCasePendingProps { export const KYCCasePending: React.FunctionComponent = (props: KYCCasePendingProps) => { const navigate = useNavigate(); + const service = kycCaseManagementApi(); const handleCancel = () => { navigate(props.returnUrl); } + const handleRefresh = () => { + service.processCase(props.currentCase.id) + .catch(err => console.error('Error processing case: ', {err})) + } + return (

Pending information

@@ -78,6 +85,7 @@ export const KYCCasePending: React.FunctionComponent = (pro style={{marginBottom: '20px'}} /> +
diff --git a/vite.config.ts b/vite.config.ts index 8075bb4..8cd4d32 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,9 +7,9 @@ export default defineConfig(({mode}) => { const env = loadEnv(mode, process.cwd(), '') - const apiTarget: string = env.API_TARGET || 'http://localhost:3000'; - const graphqlTarget: string = env.GRAPHQL_TARGET || 'http://localhost:3000'; - const socketTarget: string = env.SOCKET_TARGET || 'ws://localhost:3000'; + const apiTarget: string = env.API_TARGET1 || 'http://localhost:3000'; + const graphqlTarget: string = env.GRAPHQL_TARGET1 || 'http://localhost:3000'; + const socketTarget: string = env.SOCKET_TARGET1 || 'ws://localhost:3000'; console.log('Target urls: ', {apiTarget, graphqlTarget, socketTarget, mode})