Skip to content

Commit

Permalink
Fix print for summary information
Browse files Browse the repository at this point in the history
closes #70

Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund committed Sep 23, 2023
1 parent 6eac456 commit aff3959
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 54 deletions.
27 changes: 27 additions & 0 deletions src/components/KycCaseOverview/KycCaseOverview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import React from 'react';
import {KycCaseModel} from "../../models";
import {Stack} from "../Stack";

export interface KycCaseOverviewProps {
currentCase: KycCaseModel;
}

export const KycCaseOverview: React.FunctionComponent<KycCaseOverviewProps> = (props: KycCaseOverviewProps) => {

return (
<div className="infoBox">
<Stack gap={3}>
<div><span className="label">Customer name:</span> {props.currentCase.customer.name}</div>
<div><span className="label">Country:</span> {props.currentCase.customer.countryOfResidence}</div>
<div><span className="label">Entity type:</span> {props.currentCase.customer.entityType}</div>
<div><span className="label">Industry type:</span> {props.currentCase.customer.industryType}</div>
<div><span className="label">Customer outreach:</span> {props.currentCase.customerOutreach || 'N/A'}</div>
<div><span className="label">Counterparty name:</span> {props.currentCase.counterparty.name}</div>
<div><span className="label">Counterparty country:</span> {props.currentCase.counterparty.countryOfResidence}</div>
</Stack>
</div>
)
}
2 changes: 2 additions & 0 deletions src/components/KycCaseOverview/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export * from './KycCaseOverview';
71 changes: 71 additions & 0 deletions src/components/KycCaseResult/KycCaseResult.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import React, {ComponentType} from 'react';
import {Error, Pending} from "@carbon/icons-react";
import {Tab, TabList, TabPanel, TabPanels, Tabs} from "@carbon/react";
import {useMediaQuery} from "usehooks-ts";

import {CustomerRisk} from "../CustomerRisk";
import {KycSummary} from "../KycSummary";
import {NegativeNews} from "../NegativeNews";
import {KycCaseModel} from "../../models";

export interface KycCaseResultProps {
currentCase: KycCaseModel;
}

export const KycCaseResult: React.FunctionComponent<KycCaseResultProps> = (props: KycCaseResultProps) => {
const printMode = useMediaQuery('print')

const getIcon = (data?: {error?: string}): ComponentType<{size: number}> => {

if (!data) {
return Pending as never;
}

if (data.error) {
return Error as never;
}

return undefined
}

const isDisabled = (data?: {error?: string}): boolean => {
return !data;
}

const tabProps = (data: {error?: string}) => {
return {
renderIcon: getIcon(data),
disabled: isDisabled(data),
}
}

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} />
</>
)
}

return (
<Tabs>
<TabList aria-label="List of tabs">
<Tab {...tabProps(props.currentCase.customerRiskAssessment)}>Customer Risk</Tab>
<Tab {...tabProps(props.currentCase.negativeScreening)}>Negative News - Party</Tab>
<Tab {...tabProps(props.currentCase.counterpartyNegativeScreening)}>Negative News - Counterparty</Tab>
<Tab {...tabProps(props.currentCase.caseSummary)}>KYC Summary</Tab>
</TabList>
<TabPanels>
<TabPanel><CustomerRisk hideTitle={true} customerRisk={props.currentCase.customerRiskAssessment} /></TabPanel>
<TabPanel><NegativeNews hideTitle={true} type="Party" news={props.currentCase.negativeScreening} /></TabPanel>
<TabPanel><NegativeNews hideTitle={true} type="Counterparty" news={props.currentCase.counterpartyNegativeScreening} /></TabPanel>
<TabPanel><KycSummary hideTitle={true} kycSummary={props.currentCase.caseSummary} /></TabPanel>
</TabPanels>
</Tabs>
)
}
2 changes: 2 additions & 0 deletions src/components/KycCaseResult/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export * from './KycCaseResult'
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export * from './AtomSelect'
export * from './CustomerRisk'
export * from './NegativeNews'
export * from './KycSummary'
export * from './KycCaseOverview'
export * from './KycCaseResult'
60 changes: 6 additions & 54 deletions src/views/KYC/KYCCaseDetail/KYCCasePending/KYCCasePending.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import React, {ComponentType} from 'react';
import React from 'react';
import {useNavigate} from "react-router-dom";
import {Button, Tab, TabList, TabPanel, TabPanels, Tabs} from "@carbon/react";
import {Button} from "@carbon/react";
import {useSetAtom} from "jotai";
import {Error, Pending} from "@carbon/icons-react";

import './KYCCasePending.scss';
import {selectedKycCaseAtom} from "../../../../atoms";
import {CustomerRisk, DocumentList, KycSummary, NegativeNews, Stack} from "../../../../components";
import {DocumentList, KycCaseOverview, KycCaseResult, Stack} from "../../../../components";
import {KycCaseModel} from "../../../../models";
import {kycCaseManagementApi} from "../../../../services";

Expand All @@ -32,59 +31,12 @@ export const KYCCasePending: React.FunctionComponent<KYCCasePendingProps> = (pro
.catch(err => console.error('Error processing case: ', {err}))
}

const getIcon = (data?: {error?: string}): ComponentType<{size: number}> => {

if (!data) {
return Pending as never;
}

if (data.error) {
return Error as never;
}

return undefined
}

const isDisabled = (data?: {error?: string}): boolean => {
return !data;
}

const tabProps = (data: {error?: string}) => {
return {
renderIcon: getIcon(data),
disabled: isDisabled(data),
}
}

return (
<Stack gap={7}>
<Stack gap={5}>
<h2>Pending information</h2>
<div className="infoBox">
<Stack gap={3}>
<div><span className="label">Customer name:</span> {props.currentCase.customer.name}</div>
<div><span className="label">Country:</span> {props.currentCase.customer.countryOfResidence}</div>
<div><span className="label">Entity type:</span> {props.currentCase.customer.entityType}</div>
<div><span className="label">Industry type:</span> {props.currentCase.customer.industryType}</div>
<div><span className="label">Customer outreach:</span> {props.currentCase.customerOutreach || 'N/A'}</div>
<div><span className="label">Counterparty name:</span> {props.currentCase.counterparty.name}</div>
<div><span className="label">Counterparty country:</span> {props.currentCase.counterparty.countryOfResidence}</div>
</Stack>
</div>
<KycCaseOverview currentCase={props.currentCase} />
<DocumentList documents={props.currentCase.documents} />
<Tabs>
<TabList aria-label="List of tabs">
<Tab {...tabProps(props.currentCase.customerRiskAssessment)}>Customer Risk</Tab>
<Tab {...tabProps(props.currentCase.negativeScreening)}>Negative News - Party</Tab>
<Tab {...tabProps(props.currentCase.counterpartyNegativeScreening)}>Negative News - Counterparty</Tab>
<Tab {...tabProps(props.currentCase.caseSummary)}>KYC Summary</Tab>
</TabList>
<TabPanels>
<TabPanel><CustomerRisk hideTitle={true} customerRisk={props.currentCase.customerRiskAssessment} /></TabPanel>
<TabPanel><NegativeNews hideTitle={true} type="Party" news={props.currentCase.negativeScreening} /></TabPanel>
<TabPanel><NegativeNews hideTitle={true} type="Counterparty" news={props.currentCase.counterpartyNegativeScreening} /></TabPanel>
<TabPanel><KycSummary hideTitle={true} kycSummary={props.currentCase.caseSummary} /></TabPanel>
</TabPanels>
</Tabs>
<KycCaseResult currentCase={props.currentCase} />
<div><Button kind="tertiary" onClick={handleCancel}>Return</Button> <Button onClick={handleRefresh}>Refresh</Button></div>
</Stack>
)
Expand Down

0 comments on commit aff3959

Please sign in to comment.