Skip to content

Commit

Permalink
Update views with negative news model updates (#84)
Browse files Browse the repository at this point in the history
closes #35

Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Sep 24, 2023
1 parent eadda22 commit 09c921f
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/components/KycCaseResult/KycCaseResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export const KycCaseResult: React.FunctionComponent<KycCaseResultProps> = (props
if (printMode) {
return (
<>
<CustomerRisk customerRisk={props.currentCase.customerRiskAssessment} />
<NegativeNews type="Party" news={props.currentCase.negativeScreening} />
<NegativeNews type="Counterparty" news={props.currentCase.counterpartyNegativeScreening} />
<KycSummary kycSummary={props.currentCase.caseSummary} />
<CustomerRisk customerRisk={props.currentCase.customerRiskAssessment} />
<KycSummary kycSummary={props.currentCase.caseSummary} />
<NegativeNews type="Party" news={props.currentCase.negativeScreening} />
<NegativeNews type="Counterparty" news={props.currentCase.counterpartyNegativeScreening} />
</>
)
}
Expand Down
29 changes: 29 additions & 0 deletions src/components/ListItems/ListItems.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import React from 'react';

export interface ListItemsProps {
unordered?: boolean;
items: string[]
}

export const ListItems: React.FunctionComponent<ListItemsProps> = (props: ListItemsProps) => {
if (!props.items || props.items.length === 0) {
return (<></>)
}

if (props.unordered) {
return (
<ul>
{props.items.map((item, index) => (<li key={index}>{item}</li>))}
</ul>
)
} else {
return (
<ol>
{props.items.map((item, index) => (<li key={index}>{item}</li>))}
</ol>
)
}
}
1 change: 1 addition & 0 deletions src/components/ListItems/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ListItems'
27 changes: 24 additions & 3 deletions src/components/NegativeNews/NegativeNews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,37 @@
import React from 'react';

import './NegativeNews.scss';
import {NegativeScreeningModel} from "../../models";
import {NegativeScreeningModel, NewsItemModel} from "../../models";
import {ListItems} from "../ListItems";

export interface NegativeNewsProps {
type: string;
hideTitle?: boolean;
news?: NegativeScreeningModel;
}

const NewsItems = (props: {items?: NewsItemModel[], title: string}) => {
if (!props.items || props.items.length === 0) {
return (<></>)
}

return (
<>
<div style={{fontStyle: 'italic'}}>{props.title}</div>
{props.items.map(val => (
<div key={val.title} style={{padding: '0 5px'}}>
<div>{val.title}</div>
<div>{val.summary}</div>
<ListItems items={val.negativeNewsTopics} unordered={true} />
</div>
))}
</>
)
}

export const NegativeNews: React.FunctionComponent<NegativeNewsProps> = (props: NegativeNewsProps) => {

if (props.news && !props.news.result) {
if (props.news && !props.news.summary) {
return (<></>)
}

Expand All @@ -27,13 +47,14 @@ export const NegativeNews: React.FunctionComponent<NegativeNewsProps> = (props:
return 'Error'
}

return props.news.result || '--'
return props.news.summary || '--'
}

return (
<div style={{width: '100%', textAlign: 'left'}}>
{!props.hideTitle ? (<div className="negNewsTitle">Negative news - {props.type}</div>) : (<></>)}
<div>{getContent()}</div>
<NewsItems items={props.news?.negativeNews} title="" />
</div>
)
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export * from './NegativeNews'
export * from './KycSummary'
export * from './KycCaseOverview'
export * from './KycCaseResult'
export * from './ListItems'
24 changes: 22 additions & 2 deletions src/models/kyc-case.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,33 @@ export interface DocumentModel extends DocumentInputModel {
content: Buffer;
}


export interface NegativeScreeningModel {
result: string;
subject: string;
totalScreened: number;
negativeNewsCount: number;
negativeNews: NewsItemModel[];
nonNegativeNewsCount: number;
nonNegativeNews: NewsItemModel[];
unrelatedNewsCount: number;
unrelatedNews: NewsItemModel[];
summary: string;
error?: string;
}

export interface NewsItemModel {
title: string;
link: string;
source: string;
snippet: string;
date: string;
negativeNewsTopics?: string[];
hasNegativeNews?: boolean;
summary?: string;
}

export const isNegativeScreeningModel = (val: unknown): val is NegativeScreeningModel => {
return !!val && !!(val as NegativeScreeningModel).result
return !!val && !!(val as NegativeScreeningModel).summary
}

export interface CustomerRiskAssessmentModel {
Expand Down
108 changes: 90 additions & 18 deletions src/services/kyc-case-management/kyc-case-management.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ const LIST_CASES = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
totalScreened
unrelatedNewsCount
nonNegativeNewsCount
negativeNewsCount
}
counterpartyNegativeScreening {
result
summary
error
totalScreened
unrelatedNewsCount
nonNegativeNewsCount
negativeNewsCount
}
customerRiskAssessment {
score
Expand Down Expand Up @@ -75,12 +83,20 @@ const CASES_SUBSCRIPTION = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
totalScreened
unrelatedNewsCount
nonNegativeNewsCount
negativeNewsCount
}
counterpartyNegativeScreening {
result
summary
error
totalScreened
unrelatedNewsCount
nonNegativeNewsCount
negativeNewsCount
}
customerRiskAssessment {
score
Expand Down Expand Up @@ -116,12 +132,68 @@ const GET_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
totalScreened
unrelatedNewsCount
nonNegativeNewsCount
negativeNewsCount
unrelatedNews {
date
title
link
summary
negativeNewsTopics
hasNegativeNews
}
nonNegativeNews {
date
title
link
summary
negativeNewsTopics
hasNegativeNews
}
negativeNews {
date
title
link
summary
negativeNewsTopics
hasNegativeNews
}
}
counterpartyNegativeScreening {
result
summary
error
totalScreened
unrelatedNewsCount
nonNegativeNewsCount
negativeNewsCount
unrelatedNews {
date
title
link
summary
negativeNewsTopics
hasNegativeNews
}
nonNegativeNews {
date
title
link
summary
negativeNewsTopics
hasNegativeNews
}
negativeNews {
date
title
link
summary
negativeNewsTopics
hasNegativeNews
}
}
customerRiskAssessment {
score
Expand Down Expand Up @@ -157,11 +229,11 @@ const CREATE_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
}
counterpartyNegativeScreening {
result
summary
error
}
customerRiskAssessment {
Expand Down Expand Up @@ -198,11 +270,11 @@ const ADD_DOCUMENT_TO_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
}
counterpartyNegativeScreening {
result
summary
error
}
customerRiskAssessment {
Expand Down Expand Up @@ -239,11 +311,11 @@ const APPROVE_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
}
counterpartyNegativeScreening {
result
summary
error
}
customerRiskAssessment {
Expand Down Expand Up @@ -280,11 +352,11 @@ const REVIEW_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
}
counterpartyNegativeScreening {
result
summary
error
}
customerRiskAssessment {
Expand Down Expand Up @@ -331,11 +403,11 @@ const REMOVE_DOCUMENT_FROM_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
}
counterpartyNegativeScreening {
result
summary
error
}
customerRiskAssessment {
Expand Down Expand Up @@ -372,11 +444,11 @@ const PROCESS_CASE = gql`
countryOfResidence
}
negativeScreening {
result
summary
error
}
counterpartyNegativeScreening {
result
summary
error
}
customerRiskAssessment {
Expand Down
33 changes: 32 additions & 1 deletion src/services/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,26 @@ type Mutation {
"""Negative screening"""
type NegativeScreening {
error: String
result: String!
negativeNews: [NewsItem!]!
negativeNewsCount: Float!
nonNegativeNews: [NewsItem!]!
nonNegativeNewsCount: Float!
subject: String!
summary: String!
totalScreened: Float!
unrelatedNews: [NewsItem!]!
unrelatedNewsCount: Float!
}

type NewsItem {
date: String!
hasNegativeNews: Boolean
link: String!
negativeNewsTopics: [String!]
snippet: String!
source: String!
summary: String
title: String!
}

"""KYC Person"""
Expand All @@ -134,6 +153,9 @@ type Query {
listEntityTypes: [FormOption!]!
listIndustryTypes: [FormOption!]!
listQuestions: [DataExtractionQuestion!]!
screenNews(country: String, dateOfBirth: String, name: String!): NegativeScreening!
summarize(name: String!): SummaryResult!
validateUrl(url: String!): ValidatedUrl!
}

input ReviewCaseInput {
Expand All @@ -146,4 +168,13 @@ input ReviewCaseInput {
type Subscription {
extractDataObservable(customer: String!, questions: [DataExtractionQuestionIdInput!]!): [DataExtractionResult!]!
subscribeToCases: [KycCase!]!
}

type SummaryResult {
result: String!
}

type ValidatedUrl {
isValid: Boolean!
link: String!
}
Loading

0 comments on commit 09c921f

Please sign in to comment.