Skip to content

Commit

Permalink
Add button to issue AI calls again (#43)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Sep 20, 2023
1 parent 04e91f0 commit 102aa82
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export abstract class KycCaseManagementApi {
abstract removeDocumentFromCase(id: string, documentId: string): Promise<KycCaseModel>;
abstract reviewCase(input: ReviewCaseModel): Promise<KycCaseModel>;
abstract approveCase(input: ApproveCaseModel): Promise<KycCaseModel>;
abstract processCase(id: string): Promise<KycCaseModel>;
}

export class CaseNotFound extends Error {
Expand Down
57 changes: 57 additions & 0 deletions src/services/kyc-case-management/kyc-case-management.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>;
Expand Down Expand Up @@ -512,4 +554,19 @@ export class KycCaseManagementGraphql implements KycCaseManagementApi {
async reload(): Promise<void> {
}

async processCase(caseId: string): Promise<KycCaseModel> {
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<KycCaseModel>
}

}
4 changes: 4 additions & 0 deletions src/services/kyc-case-management/kyc-case-management.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,8 @@ export class KycCaseManagementMock implements KycCaseManagementApi {

async reload() {
}

async processCase() {
return undefined
}
}
1 change: 1 addition & 0 deletions src/services/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
Expand Down
8 changes: 8 additions & 0 deletions src/views/KYC/KYCCaseDetail/KYCCasePending/KYCCasePending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Stack
} from "../../../../components";
import {KycCaseModel} from "../../../../models";
import {kycCaseManagementApi} from "../../../../services";

export interface KYCCasePendingProps {
currentCase: KycCaseModel;
Expand All @@ -21,11 +22,17 @@ export interface KYCCasePendingProps {

export const KYCCasePending: React.FunctionComponent<KYCCasePendingProps> = (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 (
<Stack gap={5}>
<h2>Pending information</h2>
Expand Down Expand Up @@ -78,6 +85,7 @@ export const KYCCasePending: React.FunctionComponent<KYCCasePendingProps> = (pro
style={{marginBottom: '20px'}}
/>
<DocumentList documents={props.currentCase.documents} />
<div><Button onClick={handleRefresh}>Refresh</Button></div>
<NegativeNews type="Party" news={props.currentCase.negativeScreening} />
<NegativeNews type="Counterparty" news={props.currentCase.counterpartyNegativeScreening} />
<CustomerRisk customerRisk={props.currentCase.customerRiskAssessment} />
Expand Down
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down

0 comments on commit 102aa82

Please sign in to comment.