Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' of github.com:tekdi/teachers-app into re…
Browse files Browse the repository at this point in the history
…lease-1.0.0
  • Loading branch information
itsvick committed Jul 17, 2024
2 parents 0f3a9aa + d42cad3 commit 1ec41bd
Show file tree
Hide file tree
Showing 14 changed files with 407 additions and 50 deletions.
5 changes: 4 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@
"CENTER_RENAMED": "Center Renamed Successfully!",
"SEND_REQUEST": "Send Request",
"REQUEST_TO_DELETE_HAS_BEEN_SENT": "Request to Delete has been sent",
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "You are sending a request to the State Admin to delete this Center"
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "You are sending a request to the State Admin to delete this Center",
"THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "The user belongs to the following cohort: ",
"PLEASE_REMOVE_THE_USER_FROM_COHORT": "Please remove the user from these cohorts before proceeding with deletion."
},
"CENTER_SESSION": {
"THIS_SESSION": "This session",
Expand All @@ -324,6 +326,7 @@
},
"MANAGE_USERS": {
"CENTERS_REQUESTED_SUCCESSFULLY": "Center Requested Successfully"

},
"FORM": {
"FULL_NAME":"Full Name",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@
"CENTER_RENAMED": "केंद्र का नाम सफलतापूर्वक बदल दिया गया!",
"SEND_REQUEST": "अनुरोध भेजें",
"REQUEST_TO_DELETE_HAS_BEEN_SENT": " हटाने का अनुरोध भेजा गया है",
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आप राज्य प्रशासन को इस केंद्र को हटाने का अनुरोध भेज रहे हैं"
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आप राज्य प्रशासन को इस केंद्र को हटाने का अनुरोध भेज रहे हैं",
"THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "उपयोगकर्ता निम्नलिखित समूह का सदस्य है: ",
"PLEASE_REMOVE_THE_USER_FROM_COHORT": "कृपया हटाने से पहले उपयोगकर्ता को इन समूहों से हटा दें।"
},
"CENTER_SESSION": {
"THIS_SESSION": "यह सत्र",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/mr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@
"CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले गेले!",
"SEND_REQUEST": "विनंती पाठवा",
"REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटवण्याची विनंती पाठवली आहे",
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आपण या केंद्राला हटविण्याचे विनंती राज्य प्रशासनाला पाठवत आहात"
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "आपण या केंद्राला हटविण्याचे विनंती राज्य प्रशासनाला पाठवत आहात",
"THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "वापरकर्ता खालील गटाचा सदस्य आहे: ",
"PLEASE_REMOVE_THE_USER_FROM_COHORT": "हटविण्यापूर्वी कृपया वापरकर्त्याला या गटांमधून काढून टाका।"
},
"CENTER_SESSION": {
"THIS_SESSION": "हे सत्र",
Expand Down
4 changes: 3 additions & 1 deletion public/locales/or/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@
"CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାର ସହ ଚାଲିଛି!",
"SEND_REQUEST":"ଅନୁରୋଧ ପଠାନ୍ତୁ",
"REQUEST_TO_DELETE_HAS_BEEN_SENT": "ହଟାଇବାକୁ ଅନୁରୋଧ ପଠାଯାଇଛି",
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "ଆପଣ ଏହି କେନ୍ଦ୍ରଟିକୁ ବିଲୋପ କରିବା ପାଇଁ ରାଜ୍ୟ ପ୍ରଶାସନକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି"
"YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "ଆପଣ ଏହି କେନ୍ଦ୍ରଟିକୁ ବିଲୋପ କରିବା ପାଇଁ ରାଜ୍ୟ ପ୍ରଶାସନକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି",
"THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "ୟୁଜର ନିମ୍ନଲିଖିତ ସମୁହର ସଦସ୍ୟ: ",
"PLEASE_REMOVE_THE_USER_FROM_COHORT": "ଦୟାକରି ହଟାଇବା ପୂର୍ବରୁ ୟୁଜରକୁ ଏହି ସମୁହଗୁଡିକରୁ କାଢ଼ି ଦିଅନ୍ତୁ।"

}
}
Expand Down
11 changes: 3 additions & 8 deletions src/components/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import CloseIcon from '@mui/icons-material/Close';
import { showToastMessage } from './Toastify';
import manageUserStore from '@/store/manageUserStore';
import { getCohortList } from '@/services/CohortServices';

interface DeleteUserModalProps {
open: boolean;
onClose: () => void;
}
const DeleteUserModal: React.FC<DeleteUserModalProps> = ({ open, onClose }) => {
const { t } = useTranslation();
const store = manageUserStore();
const theme = useTheme<any>();
const style = {
position: 'absolute',
Expand Down Expand Up @@ -53,16 +56,8 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({ open, onClose }) => {
};

const handleDeleteAction = () => {





// setOtherReason('');
setSelectedValue('');



onClose();
showToastMessage(t('COMMON.USER_DELETED_PERMANENTLY'), 'success');
};
Expand Down
85 changes: 65 additions & 20 deletions src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import { getMyUserList } from '@/services/MyClassDetailsService';
import DeleteUserModal from './DeleteUserModal';
import Image from 'next/image';
import profileALT from '../assets/images/Profile.png';
import RemoveFacilitatorAlert from './SimpleModal';
import SimpleModal from './SimpleModal';
interface Cohort {
cohortId: string;
parentId: string;
Expand Down Expand Up @@ -82,7 +84,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
const { t } = useTranslation();
const theme = useTheme<any>();
const router = useRouter();
const store = manageUserStore();
const store = manageUserStore();
const [value, setValue] = React.useState(1);
const [users, setUsers] = useState<
{
Expand Down Expand Up @@ -112,13 +114,14 @@ const store = manageUserStore();
const [reassignBlockRequestModalOpen, setReassignBlockRequestModalOpen] =
React.useState<boolean>(false);
const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false);

const [openRemoveUserModal, setOpenRemoveUserModal] = React.useState(false);
const [removeCohortNames, setRemoveCohortNames] = React.useState('');
const CustomLink = styled(Link)(({ theme }) => ({
textDecoration: 'underline',
textDecorationColor: theme?.palette?.secondary.main,
textDecorationThickness: '1px',
}));
const setDeleteId = manageUserStore((state) => state.setDeleteId);
const setCohortDeleteId = manageUserStore((state) => state.setCohortDeleteId);

useEffect(() => {
const getFacilitator = async () => {
Expand Down Expand Up @@ -148,22 +151,26 @@ const store = manageUserStore();
return;
}
const userIds = facilitatorList.map((user: any) => user.userId);
const cohortDetailsPromises = userIds.map((userId: string) =>
const cohortDetailsPromises = userIds.map((userId: string) =>
getCohortList(userId, { filter: 'true' })
);
const cohortDetails = await Promise.all(cohortDetailsPromises);
console.log('Cohort Details:', cohortDetails);

const extractedData = facilitatorList.map((user: any, index: number) => {
const cohorts = cohortDetails[index] || [];
const cohortNames = cohorts.map((cohort: any) => cohort.cohortName).join(', ');

return {
userId: user.userId,
name: user.name,
cohortNames: cohortNames || null,
};
});

const extractedData = facilitatorList.map(
(user: any, index: number) => {
const cohorts = cohortDetails[index] || [];
const cohortNames = cohorts
.map((cohort: any) => cohort.cohortName)
.join(', ');

return {
userId: user.userId,
name: user.name,
cohortNames: cohortNames || null,
};
}
);
setTimeout(() => {
setUsers(extractedData);
});
Expand Down Expand Up @@ -244,10 +251,14 @@ const store = manageUserStore();
setState({ ...state, bottom: false });
};

const handleCloseRemoveModal = () => {
setOpenRemoveUserModal(false);
};

const toggleDrawer =
(anchor: Anchor, open: boolean, user: any) =>
(event: React.KeyboardEvent | React.MouseEvent) => {
setDeleteId(user.userId);
setCohortDeleteId(user.userId);
setCenters(
cohortsData?.[user.userId]?.map((cohort) => cohort.name) || []
);
Expand All @@ -266,7 +277,24 @@ const store = manageUserStore();

const listItemClick = async (event: React.MouseEvent, name: string) => {
if (name === 'delete-User') {
setOpenDeleteUserModal(true);
const userId = store.deleteId;
console.log(userId);

const cohortList = await getCohortList(userId);
console.log('Cohort List:', cohortList);

if (cohortList && cohortList.length > 0) {
const cohortNames = cohortList
.map((cohort: { cohortName: any }) => cohort.cohortName)
.join(', ');
setOpenRemoveUserModal(true);
setRemoveCohortNames(cohortNames);
} else {
console.log(
'User does not belong to any cohorts, proceed with deletion'
);
setOpenDeleteUserModal(true);
}

// const name = selectedUser?.name || '';
// const userId = selectedUser?.userId || '';
Expand Down Expand Up @@ -565,11 +593,13 @@ const store = manageUserStore();
borderRadius: '5px',
fontSize: '12px',
fontWeight: '600',
color: 'black',
marginBottom: '10px',
color: 'black',
marginBottom: '10px',
}}
>
{user?.cohortNames ? `${user.cohortNames}` : 'N/A'}
{user?.cohortNames
? `${user.cohortNames}`
: 'N/A'}
</Box>
</Box>
</Box>
Expand Down Expand Up @@ -704,6 +734,21 @@ const store = manageUserStore();
open={openDeleteUserModal}
onClose={handleCloseModal}
/>
<SimpleModal
primaryText="Ok"
primaryActionHandler={handleCloseRemoveModal}
open={openRemoveUserModal}
onClose={handleCloseRemoveModal}
>
{' '}
<Box mt={1.5}>
<Typography>
{t('CENTERS.THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT')}{' '}
{removeCohortNames}.{' '}
{t('CENTERS.PLEASE_REMOVE_THE_USER_FROM_COHORT')}
</Typography>
</Box>
</SimpleModal>
</>
)}

Expand Down
2 changes: 1 addition & 1 deletion src/components/PlannedSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const PlannedSession = () => {
label="Start Time"
value={date}
onChange={handleChange}
sx={{ borderRadius: '4px' }}
sx={{ borderRadius: '4px', fontSize: '2px' }}
/>
</LocalizationProvider>
</Box>
Expand Down
92 changes: 92 additions & 0 deletions src/components/SelectTopic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import {
Box,
Checkbox,
FormControl,
InputLabel,
ListItemText,
MenuItem,
Select,
SelectChangeEvent,
} from '@mui/material';
import React, { ChangeEvent, useState } from 'react';

import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';

function SelectTopic() {
const { t } = useTranslation();
const theme = useTheme<any>();

const [selectedValues, setSelectedValues] = useState<string[]>([]);

const handleChange = (event: SelectChangeEvent<string[]>) => {
const {
target: { value },
} = event;
setSelectedValues(typeof value === 'string' ? value.split(',') : value);
};

return (
<Box sx={{ padding: '8px 16px' }}>
<Box sx={{ mt: 2 }}>
<FormControl fullWidth>
<InputLabel
style={{
color: theme?.palette?.warning['A200'],
background: theme?.palette?.warning['A400'],
padding: '2px 8px',
}}
id="demo-multiple-select-label"
>
{t('CENTER_SESSION.TOPIC')}
</InputLabel>
<Select
labelId="demo-multiple-select-label"
id="demo-multiple-select"
multiple
value={selectedValues}
onChange={handleChange}
renderValue={(selected) => (selected as string[]).join(', ')}
style={{ borderRadius: '4px' }}
className="topic-select"
>
{/* <MenuItem value={'Mathematics'}>
<Checkbox
sx={{
'&.Mui-checked': {
color: theme?.palette?.warning['300'],
},
}}
checked={selectedValues.indexOf('Mathematics') > -1}
/>
<ListItemText primary="Mathematics" />
</MenuItem>
{/* Add more MenuItem components as needed */}
</Select>
</FormControl>
</Box>

<Box sx={{ my: 2 }}>
<FormControl fullWidth>
<InputLabel
style={{ color: theme?.palette?.warning['A200'] }}
id="demo-simple-select-label"
>
{t('CENTER_SESSION.SUBTOPIC')}
</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
label="Subject"
style={{ borderRadius: '4px' }}
>
{/* <MenuItem value={'Mathematics'}>Mathematics</MenuItem> */}
</Select>
</FormControl>
</Box>
</Box>
);
}

export default SelectTopic;
Loading

0 comments on commit 1ec41bd

Please sign in to comment.