Skip to content

Commit

Permalink
Merge pull request #640 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat: PS-3578  suggest Username with combination of firstname+lastname
  • Loading branch information
itsvick authored Jan 23, 2025
2 parents ea77751 + 7857ae7 commit 72387ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/components/AddLeanerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
}) => {
const [schema, setSchema] = React.useState<any>();
const [uiSchema, setUiSchema] = React.useState<any>();
const [customFormData, setCustomFormData] = React.useState<any>(formData);

const [reloadProfile, setReloadProfile] = React.useState(false);
const [openModal, setOpenModal] = React.useState(false);
const [learnerFormData, setLearnerFormData] = React.useState<any>();
Expand Down Expand Up @@ -305,9 +307,22 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
}
};


const handleChange = (event: IChangeEvent<any>) => {
console.log('Form data changed:', event.formData);
if (!isEditModal) {
const { firstName, lastName } = event.formData;

if (firstName && lastName) {
event.formData.username = firstName + lastName;
} else {
event.formData.username = "";
}
setCustomFormData({ ...event.formData });

}

};


const handleError = (errors: any) => {
console.log('Form errors:', errors);
Expand Down Expand Up @@ -355,7 +370,7 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
widgets={{}}
showErrorList={true}
customFields={customFields}
formData={formData ?? undefined}
formData={customFormData ?? undefined}
>
<FormButtons
formData={formData ?? learnerFormData}
Expand Down
18 changes: 17 additions & 1 deletion src/pages/assessments/user/[userId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function AssessmentsDetails() {
);
const [assessmentList, setAssessmentList] = useState([]);
const [subject, setSubject] = useState<any>([]);
const [fullName, setFullName] = useState<any>("");

const [assessmentInfo, setAssessmentInfo] = useState<any>();
const [isLoading, setIsLoading] = useState(false);
const [userDetails, setUserDetails] = useState<any>({});
Expand Down Expand Up @@ -229,6 +231,20 @@ function AssessmentsDetails() {
});
if (response?.result?.userData) {
setUserDetails(response?.result?.userData);
let fullName = "";

if (response?.result?.userData?.firstName) {
fullName += toPascalCase(response?.result?.userData.firstName);
}

if (response?.result?.userData?.middleName) {
fullName += (fullName ? " " : "") + toPascalCase(response?.result?.userData.middleName);
}

if (response?.result?.userData?.lastName) {
fullName += (fullName ? " " : "") + toPascalCase(response?.result?.userData.lastName);
}
setFullName(fullName);
}
} catch (error) {
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
Expand Down Expand Up @@ -316,7 +332,7 @@ function AssessmentsDetails() {
}}
/>
<Typography fontSize={'22px'} m={'1rem'}>
{toPascalCase(userDetails?.name)}
{fullName}
</Typography>
</Box>

Expand Down

0 comments on commit 72387ab

Please sign in to comment.