Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-2220: improved displaying beneficiary data when beneficiary is selected #19

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function fetchTicketSummaries(mm, filters) {
'priority', 'dueDate', 'reporter', 'reporterId',
'reporterType', 'reporterTypeName', 'category', 'flags',
'channel', 'resolution', 'title', 'dateOfIncident', 'dateCreated', 'version', 'isHistory',
'reporterFirstName', 'reporterLastName', 'reporterDob',
];
const payload = formatPageQueryWithCount(
'tickets',
Expand All @@ -54,6 +55,7 @@ export function fetchTicket(mm, filters) {
'reporterType', 'reporterTypeName', 'category', 'flags', 'channel',
'resolution', 'title', 'dateOfIncident', 'dateCreated',
'attendingStaff {id, username}', 'version', 'isHistory,', 'jsonExt',
'reporterFirstName', 'reporterLastName', 'reporterDob',
];
const payload = formatPageQueryWithCount(
'tickets',
Expand All @@ -78,6 +80,9 @@ export function fetchComments(ticket) {
'comment',
'isResolution',
'dateCreated',
'commenterFirstName',
'commenterLastName',
'commenterDob',
];
const payload = formatPageQueryWithCount(
'comments',
Expand Down Expand Up @@ -129,7 +134,7 @@ export function formatUpdateTicketGQL(ticket) {
? `reporterId: "${decodeId(ticket.reporter.id)}"`
: `reporterId: "${ticket.reporter.id}"`)
: ''}
${!!ticket.reporter && !!ticket.reporter ? 'reporterType: "Individual"' : ''}
${!!ticket.reporter && !!ticket.reporter ? `reporterType: "${ticket.reporterTypeName}"` : ''}
${ticket.nameOfComplainant ? `nameOfComplainant: "${formatGQLString(ticket.nameOfComplainant)}"` : ''}
${ticket.resolution ? `resolution: "${formatGQLString(ticket.resolution)}"` : ''}
${ticket.status ? `status: ${formatGQLString(ticket.status)}` : ''}
Expand Down
19 changes: 19 additions & 0 deletions src/components/TicketCommentsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,25 @@ class TicketCommentPanel extends Component {
/>
);
}
if (comment.commenterTypeName === 'beneficiary') {
picker = (
<PublishedComponent
pubRef="socialProtection.BeneficiaryPicker"
readOnly
value={
{
individual: {
firstName: comment.commenterFirstName,
lastName: comment.commenterLastName,
dob: comment.commenterDob,
},
}
}
module={MODULE_NAME}
label={formatMessage(this.props.intl, MODULE_NAME, 'ticket.commenter')}
/>
);
}
if (comment.commenterTypeName === null) {
picker = 'Anonymous User';
}
Expand Down
10 changes: 7 additions & 3 deletions src/components/TicketSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,13 @@ class TicketSearcher extends Component {
label="ticket.reporter"
required
value={
reporter !== undefined
&& reporter !== null ? (isEmptyObject(reporter)
? null : reporter) : null
{
individual: {
firstName: ticket.reporterFirstName,
lastName: ticket.reporterLastName,
dob: ticket.reporterDob,
},
}
}
/>
);
Expand Down
27 changes: 26 additions & 1 deletion src/dialogs/GrievanceCommentDialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { Grid } from '@material-ui/core';
import { injectIntl } from 'react-intl';
import Button from '@material-ui/core/Button';
Expand Down Expand Up @@ -35,6 +35,7 @@ function GrievanceCommentDialog({
}) {
const modulesManager = useModulesManager();
const { formatMessage } = useTranslations(MODULE_NAME, modulesManager);
const [benefitPlan, setBenefitPlan] = useState(null);
return (
<>
<Button
Expand Down Expand Up @@ -107,6 +108,30 @@ function GrievanceCommentDialog({
/>
</Grid>
)}
{commenterType === 'beneficiary' && (
<>
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="socialProtection.BenefitPlanPicker"
withNull
label="socialProtection.benefitPlan"
value={benefitPlan}
onChange={(v) => setBenefitPlan(v)}
/>
</Grid>
{benefitPlan && (
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="socialProtection.BeneficiaryPicker"
value={comment.reporter}
label="ticket.commenter"
onChange={(v) => updateCommentAttribute('commenter', v)}
benefitPlan={benefitPlan}
/>
</Grid>
)}
</>
)}
<Grid item xs={12} className={classes.item}>
<TextInput
label="ticket.comment"
Expand Down
39 changes: 15 additions & 24 deletions src/pages/EditTicketPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class EditTicketPage extends Component {
const {
stateEdited, reporter, comments,
} = this.state;

return (
<div className={classes.page}>
<Grid container>
Expand Down Expand Up @@ -183,29 +182,21 @@ class EditTicketPage extends Component {
</>
)}
{stateEdited.reporterTypeName === 'beneficiary' && (
<>
<Grid item xs={4} className={classes.item}>
<TextInput
module={MODULE_NAME}
label="ticket.nationalId"
value={reporter?.jsonExt?.national_id ?? ''}
required={false}
readOnly
/>
</Grid>
<Grid item xs={4} className={classes.item}>
<TextInput
module={MODULE_NAME}
label="ticket.email"
value={!!stateEdited && !!stateEdited.reporter
? this.extractFieldFromJsonExt(reporter, 'email')
: EMPTY_STRING}
onChange={(v) => this.updateAttribute('email', v)}
required={false}
readOnly
/>
</Grid>
</>
<PublishedComponent
pubRef="socialProtection.BeneficiaryPicker"
onChange={(v) => this.updateAttribute('reporter', v)}
readOnly
value={
{
individual: {
firstName: stateEdited.reporterFirstName,
lastName: stateEdited.reporterLastName,
dob: stateEdited.reporterDob,
},
}
}
module={MODULE_NAME}
/>
)}
</Grid>
</Paper>
Expand Down
Loading