Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member role add (fixes: #405) #406

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
member role add js lint fix
SujalLama committed Aug 2, 2021
commit b9e18dabe74d233658aa2daff763384d01fa3ae1
4 changes: 1 addition & 3 deletions api/src/middleware/permission.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const db = require("../models")
const db = require('../models')

function checkRole (dbRole, roles) {
return roles.some(el => el === dbRole)
@@ -21,11 +21,9 @@ const permit = (roles) => {
const member = await db.CommunityUser.findOne({ where: { userId: req.user.id, communityId: req.params.id }, attributes: ['role'] })

if (checkRole(member.dataValues.role, roles) || checkRole(req.user.role, roles)) {
console.log("hellonworld")
next()
} else {
res.json({ error: 'Sorry, You don\'t have permission' })
return;
}
}
}
13 changes: 5 additions & 8 deletions src/screens/admin/CommunityMemberAdmin.jsx
Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@ const ComMemberAdmin = () => {

const dispatch = useDispatch()


// fetching current community
const currentCommunity = getCommunity();
const currentCommunity = getCommunity()

useEffect(() => {
getMemberDetails()
@@ -28,8 +27,6 @@ const ComMemberAdmin = () => {
setData(data.results)
}

console.log(data);

const allowAccess = async (id) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be able to switch between roles not always make manager

const { data } = await putApi(
dispatch,
@@ -41,12 +38,12 @@ const ComMemberAdmin = () => {

return (
<DashboardLayout title={currentCommunity.name}>
{data.length && <Table
addSymbolNumber={true}
{data.length && <Table
addSymbolNumber
data={{
tblData: data,
tblProperty: ['firstName', 'lastName', 'email', 'phone', 'dateOfBirth', 'role', 'options'],
tblHeader: ['First Name', 'Last Name', 'Email', 'Phone', 'Date of Birth', 'Role', 'options'],
tblHeader: ['First Name', 'Last Name', 'Email', 'Phone', 'Date of Birth', 'Role', 'options']
}}
options={
[
@@ -56,7 +53,7 @@ const ComMemberAdmin = () => {
}
]
}
/>}
/>}
</DashboardLayout>
)
}
4 changes: 2 additions & 2 deletions src/utils/getCommunity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const getCommunity = () => {
return localStorage.getItem('currentCommunity')
return localStorage.getItem('currentCommunity')
? JSON.parse(localStorage.getItem('currentCommunity'))
: null
}
}