#74 added displayname request router for Timur

parent 4ea6a7bb
......@@ -7,6 +7,7 @@ import path from 'path';
import {config} from "../config"
import { Project } from '../models/Project';
import { Member, MemberRole } from '../models/Member';
import { auth } from '../helpers';
const router:Router = express.Router();
const dataSource = myDataSource;
......@@ -48,9 +49,25 @@ router.get('/all-fields/', async (req : Request, res : Response):Promise<object>
},
}
})
console.log('all fields users ', users)
return res.send({users})
})
//** return displayName of user, requested by userId */
router.get('/display-name/:userId',auth, async (req : Request, res : Response):Promise<object> => {
const {userId} =req.params
const displayName = await dataSource
.createQueryBuilder()
.select(['user.displayName'])
.from(User, "user")
.where("user.id = :userId", { userId })
.getOne()
if (!displayName) return res.status(404).send({message:'displayName not found'})
return res.send({displayName})
})
/**create new user*/
router.post('/', upload.single("avatar"), async (req : Request, res : Response):Promise<object> => {
const {name,surname,password,email, role} = req.body;
......
......@@ -52,7 +52,7 @@ const MemberForm = ({ onSubmit, members }) => {
useEffect(() => {
dispatch(fetchProject(params.id))
}, [members, dispatch, params]);
}, [ params]);
// console.log(user)
// const onChange = (e) => {
// const value = e.target.value;
......
......@@ -13,12 +13,13 @@ const SwitchUserForm=({submitFormHandler, users})=> {
setCurrentUser(user)
setProjectsRole([])
}
console.log('projectsRoles ', projectsRoles)
useEffect(()=>{
if(currentUser?.members.length>0) {
for (let member of currentUser.members ) {
const newProjectRole = {
let newProjectRole = {
"projectName":member.project.title,
"roleName":member.roleProject
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment