Skip to content

Commit

Permalink
Merge pull request #39 from vidyaaKhandekar/notification
Browse files Browse the repository at this point in the history
Feature #234719-Invite cohort admin
  • Loading branch information
gouravmore authored Feb 10, 2025
2 parents 396ae4c + 38e24ca commit 4d68921
Show file tree
Hide file tree
Showing 12 changed files with 731 additions and 174 deletions.
28 changes: 26 additions & 2 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
"CREATE_ROLE": "Create Role",
"USER_DELETE_FAILED": "User deletion failed",
"ASSIGN_ROLE": "Assign Role",
"ENABLE_ROLE": "Enable Role"
"ENABLE_ROLE": "Enable Role",
"SEND_INVITATION_TO_NEW_ADMIN": "Send Invitation to new cohort admin",
"SEND_INVITATION": "Send Invitation"
},
"LOGIN_PAGE": {
"USERNAME": "Username",
Expand Down Expand Up @@ -474,5 +476,27 @@
"DELETE_USER_DETAILS": "Delete User Details",
"DELETE_USER_CONFIRMATION_MESSAGE": "Are you sure you want to Archived this user?",
"NO_CHANGES_TO_UPDATE": "No Changes to Update"
}
},
"COHORTINVITATION": {
"TAKE_ACTION": "Take Action",
"INVITED_AS_ADMIN": "You have been invited to be the Admin of the cohort",
"SENT":"Sent",
"RECEIVED":"Received",
"ACCEPT_INVITATION": "Accept Invitation",
"REJECT_INVITATION": "Reject Invitation",
"NO_PENDING_REQUESTS_SENT": "No pending requests sent",
"NO_PENDING_INVITATIONS": "No pending invitations",
"INVITED_TO_JOIN_COHORT": "Invited to join cohort",
"INVITED_BY": "Invited by",
"REVOKE_INVITATION": "Revoke Invitation",
"DELETE_CONFIRMATION": "Revoke request of ",
"CANCEL": "Cancel",
"REVOKE": "Revoke",
"ACCEPTED_SUCCESS": "Accepted request successfully",
"REJECTED_SUCCESS": "Rejected request",
"ERROR_UPDATING_REQUEST": "Error in updating request",
"INVITATION_DELETED_SUCCESS": "Invitation deleted successfully",
"INVITATION_DELETED_ERROR": "Failed to delete invitation",
"FETCH_INVITATIONS_ERROR": "Failed to fetch invitations"
}
}
24 changes: 23 additions & 1 deletion public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"DELETE": "हटाएं",
"NO_DATA_FOUND": "कोई डेटा नहीं मिला",
"SUBMIT": "जमा करें",
"BACK": "वापस"
"BACK": "वापस",
"SEND_INVITATION_TO_NEW_ADMIN": "नए समूह एडमिन को आमंत्रण भेजें",
"SEND_INVITATION": "आमंत्रण भेजें"
},
"LOGIN_PAGE": {
"USERNAME": "उपयोगकर्ता नाम",
Expand Down Expand Up @@ -158,5 +160,25 @@
"EMAIL": "ईमेल",
"YEAR_OF_ JOINING_SCP": "एससीपी में शामिल होने का वर्ष",
"ASSIGN_CENTERS": "केंद्र आवंटित करें"
},
"COHORTINVITATION": {
"TAKE_ACTION": "कार्रवाई करें",
"INVITED_AS_ADMIN": "आपण कोहोर्टचे प्रशासक होण्यासाठी आमंत्रित आहात",
"ACCEPT_INVITATION": "निमंत्रण स्वीकारें",
"REJECT_INVITATION": "निमंत्रण अस्वीकारें",
"NO_PENDING_REQUESTS_SENT": "कोई लंबित अनुरोध नहीं",
"NO_PENDING_INVITATIONS": "कोई लंबित निमंत्रण नहीं",
"INVITED_TO_JOIN_COHORT": "कोहोर्ट में शामिल होने के लिए आमंत्रित किया गया",
"INVITED_BY": "द्वारा आमंत्रित",
"DELETE_INVITATION": "निमंत्रण हटाएं",
"DELETE_CONFIRMATION": "को भेजा गया निमंत्रण हटाएं",
"CANCEL": "रद्द करें",
"REVOKE": " निमंत्रण रद्द करें",
"ACCEPTED_SUCCESS": "अनुरोध सफलतापूर्वक स्वीकारा गया",
"REJECTED_SUCCESS": "अनुरोध अस्वीकार किया गया",
"ERROR_UPDATING_REQUEST": "अनुरोध अपडेट करने में त्रुटि",
"INVITATION_DELETED_SUCCESS": "निमंत्रण सफलतापूर्वक हटाया गया",
"INVITATION_DELETED_ERROR": "निमंत्रण हटाने में विफल",
"FETCH_INVITATIONS_ERROR": "निमंत्रण लाने में विफल"
}
}
24 changes: 23 additions & 1 deletion public/locales/mr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"DELETE": "हटवा",
"NO_DATA_FOUND": "डेटा सापडला नाही",
"SUBMIT": "सबमिट करा",
"BACK": "परत जा"
"BACK": "परत जा",
"SEND_INVITATION_TO_NEW_ADMIN": "नवीन कोहोर्ट प्रशासकाला आमंत्रण पाठवा",
"SEND_INVITATION": "आमंत्रण पाठवा"
},
"LOGIN_PAGE": {
"USERNAME": "वापरकर्ता नाव",
Expand Down Expand Up @@ -158,5 +160,25 @@
"EMAIL": "ईमेल",
"YEAR_OF_ JOINING_SCP": "एससीपीमध्ये सामील होण्याचे वर्ष",
"ASSIGN_CENTERS": "केंद्रे नियुक्त करा"
},
"COHORTINVITATION": {
"TAKE_ACTION": "कारवाई करा",
"INVITED_AS_ADMIN": "आपण कोहोर्टचे प्रशासक होण्यासाठी आमंत्रित आहात",
"ACCEPT_INVITATION": "निमंत्रण स्वीकारा",
"REJECT_INVITATION": "निमंत्रण नाकार करा",
"NO_PENDING_REQUESTS_SENT": "कोणतीही प्रलंबित विनंती नाही",
"NO_PENDING_INVITATIONS": "कोणतीही प्रलंबित निमंत्रणे नाहीत",
"INVITED_TO_JOIN_COHORT": "कोहोर्टमध्ये सामील होण्यासाठी आमंत्रित केले",
"INVITED_BY": "आमंत्रित करणारे",
"DELETE_INVITATION": "निमंत्रण हटवा",
"DELETE_CONFIRMATION": "याला पाठवलेले निमंत्रण हटवा",
"CANCEL": "रद्द करा",
"REVOKE": "निमंत्रण रद्द करा",
"ACCEPTED_SUCCESS": "विनंती यशस्वीरित्या स्वीकारली",
"REJECTED_SUCCESS": "विनंती नाकारली",
"ERROR_UPDATING_REQUEST": "विनंती अद्यतनित करताना त्रुटी",
"INVITATION_DELETED_SUCCESS": "निमंत्रण यशस्वीरित्या हटवले",
"INVITATION_DELETED_ERROR": "निमंत्रण हटवता आले नाही",
"FETCH_INVITATIONS_ERROR": "निमंत्रणे प्राप्त करताना त्रुटी"
}
}
24 changes: 23 additions & 1 deletion public/locales/or/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"DELETE": "ହଟାନ୍ତୁ",
"NO_DATA_FOUND": "ତଥ୍ୟ ମିଳିଲା ନାହିଁ",
"SUBMIT": "ଦାଖଲ କରନ୍ତୁ",
"BACK": "ପଛକୁ ଯାଆନ୍ତୁ"
"BACK": "ପଛକୁ ଯାଆନ୍ତୁ",
"SEND_INVITATION_TO_NEW_ADMIN": "ନୂତନ କୋହୋର୍ଟ ଏଡମିନ୍ କୁ ନିମନ୍ତ୍ରଣ ପଠାନ୍ତୁ",
"SEND_INVITATION": "ନିମନ୍ତ୍ରଣ ପଠାନ୍ତୁ"
},
"LOGIN_PAGE": {
"USERNAME": "ଉପଭୋକ୍ତା ନାମ",
Expand Down Expand Up @@ -158,5 +160,25 @@
"EMAIL": "ଇମେଲ୍",
"YEAR_OF_ JOINING_SCP": "SCP ମଧ୍ୟରେ ସାମିଲ ହେବାର ବର୍ଷ",
"ASSIGN_CENTERS": "କେନ୍ଦ୍ର ସୁପର୍ଦ୍ଦ କରନ୍ତୁ"
},
"COHORTINVITATION": {
"TAKE_ACTION": "କାର୍ଯ୍ୟ କରନ୍ତୁ",
"INVITED_AS_ADMIN": "ଆପଣ କୋହୋର୍ଟର ଏଡମିନ୍ ହେବାକୁ ନିମନ୍ତ୍ରିତ ହୋଇଛନ୍ତି",
"ACCEPT_INVITATION": "ନିମନ୍ତ୍ରଣ ଗ୍ରହଣ କରନ୍ତୁ",
"REJECT_INVITATION": "ନିମନ୍ତ୍ରଣ ଅସ୍ଵୀକାର କରନ୍ତୁ",
"NO_PENDING_REQUESTS_SENT": "କୌଣସି ଅପେକ୍ଷିତ ଅନୁରୋଧ ନାହିଁ",
"NO_PENDING_INVITATIONS": "କୌଣସି ଅପେକ୍ଷିତ ନିମନ୍ତ୍ରଣ ନାହିଁ",
"INVITED_TO_JOIN_COHORT": "କୋହୋର୍ଟ ଯୋଗଦେବାକୁ ନିମନ୍ତ୍ରିତ କରାଯାଇଛି",
"INVITED_BY": "ନିମନ୍ତ୍ରିତ କରିଛନ୍ତି",
"DELETE_INVITATION": "ନିମନ୍ତ୍ରଣ ବିଲୋପ କରନ୍ତୁ",
"DELETE_CONFIRMATION": "କୁ ପଠାଯାଇଥିବା ନିମନ୍ତ୍ରଣ ବିଲୋପ କରନ୍ତୁ",
"CANCEL": "ବାତିଲ୍ କରନ୍ତୁ",
"REVOKE": "ନିମନ୍ତ୍ରଣ ବାତିଲ୍ କରନ୍ତୁ",
"ACCEPTED_SUCCESS": "ଅନୁରୋଧ ସଫଳତାର ସହିତ ଗ୍ରହଣ କରାଯାଇଛି",
"REJECTED_SUCCESS": "ଅନୁରୋଧ ଅସ୍ଵୀକାର କରାଯାଇଛି",
"ERROR_UPDATING_REQUEST": "ଅନୁରୋଧ ଅଦ୍ୟତନ କରିବାରେ ତ୍ରୁଟି",
"INVITATION_DELETED_SUCCESS": "ନିମନ୍ତ୍ରଣ ସଫଳତାର ସହିତ ବିଲୋପ କରାଯାଇଛି",
"INVITATION_DELETED_ERROR": "ନିମନ୍ତ୍ରଣ ବିଲୋପ କରିପାରିଲେ ନାହିଁ",
"FETCH_INVITATIONS_ERROR": "ନିମନ୍ତ୍ରଣ ପ୍ରାପ୍ତି ଉପରେ ତ୍ରୁଟି"
}
}
105 changes: 55 additions & 50 deletions src/components/layouts/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React, { useEffect, useRef, useState } from "react";
import FeatherIcon from "feather-icons-react";
import { AppBar, Box, IconButton, Toolbar } from "@mui/material";
import { AppBar, Badge, Box, IconButton, Toolbar } from "@mui/material";
import MenuItem from "@mui/material/MenuItem";
import Select, { SelectChangeEvent } from "@mui/material/Select";
import config from "../../../../config.json";
import PropTypes from "prop-types";
import Image from "next/image";
import TranslateIcon from '@mui/icons-material/Translate';
import Menu from '@mui/material/Menu';
import TranslateIcon from "@mui/icons-material/Translate";
import Menu from "@mui/material/Menu";
import SearchBar from "./SearchBar";
import { useRouter } from 'next/router';


import { useRouter } from "next/router";
import MailIcon from "@mui/icons-material/Mail";
import { useTranslation } from "next-i18next";
import { createTheme } from "@mui/material/styles";
import Profile from "./Profile";
import { Mail } from "@mui/icons-material";
import InvitationMenu from "./Invitation";

const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {
const { t } = useTranslation();
Expand All @@ -28,39 +29,38 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {

const [language, setLanguage] = useState(selectedLanguage);
useEffect(() => {
if (typeof window !== 'undefined' && window.localStorage) {
const lang = localStorage.getItem('preferredLanguage') || 'en';
if (typeof window !== "undefined" && window.localStorage) {
const lang = localStorage.getItem("preferredLanguage") || "en";
setLanguage(lang);

}
}, [setLanguage]);

const handleChange = (event: SelectChangeEvent) => {
const newLocale = event.target.value;
setLanguage(newLocale);
if (typeof window !== 'undefined' && window.localStorage) {
localStorage.setItem('preferredLanguage', newLocale);
if (typeof window !== "undefined" && window.localStorage) {
localStorage.setItem("preferredLanguage", newLocale);
router.replace(router.pathname, router.asPath, { locale: newLocale });
}
};
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
console.log(event)
console.log(event);
setAnchorEl(event.currentTarget);
console.log(anchorEl)

console.log(anchorEl);
};
const handleClose = () => {
setAnchorEl(null);
};
const handleMenuItemClick = (newLocale: any) => {
console.log(newLocale);
setLanguage(newLocale);
if (typeof window !== 'undefined' && window.localStorage) {
localStorage.setItem('preferredLanguage', newLocale);
if (typeof window !== "undefined" && window.localStorage) {
localStorage.setItem("preferredLanguage", newLocale);
router.replace(router.pathname, router.asPath, { locale: newLocale });
}
handleClose();
};

return (
<AppBar sx={sx} position={position} elevation={0} className={customClass}>
<Toolbar>
Expand All @@ -76,7 +76,6 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {
},
}}
>

<FeatherIcon icon="menu" size="20" />
</IconButton>
{/* ------------------------------------------- */}
Expand All @@ -90,8 +89,7 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {

<Box flexGrow={1} />


<Box
{/* <Box
sx={{
display: "flex",
Expand All @@ -116,38 +114,45 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {
>
<TranslateIcon />
</IconButton>
</Box>
<Menu
id="long-menu"
MenuListProps={{
'aria-labelledby': 'long-button',
}}
</Box> */}

anchorEl={anchorEl}
open={open}
onClose={handleClose}
PaperProps={{
style: {
// maxHeight: ITEM_HEIGHT * 4.5,
width: '20ch',
},
}}
>
{config.languages.map((lang) => (
<MenuItem value={lang.code} key={lang.code} onClick={() => handleMenuItemClick(lang.code)}

sx={{
backgroundColor: lang.code === language ? 'rgba(0, 0, 0, 0.08)' : 'inherit',
'&:hover': {
backgroundColor: lang.code === language ? 'rgba(0, 0, 0, 0.12)' : 'rgba(0, 0, 0, 0.08)',
},
}}
>
{lang.label}
</MenuItem>
))}
</Menu>
<Profile />
<InvitationMenu />
<Menu
id="long-menu"
MenuListProps={{
"aria-labelledby": "long-button",
}}
anchorEl={anchorEl}
open={open}
onClose={handleClose}
PaperProps={{
style: {
// maxHeight: ITEM_HEIGHT * 4.5,
width: "20ch",
},
}}
>
{config.languages.map((lang) => (
<MenuItem
value={lang.code}
key={lang.code}
onClick={() => handleMenuItemClick(lang.code)}
sx={{
backgroundColor:
lang.code === language ? "rgba(0, 0, 0, 0.08)" : "inherit",
"&:hover": {
backgroundColor:
lang.code === language
? "rgba(0, 0, 0, 0.12)"
: "rgba(0, 0, 0, 0.08)",
},
}}
>
{lang.label}
</MenuItem>
))}
</Menu>
<Profile />
{/* ------------------------------------------- */}
{/* Profile Dropdown */}
{/* ------------------------------------------- */}
Expand Down
Loading

0 comments on commit 4d68921

Please sign in to comment.