forked from opencrvs/opencrvs-countryconfig
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: QR code scanner #1
Open
tahmidrahman-dsi
wants to merge
36
commits into
develop
Choose a base branch
from
feat/ocrvs-7978/qr-reader
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f56735b
chore: qr code related changes
tahmidrahman-dsi ec66906
fix: handle optional values
tahmidrahman-dsi 19f93e0
chore: add qr scanner form field
tahmidrahman-dsi be3e321
chore: some more changes
tahmidrahman-dsi 036b0f0
feat: qr code variants
tahmidrahman-dsi 3fd40ef
fix: add form configuration changes
tahmidrahman-dsi 64bf134
fix: add missing import
tahmidrahman-dsi 385bcfe
chore(WIP): set an example of how id reader field can be incorporated
tahmidrahman-dsi 43a1e5f
chore: add translations
tahmidrahman-dsi 6b79627
fix: conditionals
tahmidrahman-dsi b8048be
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig-…
tahmidrahman-dsi be7b103
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig …
tahmidrahman-dsi 3ffe6b3
fix: update yarn-lock
tahmidrahman-dsi 13477e4
Merge pull request #3 from opencrvs/qr-reader-with-latest-develop
tahmidrahman-dsi d3a6bd6
chore(wip): changes
tahmidrahman-dsi 89ed652
fix: update form config defining pending logic
tahmidrahman-dsi 6829114
Merge branch 'develop' of github.com:opencrvs/opencrvs-countryconfig-…
tahmidrahman-dsi e5d3432
refactor: rename REDIRECT to LINK_BUTTON
tahmidrahman-dsi a67dde2
chore: implement e-signet links
tahmidrahman-dsi d15f9ac
fix: remove unused custom field
tahmidrahman-dsi f8996f4
fix: improve naming
tahmidrahman-dsi cb8d286
chore: add hidden form field type
tahmidrahman-dsi 0fb71a3
Adjust field definitions and add env var for server package
euanmillar b4322f4
Merge branch 'feat/ocrvs-7978/qr-reader' of github.com:opencrvs/openc…
euanmillar f6de859
bump package number
euanmillar 974535c
fix: typo
tahmidrahman-dsi 7cb991d
Ensure redirectUri is populated
euanmillar a44b3c9
chore: update mosip images tags
tahmidrahman-dsi 7ba86ff
refactor: rename variable esignet auth url
tahmidrahman-dsi c5469a9
fix: env vars
tahmidrahman-dsi 352a962
chore: upgrade @opencrvs/mosip
tahmidrahman-dsi a36bebc
chore: upgrade mosip dep version
tahmidrahman-dsi 36f61aa
chore: update form field condition
tahmidrahman-dsi f1dc222
chore: update mosip dependency
tahmidrahman-dsi f381fe4
Merge branch 'develop' into feat/ocrvs-7978/qr-reader
tahmidrahman-dsi e810071
Merge branch 'develop' into feat/ocrvs-7978/qr-reader
tahmidrahman-dsi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { getCustomFieldMapping } from '@countryconfig/utils/mapping/field-mapping-utils' | ||
import { formMessageDescriptors } from '../common/messages' | ||
import { Conditional, SerializedFormField } from '../types/types' | ||
import { genderOptions } from '../common/select-options' | ||
import { MessageDescriptor } from 'react-intl' | ||
|
||
/** | ||
* | ||
* @param event | ||
* @param sectionId | ||
* @returns hidden field to store QR scanned data | ||
*/ | ||
export function getIDReaderField( | ||
event: string, | ||
sectionId: string, | ||
conditionals: Conditional[], | ||
label: MessageDescriptor | ||
): SerializedFormField { | ||
const fieldName: string = 'informantIDReadeer' | ||
const fieldId: string = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}` | ||
return { | ||
name: fieldName, | ||
customQuestionMappingId: fieldId, | ||
custom: true, | ||
required: false, | ||
type: 'ID_READER', | ||
label, | ||
initialValue: '', | ||
validator: [], | ||
mapping: getCustomFieldMapping(fieldId), | ||
placeholder: formMessageDescriptors.formSelectPlaceholder, | ||
conditionals, | ||
dividerLabel: { | ||
id: 'id.divider.label', | ||
defaultMessage: 'Or' | ||
}, | ||
manualInputInstructionLabel: { | ||
id: 'id.manualInputInstruction.label', | ||
defaultMessage: 'Complete fields below' | ||
}, | ||
readers: [ | ||
{ | ||
type: 'QR', | ||
labels: { | ||
button: { | ||
id: 'id.qr.button.label', | ||
defaultMessage: 'Scan ID QR code' | ||
}, | ||
scannerDialogSupportingCopy: { | ||
id: 'id.qr.scanner.supportingCopy', | ||
defaultMessage: | ||
"Place the Notifier's ID card in front of the camera." | ||
}, | ||
tutorial: { | ||
cameraCleanliness: { | ||
id: 'id.qr.tutorial.cameraCleanliness', | ||
defaultMessage: 'Ensure your camera is clean and functional.' | ||
}, | ||
distance: { | ||
id: 'id.qr.tutorial.distance', | ||
defaultMessage: | ||
'Hold the device steadily 6-12 inches away from the QR code.' | ||
}, | ||
lightBalance: { | ||
id: 'id.qr.tutorial.lightBalance', | ||
defaultMessage: | ||
'Ensure the QR code is well-lit and not damaged or blurry.' | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
name: 'redirect', | ||
validator: [], | ||
type: 'REDIRECT', | ||
label: { | ||
id: 'redirect.id', | ||
defaultMessage: 'E-signet' | ||
}, | ||
options: { | ||
url: 'test', | ||
callback: { | ||
params: { | ||
authorized: 'true' | ||
}, | ||
trigger: 'someHTTPField' | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
/** To bypass config validation */ | ||
export function getGenderCustom( | ||
event: string, | ||
sectionId: string, | ||
initialValue: { dependsOn: string[]; expression: string } | string = '' | ||
) { | ||
const fieldName: string = 'gender' | ||
const fieldId: string = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}` | ||
return { | ||
name: fieldName, | ||
type: 'SELECT_WITH_OPTIONS', | ||
customQuestionMappingId: fieldId, | ||
custom: true, | ||
label: formMessageDescriptors.sex, | ||
required: false, | ||
initialValue, | ||
validator: [], | ||
placeholder: formMessageDescriptors.formSelectPlaceholder, | ||
mapping: getCustomFieldMapping(fieldId), | ||
options: genderOptions | ||
} satisfies SerializedFormField | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tahmidrahman-dsi I thought that we would apply these functions using functions from here: opencrvs/mosip#26. Do we have to merge that one in first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @euanmillar eventually we will import these from @opencrvs/mosip. please feel free to merge if the changes look okay. After the changes are published, I can import these functions here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tahmidrahman-dsi I spoke with Pyry, and we are going to publish multiple versions so can you close this PR and instead copy over the appropriate form changes to https://github.com/opencrvs/mosip then we can merge in and use the form functions properly in this repo. Please note the latest WIP changes I merged in that repo. Will set up a call with you to discuss how to send the draft id, e.g. $. from the REDIRECT button. Can you apply any updates to the functions I created with Pathum as I gather you have renamed it LINK_BUTTON now if thats correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's correct. The update should be in mosip repo as well