Skip to content

Member role add (fixes: #405)#406

Open
SujalLama wants to merge 16 commits into
mainfrom
member-role-add
Open

Member role add (fixes: #405)#406
SujalLama wants to merge 16 commits into
mainfrom
member-role-add

Conversation

@SujalLama
Copy link
Copy Markdown
Contributor

@SujalLama SujalLama commented Jul 28, 2021

Fixes #405

Description

added role to the community member
protect route based on the role of comunity member
community member admin page is made
community manager can grant access to the other member
drop down added in table
made one route: getAllMemberDetails, getAllMembers, getCommunityUsers can be single function
rerenders the table while changing role

Screenshots

mem

Links and Curls

route:
http://localhost:3000/admin/community-members

file added:
src/middleware/memberPermit.js ( changed to : api/src/middleware/permission.js)

src/migrations/20210728085949-alter_community_user.js
../src/screens/admin/
src/components/dropDown/

file modified:
src/controllers/communityUserController.js
src/models/communityUserModel.js
src/routes/communityUserRouter.js
../src/App.jsx
src/actions/memberActions.js
src/components/table/Table.jsx
src/constants/memberConstants.js
src/reducers/memberReducers.js
src/screens/admin/CommunityMemberAdmin.jsx
src/store.js
src/screens/communityMembers/CommunityMembers.jsx
src/components/cardImage/CardImage.jsx

@SujalLama SujalLama requested review from dogi and lmmrssa July 28, 2021 12:32
@SujalLama SujalLama self-assigned this Jul 28, 2021
{
where: { communityId: req.params.id, active: true },
attributes: ['userId'],
attributes: ['userId', "role"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

linting issue

Comment thread api/src/models/communityUserModel.js Outdated
},
role: {
type: DataTypes.STRING,
defaultValue: 'manager'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

default value between model and migration seems to have conflict

Comment thread src/App.jsx Outdated
import AddTest from './screens/addTest/AddTest'
import LogoutUser from './screens/logoutUser/LogoutUser'
import PageNotFound from './screens/pageNotFound/PageNotFound'
import ComMemberAdmin from './screens/admin/ComMemberAdmin'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

try to put full name so its easier to understand

Comment thread src/screens/admin/ComMemberAdmin.jsx Outdated
? JSON.parse(localStorage.getItem('currentCommunity'))
: null
const dispatch = useDispatch();
const config = configFunc()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not required to be used instead create general putApi request

Comment thread src/screens/admin/ComMemberAdmin.jsx Outdated
<div className="com-member-container">
<div className="com-member-header">
{
["firstName", "lastName", "email", "phone", "dateOfBirth", "role", "options"].map(el => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not using table component created for admin panel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Table component is in another branch(admin-category-page), so it will be replaced after the branch is merged.

@SujalLama SujalLama requested a review from lmmrssa July 29, 2021 04:30
Comment thread api/src/middleware/memberPermit.js Outdated
@@ -0,0 +1,15 @@
const db = require("../models")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

move this to permission file so that we don't have lot of permission files

<div className="com-member-container">
<div className="com-member-header">
{
["firstName", "lastName", "email", "phone", "dateOfBirth", "role", "options"].map(el => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do manual lint fix
whole file needs to fix linting seems like its using 4 spaces instead of 2

import React, { useEffect, useState } from 'react'
import { useDispatch } from 'react-redux'
import DashboardLayout from '../../layout/dashboardLayout/DashboardLayout'
import { getApi, getCommunity, putApi } from '../../utils/apiFunc'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there was already another function to get current community

}
</div>
{
data.map(item => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use table.jsx from main branch

@SujalLama SujalLama added the WIP label Aug 2, 2021
@SujalLama SujalLama removed the WIP label Aug 2, 2021
@SujalLama SujalLama requested a review from lmmrssa August 2, 2021 08:31
// @route GET /api/community-users/community/:id/details
// @access Public

const getAllMemberDetails = async (req, res) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

seems like getAllMemberDetails, getAllMembers, getCommunityUsers can be single function

// flattening the array to show only one object
const newArray = data.map(item => {
const { userId, role, id } = item.dataValues
const { ...rest } = item.user
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this line is not required can be used directly below in place of rest.datavalues

)

// flattening the array to show only one object
const newArray = data.map(item => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it could just be nested to after findall

setData(data.results)
}

const allowAccess = async (id) => {
Copy link
Copy Markdown
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

[
{
img: '/img/edit-icon.svg',
action: allowAccess
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it should be list of roles for now lets take [manager, member, coach] and should show list which is not current role of member as dropdown

`${process.env.REACT_APP_API_BASE_URL}/api/communities-users/${id}/community/${currentCommunity.id}`,
{ role: 'manager' }
)
setSuccess(data)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is also not reloading table so have to manually do refresh

@SujalLama SujalLama added the WIP label Aug 3, 2021
@SujalLama SujalLama removed the WIP label Aug 4, 2021
@SujalLama SujalLama requested a review from lmmrssa August 4, 2021 12:11
@lmmrssa lmmrssa added the WIP label Aug 9, 2021
@SujalLama SujalLama added WIP and removed WIP labels Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add role in the community_users tbl

2 participants