Skip to content

Commit 530e9ff

Browse files
authored
Merge pull request #903 from jembi/revert-902-revert-899-updated-security-questions
Fixes for user creation and on-boarding flow
2 parents 700cb69 + afd9442 commit 530e9ff

File tree

29 files changed

+460
-194
lines changed

29 files changed

+460
-194
lines changed
1.08 KB
Binary file not shown.
1.13 KB
Binary file not shown.
41 Bytes
Binary file not shown.

packages/components/src/components/icons/CrossLarge.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react'
22

33
export const CrossLarge = (props: React.HTMLAttributes<SVGElement>) => (
44
<svg width={20} height={20} {...props}>
5-
<title>{'F868D4F5-684F-436B-9D80-2FF60C005AE7'}</title>
65
<g transform="rotate(-45 8.194 14.284)" fill="#FFF" fillRule="nonzero">
76
<rect x={11} width={3} height={25} rx={1.5} />
87
<rect

packages/components/src/components/interface/FloatingNotification.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ export class FloatingNotification extends React.Component<IProps> {
8888
{type === NOTIFICATION_TYPE.ERROR && <Error />}
8989
<NotificationMessage>{children}</NotificationMessage>
9090
</Content>
91-
<Cancel onClick={callback} className={callback ? ' clickable' : ''}>
91+
<Cancel
92+
id={`${id}Cancel`}
93+
onClick={callback}
94+
className={callback ? ' clickable' : ''}
95+
>
9296
<CrossLarge />
9397
</Cancel>
9498
</NotificationContainer>

packages/register/src/components/Notification.test.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,48 @@ describe('when app notifies the user', () => {
135135
})
136136
})
137137
})
138+
139+
describe('When user submits a form', () => {
140+
describe('In case of successful submission', () => {
141+
beforeEach(() => {
142+
const action = actions.showSubmitFormSuccessToast('userFormSuccess')
143+
store.dispatch(action)
144+
app.update()
145+
})
146+
147+
it('shows submit success toast', () => {
148+
expect(app.find('#submissionSuccessToast').hostNodes()).toHaveLength(1)
149+
})
150+
151+
it('clicking cancel button should hide the toast', () => {
152+
app
153+
.find('#submissionSuccessToastCancel')
154+
.hostNodes()
155+
.simulate('click')
156+
app.update()
157+
expect(store.getState().notification.submitFormSuccessToast).toBe(null)
158+
})
159+
})
160+
161+
describe('In case of failed submission', () => {
162+
beforeEach(() => {
163+
const action = actions.showSubmitFormErrorToast('userFormFail')
164+
store.dispatch(action)
165+
app.update()
166+
})
167+
168+
it('shows submit fail toast', () => {
169+
expect(app.find('#submissionErrorToast').hostNodes()).toHaveLength(1)
170+
})
171+
172+
it('clicking cancel button should hide the toast', () => {
173+
app
174+
.find('#submissionErrorToastCancel')
175+
.hostNodes()
176+
.simulate('click')
177+
app.update()
178+
expect(store.getState().notification.submitFormErrorToast).toBe(null)
179+
})
180+
})
181+
})
138182
})

packages/register/src/components/Notification.tsx

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import { getLanguage } from '@opencrvs/register/src/i18n/selectors'
88
import { IStoreState } from '@opencrvs/register/src/store'
99
import {
1010
Notification,
11-
NOTIFICATION_TYPE
11+
NOTIFICATION_TYPE,
12+
FloatingNotification
1213
} from '@opencrvs/components/lib/interface'
1314
import {
1415
hideNewContentAvailableNotification,
1516
hideBackgroundSyncedNotification,
1617
hideConfigurationErrorNotification,
17-
toggleDraftSavedNotification
18+
toggleDraftSavedNotification,
19+
hideSubmitFormSuccessToast,
20+
hideSubmitFormErrorToast
1821
} from '@register/notification/actions'
1922

2023
type NotificationProps = {
@@ -25,12 +28,16 @@ type NotificationProps = {
2528
syncCount: number
2629
waitingSW: ServiceWorker | null
2730
saveDraftClicked: boolean
31+
submitFormSuccessToast: string | null
32+
submitFormErrorToast: string | null
2833
}
2934

3035
type DispatchProps = {
3136
hideNewContentAvailableNotification: typeof hideNewContentAvailableNotification
3237
hideBackgroundSyncedNotification: typeof hideBackgroundSyncedNotification
3338
hideConfigurationErrorNotification: typeof hideConfigurationErrorNotification
39+
hideSubmitFormSuccessToast: typeof hideSubmitFormSuccessToast
40+
hideSubmitFormErrorToast: typeof hideSubmitFormErrorToast
3441
toggleDraftSavedNotification: typeof toggleDraftSavedNotification
3542
}
3643

@@ -55,6 +62,18 @@ export const messages: {
5562
defaultMessage: 'Your draft has been saved',
5663
description:
5764
'The message that appears in notification when save drafts button is clicked'
65+
},
66+
userFormSuccess: {
67+
id: 'register.notification.userFormSuccess',
68+
defaultMessage: 'New user created',
69+
description:
70+
'The message that appears in notification when a new user is created'
71+
},
72+
userFormFail: {
73+
id: 'register.notification.userFormFail',
74+
defaultMessage: 'Sorry! Something went wrong',
75+
description:
76+
'The message that appears in notification when a new user creation fails'
5877
}
5978
})
6079

@@ -84,6 +103,14 @@ class Component extends React.Component<
84103
this.props.toggleDraftSavedNotification()
85104
}
86105

106+
hideSubmitFormSuccessToast = () => {
107+
this.props.hideSubmitFormSuccessToast()
108+
}
109+
110+
hideSubmitFormErrorToast = () => {
111+
this.props.hideSubmitFormErrorToast()
112+
}
113+
87114
render() {
88115
const {
89116
children,
@@ -92,7 +119,9 @@ class Component extends React.Component<
92119
configurationErrorVisible,
93120
syncCount,
94121
intl,
95-
saveDraftClicked
122+
saveDraftClicked,
123+
submitFormSuccessToast,
124+
submitFormErrorToast
96125
} = this.props
97126

98127
return (
@@ -138,6 +167,29 @@ class Component extends React.Component<
138167
{intl.formatMessage(messages.draftsSaved)}
139168
</Notification>
140169
)}
170+
171+
{submitFormSuccessToast && (
172+
<FloatingNotification
173+
id="submissionSuccessToast"
174+
show={Boolean(submitFormSuccessToast)}
175+
type={NOTIFICATION_TYPE.SUCCESS}
176+
callback={this.hideSubmitFormSuccessToast}
177+
>
178+
{intl.formatMessage(messages[submitFormSuccessToast])}
179+
</FloatingNotification>
180+
)}
181+
182+
{submitFormErrorToast && (
183+
<FloatingNotification
184+
id="submissionErrorToast"
185+
show={Boolean(submitFormErrorToast)}
186+
type={NOTIFICATION_TYPE.ERROR}
187+
callback={this.hideSubmitFormErrorToast}
188+
>
189+
{intl.formatMessage(messages[submitFormErrorToast])}
190+
</FloatingNotification>
191+
)}
192+
141193
{/* More notification types can be added here */}
142194
</div>
143195
)
@@ -153,7 +205,9 @@ const mapStateToProps = (store: IStoreState) => {
153205
configurationErrorVisible: store.notification.configurationErrorVisible,
154206
syncCount: store.notification.syncCount,
155207
waitingSW: store.notification.waitingSW,
156-
saveDraftClicked: store.notification.saveDraftClicked
208+
saveDraftClicked: store.notification.saveDraftClicked,
209+
submitFormSuccessToast: store.notification.submitFormSuccessToast,
210+
submitFormErrorToast: store.notification.submitFormErrorToast
157211
}
158212
}
159213

@@ -164,6 +218,8 @@ export const NotificationComponent = withRouter(
164218
hideNewContentAvailableNotification,
165219
hideBackgroundSyncedNotification,
166220
hideConfigurationErrorNotification,
221+
hideSubmitFormSuccessToast,
222+
hideSubmitFormErrorToast,
167223
toggleDraftSavedNotification
168224
}
169225
)(injectIntl(Component))

packages/register/src/components/form/SearchField.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,17 @@ class SearchFieldClass extends React.Component<IFullProps, IState> {
191191
const placeHolderText = intl.formatMessage(messages.placeHolderText)
192192
const locations: ILocation[] = [
193193
{
194-
id: '79776844-b606-40e9-8358-7d82147f702a',
194+
id: '454b4008-7ffd-4808-9ed4-4613d4047021',
195195
name: 'Moktarpur Union Parishad',
196196
detailedLocation: 'Moktarpur, Kaliganj, Gazipur, Dhaka'
197197
},
198198
{
199-
id: 'd8f5e899-0461-4d58-943f-3a980733a8d3',
199+
id: '759a0452-ef5b-4853-95d0-2f231c22e230',
200200
name: 'Amdia Union Parishad',
201201
detailedLocation: 'Amdia, Narsingdi Sadar, Narsingdi, Dhaka'
202202
},
203203
{
204-
id: '3e7a3524-e0d2-4a5b-959a-845efbe1fca8',
204+
id: '4140ccc2-a5ed-4008-bf13-96ddbc15eb6c',
205205
name: 'Bhurungamari Union Parishad',
206206
detailedLocation: 'Bhurungamari, Bhurungamari, Kurigram, Rangpur'
207207
}

packages/register/src/i18n/locales/bn.ts

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -517,20 +517,22 @@ export const BENGALI_STATE: ILanguage = {
517517
'register.form.modal.submitDescription':
518518
'“সাবমিট” ট্যাব-এ ক্লিক করে আপনি নিশ্চিত করছেন যে উপরোক্ত তথ্য বিবরনী গুলো সঠিক এবং পর্যালোচিত যা সিভিল রেজিস্ট্রেশন কর্তৃপক্ষের সাথে শেয়ার করা যেতে পারে।',
519519
'register.form.modal.submitButton': 'জমা দিন',
520-
'register.home.header.FIELD_AGENT': 'মাঠকর্মী',
521-
'register.home.header.REGISTRATION_CLERK': 'নিবন্ধন ক্লার্ক',
522-
'register.home.header.LOCAL_REGISTRAR': 'নিবন্ধক',
523-
'register.home.header.DISTRICT_REGISTRAR': 'জেলা নিবন্ধক',
524-
'register.home.header.STATE_REGISTRAR': 'অঞ্চল নিবন্ধক',
525-
'register.home.header.NATIONAL_REGISTRAR': 'জাতীয় নিবন্ধক',
526-
'register.home.header.LOCAL_SYSTEM_NATIONAL': 'সিস্টেম অ্যাডমিন (জাতীয়)',
527-
'register.home.header.PERFORMANCE_OVERSIGHT': 'কর্মক্ষমতা তত্ত্বাবধান',
528-
'register.home.header.PERFORMANCE_MANAGEMENT': 'কর্মক্ষমতা ব্যবস্থাপনা',
520+
'register.home.header.fieldAgent': 'মাঠকর্মী',
521+
'register.home.header.registrationClerk': 'নিবন্ধন ক্লার্ক',
522+
'register.home.header.localRegistrar': 'নিবন্ধক',
523+
'register.home.header.districtRegistrar': 'জেলা নিবন্ধক',
524+
'register.home.header.stateRegistrar': 'অঞ্চল নিবন্ধক',
525+
'register.home.header.nationalRegistrar': 'জাতীয় নিবন্ধক',
526+
'register.home.header.nationalSystemAdmin': 'সিস্টেম অ্যাডমিন (জাতীয়)',
527+
'register.home.header.performanceOversight': 'কর্মক্ষমতা তত্ত্বাবধান',
528+
'register.home.header.performanceManagement': 'কর্মক্ষমতা ব্যবস্থাপনা',
529529
'register.notification.newContentAvailable':
530530
'কিছু তথ্য হালনাগাদ করা হয়েছে, রিফ্রেশ করতে এখানে ক্লিক করুন।',
531531
'register.notification.declarationsSynced':
532532
'ইন্টারনেট সংযোগ ফিরে আসায় আমরা {syncCount} টি নতুন জন্ম ঘোষণা সিঙ্ক করেছি',
533533
'register.notification.draftsSaved': 'আপনার খসড়া সংরক্ষণ করা হয়েছে',
534+
'register.notification.userFormSuccess': 'নতুন ব্যবহারকারী তৈরি করা হয়েছে',
535+
'register.notification.userFormFail': 'দুঃখিত কিছু ভুল হয়েছে',
534536
'register.savedRegistration.online.title': 'তথ্য বিবরনী জমাদান',
535537
'register.rejectionTitle': 'Application rejected',
536538
'register.completeRegistration.online.title': 'নিবন্ধন সম্পন্ন',
@@ -1064,27 +1066,27 @@ export const BENGALI_STATE: ILanguage = {
10641066
'register.sysAdminHome.users': 'ইউজারস',
10651067
'register.sysAdminHome.devices': 'ডিভাইসেস',
10661068
'register.sysAdminHome.config': 'কনফিগ',
1067-
'register.home.header.LOCAL_SYSTEM_ADMIN': 'সিস এডমিন ',
1069+
'register.home.header.localSystemAdmin': 'সিস এডমিন ',
10681070
'register.home.header.systemTitle': 'সিস্টেম',
10691071
'register.home.header.settingsTitle': 'সেটিংস',
10701072
'register.home.header.helpTitle': 'সাহায্য',
10711073
'register.home.header.logoutTitle': 'লগআউট',
10721074
'userSetup.landing.title': 'OpenCRVS এ স্বাগতম',
10731075
'userSetup.landing.instruction':
10741076
'আপনি আপনার অ্যাকাউন্ট সেট আপ সম্পূর্ণ করার মাত্র কয়েক পদক্ষেপ দূরে।',
1075-
'userSetup.type.HOSPITAL': 'হাসপাতাল',
1076-
'userSetup.type.CHA': 'CHA',
1077-
'userSetup.type.ENTREPENEUR': 'উদ্যোক্তা',
1078-
'userSetup.type.DATA_ENTRY_CLERK': 'ডাটা এন্ট্রি কেরানি',
1079-
'userSetup.type.SECRETARY': 'সচিব',
1080-
'userSetup.type.CHAIRMAN': 'চেয়ারম্যান',
1081-
'userSetup.type.MAYOR': 'মেয়র',
1082-
'userSetup.type.LOCAL_SYSTEM_ADMIN': 'সিস্টেম অ্যাডমিন (স্থানীয়)',
1083-
'userSetup.type.NATIONAL_SYSTEM_ADMIN': 'সিস্টেম অ্যাডমিন (জাতীয়)',
1084-
'userSetup.type.CABINET_DIVISION': 'মন্ত্রিপরিষদ বিভাগ',
1085-
'userSetup.type.HEALTH_DIVISION': 'স্বাস্থ্য বিভাগ',
1086-
'userSetup.type.ORG_DIVISION': 'ORG বিভাগ',
1087-
'userSetup.type.BBS': 'পরিসংখ্যান ব্যুরো বাংলাদেশ',
1077+
'userSetup.type.hospital': 'হাসপাতাল',
1078+
'userSetup.type.cha': 'CHA',
1079+
'userSetup.type.entrepeneur': 'উদ্যোক্তা',
1080+
'userSetup.type.dataEntryClerk': 'ডাটা এন্ট্রি কেরানি',
1081+
'userSetup.type.secretary': 'সচিব',
1082+
'userSetup.type.chairman': 'চেয়ারম্যান',
1083+
'userSetup.type.mayor': 'মেয়র',
1084+
'userSetup.type.localSystemAdmin': 'সিস্টেম অ্যাডমিন (স্থানীয়)',
1085+
'userSetup.type.nationalSystemAdmin': 'সিস্টেম অ্যাডমিন (জাতীয়)',
1086+
'userSetup.type.cabinetDivision': 'মন্ত্রিপরিষদ বিভাগ',
1087+
'userSetup.type.healthDivision': 'স্বাস্থ্য বিভাগ',
1088+
'userSetup.type.orgDivision': 'ORG বিভাগ',
1089+
'userSetup.type.bbs': 'পরিসংখ্যান ব্যুরো বাংলাদেশ',
10881090
'userSetup.landing.button.start': 'শুরু',
10891091
'user.form.name': 'ব্যবহারকারী',
10901092
'user.title.create': 'নতুন ব্যবহারকারী তৈরি',
@@ -1114,24 +1116,25 @@ export const BENGALI_STATE: ILanguage = {
11141116
'register.securityquestion.securityQuestionLabel':
11151117
'নিরাপত্তা প্রশ্ন {count}',
11161118
'table.column.header.name': 'নাম',
1119+
'table.column.header.username': 'ব্যবহারকারীর নাম',
11171120
'table.column.header.role': 'দায়িত্ব',
11181121
'table.column.header.type': 'ধরন',
11191122
'table.column.header.status': 'অবস্থা',
11201123
'register.securityquestion.answer': 'উত্তর',
1121-
'register.userSetup.securityQuestions.BIRTH_TOWN':
1124+
'register.userSetup.securityQuestions.birthTown':
11221125
'কোন শহরে আপনার জন্ম হয়?',
1123-
'register.userSetup.securityQuestions.FIRST_SCHOOL':
1124-
'আপনার প্রথম স্কুলের নাম কি?',
1125-
'register.userSetup.securityQuestions.MOTHER_NICK_NAME':
1126-
'আপনার মা এর ডাক নাম কি?',
1127-
'register.userSetup.securityQuestions.FATHER_NICK_NAME':
1128-
'আপনার বাবার ডাক নাম কি?',
1129-
'register.userSetup.securityQuestions.FAVORITE_TEACHER':
1130-
'আপনার প্রিয় শিক্ষক কে?',
1131-
'register.userSetup.securityQuestions.FAVORITE_MOVIE':
1126+
'register.userSetup.securityQuestions.hightSchool':
1127+
'আপনার উচ্চ বিদ্যালয় নাম কি?',
1128+
'register.userSetup.securityQuestions.motherName': 'আপনার মা এর নাম কি?',
1129+
'register.userSetup.securityQuestions.favoriteTeacher':
1130+
'আপনার প্রিয় স্কুল শিক্ষকের নাম কি?',
1131+
'register.userSetup.securityQuestions.favoriteMovie':
11321132
'আপনার প্রিয় সিনেমা কি?',
1133-
'register.userSetup.securityQuestions.FAVORITE_COLOR':
1134-
'আপনার প্রিয় রং কি?',
1133+
'register.userSetup.securityQuestions.favoriteSong': 'আপনার প্রিয় গান কি?',
1134+
'register.userSetup.securityQuestions.favoriteFood':
1135+
'আপনার প্রিয় খাদ্য কি?',
1136+
'register.userSetup.securityQuestions.firstChildName':
1137+
'আপনার প্রথম সন্তানের নাম কি?',
11351138
'formFields.SearchField.modalTitle': `{fieldName, select, registrationOffice {নির্ধারিত নিবন্ধন অফিস}}`,
11361139
'formFields.SearchField.modalCancel': 'বাতিল',
11371140
'formFields.SearchField.modalSelect': 'নির্বাচন ',

0 commit comments

Comments
 (0)