Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' of github.com:tekdi/teachers-app into ce…
Browse files Browse the repository at this point in the history
…nterSession
  • Loading branch information
shreyas143shinde committed Jul 19, 2024
2 parents 4cd263c + b2f60d6 commit 15fac86
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 50 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/pratham-aws-deployment.yaml

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/CohortFacilitatorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getFieldValue,
toPascalCase,
} from '@/utils/Helper';
import LearnersList from '@/components/LearnersList';
import LearnersList from '@/components/LearnersListItem';
import { Status, limit } from '@/utils/app.constant';
import { showToastMessage } from './Toastify';
import { useTranslation } from 'next-i18next';
Expand Down
4 changes: 2 additions & 2 deletions src/components/CohortLearnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getFieldValue,
toPascalCase,
} from '@/utils/Helper';
import LearnersList from '@/components/LearnersList';
import LearnersListItem from '@/components/LearnersListItem';
import { Status, limit } from '@/utils/app.constant';
import { showToastMessage } from './Toastify';
import { useTranslation } from 'next-i18next';
Expand Down Expand Up @@ -84,7 +84,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
<>
{userData?.map((data: any) => {
return (
<LearnersList
<LearnersListItem
key={data.userId}
userId={data.userId}
learnerName={data.name}
Expand Down
6 changes: 3 additions & 3 deletions src/components/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import { getCohortList } from '@/services/CohortServices';
import { updateFacilitator } from '@/services/ManageUser';

interface DeleteUserModalProps {
deleteFacilitatorId: string;
userId: string;
open: boolean;
onClose: () => void;
}
const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
deleteFacilitatorId,
userId,
open,
onClose,
}) => {
Expand Down Expand Up @@ -67,7 +67,7 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
reason: selectedValue,
};

const response = await updateFacilitator(deleteFacilitatorId, userData);
const response = await updateFacilitator(userId, userData);

console.log(response);

Expand Down
2 changes: 1 addition & 1 deletion src/components/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({
{showTwoButtons ? (
<>
<Button
variant="contained"
variant="outlined"
color="primary"
sx={{
'&.Mui-disabled': {
Expand Down
10 changes: 5 additions & 5 deletions src/components/GeneratedSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const GenerateSchemaAndUiSchema = (
fieldSchema.type = 'string';
fieldSchema.oneOf = options.map((opt: FieldOption) => ({
const: opt.value,
title: t(`FORM.${opt.label}`),
title: t(`FORM.${opt.label}`) === `FORM.${opt.label}` ? opt.label : t(`FORM.${opt.label}`),
}));
fieldUiSchema['ui:widget'] = 'select';
break;
Expand All @@ -76,7 +76,7 @@ export const GenerateSchemaAndUiSchema = (
type: 'string',
oneOf: options.map((opt: FieldOption) => ({
const: opt.value,
title: t(`FORM.${opt.label}`),
title: t(`FORM.${opt.label}`) === `FORM.${opt.label}` ? opt.label : t(`FORM.${opt.label}`),
})),
};
fieldSchema.uniqueItems = true;
Expand All @@ -86,7 +86,7 @@ export const GenerateSchemaAndUiSchema = (
fieldSchema.type = 'string';
fieldSchema.oneOf = options.map((opt: FieldOption) => ({
const: opt.value,
title: t(`FORM.${opt.label}`),
title: t(`FORM.${opt.label}`) === `FORM.${opt.label}` ? opt.label : t(`FORM.${opt.label}`),
}));
fieldUiSchema['ui:widget'] = 'CustomRadioWidget';
break;
Expand All @@ -108,7 +108,7 @@ export const GenerateSchemaAndUiSchema = (
type: 'string',
oneOf: options.map((opt: FieldOption) => ({
const: opt.value,
title: t(`FORM.${opt.label}`),
title: t(`FORM.${opt.label}`) === `FORM.${opt.label}` ? opt.label : t(`FORM.${opt.label}`),
})),
};
fieldSchema.uniqueItems = true;
Expand All @@ -121,7 +121,7 @@ export const GenerateSchemaAndUiSchema = (
type: 'string',
oneOf: options.map((opt: FieldOption) => ({
const: opt.value,
title: t(`FORM.${opt.label}`),
title: t(`FORM.${opt.label}`) === `FORM.${opt.label}` ? opt.label : t(`FORM.${opt.label}`),
})),
};
fieldSchema.uniqueItems = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import { updateCohortMemberStatus } from '@/services/MyClassDetailsService';
// import Woman2Icon from '@mui/icons-material/Woman2';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';

type Anchor = 'bottom';
const centerList = ['Nashik', 'Shirdi', 'kamptee'];
const centers = ['shirdi'];

const LearnersList: React.FC<LearnerListProps> = ({
const LearnersListItem: React.FC<LearnerListProps> = ({
userId,
learnerName,
isDropout,
Expand All @@ -58,6 +59,9 @@ const LearnersList: React.FC<LearnerListProps> = ({
setConfirmationModalReassignCentersOpen,
] = React.useState<boolean>(false);

console.log(userId);


const [learnerState, setLearnerState] = React.useState({
loading: false,
isModalOpenLearner: false,
Expand All @@ -68,6 +72,8 @@ const LearnersList: React.FC<LearnerListProps> = ({
});

const theme = useTheme<any>();
const router = useRouter();
const { learnerId }: any = router.query;
const { t } = useTranslation();
const [openCentersModal, setOpenCentersModal] = React.useState(false);
const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false);
Expand Down Expand Up @@ -616,9 +622,9 @@ const LearnersList: React.FC<LearnerListProps> = ({
isForLearner={true}
/>

<DeleteUserModal open={openDeleteUserModal} onClose={handleCloseModal} />
<DeleteUserModal userId={userId} open={openDeleteUserModal} onClose={handleCloseModal} />
</>
);
};

export default LearnersList;
export default LearnersListItem;
8 changes: 4 additions & 4 deletions src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { editEditUser } from '@/services/ProfileService';
import ConfirmationModal from '@/components/ConfirmationModal';
import { Status } from '@/utils/app.constant';
import AddIcon from '@mui/icons-material/Add';
import LearnersList from '@/components/LearnersList';
import LearnersList from '@/components/LearnersListItem';
import Link from 'next/link';
import { styled } from '@mui/system';
import manageUserStore from '../store/manageUserStore';
Expand Down Expand Up @@ -116,7 +116,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false);
const [openRemoveUserModal, setOpenRemoveUserModal] = React.useState(false);
const [removeCohortNames, setRemoveCohortNames] = React.useState('');
const [deleteFacilitatorId, setDeleteFacilitatorId] = React.useState('');
const [userId, setUserId] = React.useState('');
const CustomLink = styled(Link)(({ theme }) => ({
textDecoration: 'underline',
textDecorationColor: theme?.palette?.secondary.main,
Expand Down Expand Up @@ -303,7 +303,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
const listItemClick = async (event: React.MouseEvent, name: string) => {
if (name === 'delete-User') {
const userId = store?.deleteId;
setDeleteFacilitatorId(userId);
setUserId(userId);

const cohortList = await getCohortList(userId);
console.log('Cohort List:', cohortList);
Expand Down Expand Up @@ -757,7 +757,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
/>

<DeleteUserModal
deleteFacilitatorId={deleteFacilitatorId}
userId={userId}
open={openDeleteUserModal}
onClose={handleCloseModal}
/>
Expand Down
32 changes: 23 additions & 9 deletions src/components/SimpleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,48 @@ const SimpleModal: React.FC<SimpleModalProps> = ({
const { t } = useTranslation();
const store = manageUserStore();
const theme = useTheme<any>();
const style = {
padding: '20px',

const modalStyle = {
paddingTop: '0',
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
paddingBottom: theme.spacing(2),
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: '85%',
boxShadow: 24,
bgcolor: '#fff',
borderRadius: '16px',
maxHeight: '80vh',
overflowY: 'auto',
backgroundColor: '#fff',
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shadows[5],
'@media (min-width: 600px)': {
width: '450px',
maxHeight: '80vh',
overflowY: 'auto',
},
};

const titleStyle = {
position: 'sticky',
top: '0',
backgroundColor: '#fff',
padding: theme.spacing(2),
zIndex: 9999,
borderBottom: `1px solid ${theme.palette.divider}`,
};

return (
<Modal
open={open}
aria-labelledby="child-modal-title"
aria-describedby="child-modal-description"
>
<Box sx={{ ...style }}>
<Box sx={modalStyle}>
<Box
display={'flex'}
justifyContent={'space-between'}
sx={{ padding: '18px 16px' }}
// sx={{ padding: '18px 16px' }}
sx={titleStyle}
>
<Box marginBottom={'0px'}>
<Typography
Expand Down
1 change: 0 additions & 1 deletion src/pages/centers/[cohortId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import AddLearnerModal from '@/components/AddLeanerModal';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import Box from '@mui/material/Box';
import CenterSessionModal from '@/components/CenterSessionModal';
import CohortFacilitatorList from '@/components/CohortFacilitatorList';
import CohortLearnerList from '@/components/CohortLearnerList';
import { CustomField } from '@/utils/Interfaces';
import DeleteCenterModal from '@/components/center/DeleteCenterModal';
Expand Down
2 changes: 2 additions & 0 deletions src/pages/learner/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ const LearnerProfile: React.FC = () => {
const userDetails = data;
try {
if (userId) {
console.log("HELLO");

const response = await editEditUser(user_id, userDetails);
ReactGA.event('edit-learner-profile-successful', { userId: userId });

Expand Down
15 changes: 14 additions & 1 deletion src/services/CreateUserService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { get } from "./RestClient";
import { get, post } from "./RestClient";
import {createUserParam} from '../utils/Interfaces'

export const getFormRead = async (context: string, contextType: string): Promise<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/form/read?context=${context}&contextType=${contextType}`;
Expand All @@ -18,3 +19,15 @@ export const getFormRead = async (context: string, contextType: string): Promise
// throw error;
}
};

export const createUser = async (
userData: createUserParam): Promise<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/create`;
try {
const response = await post(apiUrl, { userData });
return response?.data?.result;
} catch (error) {
console.error('error in getting cohort list', error);
throw error;
}
};
19 changes: 19 additions & 0 deletions src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,22 @@ export interface FacilitatorDeleteUserData {
status: string;
reason: string;
}

export interface TenantCohortRoleMapping {
tenantId: string;
roleId: string;
}

export interface CustomField {
fieldId: string;
value: string;
}

export interface createUserParam {
username: string;
name: string;
email: string;
password: string;
tenantCohortRoleMapping: TenantCohortRoleMapping[];
customFields: CustomField[];
}

0 comments on commit 15fac86

Please sign in to comment.