Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ HTTP input now accepts `field('..')` references in the HTTP body definition.
field(<page>.query-params).get('data.code')

- **Removed support for following scopes**

- `NATLSYSADMIN`
- `DECLARE`
- `VALIDATE`
Expand All @@ -37,6 +38,8 @@ HTTP input now accepts `field('..')` references in the HTTP body definition.
- `RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES`
- `PROFILE_UPDATE`

- Review page now supports PDF rendering when a PDF link is clicked allowing to verify the uploaded PDF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test case for this?


## [1.9.0](https://github.com/opencrvs/opencrvs-core/compare/v1.8.1...v1.9.0)

### Breaking changes
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/tests/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@
"review.modal.desc.submitConfirmation": "{completeDeclaration, select, true {This declaration will be sent to the Registrar for them to review.} false {This declaration will be sent to the Registrar for completion. Please inform the Informant that they will need to visit the office with the missing information and supporting documents.}}",
"review.modal.title.registerConfirmation": "Register this {event}?",
"review.modal.title.submitConfirmation": "{completeDeclaration, select, true {Send declaration for review?} false {Send incomplete declaration?}}",
"review.panViewer.openPDF": "Open PDF in new tab",
"review.rejection.form": "Rejection form",
"review.rejection.form.commentInstruction": "Please provide specific instructions of what needs to be updated by the health worker to correctly update the declaration",
"review.rejection.form.commentLabel": "Comments or instructions for health worker to rectify declaration",
Expand Down
2 changes: 1 addition & 1 deletion packages/commons/src/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { extendZodWithOpenApi } from 'zod-openapi'
extendZodWithOpenApi(z)

export const MINIO_REGEX =
/^https?:\/\/[^\/]+(.*)?\/[^\/?]+\.(jpg|png|jpeg|svg)(\?.*)?$/i
/^https?:\/\/[^\/]+(.*)?\/[^\/?]+\.(jpg|png|jpeg|pdf|svg)(\?.*)?$/i

export function isBase64FileString(str: string) {
if (str === '' || str.trim() === '') {
Expand Down
45 changes: 40 additions & 5 deletions packages/components/src/DocumentViewer/components/PanViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/
import * as React from 'react'
import { useIntl } from 'react-intl'
import { useState } from 'react'
import ReactPanZoom from './PanDraggable'
import { Button } from '../../Button'
import { Icon } from '../../Icon'
import styled from 'styled-components'

const StyledReactPanZoom = styled(ReactPanZoom)<{
Expand Down Expand Up @@ -39,9 +42,23 @@ interface IProps {
}

const PanViewer: React.FC<IProps> = ({ image, zoom, rotation }) => {
const intl = useIntl()
const [dx] = useState(0)
const [dy] = useState(0)

const isPdf = image.endsWith('.pdf')

const handleOpenPdf = async () => {
try {
const res = await fetch(image, { cache: 'default' })
const blob = await res.blob()
const blobUrl = URL.createObjectURL(blob)
window.open(blobUrl, '_blank')
} catch (err) {
console.error('Failed to open PDF', err)
}
}

Comment on lines +51 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the name of the component "pan viewer" it makes me think this might not be the right place for this logic. Pan viewer, if I'm not mistaken, is the component that makes it possible to zoom / pan the image that is previewed. Should this be one level up? @pankaj-pant @bvenceslas

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikukissa you are right. It should be moved a level up. Although we have discovered internally that the PDF upload scope got accidentally introduced, and we are reverting back to image uploads for a cert that has been printed + signed + stamped (so a image taken with a phone/tablet). With that in mind, if this PR helps @tareq89 in the scope of this ticket #3613, please use the general gist of the fix. I think @euanmillar already updated in the issue 3613 the status of @bvenceslas's availability

return (
<React.Fragment>
<StyledReactPanZoom
Expand All @@ -51,11 +68,29 @@ const PanViewer: React.FC<IProps> = ({ image, zoom, rotation }) => {
rotation={rotation}
key={dx}
>
<img
src={image}
alt="Supporting Document"
style={{ transform: `rotate(${rotation}deg)` }}
/>
{!isPdf ? (
<img
src={image}
alt="Supporting Document"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs translation key

style={{ transform: `rotate(${rotation}deg)` }}
/>
) : (
<Button
id="preview_close"
aria-label="Preview PDF1970
in new tab"
size="medium"
type="positive"
onClick={handleOpenPdf}
>
{intl.formatMessage({
id: 'review.panViewer.openPDF',
defaultMessage: 'Open PDF in a new tab',
description: 'Label for open PDF button'
})}
<Icon name="ArrowSquareOut" size="medium" />
</Button>
)}
</StyledReactPanZoom>
</React.Fragment>
)
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/Icon/all-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
ArchiveTray,
ArrowCircleDown,
ArrowCounterClockwise,
ArrowSquareOut,
ArrowLeft,
ArrowRight,
Buildings,
Expand Down
Loading