From 06c848ff5db730ec8c7309f71a329c4d53188831 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 21 Jan 2025 15:07:41 +0530 Subject: [PATCH 1/4] Issue feat PS-3574:Add firstname , lastname gender changes of learner and facilitator --- src/components/AddFacilitator.tsx | 5 +++-- src/components/CohortFacilitatorList.tsx | 2 +- src/components/CohortLearnerList.tsx | 2 +- src/components/LearnersListItem.tsx | 6 +++--- src/pages/attendance-history.tsx | 2 +- src/pages/attendance-overview.tsx | 3 ++- src/pages/board-enrollment/index.tsx | 4 +++- src/pages/observation/[observationId]/index.tsx | 2 +- src/utils/app.constant.ts | 3 +++ 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/components/AddFacilitator.tsx b/src/components/AddFacilitator.tsx index 10aa49db..3a18c0c6 100644 --- a/src/components/AddFacilitator.tsx +++ b/src/components/AddFacilitator.tsx @@ -9,6 +9,7 @@ import { RoleId, Status, Telemetry, + fieldKeys, } from '@/utils/app.constant'; import React, { useEffect } from 'react'; import ReactGA from 'react-ga4'; @@ -221,7 +222,7 @@ const AddFacilitatorModal: React.FC = ({ const fieldSchema = schemaProperties[fieldKey]; const fieldId = fieldSchema?.fieldId; - if (fieldId === null || fieldId === 'null') { + if (fieldId === null || fieldId === 'null' || fieldKey===fieldKeys.GENDER) { if (typeof fieldValue !== 'object') { apiBody[fieldKey] = fieldValue; if (fieldKey === 'name') { @@ -355,7 +356,7 @@ const AddFacilitatorModal: React.FC = ({ telemetryFactory.interact(telemetryInteract); await sendEmail( - apiBody['name'], + apiBody['firstName'], formData?.email, password, formData?.email diff --git a/src/components/CohortFacilitatorList.tsx b/src/components/CohortFacilitatorList.tsx index 4ef617b9..0b2d9ae1 100644 --- a/src/components/CohortFacilitatorList.tsx +++ b/src/components/CohortFacilitatorList.tsx @@ -77,7 +77,7 @@ const CohortLearnerList: React.FC = ({ (field: { label: string }) => field.label === 'AGE' ); return { - name: toPascalCase(user?.name), + name: toPascalCase(user?.firstName || '') + ' ' + (user?.lastName ? toPascalCase(user.lastName) : ""), userId: user?.userId, memberStatus: user?.status, statusReason: user?.statusReason, diff --git a/src/components/CohortLearnerList.tsx b/src/components/CohortLearnerList.tsx index 40f921a8..e486be31 100644 --- a/src/components/CohortLearnerList.tsx +++ b/src/components/CohortLearnerList.tsx @@ -67,7 +67,7 @@ const CohortLearnerList: React.FC = ({ (field: { label: string }) => field.label === 'AGE' ); return { - name: toPascalCase(user?.name), + name: toPascalCase(user?.firstName || '') + ' ' + (user?.lastName ? toPascalCase(user.lastName) : ""), userId: user?.userId, memberStatus: user?.status, statusReason: user?.statusReason, diff --git a/src/components/LearnersListItem.tsx b/src/components/LearnersListItem.tsx index 07e52162..72830cbd 100644 --- a/src/components/LearnersListItem.tsx +++ b/src/components/LearnersListItem.tsx @@ -408,15 +408,15 @@ const LearnersListItem: React.FC = ({ const stringAvatar = (name: string) => { if (name) { const nameParts = name.split(' '); - + return { children: nameParts.length === 1 ? nameParts[0][0] - : `${nameParts[0][0]}${nameParts[1][0]}`, + : `${nameParts[0][0]}${nameParts[1]?.[0] || ''}`, }; } - + return ''; }; diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index 7b3ebed8..0e361376 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -241,7 +241,7 @@ const UserAttendanceHistory = () => { const nameUserIdArray = resp ?.map((entry: any) => ({ userId: entry.userId, - name: toPascalCase(entry.name), + name: toPascalCase(entry?.firstName || '') + ' ' + (entry?.lastName ? toPascalCase(entry.lastName) : ""), memberStatus: entry.status, createdAt: entry.createdAt, updatedAt: entry.updatedAt, diff --git a/src/pages/attendance-overview.tsx b/src/pages/attendance-overview.tsx index 56557f54..2cbc0568 100644 --- a/src/pages/attendance-overview.tsx +++ b/src/pages/attendance-overview.tsx @@ -213,7 +213,8 @@ const AttendanceOverview: React.FC = () => { if (resp) { const nameUserIdArray = resp?.map((entry: any) => ({ userId: entry.userId, - name: toPascalCase(entry.name), + name: toPascalCase(entry?.firstName || '') + ' ' + (entry?.lastName ? toPascalCase(entry.lastName) : ""), + memberStatus: entry.status, })); if (nameUserIdArray) { diff --git a/src/pages/board-enrollment/index.tsx b/src/pages/board-enrollment/index.tsx index 09165117..793af7c6 100644 --- a/src/pages/board-enrollment/index.tsx +++ b/src/pages/board-enrollment/index.tsx @@ -237,7 +237,9 @@ const BoardEnrollment = () => { return members.map((entry: any) => ({ userId: entry.userId, cohortMembershipId: entry.cohortMembershipId, - name: toPascalCase(entry.name), + name: toPascalCase(entry?.firstName || '') + ' ' + (entry?.lastName ? toPascalCase(entry.lastName) : ""), + + memberStatus: entry.status, statusReason: entry.statusReason, customField: entry.customField, diff --git a/src/pages/observation/[observationId]/index.tsx b/src/pages/observation/[observationId]/index.tsx index 171b1fc4..aefb3d75 100644 --- a/src/pages/observation/[observationId]/index.tsx +++ b/src/pages/observation/[observationId]/index.tsx @@ -338,7 +338,7 @@ setFilteredEntityData(result) (field: { label: string }) => field.label === 'AGE' ); return { - name: toPascalCase(user?.name), + name: toPascalCase(user?.firstName || '') + ' ' + (user?.lastName ? toPascalCase(user.lastName) : ""), userId: user?.userId, memberStatus: user?.status, statusReason: user?.statusReason, diff --git a/src/utils/app.constant.ts b/src/utils/app.constant.ts index 65c81eaf..8eb29c6a 100644 --- a/src/utils/app.constant.ts +++ b/src/utils/app.constant.ts @@ -255,3 +255,6 @@ export enum sessionType { PLANNED = 'planned', EXTRA = 'extra', } +export enum fieldKeys { + GENDER="gender" +} \ No newline at end of file From 7bad0fff248e634d83a76850448010b9a11dd1dc Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 21 Jan 2025 18:22:31 +0530 Subject: [PATCH 2/4] Issue feat : update pr --- src/pages/assessments/index.tsx | 3 +-- src/pages/observation/[observationId]/index.tsx | 2 +- src/utils/Interfaces.ts | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/assessments/index.tsx b/src/pages/assessments/index.tsx index c6509bcc..78f5b56a 100644 --- a/src/pages/assessments/index.tsx +++ b/src/pages/assessments/index.tsx @@ -117,8 +117,7 @@ const Assessments = () => { if (resp) { const userDetails = resp.map((user: any) => ({ ...user, - name: toPascalCase(user.name), - userId: user.userId, + name: toPascalCase(user?.firstName || '') + ' ' + (user?.lastName ? toPascalCase(user.lastName) : ""), userId: user.userId, })); setCohortMembers(userDetails); } diff --git a/src/pages/observation/[observationId]/index.tsx b/src/pages/observation/[observationId]/index.tsx index aefb3d75..2bc95a6d 100644 --- a/src/pages/observation/[observationId]/index.tsx +++ b/src/pages/observation/[observationId]/index.tsx @@ -313,7 +313,7 @@ setFilteredEntityData(result) const filters = { cohortId: selectedCohort, } as CohortMemberList['filters']; - if (searchInput !== '') filters.name = searchInput; + if (searchInput !== '') filters.firstName = searchInput; //const limit=limit; let response; if (entity === ObservationEntityType?.LEARNER) { diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index a61a7fb4..30c1a781 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -96,6 +96,7 @@ export interface CohortMemberList { role?: string; status?: string[]; name?: string | undefined; + firstName?:string }; includeArchived?: boolean; } From a8d3506414eece61bcdad8adc2a3be35921f8664 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 21 Jan 2025 19:01:04 +0530 Subject: [PATCH 3/4] update pr --- src/components/AddLeanerModal.tsx | 2 +- src/components/GeneratedSchemas.ts | 5 +++++ src/utils/Interfaces.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/AddLeanerModal.tsx b/src/components/AddLeanerModal.tsx index eee8acd1..159528e9 100644 --- a/src/components/AddLeanerModal.tsx +++ b/src/components/AddLeanerModal.tsx @@ -258,7 +258,7 @@ const AddLearnerModal: React.FC = ({ username, password, userEmail, - apiBody['name'] + apiBody['firstName'] ); } else { showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error'); diff --git a/src/components/GeneratedSchemas.ts b/src/components/GeneratedSchemas.ts index 8343d4d2..950ad422 100644 --- a/src/components/GeneratedSchemas.ts +++ b/src/components/GeneratedSchemas.ts @@ -115,6 +115,11 @@ export const GenerateSchemaAndUiSchema = ( })); fieldUiSchema['ui:widget'] = 'CustomRadioWidget'; break; + case 'date': + fieldSchema.type = 'string'; + fieldSchema.format = 'date'; + fieldUiSchema['ui:widget'] = 'date'; + break; default: break; } diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index 30c1a781..5f76cbb2 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -433,7 +433,7 @@ export interface FieldOption { export interface Field { name: string; - type: 'text' | 'numeric' | 'drop_down' | 'checkbox' | 'radio' | 'email'; + type: 'text' | 'numeric' | 'drop_down' | 'checkbox' | 'radio' | 'email' | 'date'; label: string; order: string; coreField: number; From e1faffc826b8f92e19645d0aa3c7505740741948 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Wed, 22 Jan 2025 12:56:51 +0530 Subject: [PATCH 4/4] update pr --- src/components/AddLeanerModal.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/AddLeanerModal.tsx b/src/components/AddLeanerModal.tsx index 159528e9..1325d76b 100644 --- a/src/components/AddLeanerModal.tsx +++ b/src/components/AddLeanerModal.tsx @@ -266,8 +266,11 @@ const AddLearnerModal: React.FC = ({ } } } catch (error: any) { - if (error?.response?.data?.params?.err === 'User already exist.') { - showToastMessage(error?.response?.data?.params?.err, 'error'); + if (error?.response?.data?.params?.err === "User already exist.") { + showToastMessage(error?.response?.data?.params?.err, "error"); + } + else if (error?.response?.data?.params?.errmsg === "Email already exists") { + showToastMessage(error?.response?.data?.params?.errmsg, "error"); } else { showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error'); }