Skip to content

Commit

Permalink
Merge pull request #49 from suvarnakale/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1250 feat: on adding or deleting user list updated
  • Loading branch information
itsvick authored Jul 26, 2024
2 parents e72f86f + 6425d6d commit 6a3eb2b
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 97 deletions.
16 changes: 13 additions & 3 deletions src/components/AddLeanerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ import { showToastMessage } from './Toastify';
interface AddLearnerModalProps {
open: boolean;
onClose: () => void;
onLearnerAdded: () => void;
}
const AddLearnerModal: React.FC<AddLearnerModalProps> = ({ open, onClose }) => {
const AddLearnerModal: React.FC<AddLearnerModalProps> = ({
open,
onClose,
onLearnerAdded,
}) => {
const [schema, setSchema] = React.useState<any>();
const [uiSchema, setUiSchema] = React.useState<any>();
const [credentials, setCredentials] = React.useState({
Expand Down Expand Up @@ -148,8 +153,13 @@ const AddLearnerModal: React.FC<AddLearnerModalProps> = ({ open, onClose }) => {
console.log(apiBody);

const response = await createUser(apiBody);
onClose();
showToastMessage(t('COMMON.LEARNER_CREATED_SUCCESSFULLY'), 'success');
if (response) {
onClose();
onLearnerAdded();
showToastMessage(t('COMMON.LEARNER_CREATED_SUCCESSFULLY'), 'success');
} else {
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'success');
}
};

const handleChange = (event: IChangeEvent<any>) => {
Expand Down
10 changes: 8 additions & 2 deletions src/components/CohortFacilitatorList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React, { useEffect } from 'react';
import { getMyCohortFacilitatorList, getMyCohortMemberList } from '@/services/MyClassDetailsService';
import {
getMyCohortFacilitatorList,
getMyCohortMemberList,
} from '@/services/MyClassDetailsService';
import {
capitalizeEachWord,
getFieldValue,
Expand Down Expand Up @@ -49,7 +52,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
});

console.log(response);

const resp = response?.result?.userDetails;

if (resp) {
Expand Down Expand Up @@ -78,6 +81,8 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
getCohortMemberList();
}, [cohortId, reloadState]);

const onDelete = () => {};

console.log('userData', userData);
return (
<div>
Expand All @@ -98,6 +103,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
reloadState={reloadState}
setReloadState={setReloadState}
showMiniProfile={false}
onLearnerDelete={onDelete}
/>
);
})}
Expand Down
15 changes: 12 additions & 3 deletions src/components/CohortLearnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ interface CohortLearnerListProp {
cohortId: any;
reloadState: boolean;
setReloadState: React.Dispatch<React.SetStateAction<boolean>>;
isLearnerAdded: boolean;
}

const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
cohortId,
reloadState,
setReloadState,
isLearnerAdded,
}) => {
const [loading, setLoading] = React.useState<boolean>(false);
const [userData, setUserData] = React.useState<UserDataProps[]>();
const [isLearnerDeleted, setIsLearnerDeleted] =
React.useState<boolean>(false);

const { t } = useTranslation();

Expand Down Expand Up @@ -73,7 +77,11 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
}
};
getCohortMemberList();
}, [cohortId, reloadState]);
}, [cohortId, reloadState, isLearnerAdded, isLearnerDeleted]);

const handleLearnerDelete = () => {
setIsLearnerDeleted(true);
};

console.log('userData', userData);
return (
Expand All @@ -85,7 +93,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
{userData?.map((data: any) => {
return (
<LearnersListItem
type={Role.STUDENT}
type={Role.STUDENT}
key={data.userId}
userId={data.userId}
learnerName={data.name}
Expand All @@ -95,7 +103,8 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
statusReason={data.statusReason}
reloadState={reloadState}
setReloadState={setReloadState}
showMiniProfile= {true}
showMiniProfile={true}
onLearnerDelete={handleLearnerDelete}
/>
);
})}
Expand Down
4 changes: 3 additions & 1 deletion src/components/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ interface DeleteUserModalProps {
userId: string;
open: boolean;
onClose: () => void;
onUserDelete: () => void;
}
const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
type,
userId,
open,
onClose,
onUserDelete,
}) => {
const store = manageUserStore();
const { t } = useTranslation();
Expand All @@ -59,7 +61,6 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
{ value: 'Duplicated User', label: 'Duplicated User' },
// { value: 'Other', label: 'Other' },
];


const handleRadioChange = (value: string) => {
console.log(value);
Expand Down Expand Up @@ -88,6 +89,7 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({

setSelectedValue('');
onClose();
onUserDelete();
showToastMessage(t('COMMON.USER_DELETED_PERMANENTLY'), 'success');
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/GeneratedSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const GenerateSchemaAndUiSchema = (
switch (type) {
case 'text':
fieldSchema.type = 'string';
fieldUiSchema['ui:help'] = t(`FORM.${field?.hint}`);
fieldUiSchema['ui:help'] = field?.hint ? t(`FORM.${field?.hint}`) : '';
break;
case 'email':
fieldSchema.type = 'string';
Expand Down
Loading

0 comments on commit 6a3eb2b

Please sign in to comment.