forked from openimis/openimis-fe-grievance_js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CM-832: added generating pdf reports - comments and grievance
- Loading branch information
1 parent
3d82f9a
commit 9f3d992
Showing
6 changed files
with
373 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* eslint-disable no-nested-ternary */ | ||
/* eslint-disable no-undef */ | ||
import React, { | ||
forwardRef, | ||
} from 'react'; | ||
|
||
import { Divider } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
|
||
import { | ||
useTranslations, useModulesManager, | ||
} from '@openimis/fe-core'; | ||
import { MODULE_NAME } from '../constants'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
topHeader: { | ||
display: 'flex', | ||
justifyContent: 'start', | ||
alignItems: 'center', | ||
width: '100%', | ||
|
||
'& img': { | ||
minWidth: '250px', | ||
maxWidth: '300px', | ||
width: 'auto', | ||
height: 'auto', | ||
}, | ||
}, | ||
printContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: '20px', | ||
fontWeight: '500', | ||
}, | ||
date: { | ||
fontSize: '16px', | ||
}, | ||
detailsContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
padding: '12px', | ||
width: '100%', | ||
}, | ||
detailRow: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
padding: '4px', | ||
}, | ||
detailName: { | ||
fontWeight: '600', | ||
fontSize: '16px', | ||
textTransform: 'uppercase', | ||
}, | ||
detailValue: { | ||
fontWeight: '500', | ||
backgroundColor: '#f5f5f5', | ||
padding: '6px', | ||
borderRadius: '8px', | ||
fontSize: '15px', | ||
}, | ||
containerPadding: { | ||
padding: '32px', | ||
}, | ||
dividerMargin: { | ||
margin: '12px 0', | ||
}, | ||
resolutionComment: { | ||
color: '#d9534f', | ||
fontWeight: 'bold', | ||
}, | ||
})); | ||
|
||
const TicketPrintCommentTemplate = forwardRef(({ ticketComments }, ref) => { | ||
const classes = useStyles(); | ||
const modulesManager = useModulesManager(); | ||
const { formatMessage } = useTranslations(modulesManager, MODULE_NAME); | ||
|
||
const formatCommenterName = (commenterTypeName, commenter) => { | ||
if (!commenterTypeName) return 'Anonymous User'; | ||
|
||
if (commenterTypeName === 'individual') { | ||
const commenterData = JSON.parse(JSON.parse(commenter)); | ||
return `Individual: ${commenterData.firstName} ${commenterData.lastName}`; | ||
} | ||
|
||
if (commenterTypeName === 'user') { | ||
const commenterData = JSON.parse(JSON.parse(commenter)); | ||
return `User: ${commenterData.username}`; | ||
} | ||
|
||
return commenterTypeName; | ||
}; | ||
|
||
const formatDate = (dateStr) => { | ||
const date = new Date(dateStr); | ||
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`; | ||
}; | ||
|
||
return ( | ||
<div ref={ref} className={classes.containerPadding}> | ||
<div className={classes.topHeader} /> | ||
<Divider className={classes.dividerMargin} /> | ||
<div className={classes.detailsContainer}> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.comments')}</p> | ||
<div className={classes.detailValue}> | ||
{ticketComments?.length > 0 ? ( | ||
ticketComments.map((comment) => ( | ||
<div | ||
key={comment.id} | ||
className={comment.isResolution ? classes.resolutionComment : ''} | ||
style={{ marginBottom: '8px' }} | ||
> | ||
<strong> | ||
{formatCommenterName(comment.commenterTypeName, comment.commenter)} | ||
: | ||
</strong> | ||
{' '} | ||
{comment.comment} | ||
<div style={{ fontSize: '12px', color: '#777' }}> | ||
{formatDate(comment.dateCreated)} | ||
</div> | ||
</div> | ||
)) | ||
) : ( | ||
<p>{formatMessage('ticket.template.noComments')}</p> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
export default TicketPrintCommentTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* eslint-disable no-nested-ternary */ | ||
/* eslint-disable no-undef */ | ||
import React, { | ||
forwardRef, | ||
} from 'react'; | ||
|
||
import { Divider } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
|
||
import { | ||
useTranslations, useModulesManager, | ||
} from '@openimis/fe-core'; | ||
import { MODULE_NAME } from '../constants'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
topHeader: { | ||
display: 'flex', | ||
justifyContent: 'start', | ||
alignItems: 'center', | ||
width: '100%', | ||
|
||
'& img': { | ||
minWidth: '250px', | ||
maxWidth: '300px', | ||
width: 'auto', | ||
height: 'auto', | ||
}, | ||
}, | ||
printContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: '20px', | ||
fontWeight: '500', | ||
}, | ||
date: { | ||
fontSize: '16px', | ||
}, | ||
detailsContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
padding: '12px', | ||
width: '100%', | ||
}, | ||
detailRow: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
padding: '4px', | ||
}, | ||
detailName: { | ||
fontWeight: '600', | ||
fontSize: '16px', | ||
textTransform: 'uppercase', | ||
}, | ||
detailValue: { | ||
fontWeight: '500', | ||
backgroundColor: '#f5f5f5', | ||
padding: '6px', | ||
borderRadius: '8px', | ||
fontSize: '15px', | ||
}, | ||
containerPadding: { | ||
padding: '32px', | ||
}, | ||
dividerMargin: { | ||
margin: '12px 0', | ||
}, | ||
})); | ||
|
||
const TicketPrintTemplate = forwardRef(({ ticket, reporter }, ref) => { | ||
const classes = useStyles(); | ||
const modulesManager = useModulesManager(); | ||
const { formatMessage } = useTranslations(modulesManager, MODULE_NAME); | ||
|
||
return ( | ||
<div ref={ref} className={classes.containerPadding}> | ||
<div className={classes.topHeader} /> | ||
<Divider className={classes.dividerMargin} /> | ||
<div className={classes.detailsContainer}> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.title')}</p> | ||
<p className={classes.detailValue}>{ticket.title}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.ticketCode')}</p> | ||
<p className={classes.detailValue}>{ticket.code}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.status')}</p> | ||
<p className={classes.detailValue}>{ticket.status}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.dateOfIncident')}</p> | ||
<p className={classes.detailValue}>{ticket.dateOfIncident}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.channel')}</p> | ||
<p className={classes.detailValue}>{ticket.channel}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.category')}</p> | ||
<p className={classes.detailValue}>{ticket.category}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.flags')}</p> | ||
<p className={classes.detailValue}>{ticket.flags}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.priority')}</p> | ||
<p className={classes.detailValue}>{ticket.priority}</p> | ||
</div> | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.description')}</p> | ||
<p className={classes.detailValue}>{ticket.description}</p> | ||
</div> | ||
{ticket.reporterTypeName === 'individual' && ( | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.reporter')}</p> | ||
<p className={classes.detailValue}> | ||
{reporter && reporter.individual | ||
? `${reporter.individual.firstName} ${reporter.individual.lastName} ${reporter.individual.dob}` | ||
: reporter | ||
? `${reporter.firstName} ${reporter.lastName} ${reporter.dob}` | ||
: EMPTY_STRING} | ||
</p> | ||
</div> | ||
)} | ||
{ticket.reporterTypeName === 'beneficiary' && ( | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.reporter')}</p> | ||
<p className={classes.detailValue}> | ||
{reporter?.jsonExt?.national_id ?? ''} | ||
</p> | ||
</div> | ||
)} | ||
{ticket.reporterTypeName === null && ( | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.reporter')}</p> | ||
<p className={classes.detailValue}>{formatMessage('ticket.anonymousUser')}</p> | ||
</div> | ||
)} | ||
<div className={classes.detailRow}> | ||
<p className={classes.detailName}>{formatMessage('ticket.template.attendingStaff')}</p> | ||
<p className={classes.detailValue}>{ticket?.attendingStaff?.username}</p> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
export default TicketPrintTemplate; |
Oops, something went wrong.