-
Notifications
You must be signed in to change notification settings - Fork 73
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/ocrvs 7978/qr reader #8196
base: develop
Are you sure you want to change the base?
Changes from 49 commits
7330f51
4c01e21
2801173
01718e5
322dc1f
d5cfb67
2a99bf9
4112f58
bda1f8f
952dbee
29076fa
80f5d99
5037cf3
c214ce8
8d60581
9879729
4ec4f56
4350011
e892be2
d298fd9
9b41a69
4399fad
f994875
61fbc7e
41bfb99
91062cd
425ee00
354bc8e
5e9ecb7
fb482ef
290228a
a3d468b
f134c23
1bc9ea0
28edf58
d2f7beb
841dbad
d4c1c57
400b303
70dd226
892cc6a
7c55040
6589f9e
67fa6d5
4f3e8e2
3ce87c9
0723fb6
0996d0a
745a2d9
1b6b5f6
271fdc9
17145de
61c48f6
945cacd
c7b1ce9
633e8fd
57d0318
82b4601
7e0dc81
02c283f
f2368f5
d6ea209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @naftis this is the newly added |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
import React from 'react' | ||
import { BannerType, IFormFieldValue } from '@client/forms' | ||
import { useIntl } from 'react-intl' | ||
import { Pill, Banner, Icon, Button, Text } from '@opencrvs/components' | ||
import { messages } from '@client/i18n/messages/views/id-verification-banner' | ||
|
||
export const IDVerificationBanner = ({ | ||
type, | ||
idFieldName, | ||
setFieldValue | ||
}: { | ||
type: BannerType | ||
setFieldValue: (name: string, value: IFormFieldValue) => void | ||
idFieldName: string | ||
}) => { | ||
const intl = useIntl() | ||
const handleReset = () => { | ||
setFieldValue(idFieldName, '') | ||
setFieldValue('verified', '') | ||
} | ||
if (type === 'pending') { | ||
return ( | ||
<Banner.Container> | ||
<Banner.Header type="pending"> | ||
<Pill | ||
type="pending" | ||
size="small" | ||
pillTheme="dark" | ||
label={ | ||
<> | ||
<Icon name="QrCode" size="small" /> | ||
{intl.formatMessage(messages.pending.title)} | ||
</> | ||
} | ||
/> | ||
<Icon name="Clock" size="large" /> | ||
</Banner.Header> | ||
<Banner.Body> | ||
<Text variant="reg16" element="span"> | ||
{intl.formatMessage(messages.pending.description)} | ||
</Text> | ||
</Banner.Body> | ||
<Banner.Footer justifyContent="flex-end"> | ||
<Button type="secondary" onClick={handleReset}> | ||
{intl.formatMessage(messages.actions.reset)} | ||
</Button> | ||
</Banner.Footer> | ||
</Banner.Container> | ||
) | ||
} else if (type === 'verified') { | ||
return ( | ||
<Banner.Container> | ||
<Banner.Header type="default"> | ||
<Pill | ||
type="default" | ||
size="small" | ||
pillTheme="dark" | ||
label={ | ||
<> | ||
<Icon name="CircleWavyCheck" size="small" /> | ||
{intl.formatMessage(messages.success.title)} | ||
</> | ||
} | ||
/> | ||
<Icon name="FilledCheck" size="large" /> | ||
</Banner.Header> | ||
<Banner.Body> | ||
<Text variant="reg16" element="span"> | ||
{intl.formatMessage(messages.success.description)} | ||
</Text> | ||
</Banner.Body> | ||
<Banner.Footer justifyContent="flex-end"> | ||
<Button type="secondary" onClick={handleReset}> | ||
{intl.formatMessage(messages.actions.revoke)} | ||
</Button> | ||
</Banner.Footer> | ||
</Banner.Container> | ||
) | ||
} else if (type === 'failed') { | ||
return ( | ||
<Banner.Container> | ||
<Banner.Header type="inactive"> | ||
<Pill | ||
type="inactive" | ||
size="small" | ||
pillTheme="dark" | ||
label={ | ||
<> | ||
<Icon name="X" size="small" /> | ||
{intl.formatMessage(messages.failed.title)} | ||
</> | ||
} | ||
/> | ||
<Icon name="Close" size="large" /> | ||
</Banner.Header> | ||
<Banner.Body> | ||
<Text variant="reg16" element="span"> | ||
{intl.formatMessage(messages.failed.description)} | ||
</Text> | ||
</Banner.Body> | ||
<Banner.Footer justifyContent="flex-end"> | ||
<Button type="secondary" onClick={handleReset}> | ||
{intl.formatMessage(messages.actions.reset)} | ||
</Button> | ||
</Banner.Footer> | ||
</Banner.Container> | ||
) | ||
} else return null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* OpenCRVS is also distributed under the terms of the Civil Registration | ||
* & Healthcare Disclaimer located at http://opencrvs.org/license. | ||
* | ||
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. | ||
*/ | ||
import React from 'react' | ||
import { QRReader } from '@opencrvs/components/src/IDReader/readers/QRReader/QRReader' | ||
import { | ||
IFormData, | ||
IFormField, | ||
IFormFieldValue, | ||
IFormSectionData, | ||
Ii18nIDReaderFormField, | ||
Ii18nRedirectFormField, | ||
ReaderType | ||
} from '@client/forms' | ||
import { RedirectField } from './Redirect' | ||
import { | ||
internationaliseFieldObject, | ||
isReaderQR, | ||
isReaderRedirect | ||
} from '@client/forms/utils' | ||
import { | ||
messages, | ||
tutorialMessages | ||
} from '@client/i18n/messages/views/qr-reader' | ||
import { useIntl } from 'react-intl' | ||
|
||
interface ReaderGeneratorProps { | ||
readers: ReaderType[] | ||
fields: IFormField[] | ||
field: Ii18nIDReaderFormField | ||
form: IFormSectionData | ||
draft: IFormData | ||
setFieldValue: (name: string, value: IFormFieldValue) => void | ||
} | ||
export const ReaderGenerator = ({ | ||
readers, | ||
field, | ||
form, | ||
draft, | ||
fields, | ||
setFieldValue | ||
}: ReaderGeneratorProps) => { | ||
const intl = useIntl() | ||
return ( | ||
<> | ||
{readers.map((reader) => { | ||
const { type } = reader | ||
if (isReaderQR(reader)) { | ||
return ( | ||
<QRReader | ||
key={type} | ||
labels={{ | ||
button: intl.formatMessage(messages.button), | ||
scannerDialogSupportingCopy: intl.formatMessage( | ||
messages.scannerDialogSupportingCopy | ||
), | ||
tutorial: { | ||
cameraCleanliness: intl.formatMessage( | ||
tutorialMessages.cameraCleanliness | ||
), | ||
distance: intl.formatMessage(tutorialMessages.distance), | ||
lightBalance: intl.formatMessage( | ||
tutorialMessages.lightBalance | ||
) | ||
} | ||
}} | ||
onScan={(data) => { | ||
setFieldValue(field.name, data) | ||
setFieldValue('verified', 'pending') | ||
}} | ||
onError={(error) => console.error(error)} | ||
/> | ||
) | ||
} else if (isReaderRedirect(reader)) { | ||
return ( | ||
<RedirectField | ||
key={type} | ||
form={form} | ||
draft={draft} | ||
fieldDefinition={ | ||
internationaliseFieldObject( | ||
intl, | ||
reader | ||
) as Ii18nRedirectFormField | ||
} | ||
fields={fields} | ||
setFieldValue={setFieldValue} | ||
isDisabled={false} | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the redirect inside the reader and not just a generic form field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @naftis good point. Well, in the view component, e-signet button is inside the id-reader component Thought it would be better in code as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah makes sense. Should we consider renaming the field to a LINK_BUTTON or something? Got a bit confused as it isn't necessarily a redirect anymore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, thanks @naftis. I am on it |
||
) | ||
} else return null | ||
})} | ||
</> | ||
) | ||
} |
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.
This is form field component