Member role add (fixes: #405)#406
Conversation
| { | ||
| where: { communityId: req.params.id, active: true }, | ||
| attributes: ['userId'], | ||
| attributes: ['userId', "role"], |
| }, | ||
| role: { | ||
| type: DataTypes.STRING, | ||
| defaultValue: 'manager' |
There was a problem hiding this comment.
default value between model and migration seems to have conflict
| import AddTest from './screens/addTest/AddTest' | ||
| import LogoutUser from './screens/logoutUser/LogoutUser' | ||
| import PageNotFound from './screens/pageNotFound/PageNotFound' | ||
| import ComMemberAdmin from './screens/admin/ComMemberAdmin' |
There was a problem hiding this comment.
try to put full name so its easier to understand
| ? JSON.parse(localStorage.getItem('currentCommunity')) | ||
| : null | ||
| const dispatch = useDispatch(); | ||
| const config = configFunc() |
There was a problem hiding this comment.
this is not required to be used instead create general putApi request
| <div className="com-member-container"> | ||
| <div className="com-member-header"> | ||
| { | ||
| ["firstName", "lastName", "email", "phone", "dateOfBirth", "role", "options"].map(el => { |
There was a problem hiding this comment.
this is not using table component created for admin panel
There was a problem hiding this comment.
Table component is in another branch(admin-category-page), so it will be replaced after the branch is merged.
| @@ -0,0 +1,15 @@ | |||
| const db = require("../models") | |||
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
there was already another function to get current community
| } | ||
| </div> | ||
| { | ||
| data.map(item => { |
| // @route GET /api/community-users/community/:id/details | ||
| // @access Public | ||
|
|
||
| const getAllMemberDetails = async (req, res) => { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
it could just be nested to after findall
| setData(data.results) | ||
| } | ||
|
|
||
| const allowAccess = async (id) => { |
There was a problem hiding this comment.
this should be able to switch between roles not always make manager
| [ | ||
| { | ||
| img: '/img/edit-icon.svg', | ||
| action: allowAccess |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
this is also not reloading table so have to manually do refresh
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
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