Merge pull request #40 from AdvancedAlgos/develop
Fixes for multiple issues
This commit is contained in:
67 files changed
+806
-745
No files matched your search
+5
-1
@@ -1,3 +1,7 @@
|
||||
{
|
||||
"presets": ["@babel/preset-env"]
|
||||
"presets": ["@babel/preset-env"],
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-throw-expressions",
|
||||
["@babel/plugin-proposal-class-properties", { "loose": true }]
|
||||
]
|
||||
}
|
||||
Generated
+42
@@ -575,6 +575,20 @@
|
||||
"@babel/plugin-syntax-async-generators": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-proposal-class-properties": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.1.0.tgz",
|
||||
"integrity": "sha512-/PCJWN+CKt5v1xcGn4vnuu13QDoV+P7NcICP44BoonAJoPSGwVkgrXihFIQGiEjjPlUDBIw1cM7wYFLARS2/hw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/helper-function-name": "^7.1.0",
|
||||
"@babel/helper-member-expression-to-functions": "^7.0.0",
|
||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/helper-replace-supers": "^7.1.0",
|
||||
"@babel/plugin-syntax-class-properties": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-proposal-json-strings": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz",
|
||||
@@ -602,6 +616,16 @@
|
||||
"@babel/plugin-syntax-optional-catch-binding": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-proposal-throw-expressions": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-throw-expressions/-/plugin-proposal-throw-expressions-7.0.0.tgz",
|
||||
"integrity": "sha512-CA2EUiwnbXrsdV4hy3jYghm91WaL7zL7xYfu628dyItRr6gylbRxshghGEK/Hhm//rR58N3PBmEeuYqSW57IUQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/plugin-syntax-throw-expressions": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-proposal-unicode-property-regex": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.0.0.tgz",
|
||||
@@ -620,6 +644,15 @@
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-syntax-class-properties": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.0.0.tgz",
|
||||
"integrity": "sha512-cR12g0Qzn4sgkjrbrzWy2GE7m9vMl/sFkqZ3gIpAQdrvPDnLM8180i+ANDFIXfjHo9aqp0ccJlQ0QNZcFUbf9w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-syntax-json-strings": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.0.0.tgz",
|
||||
@@ -644,6 +677,15 @@
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-syntax-throw-expressions": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-throw-expressions/-/plugin-syntax-throw-expressions-7.0.0.tgz",
|
||||
"integrity": "sha512-/5uORdWlPta/ALhI5zKtm0Y9vAYOa7HJMML0OnCGk9XZA4hpGjb0Xjt/OVDCJVawC/4FrlAGCHOaj9BtWeVDvg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/plugin-transform-arrow-functions": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.0.0.tgz",
|
||||
|
||||
@@ -37,7 +37,10 @@
|
||||
"winston": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-class-properties": "^7.1.0",
|
||||
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
|
||||
"graphql-cli": "^2.16.5",
|
||||
"lodash.merge": "^4.6.1",
|
||||
"npm-run-all": "4.1.3",
|
||||
"prisma": "^1.18.1"
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
const getMember = async (req, res, next, db) => {
|
||||
if (!req.user) return next()
|
||||
const member = await db.query.member({
|
||||
where: { authId: req.user.sub }
|
||||
})
|
||||
req.user = { user: member }
|
||||
next()
|
||||
}
|
||||
|
||||
module.exports = { getMember }
|
||||
@@ -1,28 +0,0 @@
|
||||
const jwksClient = require('jwks-rsa')
|
||||
const jwt = require('jsonwebtoken')
|
||||
const jwks = jwksClient({
|
||||
cache: true,
|
||||
rateLimit: true,
|
||||
jwksRequestsPerMinute: 1,
|
||||
jwksUri: `https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`
|
||||
})
|
||||
|
||||
const validateIdToken = idToken =>
|
||||
new Promise((resolve, reject) => {
|
||||
const { header, payload } = jwt.decode(idToken, { complete: true })
|
||||
if (!header || !header.kid || !payload) reject(new Error('Invalid Token'))
|
||||
jwks.getSigningKey(header.kid, (err, key) => {
|
||||
if (err) reject({ error: `Error getting signing key: ${err.message}` })
|
||||
jwt.verify(
|
||||
idToken,
|
||||
key.publicKey,
|
||||
{ algorithms: ['RS256'] },
|
||||
(err, decoded) => {
|
||||
if (err) reject('jwt verify error: ' + err.message)
|
||||
resolve(decoded)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
module.exports = { validateIdToken }
|
||||
+32
-61
@@ -1,13 +1,12 @@
|
||||
import { SchemaDirectiveVisitor } from 'apollo-server-express'
|
||||
import _get from 'lodash.get'
|
||||
import { logger } from '../logger'
|
||||
|
||||
import { AuthenticationError, ForbiddenError } from '../errors'
|
||||
import { validateIdToken } from '../auth/validateIdToken'
|
||||
import { logger, AuthenticationError } from '../logger'
|
||||
|
||||
const memberLocationOnContext = 'request.user'
|
||||
const userIdOnContext = 'request.headers.userid'
|
||||
const bearerAccessToken = 'request.headers.authorization'
|
||||
|
||||
const ctxUserId = ctx => _get(ctx, userIdOnContext)
|
||||
const ctxMember = ctx => _get(ctx, memberLocationOnContext)
|
||||
const ctxToken = ctx => _get(ctx, bearerAccessToken)
|
||||
|
||||
@@ -29,48 +28,20 @@ const createMember = async (ctx, idToken, info) => {
|
||||
return member
|
||||
}
|
||||
|
||||
const isLoggedIn = async ctx => {
|
||||
logger.info(`isLoggedIn 0: ${JSON.stringify(ctx.request.headers)}`)
|
||||
let member = ctxMember(ctx, memberLocationOnContext)
|
||||
let token = ctxToken(ctx, bearerAccessToken)
|
||||
let memberToken
|
||||
logger.info('isLoggedIn: ', member, token)
|
||||
if (!member && token) {
|
||||
let scheme, credentials
|
||||
const tokenParts = token.split(' ')
|
||||
if (tokenParts.length === 2) {
|
||||
scheme = tokenParts[0]
|
||||
credentials = tokenParts[1]
|
||||
}
|
||||
|
||||
if (/^Bearer$/i.test(scheme)) {
|
||||
token = credentials
|
||||
//verify token
|
||||
try {
|
||||
memberToken = await validateIdToken(token)
|
||||
const authId = memberToken.sub
|
||||
exists = await ctx.db.query.member({ where: { authId: authId } })
|
||||
if (!member && exists === null) {
|
||||
member = await createMember(ctx, memberToken).then(res => {
|
||||
return res
|
||||
})
|
||||
|
||||
return member
|
||||
}
|
||||
return member
|
||||
} catch (err) {
|
||||
memberToken = false
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!member) {
|
||||
throw new AuthenticationError('Access token is missing or expired')
|
||||
}
|
||||
const isUserId = async ctx => {
|
||||
logger.info(`isUserId 0: ${ctx.request.headers.userid}`)
|
||||
logger.info(`isUserId 1: ${ctx.request}`)
|
||||
let member = await ctxUserId(ctx)
|
||||
logger.info(member)
|
||||
if (!member) {
|
||||
throw new AuthenticationError()
|
||||
} else {
|
||||
return member
|
||||
}
|
||||
}
|
||||
|
||||
const isRequestingMemberAlsoOwner = ({ ctx, memberId, type, typeId }) =>
|
||||
ctx.db.exists[type]({ slug: typeId, owner: memberId })
|
||||
const isRequestingMemberAlsoOwner = ({ ctx, memberId, type, teamSlug }) =>
|
||||
ctx.db.exists[type]({ slug: teamSlug, owner: memberId })
|
||||
const isRequestingMember = ({ ctx, memberId }) => ctx.db.exists.Member({ authId: memberId })
|
||||
|
||||
|
||||
@@ -89,17 +60,18 @@ const assertAuth = ctx => {
|
||||
// Directive resolvers (apollo v1 syntax)
|
||||
export const directiveResolvers = {
|
||||
isAuthenticated: async (next, source, args, ctx) => {
|
||||
let result = await isLoggedIn(ctx)
|
||||
logger.info('directive isAuthenticated: ', result)
|
||||
let result = await isUserId(ctx)
|
||||
logger.info('directive isAuthenticated: ')
|
||||
logger.info(await result)
|
||||
return next(result)
|
||||
},
|
||||
hasRole: (next, source, { roles }, ctx) => {
|
||||
const { role } = isLoggedIn(ctx)
|
||||
const { role } = isUserId(ctx)
|
||||
logger.info('directive hasRole: ', role)
|
||||
if (roles.includes(role)) {
|
||||
return next()
|
||||
}
|
||||
throw new ForbiddenError('Insufficient permissions')
|
||||
throw new AuthenticationError('Insufficient permissions')
|
||||
},
|
||||
isOwner: async (next, source, { type }, ctx) => {
|
||||
logger.info('directive isOwner: ', source, type, ctx)
|
||||
@@ -107,47 +79,46 @@ export const directiveResolvers = {
|
||||
source && source.id
|
||||
? source
|
||||
: ctx.request.body.variables ? ctx.request.body.variables : { id: null }
|
||||
const user = await isLoggedIn(ctx)
|
||||
const memberId = user.sub
|
||||
const userId = await isUserId(ctx)
|
||||
const isOwner =
|
||||
type === `Member`
|
||||
? memberId === typeId
|
||||
: await isRequestingMemberAlsoOwner({ ctx, memberId, type, typeId })
|
||||
: await isRequestingMemberAlsoOwner({ ctx, userId, type, typeId })
|
||||
if (isOwner) {
|
||||
return next()
|
||||
}
|
||||
throw new ForbiddenError('Insufficient permissions')
|
||||
throw new AuthenticationError('Insufficient permissions')
|
||||
},
|
||||
isOwnerOrHasRole: async (next, source, { roles, type }, ctx, ...p) => {
|
||||
const { authId: memberId } = await isLoggedIn(ctx)
|
||||
logger.info('directive isOwnerOrHasRole 1: ', memberId, roles, type)
|
||||
if(memberId === undefined && role=== undefined) throw new Error(`Not logged in`)
|
||||
const userId = await isUserId(ctx)
|
||||
logger.info('directive isOwnerOrHasRole 1: ', userId, roles, type)
|
||||
if(userId === undefined && role=== undefined) throw new Error(`Not logged in`)
|
||||
if (roles.includes(role)) {
|
||||
return next()
|
||||
}
|
||||
|
||||
const { authId: typeId } = ctx.request.body.variables
|
||||
const { teamSlug } = ctx.request.body.variables
|
||||
const isOwner = await isRequestingMemberAlsoOwner({
|
||||
ctx,
|
||||
memberId,
|
||||
userId,
|
||||
type,
|
||||
typeId
|
||||
teamSlug
|
||||
})
|
||||
logger.info('directive isOwnerOrHasRole 2: ', typeId, memberId, role, isOwner)
|
||||
logger.info('directive isOwnerOrHasRole 2: ', teamSlug, userId, role, isOwner)
|
||||
if (isOwner) {
|
||||
return next()
|
||||
}
|
||||
|
||||
const hasRole = await isRequestingMember({
|
||||
ctx,
|
||||
memberId,
|
||||
userId,
|
||||
type,
|
||||
typeId
|
||||
teamSlug
|
||||
})
|
||||
if(hasRole){
|
||||
return next()
|
||||
}
|
||||
throw new ForbiddenError('Insufficient permissions')
|
||||
throw new AuthenticationError('Insufficient permissions')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const gql = require('graphql-tag')
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
const TEAM_FB_FRAGMENT = gql`{
|
||||
id
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
const gql = require('graphql-tag')
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
const TEAMS_CONNECTIONS_FRAGMENT = gql`{
|
||||
edges {
|
||||
@@ -1,4 +1,4 @@
|
||||
const gql = require('graphql-tag')
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
const TEAMS_FRAGMENT = gql`{
|
||||
id
|
||||
@@ -0,0 +1,17 @@
|
||||
export const createMember = async function (ctx, info, authId) {
|
||||
logger.info('createMember', authId)
|
||||
const member = await ctx.db.mutation.upsertMember({
|
||||
where: {
|
||||
authId: authId,
|
||||
},
|
||||
create: {
|
||||
authId: authId,
|
||||
alias: idToken.nickname
|
||||
},
|
||||
update: {
|
||||
authId: authId,
|
||||
alias: idToken.nickname
|
||||
}
|
||||
}, info)
|
||||
return member
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,194 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import { getUser } from '../../../middleware/getMember'
|
||||
|
||||
import { sendTeamMemberInvite, sendTeamCreateConfirmation, verifyInviteToken } from '../../../email/sendgrid'
|
||||
|
||||
import TEAMS_CONNECTIONS_FRAGMENT from '../../fragments/TeamsConnectionsFragment'
|
||||
import TEAMS_FRAGMENT from '../../fragments/TeamsFragment'
|
||||
import TEAM_FB_FRAGMENT from '../../fragments/TeamFBFragment'
|
||||
|
||||
import { logger, AuthenticationError } from '../../../logger'
|
||||
|
||||
export const resolvers = {
|
||||
Mutation: {
|
||||
async sendMemberInviteSG(parent, { email, teamId }, ctx, info) {
|
||||
const team = await ctx.db.query.team({ where: { id: teamId } }, TEAMS_FRAGMENT)
|
||||
const addMember = await ctx.db.mutation.upsertTeamMembers({
|
||||
where:{email: email},
|
||||
create:{role:'MEMBER', email:email, team: {connect: {id: teamId}}, status:{create:{status: 'INVITED', reason: `Invited by ${team.members[0].member.alias}`}}},
|
||||
update:{role: 'MEMBER', email: email, team: {connect: {id: teamId}}, status:{create:{status: 'INVITED', reason: `Invite resent by ${team.members[0].member.alias}`}}}},
|
||||
`{ id }`)
|
||||
const sendInvite = await sendTeamMemberInvite(email, team)
|
||||
return sendInvite
|
||||
},
|
||||
async verifyTeamInvite(parent, { token }, ctx, info) {
|
||||
let verifiedToken = null
|
||||
let team = null
|
||||
try {
|
||||
verifiedToken = await verifyInviteToken(token)
|
||||
team = {
|
||||
email: verifiedToken.email,
|
||||
team: {
|
||||
slug: verifiedToken.team
|
||||
}
|
||||
}
|
||||
logger.info('verifyTeamInvite.token: ', await verifiedToken)
|
||||
} catch (err) {
|
||||
logger.debug('verifyTeamInvite. err: ', err)
|
||||
throw new Error(err.message)
|
||||
}
|
||||
return team
|
||||
},
|
||||
async createTeam(parent, { name, slug, botName, botSlug }, ctx, info) {
|
||||
logger.info('createTeam ctx.request.user:')
|
||||
logger.info(ctx.request.user)
|
||||
|
||||
const authId = ctx.request.headers.userid
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
|
||||
return getUser(authId)
|
||||
.then(async result => {
|
||||
logger.info('axios:')
|
||||
logger.info(result)
|
||||
|
||||
const alias = result.data.users_User.alias
|
||||
const email = result.data.users_User.email
|
||||
const avatar = 'https://aadevelop.blob.core.windows.net/module-teams/module-default/aa-avatar-default.png'
|
||||
const banner = 'https://aadevelop.blob.core.windows.net/module-teams/module-default/aa-banner-default.png'
|
||||
|
||||
const createTeamUrl = encodeURI(`${slug}/${name}/${alias}/${botSlug}/${botName}`)
|
||||
logger.info('createTeamUrl:')
|
||||
logger.info(JSON.stringify(await createTeamUrl))
|
||||
|
||||
const platformUrl = 'https://develop.advancedalgos.net/AABrowserAPI/newTeam/'
|
||||
// const platformUrl = 'http://localhost:1337/AABrowserAPI/teamSetup/'
|
||||
|
||||
logger.info(`${platformUrl}${createTeamUrl}/${authId}`)
|
||||
const createPlatformTeam = await axios.get(`${platformUrl}${createTeamUrl}/${authId}`)
|
||||
.then((result) => {
|
||||
console.log('createPlatformTeam result:', result.data)
|
||||
if(result.data.message === 'Team Name already taken'){
|
||||
return result.data.message
|
||||
}
|
||||
if(result.data.result === 'Fail'){
|
||||
return result.data.message
|
||||
}
|
||||
return result
|
||||
})
|
||||
.catch(err =>{
|
||||
logger.debug('createPlatformTeam err:')
|
||||
logger.debug(err)
|
||||
throw new Error(err)
|
||||
})
|
||||
console.log('createPlatformTeam returned: ', await createPlatformTeam)
|
||||
if(await createPlatformTeam === 'Team Name already taken'){
|
||||
return createPlatformTeam
|
||||
}
|
||||
|
||||
const existingMember = await ctx.db.query.member({ where: { authId } }, `{id}`)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'existingMember error: ')
|
||||
return err
|
||||
})
|
||||
|
||||
logger.info('existingMember:')
|
||||
logger.info(await existingMember)
|
||||
|
||||
let createTeam
|
||||
if(existingMember.id !== null){
|
||||
logger.info('createTeam with existingMember:')
|
||||
createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {connect: {authId: authId}}, role: 'OWNER', status: { create: { status: 'ACTIVE', reason: `Connected to Team ${name}`}}}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeamMutation error: ')
|
||||
return err
|
||||
})
|
||||
} else {
|
||||
logger.info('createTeam without existingMember:')
|
||||
createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {create: {authId: authId, alias: alias, visible:'true', status: { create: { status: 'ACTIVE', reason: `Created team ${name}`}}}}, role: 'OWNER', status: { create: { status: 'ACTIVE', reason: `Created with Team ${name}`}}}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeamMutation error: ')
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// sendTeamCreateConfirmation(email, name, botName)
|
||||
|
||||
return createTeam
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.debug('createTeam error: ')
|
||||
return err
|
||||
})
|
||||
},
|
||||
async updateTeamProfile(parent, { slug, owner, description, motto, avatar, banner }, ctx, info) {
|
||||
return ctx.db.mutation.updateTeam({data:{profile: {update: {description: description, motto: motto, avatar: avatar, banner: banner}}}, where:{slug: slug}}, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug('createTeam error: ', err)
|
||||
return err
|
||||
})
|
||||
},
|
||||
async updateFB(parent, { fbId, avatar}, ctx, info) {
|
||||
return ctx.db.mutation.updateFinancialBeings({data:{avatar:avatar}, where:{id:fbId}}, info)
|
||||
.catch((err) => {
|
||||
logger.debug('createTeam error: ', err)
|
||||
return err
|
||||
})
|
||||
},
|
||||
async deleteTeam(parent, { slug, botSlug }, ctx, info) {
|
||||
logger.info('DeleteTeam resolver')
|
||||
const authId = ctx.request.headers.userid
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
logger.info(authId)
|
||||
logger.info('getUser')
|
||||
logger.info(getUser)
|
||||
|
||||
return getUser(authId)
|
||||
.then(async result => {
|
||||
logger.info('deleteTeam axios:')
|
||||
logger.info(await result)
|
||||
|
||||
const alias = await result.data.users_User.alias
|
||||
// const email = result.data.users_User.email
|
||||
const deleteTeamUrl = encodeURI(`${slug}/${alias}/${botSlug}`)
|
||||
logger.info('deleteTeamUrl:')
|
||||
logger.info(JSON.stringify(await deleteTeamUrl))
|
||||
|
||||
const platformUrl = 'https://develop.advancedalgos.net/AABrowserAPI/deleteTeam/'
|
||||
// const platformUrl = 'http://localhost:1337/AABrowserAPI/teamSetup/'
|
||||
|
||||
logger.info(`${platformUrl}${deleteTeamUrl}/${authId}`)
|
||||
const deletePlatformTeam = await axios.get(`${platformUrl}${deleteTeamUrl}/${authId}`)
|
||||
.then((result) => {
|
||||
console.log('deletePlatformTeam result:', result.data)
|
||||
if(result.data.result === 'Fail'){
|
||||
return result.data.message
|
||||
}
|
||||
return result
|
||||
})
|
||||
.catch(err =>{
|
||||
logger.debug('deletePlatformTeam err:')
|
||||
logger.debug(err)
|
||||
throw new Error(err)
|
||||
})
|
||||
console.log('deletePlatformTeam returned: ', await deletePlatformTeam)
|
||||
|
||||
return ctx.db.mutation.deleteTeam({ where: { slug } }, info)
|
||||
.catch((res) => {
|
||||
logger.info('deleteTeam error: ', res)
|
||||
const errors = res.graphQLErrors.map((error) => {
|
||||
return error.message
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.debug('deleteTeam error: ')
|
||||
return err
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { logger, AuthenticationError, DatabaseError } from '../../../logger'
|
||||
|
||||
export const member = async (parent, arg, ctx, info) => {
|
||||
logger.info(' --> resolver.member')
|
||||
logger.info(ctx.request)
|
||||
const authId = ctx.request.headers.userid
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
return ctx.db.query.member({ where: { authId } }, info)
|
||||
.catch(err => {
|
||||
logger.debug('resolver.member error: ')
|
||||
logger.debug(err)
|
||||
throw new DatabaseError(`Member Data Error: ${err.message}`)
|
||||
})
|
||||
}
|
||||
|
||||
export const owner = async (parent, args, ctx, info) => {
|
||||
logger.info('resolver.query.owner ctx: ')
|
||||
const authId = ctx.request.userId
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
return ctx.db.query.member({ where: { authId: authId } }, info)
|
||||
.catch(err => {
|
||||
logger.debug('resolver.owner error: ')
|
||||
logger.debug(err)
|
||||
throw new DatabaseError(`Member Data Error: ${err.message}`)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { logger } from '../../../logger'
|
||||
|
||||
import TEAMS_CONNECTIONS_FRAGMENT from '../../fragments/TeamsConnectionsFragment'
|
||||
import TEAMS_FRAGMENT from '../../fragments/TeamsFragment'
|
||||
|
||||
export const teams = async (parent, args, ctx, info) => {
|
||||
logger.info('teams')
|
||||
console.log('teams')
|
||||
return ctx.db.query.teamsConnection({}, TEAMS_CONNECTIONS_FRAGMENT)
|
||||
}
|
||||
|
||||
export const teamById = async (parent, { id }, ctx, info) => {
|
||||
return ctx.db.query.team({ where: { id } }, info)
|
||||
}
|
||||
|
||||
export const teamByName = async (parent, { name }, ctx, info) => {
|
||||
return ctx.db.query.team({ where: { name: name } }, `{ name }`)
|
||||
}
|
||||
|
||||
export const teamWithRole = async (parent, { teamId, role }, ctx, info) => {
|
||||
return ctx.db.query.teamsConnection({where: {AND: [{id: teamId},{members_some:{role: role}}]}, first:1}, info)
|
||||
}
|
||||
|
||||
export const teamsByOwner = async (parent, args, ctx, info) => {
|
||||
logger.info('teamsByOwner')
|
||||
const authId = ctx.request.headers.userid
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
return ctx.db.query.teams({where: { owner: authId }, orderBy:'updatedAt_DESC'}, TEAMS_FRAGMENT)
|
||||
}
|
||||
|
||||
export const teamsByRole = async (parent, args, ctx, info) => {
|
||||
const authId = ctx.request.headers.userid
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
let teamAdmin
|
||||
try {
|
||||
teamAdmin= await ctx.db.query.teams({where: {members_some: {AND: [{member: {authId: authId}, role_not:'MEMBER'}]}}}, TEAMS_FRAGMENT)
|
||||
} catch (err) {
|
||||
logger.debug('teamsByRole error: ')
|
||||
logger.debug(err)
|
||||
const errors = res.graphQLErrors.map((error) => {
|
||||
return error.message
|
||||
})
|
||||
return errors
|
||||
}
|
||||
logger.info('teamsByRole teamAdmin: ', teamAdmin)
|
||||
return teamAdmin
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { logger } from '../../../logger'
|
||||
|
||||
export const fbByTeamMember = async (parent, args, ctx, info) => {
|
||||
logger.info('fbByTeamMember: ', args, ctx.request, ctx.request.res.req.user)
|
||||
const authId = ctx.request.headers.userid
|
||||
if (!authId) {
|
||||
throw new AuthenticationError()
|
||||
}
|
||||
let teamMemberFB = await ctx.db.query.teams({where: {members_some: {AND: [{member: {authId: authId}}]}}, orderBy: 'updatedAt_DESC'}, TEAM_FB_FRAGMENT)
|
||||
logger.info('fbByTeamMember response: ', await teamMemberFB[0])
|
||||
return teamMemberFB[0]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { logger } from '../../../logger'
|
||||
|
||||
import { member, owner } from './Member'
|
||||
import { teams, teamById, teamByName, teamWithRole, teamsByOwner, teamsByRole } from './Team'
|
||||
import{ fbByTeamMember } from './TeamMember'
|
||||
|
||||
export const resolvers = {
|
||||
Query: {
|
||||
member: (parent, arg, ctx, info) => member(parent, arg, ctx, info),
|
||||
teams: (parent, arg, ctx, info) => teams(parent, arg, ctx, info),
|
||||
teamById: (parent, arg, ctx, info) => teamById(parent, arg, ctx, info),
|
||||
teamByName: (parent, arg, ctx, info) => teamByName(parent, arg, ctx, info),
|
||||
teamWithRole: (parent, arg, ctx, info) => teamWithRole(parent, arg, ctx, info),
|
||||
teamsByOwner: (parent, arg, ctx, info) => teamsByOwner(parent, arg, ctx, info),
|
||||
teamsByRole: (parent, arg, ctx, info) => teamsByRole(parent, arg, ctx, info),
|
||||
owner: (parent, arg, ctx, info) => owner(parent, arg, ctx, info),
|
||||
fbByTeamMember: (parent, arg, ctx, info) => fbByTeamMember(parent, arg, ctx, info)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { resolvers as queryResolvers } from './Query'
|
||||
import { resolvers as mutationResolvers } from './Mutation'
|
||||
|
||||
export const resolvers = merge(queryResolvers, mutationResolvers)
|
||||
@@ -1,4 +1,4 @@
|
||||
# import Query.TeamConnection, Team from "./generated/prisma.graphql"
|
||||
# import Query.TeamConnection, Team from "../generated/prisma.graphql"
|
||||
|
||||
directive @isAuthenticated on QUERY | FIELD | MUTATION
|
||||
directive @hasRole(roles: [String]) on QUERY | FIELD | MUTATION
|
||||
@@ -11,12 +11,11 @@ type Query {
|
||||
teamByName(name: String!): Team
|
||||
teamById(teamId: String!): Team
|
||||
teamWithRole(teamId: String!, role: String!): Team
|
||||
teamsByOwner(ownerId: String!): [Team!]! @isAuthenticated
|
||||
teamsByOwner: [Team!]! @isAuthenticated
|
||||
teamsByRole: [Team!]! @isAuthenticated
|
||||
fbByTeamMember: Team @isAuthenticated
|
||||
owner: Member @isAuthenticated
|
||||
currentMember: Member @isAuthenticated
|
||||
member(authId: String!): Member @isAuthenticated
|
||||
member: Member @isAuthenticated
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
@@ -25,7 +24,7 @@ type Mutation {
|
||||
createTeam(name: String!, slug: String!, botName: String!, botSlug: String!): Team @isAuthenticated
|
||||
updateTeamProfile(slug: String!, description: String, motto: String, avatar: String, banner: String): Team @isAuthenticated
|
||||
updateFB(fbId: String!, avatar: String): FinancialBeings @isAuthenticated
|
||||
deleteTeam(slug: String!): Team @isAuthenticated @isOwner(type: "Team")
|
||||
deleteTeam(slug: String!, botSlug: String!): Team @isAuthenticated @isOwner(type: "Team")
|
||||
sendMemberInviteSG(email: String!, teamId: String!): String
|
||||
confirmMember(token: String!): String
|
||||
removeTeamMember(teamId: String!, memberId: String!): String
|
||||
@@ -35,18 +34,14 @@ fragment MemberInfo on Member {
|
||||
id
|
||||
authId
|
||||
alias
|
||||
isActive
|
||||
profile {
|
||||
...MemberProfileInfo
|
||||
visible
|
||||
status {
|
||||
...MemberStatusInfo
|
||||
}
|
||||
}
|
||||
|
||||
fragment MemberProfileInfo on MemberProfile {
|
||||
firstName
|
||||
lastName
|
||||
email
|
||||
avatar
|
||||
role {
|
||||
name
|
||||
}
|
||||
fragment MemberStatusInfo on MemberStatus {
|
||||
status
|
||||
reason
|
||||
createdAt
|
||||
}
|
||||
+7
-309
@@ -13,17 +13,10 @@ import { importSchema } from 'graphql-import'
|
||||
import parser from 'fast-xml-parser'
|
||||
import axios from 'axios'
|
||||
|
||||
import checkJwt from './auth/middleware/jwt'
|
||||
import { getMember } from './auth/middleware/getMember'
|
||||
import { validateIdToken } from './auth/validateIdToken'
|
||||
import { resolvers } from './graphql/resolvers'
|
||||
|
||||
import { schemaDirectives } from './directives'
|
||||
|
||||
import { sendTeamMemberInvite, sendTeamCreateConfirmation, verifyInviteToken } from './email/sendgrid'
|
||||
|
||||
import TEAMS_FRAGMENT from './graphql/TeamsFragment'
|
||||
import TEAMS_CONNECTIONS_FRAGMENT from './graphql/TeamsConnectionsFragment'
|
||||
import TEAM_FB_FRAGMENT from './graphql/TeamFBFragment'
|
||||
|
||||
import pubsub from './pubsub'
|
||||
import { logger } from './logger'
|
||||
|
||||
@@ -32,286 +25,6 @@ const GRAPHQL_SUBSCRIPTIONS = '/graphql'
|
||||
const PORT = 4001
|
||||
const NODE_ENV = 'development'
|
||||
|
||||
const createMember = async function (ctx, info, idToken) {
|
||||
logger.info('createMember', idToken)
|
||||
const member = await ctx.db.mutation.upsertMember({
|
||||
where: {
|
||||
authId: idToken.sub,
|
||||
},
|
||||
create: {
|
||||
authId: idToken.sub,
|
||||
alias: idToken.nickname
|
||||
},
|
||||
update: {
|
||||
authId: idToken.sub,
|
||||
alias: idToken.nickname
|
||||
}
|
||||
}, info)
|
||||
return member
|
||||
}
|
||||
|
||||
const ctxMember = ctx => ctx.request.user
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
async member(parent, arg, ctx, info) {
|
||||
logger.info('member: ', parent, arg)
|
||||
return ctx.db.query.member({ where: { authId: arg.authId } }, info)
|
||||
},
|
||||
async currentMember(parent, args, ctx, info) {
|
||||
logger.info('currentMember: ', ctx.request.res.req.user, ctx.token)
|
||||
const authId = ctx.request.res.req.user.sub
|
||||
|
||||
return ctx.db.query.member({ where: { authId } }, info)
|
||||
},
|
||||
teams(parent, args, ctx, info) {
|
||||
logger.info('teams: ', ctx.request.res)
|
||||
return ctx.db.query.teamsConnection({}, TEAMS_CONNECTIONS_FRAGMENT)
|
||||
},
|
||||
async teamById(parent, { id }, ctx, info) {
|
||||
return ctx.db.query.team({ where: { id } }, info)
|
||||
},
|
||||
async teamByName(parent, { name }, ctx, info) {
|
||||
return ctx.db.query.team({ where: { name: name } }, `{ name }`)
|
||||
},
|
||||
async teamWithRole(parent, { teamId, role }, ctx, info) {
|
||||
return ctx.db.query.teamsConnection({where: {AND: [{id: teamId},{members_some:{role: role}}]}, first:1}, info)
|
||||
},
|
||||
async teamsByOwner(parent, { ownerId }, ctx, info) {
|
||||
return ctx.db.query.teams({where: { owner: ownerId }, orderBy:'updatedAt_DESC'}, TEAMS_FRAGMENT)
|
||||
},
|
||||
async teamsByRole(parent, args, ctx, info) {
|
||||
const authId = ctx.request.user.sub
|
||||
let teamAdmin
|
||||
try {
|
||||
teamAdmin= await ctx.db.query.teams({where: {members_some: {AND: [{member: {authId: authId}, role_not:'MEMBER'}]}}}, TEAMS_FRAGMENT)
|
||||
} catch (err) {
|
||||
logger.debug('teamsByRole error: ')
|
||||
logger.debug(err)
|
||||
const errors = res.graphQLErrors.map((error) => {
|
||||
return error.message
|
||||
})
|
||||
return errors
|
||||
}
|
||||
logger.info('teamsByRole teamAdmin: ', teamAdmin)
|
||||
return teamAdmin
|
||||
},
|
||||
async fbByTeamMember(parent, args, ctx, info) {
|
||||
logger.info('fbByTeamMember: ', args, ctx.request, ctx.request.res.req.user)
|
||||
const authId = ctx.request.user.sub
|
||||
let teamMemberFB = await ctx.db.query.teams({where: {members_some: {AND: [{member: {authId: authId}}]}}, orderBy: 'updatedAt_DESC'}, TEAM_FB_FRAGMENT)
|
||||
logger.info('fbByTeamMember response: ', await teamMemberFB[0])
|
||||
return teamMemberFB[0]
|
||||
},
|
||||
async owner(parent, args, ctx, info) {
|
||||
logger.info('resolver.query.owner ctx: ', ctxMember(ctx))
|
||||
return ctx.db.query.member({ where: { id: ctxMember(ctx).authId } }, info)
|
||||
.catch(err => {
|
||||
logger.debug('createTeam error: ', err)
|
||||
const errors = res.graphQLErrors.map((error) => {
|
||||
return error.message
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
async authenticate(parent, { idToken }, ctx, info) {
|
||||
let memberToken = null
|
||||
try {
|
||||
memberToken = await validateIdToken(idToken)
|
||||
logger.info('authenticate.memberToken: ', await memberToken)
|
||||
} catch (err) {
|
||||
logger.debug('authenticat.validateIdToken err: ', err)
|
||||
throw new Error(err.message)
|
||||
}
|
||||
const authId = memberToken.sub
|
||||
let member = await ctx.db.query.member({ where: { authId } }, info)
|
||||
|
||||
if (!member) {
|
||||
try {
|
||||
return createMember(ctx, info, memberToken)
|
||||
} catch (error) {
|
||||
throw new Error(error.message)
|
||||
}
|
||||
}
|
||||
return member
|
||||
},
|
||||
async sendMemberInviteSG(parent, { email, teamId }, ctx, info) {
|
||||
const team = await ctx.db.query.team({ where: { id: teamId } }, TEAMS_FRAGMENT)
|
||||
const addMember = await ctx.db.mutation.upsertTeamMembers({
|
||||
where:{email: email},
|
||||
create:{role:'MEMBER', email:email, team: {connect: {id: teamId}}, status:{create:{status: 'INVITED', reason: `Invited by ${team.members[0].member.alias}`}}},
|
||||
update:{role: 'MEMBER', email: email, team: {connect: {id: teamId}}, status:{create:{status: 'INVITED', reason: `Invite resent by ${team.members[0].member.alias}`}}}},
|
||||
`{ id }`)
|
||||
const sendInvite = await sendTeamMemberInvite(email, team)
|
||||
return sendInvite
|
||||
},
|
||||
async verifyTeamInvite(parent, { token }, ctx, info) {
|
||||
let verifiedToken = null
|
||||
let team = null
|
||||
try {
|
||||
verifiedToken = await verifyInviteToken(token)
|
||||
team = {
|
||||
email: verifiedToken.email,
|
||||
team: {
|
||||
slug: verifiedToken.team
|
||||
}
|
||||
}
|
||||
logger.info('verifyTeamInvite.token: ', await verifiedToken)
|
||||
} catch (err) {
|
||||
logger.debug('verifyTeamInvite. err: ', err)
|
||||
throw new Error(err.message)
|
||||
}
|
||||
return team
|
||||
},
|
||||
async createTeam(parent, { name, slug, botName, botSlug }, ctx, info) {
|
||||
logger.info('createTeam ctx.request.user:')
|
||||
logger.info(ctx.request.user)
|
||||
|
||||
const authId = ctx.request.user.sub
|
||||
|
||||
const encodedAuthId = encodeURI(authId)
|
||||
const encodedURL = `https://users-api.advancedalgos.net/graphql?query=%7B%0A%20%20userByAuthId(authId:%20%22${authId}%22)%20%7B%0A%20%20%20%20id%0A%20%20%20%20email%0A%20%20%20%20alias%0A%20%20%7D%0A%7D%0A`
|
||||
const decodedURL = decodeURI(encodedURL)
|
||||
return getUser(authId)
|
||||
.then(async result => {
|
||||
logger.info('axios:')
|
||||
logger.info(result)
|
||||
|
||||
const alias = result.data.users_UserByAuthId.alias
|
||||
const email = result.data.users_UserByAuthId.email
|
||||
const avatar = 'https://aadevelop.blob.core.windows.net/module-teams/module-default/aa-avatar-default.png'
|
||||
const banner = 'https://aadevelop.blob.core.windows.net/module-teams/module-default/aa-banner-default.png'
|
||||
|
||||
const createTeamUrl = encodeURI(`${slug}/${name}/${alias}/${botSlug}/${botName}`)
|
||||
logger.info('createTeamUrl:')
|
||||
logger.info(JSON.stringify(await createTeamUrl))
|
||||
|
||||
const platformUrl = 'https://develop.advancedalgos.net/AABrowserAPI/teamSetup/'
|
||||
// const platformUrl = 'http://localhost:1337/AABrowserAPI/teamSetup/'
|
||||
|
||||
logger.info(`${platformUrl}${createTeamUrl}/${authId}`)
|
||||
const createPlatformTeam = await axios.get(`${platformUrl}${createTeamUrl}/${authId}`)
|
||||
.then((result) => {
|
||||
console.log('createPlatformTeam result:', result.data)
|
||||
if(result.data.message === 'Team Name already taken'){
|
||||
return result.data.message
|
||||
}
|
||||
if(result.data.result === 'Fail'){
|
||||
return result.data.message
|
||||
}
|
||||
return result
|
||||
})
|
||||
.catch(err =>{
|
||||
logger.debug('createPlatformTeam err:')
|
||||
logger.debug(err)
|
||||
throw new Error(err)
|
||||
})
|
||||
console.log('createPlatformTeam returned: ', await createPlatformTeam)
|
||||
if(await createPlatformTeam === 'Team Name already taken'){
|
||||
return createPlatformTeam
|
||||
}
|
||||
|
||||
const existingMember = await ctx.db.query.member({ where: { authId } }, `{id}`)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'existingMember error: ')
|
||||
return err
|
||||
})
|
||||
|
||||
logger.info('existingMember:')
|
||||
logger.info(await existingMember)
|
||||
|
||||
let createTeam
|
||||
if(existingMember.id !== null){
|
||||
logger.info('createTeam with existingMember:')
|
||||
createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {connect: {authId: authId}}, role: 'OWNER', status: { create: { status: 'ACTIVE', reason: `Connected to Team ${name}`}}}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeamMutation error: ')
|
||||
return err
|
||||
})
|
||||
} else {
|
||||
logger.info('createTeam without existingMember:')
|
||||
createTeam = await ctx.db.mutation.createTeam({ data: {name: name, slug: slug, owner: authId, members: {create: {member: {create: {authId: authId, alias: alias, visible:'true', status: { create: { status: 'ACTIVE', reason: `Created team ${name}`}}}}, role: 'OWNER', status: { create: { status: 'ACTIVE', reason: `Created with Team ${name}`}}}}, profile: {create: {avatar: avatar, banner: banner}}, fb: {create: {name: botName, slug: botSlug, kind:'TRADER', avatar: avatar, status: {create: {status: 'ACTIVE', reason: "Cloned on team creation"}}}}, status: {create: {status: 'ACTIVE', reason:"Team created"}}} }, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug(err, 'createTeamMutation error: ')
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
// sendTeamCreateConfirmation(email, name, botName)
|
||||
|
||||
return createTeam
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.debug('createTeam error: ')
|
||||
return err
|
||||
})
|
||||
},
|
||||
async updateTeamProfile(parent, { slug, owner, description, motto, avatar, banner }, ctx, info) {
|
||||
return ctx.db.mutation.updateTeam({data:{profile: {update: {description: description, motto: motto, avatar: avatar, banner: banner}}}, where:{slug: slug}}, TEAMS_FRAGMENT)
|
||||
.catch((err) => {
|
||||
logger.debug('createTeam error: ', err)
|
||||
return err
|
||||
})
|
||||
},
|
||||
async updateFB(parent, { fbId, avatar}, ctx, info) {
|
||||
return ctx.db.mutation.updateFinancialBeings({data:{avatar:avatar}, where:{id:fbId}}, info)
|
||||
.catch((err) => {
|
||||
logger.debug('createTeam error: ', err)
|
||||
return err
|
||||
})
|
||||
},
|
||||
async deleteTeam(parent, { slug }, ctx, info) {
|
||||
return ctx.db.mutation.deleteTeam({ where: { slug } }, info)
|
||||
.catch((res) => {
|
||||
logger.info('deleteTeam error: ', res)
|
||||
const errors = res.graphQLErrors.map((error) => {
|
||||
return error.message
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getUser = authId => {
|
||||
logger.info('getUser')
|
||||
logger.info(authId)
|
||||
const API_URL = 'https://app-api.advancedalgos.net/graphql'
|
||||
return new Promise(resolve => {
|
||||
try {
|
||||
const result = axios.post(API_URL, {
|
||||
query: `query users_UserByAuthId($authId: String!) {
|
||||
users_UserByAuthId(authId: $authId){
|
||||
id
|
||||
alias
|
||||
email
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
authId: authId
|
||||
}
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
logger.info('getUser result')
|
||||
logger.info(result.data)
|
||||
resolve(result.data)
|
||||
})
|
||||
.catch(err => {
|
||||
logger.info('getUser err')
|
||||
logger.info(err)
|
||||
throw new Error(err)
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
resolve(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const db = new Prisma({
|
||||
fragmentReplacements: extractFragmentReplacements(resolvers),
|
||||
typeDefs: 'src/generated/prisma.graphql',
|
||||
@@ -322,20 +35,7 @@ const db = new Prisma({
|
||||
|
||||
const app = express()
|
||||
|
||||
const connectionMiddlewares = [
|
||||
checkJwt,
|
||||
function (err, req, res, next) {
|
||||
logger.info('checkJwt: ', err, req.headers, req.user)
|
||||
if (err) {
|
||||
return res.status(201).send(err.message)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
},
|
||||
// (req, res, done) => getMember(req, res, done, db)
|
||||
]
|
||||
|
||||
app.post(GRAPHQL_ENDPOINT, ...connectionMiddlewares)
|
||||
app.post(GRAPHQL_ENDPOINT)
|
||||
|
||||
const corsOptions = {
|
||||
"origin": "*",
|
||||
@@ -355,16 +55,16 @@ const options = {
|
||||
const server = createApolloServer(app, {
|
||||
graphqlEndpoint: GRAPHQL_ENDPOINT,
|
||||
subscriptionsEndpoint: GRAPHQL_SUBSCRIPTIONS,
|
||||
wsMiddlewares: connectionMiddlewares,
|
||||
apolloServerOptions: { formatError },
|
||||
typeDefs: importSchema('src/schema.graphql'),
|
||||
typeDefs: importSchema('src/graphql/schema.graphql'),
|
||||
resolvers,
|
||||
resolverValidationOptions: { requireResolversForResolveType: false },
|
||||
schemaDirectives,
|
||||
context: req => ({
|
||||
...req ,
|
||||
token: req.headers,
|
||||
user: req.user,
|
||||
token: req.headers ? req.headers : undefined,
|
||||
user: req.user ? req.user : undefined,
|
||||
userId: (req.headers && req.headers.userid) ? req.headers.userid : undefined,
|
||||
db,
|
||||
pubsub
|
||||
})
|
||||
@@ -375,5 +75,3 @@ server.listen({ port: PORT }, () => {
|
||||
`🚀 GraphQL Server is running on http://localhost:${PORT}${GRAPHQL_ENDPOINT} in "${NODE_ENV}" mode\n`
|
||||
)
|
||||
})
|
||||
|
||||
module.exports= { createMember }
|
||||
@@ -0,0 +1,19 @@
|
||||
export class AuthenticationError extends Error {
|
||||
code = 401
|
||||
message = 'Not Authenticated - you have to be authenticated to perform this action'
|
||||
}
|
||||
|
||||
export class DatabaseError extends Error {
|
||||
code = 404
|
||||
message = 'Resource not found : ' + this.message
|
||||
}
|
||||
|
||||
export class WrongArgumentsError extends Error {
|
||||
code = 400
|
||||
message = 'Wrong arguments : ' + this.message
|
||||
}
|
||||
|
||||
export class ServiceUnavailableError extends Error {
|
||||
code = 503
|
||||
message = 'At least one service is unresponding ' + this.message
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { createLogger, format, transports } from 'winston'
|
||||
import { inspect } from 'util'
|
||||
|
||||
import { AuthentificationError, DatabaseError, WrongArgumentsError, ServiceUnavailableError } from './errors'
|
||||
|
||||
class LoggerService {
|
||||
constructor() {
|
||||
const winstonTransports = [
|
||||
@@ -28,4 +30,4 @@ class LoggerService {
|
||||
}
|
||||
|
||||
export const logger = new LoggerService() // Default logger
|
||||
export { LoggerService }
|
||||
export { LoggerService, AuthentificationError, DatabaseError, WrongArgumentsError, ServiceUnavailableError }
|
||||
@@ -0,0 +1,57 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import { logger, DatabaseError } from '../logger'
|
||||
|
||||
export const getMember = async (req, res, next, db) => {
|
||||
if (!req.headers.userId) return next()
|
||||
logger.info('getMember ')
|
||||
logger.info(req.headers.userId)
|
||||
try {
|
||||
const member = await getUser(req.headers.userId)
|
||||
req.user = await member
|
||||
next()
|
||||
} catch (err) {
|
||||
next()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const getUser = authId => {
|
||||
logger.info('getUser MiddleWare')
|
||||
logger.info(authId)
|
||||
const API_URL = 'https://app-api.advancedalgos.net/graphql'
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
return axios.post(API_URL, {
|
||||
query: `query users_User($userId: ID!) {
|
||||
users_User(id: $userId){
|
||||
id
|
||||
alias
|
||||
email
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
userId: authId
|
||||
}
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
logger.info('getUser result')
|
||||
logger.info(res.data)
|
||||
resolve(res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
logger.info('getUser err')
|
||||
logger.info(err)
|
||||
reject(new DatabaseError(err))
|
||||
})
|
||||
} catch (error) {
|
||||
reject(new DatabaseError(error))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export default getUser
|
||||
File renamed without changes.
@@ -2,8 +2,8 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const DELETE_TEAM = gql`
|
||||
mutation deleteTeam($slug: String!) {
|
||||
teams_DeleteTeam(slug: $slug) {
|
||||
mutation deleteTeam($slug: String!, $botSlug: String!) {
|
||||
teams_DeleteTeam(slug: $slug, botSlug: $botSlug) {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GET_TEAMS_BY_OWNER = gql`
|
||||
query teamsByOwnerQuery($authId: String!) {
|
||||
teams_TeamsByOwner(ownerId: $authId) {
|
||||
query teamsByOwnerQuery {
|
||||
teams_TeamsByOwner {
|
||||
id
|
||||
name
|
||||
slug
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import log from './log'
|
||||
|
||||
const ErrorResponse = {
|
||||
'unique constraint': 'Sorry, already taken! Please create a unique '
|
||||
}
|
||||
|
||||
export const checkGraphQLError = error => {
|
||||
console.log('checkGraphQLError ', ErrorResponse)
|
||||
log.debug('checkGraphQLError ', ErrorResponse)
|
||||
if (error.search(/unique constraint/)) {
|
||||
const field = error.substring(error.indexOf('=') + 1)
|
||||
console.log('unique constraint', field.replace(/ +/g, ''))
|
||||
log.debug('unique constraint', field.replace(/ +/g, ''))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import minilog from 'minilog'
|
||||
|
||||
if (process.env.NODE_ENV === 'development') minilog.enable()
|
||||
|
||||
const log = minilog('frontend')
|
||||
|
||||
export default log
|
||||
@@ -13,9 +13,12 @@ import UsersIcon from '@material-ui/icons/People'
|
||||
import SearchIcon from '@material-ui/icons/Search'
|
||||
import AdbIcon from '@material-ui/icons/Adb'
|
||||
import SettingsApplicationsIcon from '@material-ui/icons/SettingsApplications'
|
||||
import BugReportIcon from '@material-ui/icons/BugReport'
|
||||
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const SettingsLink = props => <Link to='/teams/settings' {...props} />
|
||||
const FBLink = props => <Link to='/teams/financial-beings' {...props} />
|
||||
const MembersLink = props => <Link to='/teams/team-members' {...props} />
|
||||
@@ -61,13 +64,13 @@ const styles = theme => ({
|
||||
class TeamBar extends Component {
|
||||
render () {
|
||||
const { classes, user, match } = this.props
|
||||
console.log('TeamBar: ', user, match)
|
||||
log.debug('TeamBar: ', user, match)
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<AppBar position='static' color='secondary'>
|
||||
<Toolbar>
|
||||
<Toolbar variant='dense'>
|
||||
<Typography variant='h5' color='inherit' className={classes.flex}>
|
||||
Manage Teams
|
||||
Teams
|
||||
</Typography>
|
||||
<Button
|
||||
variant='text'
|
||||
@@ -113,12 +116,22 @@ class TeamBar extends Component {
|
||||
variant='text'
|
||||
size='small'
|
||||
className={classNames(classes.button, classes.cssRoot)}
|
||||
title='Manage Financial Beings'
|
||||
title='Your Global Team Settings'
|
||||
component={SettingsLink}
|
||||
to={`${match.url}/settings`}>
|
||||
<SettingsApplicationsIcon className={classNames(classes.leftIcon, classes.iconSmall)} />
|
||||
Settings
|
||||
</Button>
|
||||
<Button
|
||||
variant='text'
|
||||
size='small'
|
||||
className={classNames(classes.button, classes.cssRoot)}
|
||||
title='Report a Teams Module bug'
|
||||
to='https://github.com/AdvancedAlgos/TeamsModule/issues'
|
||||
>
|
||||
<BugReportIcon className={classNames(classes.leftIcon, classes.iconSmall)} />
|
||||
Report
|
||||
</Button>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
</div>
|
||||
|
||||
@@ -10,9 +10,11 @@ import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import CREATE_TEAM from '../../../graphql/teams/CreateTeamMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const CreateTeam = ({ authId }) => {
|
||||
let input
|
||||
console.log('CreateTeam', authId)
|
||||
log.debug('CreateTeam', authId)
|
||||
|
||||
return (
|
||||
<Mutation
|
||||
@@ -33,7 +35,7 @@ const CreateTeam = ({ authId }) => {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
@@ -73,7 +75,7 @@ const handleSubmit = async (e, createTeam, input) => {
|
||||
const currentUser = await getItem('user')
|
||||
let authId = JSON.parse(currentUser)
|
||||
authId = authId.authId
|
||||
console.log('createTeam submit: ', authId)
|
||||
log.debug('createTeam submit: ', authId)
|
||||
const name = input.value
|
||||
const slug = slugify(name)
|
||||
await createTeam({ variables: { name, slug, owner: authId } })
|
||||
|
||||
@@ -18,7 +18,7 @@ import { isEmpty } from '../../../utils/js-helpers'
|
||||
import CREATE_TEAM from '../../../graphql/teams/CreateTeamMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
// import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -207,7 +207,7 @@ export class CreateTeamDialog extends Component {
|
||||
|
||||
async handleSubmit (e, createTeam, name, botName) {
|
||||
e.preventDefault()
|
||||
console.log('createTeam submit: ', name, botName)
|
||||
log.debug('createTeam submit: ', name, botName)
|
||||
const slug = this.slugify(name)
|
||||
const botSlug = this.slugify(botName)
|
||||
await createTeam({ variables: { name, slug, botName, botSlug } })
|
||||
|
||||
@@ -11,6 +11,8 @@ import DialogContentText from '@material-ui/core/DialogContentText'
|
||||
import DialogTitle from '@material-ui/core/DialogTitle'
|
||||
import Typography from '@material-ui/core/Typography'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export class CreateTeamDialog extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
@@ -50,7 +52,7 @@ export class CreateTeamDialog extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props)
|
||||
log.debug(this.props)
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
|
||||
@@ -16,15 +16,17 @@ import { MessageCard } from '@advancedalgos/web-components'
|
||||
import { isDefined, isString } from '../../../utils/js-helpers'
|
||||
import { getItem } from '../../../utils/local-storage'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const DashTeam = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('DashTeam: ', user)
|
||||
log.debug('DashTeam: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('DashTeam 2: ', owner, authId)
|
||||
log.debug('DashTeam 2: ', owner, authId)
|
||||
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
@@ -46,7 +48,7 @@ export const DashTeam = ({ classes, user = null }) => {
|
||||
</Typography>
|
||||
<Query query={GET_TEAMS_BY_OWNER} variables={{ authId }}>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
let errors
|
||||
let queryLoader
|
||||
if (error) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { isEmpty } from '../../../utils/js-helpers'
|
||||
|
||||
import SEND_MEMBER_INVITE from '../../../graphql/teams/SendMemberInvite'
|
||||
|
||||
// import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogStyle: {
|
||||
@@ -60,7 +60,7 @@ export class InviteMemberDialog extends Component {
|
||||
return (
|
||||
<Mutation mutation={SEND_MEMBER_INVITE} >
|
||||
{(sendMemberInvite, { loading, error, data }) => {
|
||||
console.log('sendMemberInvite: ', data)
|
||||
log.debug('sendMemberInvite: ', data)
|
||||
let errors
|
||||
let loader = null
|
||||
if (loading) {
|
||||
@@ -187,7 +187,7 @@ export class InviteMemberDialog extends Component {
|
||||
|
||||
async handleSubmit (e, sendMemberInvite, email, teamId) {
|
||||
e.preventDefault()
|
||||
console.log('sendMemberInvite submit: ', email, teamId)
|
||||
log.debug('sendMemberInvite submit: ', email, teamId)
|
||||
await sendMemberInvite({ variables: { email, teamId } })
|
||||
this.setState({ email: '' })
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
import GET_AZURE_SAS from '../../../graphql/teams/GetAzureSASMutation'
|
||||
|
||||
const styles = theme => ({
|
||||
@@ -52,7 +54,7 @@ export class ManageFBEdit extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log('ManageFBEdit ', this.props, this.props.slug, this.props.fb)
|
||||
log.debug('ManageFBEdit ', this.props, this.props.slug, this.props.fb)
|
||||
const { classes, fb, slug } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -75,7 +77,7 @@ export class ManageFBEdit extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('updateTeamProfile error:', displayMessage)
|
||||
log.debug('updateTeamProfile error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
@@ -105,7 +107,7 @@ export class ManageFBEdit extends Component {
|
||||
<DialogContent>
|
||||
<Mutation mutation={GET_AZURE_SAS} >
|
||||
{(getAzureSAS, { loading, error, data }) => {
|
||||
console.log('getAzureSAS: ', loading, error, data, fb)
|
||||
log.debug('getAzureSAS: ', loading, error, data, fb)
|
||||
const AzureStorageUrl = process.env.AZURE_STORAGE_URL
|
||||
const containerName = slug
|
||||
let AzureSASURL
|
||||
@@ -195,12 +197,12 @@ export class ManageFBEdit extends Component {
|
||||
}
|
||||
|
||||
handleAvatar (avatarUrl) {
|
||||
console.log('handleAvatar: ', avatarUrl)
|
||||
log.debug('handleAvatar: ', avatarUrl)
|
||||
this.setState({ avatar: `${avatarUrl}?${Math.random()}` })
|
||||
}
|
||||
|
||||
async handleSubmit (e, updateFB, fbId, slug) {
|
||||
console.log('handleSubmit: ', this.state)
|
||||
log.debug('handleSubmit: ', this.state)
|
||||
e.preventDefault()
|
||||
|
||||
await updateFB({
|
||||
|
||||
@@ -10,8 +10,10 @@ import Typography from '@material-ui/core/Typography'
|
||||
|
||||
import ManageFBEdit from './ManageFBEdit'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const ManageFBItem = ({ classes, team, authId }) => {
|
||||
console.log('ManageFBItem', team, team.fb[0], team.profile.avatar)
|
||||
log.debug('ManageFBItem', team, team.fb[0], team.profile.avatar)
|
||||
let avatar
|
||||
if (team.fb[0].avatar !== undefined && team.fb[0].avatar !== 'a') {
|
||||
avatar = team.fb[0].avatar
|
||||
|
||||
@@ -12,6 +12,8 @@ import { getItem } from '../../../utils/local-storage'
|
||||
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
import ManageFBItem from './ManageFBItem'
|
||||
import CreateTeamDialog from './CreateTeamDialog'
|
||||
|
||||
@@ -50,12 +52,12 @@ const styles = theme => ({
|
||||
export const ManageFBList = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('ManageTeamsList: ', user)
|
||||
log.debug('ManageTeamsList: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('ManageTeamsList 2: ', owner, authId)
|
||||
log.debug('ManageTeamsList 2: ', owner, authId)
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
@@ -72,7 +74,7 @@ export const ManageFBList = ({ classes, user = null }) => {
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
|
||||
let errors = null
|
||||
if (error) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import REMOVE_TEAM_MEMBER from '../../../graphql/teams/RemoveTeamMemberMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -54,7 +55,7 @@ export class ManageMemberDelete extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.teamId)
|
||||
log.debug(this.props, this.props.teamId)
|
||||
const { classes, teamId, authId } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -72,7 +73,7 @@ export class ManageMemberDelete extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
|
||||
@@ -17,6 +17,7 @@ import SET_TEAM_MEMBER_ROLE from '../../../graphql/teams/SetTeamMemberRoleMutati
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -62,7 +63,7 @@ export class ManageMemberRole extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.teamId)
|
||||
log.debug(this.props, this.props.teamId)
|
||||
const { classes, teamId, authId } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -80,7 +81,7 @@ export class ManageMemberRole extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
|
||||
@@ -10,6 +10,8 @@ import Card from '@material-ui/core/Card'
|
||||
import CardContent from '@material-ui/core/CardContent'
|
||||
import CardActions from '@material-ui/core/CardActions'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
display: 'block',
|
||||
@@ -47,7 +49,7 @@ export class ManageMemberStatus extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.status)
|
||||
log.debug(this.props, this.props.status)
|
||||
const { classes, status } = this.props
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -9,8 +9,10 @@ import ManageMemberRole from './ManageMemberRole'
|
||||
import ManageMemberStatus from './ManageMemberStatus'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const ManageMembersItem = ({ classes, member, teamId, authId }) => {
|
||||
console.log('ManageMembersItem', member)
|
||||
log.debug('ManageMembersItem', member)
|
||||
let profile = null
|
||||
let email = null
|
||||
let memberStatus = null
|
||||
|
||||
@@ -12,6 +12,8 @@ import InviteMemberDialog from './InviteMemberDialog'
|
||||
import ManageMembersItem from './ManageMembersItem'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
heroContent: {
|
||||
maxWidth: 600,
|
||||
@@ -56,7 +58,7 @@ const styles = theme => ({
|
||||
})
|
||||
|
||||
export const ManageMembersTeamItem = ({ classes, team, authId }) => {
|
||||
console.log('ManageMembersItem', team, team.profile, team.profile.avatar)
|
||||
log.debug('ManageMembersItem', team, team.profile, team.profile.avatar)
|
||||
let avatar
|
||||
if (team.profile.avatar !== undefined && team.profile.avatar !== 'a') {
|
||||
avatar = team.profile.avatar
|
||||
|
||||
@@ -15,6 +15,7 @@ import DELETE_TEAM from '../../../graphql/teams/DeleteTeamMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -54,7 +55,7 @@ export class ManageTeamDelete extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.slug)
|
||||
log.debug(this.props, this.props.slug)
|
||||
const { classes, authId } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -77,7 +78,7 @@ export class ManageTeamDelete extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
|
||||
@@ -11,6 +11,8 @@ import CardContent from '@material-ui/core/CardContent'
|
||||
import CardActions from '@material-ui/core/CardActions'
|
||||
import CardMedia from '@material-ui/core/CardMedia'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
display: 'block',
|
||||
@@ -62,7 +64,7 @@ export class ManageTeamDetails extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props.team)
|
||||
log.debug(this.props.team)
|
||||
const { classes } = this.props
|
||||
const { name, members, profile, createdAt } = this.props.team
|
||||
let avatar
|
||||
|
||||
@@ -15,6 +15,8 @@ import Typography from '@material-ui/core/Typography'
|
||||
|
||||
import { MessageCard, ImageUpload } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
import UPDATE_TEAM_PROFILE from '../../../graphql/teams/UpdateTeamProfileMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
@@ -44,7 +46,7 @@ export class ManageTeamEdit extends Component {
|
||||
this.handleAvatar = this.handleAvatar.bind(this)
|
||||
this.handleBanner = this.handleBanner.bind(this)
|
||||
|
||||
console.log('ManageTeamEdit', props.team)
|
||||
log.debug('ManageTeamEdit', props.team)
|
||||
const motto = props.team.profile.motto || ''
|
||||
const description = props.team.profile.description || ''
|
||||
const avatar = props.team.profile.avatar || ''
|
||||
@@ -61,7 +63,7 @@ export class ManageTeamEdit extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log('ManageTeamEdit ', this.props, this.props.slug, this.props.team)
|
||||
log.debug('ManageTeamEdit ', this.props, this.props.slug, this.props.team)
|
||||
const { classes, team } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -84,7 +86,7 @@ export class ManageTeamEdit extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('updateTeamProfile error:', displayMessage)
|
||||
log.debug('updateTeamProfile error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
@@ -114,7 +116,7 @@ export class ManageTeamEdit extends Component {
|
||||
<DialogContent>
|
||||
<Mutation mutation={GET_AZURE_SAS} >
|
||||
{(getAzureSAS, { loading, error, data }) => {
|
||||
console.log('getAzureSAS: ', loading, error, data, team.profile)
|
||||
log.debug('getAzureSAS: ', loading, error, data, team.profile)
|
||||
const AzureStorageUrl = process.env.AZURE_STORAGE_URL
|
||||
const containerName = team.slug
|
||||
let AzureSASURL
|
||||
@@ -132,7 +134,7 @@ export class ManageTeamEdit extends Component {
|
||||
if (team.profile !== null && team.profile.banner !== undefined && team.profile.banner !== null) banner = team.profile.banner
|
||||
if (this.state.banner !== null) banner = this.state.banner
|
||||
if (this.state.banner === null && team.profile !== null && team.profile.banner === undefined) banner = 'https://algobotcommstorage.blob.core.windows.net/aateammodule/aa-banner-default.png'
|
||||
console.log('team images: ', avatar, banner)
|
||||
log.debug('team images: ', avatar, banner)
|
||||
|
||||
if (loading || data === undefined) {
|
||||
return (<MessageCard message='Loading...' />)
|
||||
@@ -262,17 +264,17 @@ export class ManageTeamEdit extends Component {
|
||||
}
|
||||
|
||||
handleAvatar (avatarUrl) {
|
||||
console.log('handleAvatar: ', avatarUrl)
|
||||
log.debug('handleAvatar: ', avatarUrl)
|
||||
this.setState({ avatar: `${avatarUrl}?${Math.random()}` })
|
||||
}
|
||||
|
||||
handleBanner (bannerUrl) {
|
||||
console.log('handleBanner: ', bannerUrl)
|
||||
log.debug('handleBanner: ', bannerUrl)
|
||||
this.setState({ banner: `${bannerUrl}?${Math.random()}` })
|
||||
}
|
||||
|
||||
async handleSubmit (e, updateTeamProfile, slug) {
|
||||
console.log('handleSubmit: ', this.state)
|
||||
log.debug('handleSubmit: ', this.state)
|
||||
e.preventDefault()
|
||||
|
||||
await updateTeamProfile({
|
||||
|
||||
@@ -14,6 +14,8 @@ import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
import ManageMembersTeamItem from './ManageMembersTeamItem'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
heroContent: {
|
||||
maxWidth: 600,
|
||||
@@ -49,12 +51,12 @@ const styles = theme => ({
|
||||
export const ManageTeamMembersList = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('ManageTeamsList: ', user)
|
||||
log.debug('ManageTeamsList: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('ManageTeamsList 2: ', owner, authId)
|
||||
log.debug('ManageTeamsList 2: ', owner, authId)
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
@@ -71,7 +73,7 @@ export const ManageTeamMembersList = ({ classes, user = null }) => {
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
let errors = null
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
|
||||
@@ -12,8 +12,10 @@ import ManageTeamDetails from './ManageTeamDetails'
|
||||
import ManageTeamDelete from './ManageTeamDelete'
|
||||
import ManageTeamEdit from './ManageTeamEdit'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const ManageTeamsItem = ({ classes, team, authId }) => {
|
||||
console.log('ManageTeamsItem', team, team.profile, team.profile.avatar)
|
||||
log.debug('ManageTeamsItem', team, team.profile, team.profile.avatar)
|
||||
let avatar
|
||||
if (team.profile.avatar !== undefined && team.profile.avatar !== 'a') {
|
||||
avatar = team.profile.avatar
|
||||
|
||||
@@ -15,6 +15,8 @@ import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
import ManageTeamsItem from './ManageTeamsItem'
|
||||
import CreateTeamDialog from './CreateTeamDialog'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
heroContent: {
|
||||
maxWidth: 600,
|
||||
@@ -50,12 +52,12 @@ const styles = theme => ({
|
||||
export const ManageTeamsList = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('ManageTeamsList: ', user)
|
||||
log.debug('ManageTeamsList: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('ManageTeamsList 2: ', owner, authId)
|
||||
log.debug('ManageTeamsList 2: ', owner, authId)
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
@@ -72,7 +74,7 @@ export const ManageTeamsList = ({ classes, user = null }) => {
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
|
||||
let errors = null
|
||||
if (error) {
|
||||
|
||||
@@ -16,6 +16,8 @@ import FinancialBeings from './FinancialBeings'
|
||||
import TeamMembers from './TeamMembers'
|
||||
import Settings from './settings'
|
||||
|
||||
import log from '../../utils/log'
|
||||
|
||||
const drawerWidth = 240
|
||||
|
||||
const styles = theme => ({
|
||||
@@ -81,9 +83,9 @@ const DashboardCheckSession = lifecycle({
|
||||
async componentDidMount () {
|
||||
try {
|
||||
const authenticated = await this.props.auth.isAuthenticated()
|
||||
console.log('DashboardCheckSession res: ', authenticated)
|
||||
log.debug('DashboardCheckSession res: ', authenticated)
|
||||
} catch (err) {
|
||||
console.log('DashboardCheckSession err: ', err)
|
||||
log.debug('DashboardCheckSession err: ', err)
|
||||
}
|
||||
}
|
||||
})(Dashboard)
|
||||
|
||||
@@ -20,6 +20,8 @@ import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
display: 'block',
|
||||
@@ -41,7 +43,6 @@ export class ManageFBEdit extends Component {
|
||||
this.handleAvatar = this.handleAvatar.bind(this)
|
||||
|
||||
const avatar = props.fb.avatar || ''
|
||||
this.authId = props.authId
|
||||
|
||||
this.state = {
|
||||
open: false,
|
||||
@@ -50,15 +51,14 @@ export class ManageFBEdit extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log('ManageFBEdit ', this.props, this.props.slug, this.props.fb)
|
||||
log.debug('ManageFBEdit ', this.props, this.props.slug, this.props.fb)
|
||||
const { classes, fb, slug } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
mutation={UPDATE_FB}
|
||||
refetchQueries={[
|
||||
{
|
||||
query: GET_TEAMS_BY_OWNER,
|
||||
variables: { authId: this.authId }
|
||||
query: GET_TEAMS_BY_OWNER
|
||||
}
|
||||
]}
|
||||
>
|
||||
@@ -82,7 +82,7 @@ export class ManageFBEdit extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('updateTeamProfile error:', displayMessage)
|
||||
log.debug('updateTeamProfile error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
@@ -176,12 +176,12 @@ export class ManageFBEdit extends Component {
|
||||
}
|
||||
|
||||
handleAvatar (avatarUrl) {
|
||||
console.log('handleAvatar: ', avatarUrl)
|
||||
log.debug('handleAvatar: ', avatarUrl)
|
||||
this.setState({ avatar: `${avatarUrl}?${Math.random()}` })
|
||||
}
|
||||
|
||||
async handleSubmit (e, updateFB, fbId, slug) {
|
||||
console.log('handleSubmit: ', this.state)
|
||||
log.debug('handleSubmit: ', this.state)
|
||||
e.preventDefault()
|
||||
|
||||
await updateFB({
|
||||
@@ -197,8 +197,7 @@ export class ManageFBEdit extends Component {
|
||||
ManageFBEdit.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
slug: PropTypes.string.isRequired,
|
||||
fb: PropTypes.object,
|
||||
authId: PropTypes.string.isRequired
|
||||
fb: PropTypes.object
|
||||
}
|
||||
|
||||
export default withStyles(styles)(ManageFBEdit)
|
||||
@@ -10,8 +10,10 @@ import Typography from '@material-ui/core/Typography'
|
||||
|
||||
import ManageFBEdit from './ManageFBEdit'
|
||||
|
||||
export const ManageFBItem = ({ classes, team, authId }) => {
|
||||
console.log('ManageFBItem', team, team.fb[0], team.profile.avatar)
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const ManageFBItem = ({ classes, team }) => {
|
||||
log.debug('ManageFBItem', team, team.fb[0], team.profile.avatar)
|
||||
let avatar
|
||||
if (team.fb[0].avatar !== undefined && team.fb[0].avatar !== 'a') {
|
||||
avatar = team.fb[0].avatar
|
||||
@@ -36,7 +38,7 @@ export const ManageFBItem = ({ classes, team, authId }) => {
|
||||
</Typography>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
<ManageFBEdit slug={team.slug} fb={team.fb[0]} authId={authId} />
|
||||
<ManageFBEdit slug={team.slug} fb={team.fb[0]} />
|
||||
</CardActions>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -46,8 +48,7 @@ export const ManageFBItem = ({ classes, team, authId }) => {
|
||||
|
||||
ManageFBItem.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
team: PropTypes.object.isRequired,
|
||||
authId: PropTypes.string.isRequired
|
||||
team: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default ManageFBItem
|
||||
@@ -1,17 +1,15 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Query } from 'react-apollo'
|
||||
import { withStateHandlers, lifecycle, compose } from 'recompose'
|
||||
|
||||
import Grid from '@material-ui/core/Grid'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import { isDefined, isString } from '../../../utils/js-helpers'
|
||||
import { getItem } from '../../../utils/local-storage'
|
||||
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
import ManageFBItem from './ManageFBItem'
|
||||
|
||||
const styles = theme => ({
|
||||
@@ -46,94 +44,63 @@ const styles = theme => ({
|
||||
}
|
||||
})
|
||||
|
||||
export const ManageFBList = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('ManageTeamsList: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('ManageTeamsList 2: ', owner, authId)
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid>
|
||||
<MessageCard message='Loading...' />
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<Query
|
||||
query={GET_TEAMS_BY_OWNER}
|
||||
variables={{ authId }}
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
export const ManageFBList = ({ classes }) => (
|
||||
<Query
|
||||
query={GET_TEAMS_BY_OWNER}
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
|
||||
let errors = null
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
return <MessageCard message={message} />
|
||||
})
|
||||
}
|
||||
if (!loading && !error) {
|
||||
if (data.teams_TeamsByOwner.length > 0) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Grid container spacing={40}>
|
||||
{!loading &&
|
||||
data.teams_TeamsByOwner.map(team => (
|
||||
<ManageFBItem
|
||||
key={team.id}
|
||||
team={team}
|
||||
classes={classes}
|
||||
authId={authId}
|
||||
/>
|
||||
))}
|
||||
{errors}
|
||||
</Grid>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
let errors = null
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
return <MessageCard message={message} />
|
||||
})
|
||||
}
|
||||
if (!loading && !error) {
|
||||
if (data.teams_TeamsByOwner.length > 0) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={12}>
|
||||
<MessageCard message='Loading...' />
|
||||
{errors !== null && <MessageCard message={errors} />}
|
||||
</Grid>
|
||||
{!loading &&
|
||||
data.teams_TeamsByOwner.map(team => (
|
||||
<ManageFBItem
|
||||
key={team.id}
|
||||
team={team}
|
||||
classes={classes}
|
||||
/>
|
||||
))}
|
||||
{errors}
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
}}
|
||||
</Query>
|
||||
)
|
||||
}
|
||||
}
|
||||
</React.Fragment>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={12}>
|
||||
<MessageCard message='No financial beings yet — Create a team first!' />
|
||||
{errors !== null && <MessageCard message={errors} />}
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={12}>
|
||||
<MessageCard message='Loading...' />
|
||||
{errors !== null && <MessageCard message={errors} />}
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
}}
|
||||
</Query>
|
||||
)
|
||||
|
||||
ManageFBList.propTypes = {
|
||||
user: PropTypes.any,
|
||||
classes: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
const getUserOnMount = lifecycle({
|
||||
componentDidMount () {
|
||||
getItem('user').then(user => {
|
||||
this.setState({ user })
|
||||
}) // Set user to state
|
||||
}
|
||||
})
|
||||
|
||||
const mapStateToProps = withStateHandlers(() => ({ user: null }), {
|
||||
user: ({ user }) => () => ({ user })
|
||||
})
|
||||
|
||||
const ManageFBListAuthId = compose(
|
||||
mapStateToProps,
|
||||
getUserOnMount
|
||||
)(ManageFBList)
|
||||
|
||||
export default withStyles(styles)(ManageFBListAuthId)
|
||||
export default withStyles(styles)(ManageFBList)
|
||||
@@ -18,7 +18,7 @@ import { isEmpty } from '../../../utils/js-helpers'
|
||||
import CREATE_TEAM from '../../../graphql/teams/CreateTeamMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
// import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -66,13 +66,12 @@ export class CreateTeamDialog extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { classes, authId } = this.props
|
||||
const { classes } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
mutation={CREATE_TEAM}
|
||||
refetchQueries={[{
|
||||
query: GET_TEAMS_BY_OWNER,
|
||||
variables: { authId: authId }
|
||||
query: GET_TEAMS_BY_OWNER
|
||||
}]}
|
||||
>
|
||||
{(createTeam, { loading, error, data }) => {
|
||||
@@ -207,7 +206,7 @@ export class CreateTeamDialog extends Component {
|
||||
|
||||
async handleSubmit (e, createTeam, name, botName) {
|
||||
e.preventDefault()
|
||||
console.log('createTeam submit: ', name, botName)
|
||||
log.debug('createTeam submit: ', name, botName)
|
||||
const slug = this.slugify(name)
|
||||
const botSlug = this.slugify(botName)
|
||||
await createTeam({ variables: { name, slug, botName, botSlug } })
|
||||
@@ -255,8 +254,7 @@ export class CreateTeamDialog extends Component {
|
||||
}
|
||||
|
||||
CreateTeamDialog.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
authId: PropTypes.string
|
||||
classes: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default withStyles(styles)(CreateTeamDialog)
|
||||
@@ -15,6 +15,7 @@ import DELETE_TEAM from '../../../graphql/teams/DeleteTeamMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -54,15 +55,14 @@ export class ManageTeamDelete extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.slug)
|
||||
const { classes, authId } = this.props
|
||||
log.debug(this.props, this.props.slug)
|
||||
const { classes } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
mutation={DELETE_TEAM}
|
||||
refetchQueries={[
|
||||
{
|
||||
query: GET_TEAMS_BY_OWNER,
|
||||
variables: { authId }
|
||||
query: GET_TEAMS_BY_OWNER
|
||||
}
|
||||
]}
|
||||
>
|
||||
@@ -77,7 +77,7 @@ export class ManageTeamDelete extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
@@ -123,7 +123,8 @@ export class ManageTeamDelete extends Component {
|
||||
this.handleSubmit(
|
||||
e,
|
||||
deleteTeam,
|
||||
this.props.slug
|
||||
this.props.slug,
|
||||
this.props.botSlug
|
||||
)
|
||||
}}
|
||||
color='primary'
|
||||
@@ -140,9 +141,9 @@ export class ManageTeamDelete extends Component {
|
||||
)
|
||||
}
|
||||
|
||||
async handleSubmit (e, deleteTeam, slug) {
|
||||
async handleSubmit (e, deleteTeam, slug, botSlug) {
|
||||
e.preventDefault()
|
||||
await deleteTeam({ variables: { slug } })
|
||||
await deleteTeam({ variables: { slug, botSlug } })
|
||||
this.setState({ open: false })
|
||||
}
|
||||
}
|
||||
@@ -150,7 +151,7 @@ export class ManageTeamDelete extends Component {
|
||||
ManageTeamDelete.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
slug: PropTypes.string.isRequired,
|
||||
authId: PropTypes.string.isRequired
|
||||
botSlug: PropTypes.string.isRequired
|
||||
}
|
||||
|
||||
export default withStyles(styles)(ManageTeamDelete)
|
||||
@@ -11,6 +11,8 @@ import CardContent from '@material-ui/core/CardContent'
|
||||
import CardActions from '@material-ui/core/CardActions'
|
||||
import CardMedia from '@material-ui/core/CardMedia'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
display: 'block',
|
||||
@@ -62,7 +64,7 @@ export class ManageTeamDetails extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props.team)
|
||||
log.debug(this.props.team)
|
||||
const { classes } = this.props
|
||||
const { name, members, profile, createdAt } = this.props.team
|
||||
let avatar
|
||||
|
||||
@@ -19,6 +19,7 @@ import UPDATE_TEAM_PROFILE from '../../../graphql/teams/UpdateTeamProfileMutatio
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -42,12 +43,11 @@ export class ManageTeamEdit extends Component {
|
||||
this.handleAvatar = this.handleAvatar.bind(this)
|
||||
this.handleBanner = this.handleBanner.bind(this)
|
||||
|
||||
console.log('ManageTeamEdit', props.team)
|
||||
log.debug('ManageTeamEdit', props.team)
|
||||
const motto = props.team.profile.motto || ''
|
||||
const description = props.team.profile.description || ''
|
||||
const avatar = props.team.profile.avatar || null
|
||||
const banner = props.team.profile.banner || null
|
||||
this.authId = props.authId
|
||||
|
||||
this.state = {
|
||||
open: false,
|
||||
@@ -60,14 +60,13 @@ export class ManageTeamEdit extends Component {
|
||||
|
||||
render () {
|
||||
const { classes, team, match } = this.props
|
||||
console.log('ManageTeamEdit ', this.props, this.props.slug, this.props.team, match)
|
||||
log.debug('ManageTeamEdit ', this.props, this.props.slug, this.props.team, match)
|
||||
return (
|
||||
<Mutation
|
||||
mutation={UPDATE_TEAM_PROFILE}
|
||||
refetchQueries={[
|
||||
{
|
||||
query: GET_TEAMS_BY_OWNER,
|
||||
variables: { authId: this.authId }
|
||||
query: GET_TEAMS_BY_OWNER
|
||||
}
|
||||
]}
|
||||
>
|
||||
@@ -84,7 +83,7 @@ export class ManageTeamEdit extends Component {
|
||||
if (this.state.banner === null && team.profile !== null && (team.profile.banner === undefined || team.profile.banner === null)) banner = 'https://aadevelop.blob.core.windows.net/module-teams/module-default/aa-banner-default.png'
|
||||
if (team.profile !== null && team.profile.banner !== undefined && team.profile.banner !== null) banner = team.profile.banner
|
||||
if (this.state.banner !== null) banner = this.state.banner
|
||||
console.log('team images: ', avatar, banner)
|
||||
log.debug('team images: ', avatar, banner)
|
||||
|
||||
let errors
|
||||
let loader
|
||||
@@ -96,7 +95,7 @@ export class ManageTeamEdit extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('updateTeamProfile error:', displayMessage)
|
||||
log.debug('updateTeamProfile error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
@@ -244,17 +243,17 @@ export class ManageTeamEdit extends Component {
|
||||
}
|
||||
|
||||
handleAvatar (avatarUrl) {
|
||||
console.log('handleAvatar: ', avatarUrl)
|
||||
log.debug('handleAvatar: ', avatarUrl)
|
||||
this.setState({ avatar: `${avatarUrl}?${Math.random()}` })
|
||||
}
|
||||
|
||||
handleBanner (bannerUrl) {
|
||||
console.log('handleBanner: ', bannerUrl)
|
||||
log.debug('handleBanner: ', bannerUrl)
|
||||
this.setState({ banner: `${bannerUrl}?${Math.random()}` })
|
||||
}
|
||||
|
||||
async handleSubmit (e, updateTeamProfile, slug) {
|
||||
console.log('handleSubmit: ', this.state)
|
||||
log.debug('handleSubmit: ', this.state)
|
||||
e.preventDefault()
|
||||
|
||||
await updateTeamProfile({
|
||||
@@ -275,7 +274,6 @@ ManageTeamEdit.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
slug: PropTypes.string.isRequired,
|
||||
team: PropTypes.object,
|
||||
authId: PropTypes.string.isRequired,
|
||||
match: PropTypes.object
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
import ManageMembersTeamItem from './ManageMembersTeamItem'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
heroContent: {
|
||||
maxWidth: 600,
|
||||
@@ -49,12 +51,12 @@ const styles = theme => ({
|
||||
export const ManageTeamMembersList = ({ classes, user = null }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('ManageTeamsList: ', user)
|
||||
log.debug('ManageTeamsList: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('ManageTeamsList 2: ', owner, authId)
|
||||
log.debug('ManageTeamsList 2: ', owner, authId)
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
@@ -67,11 +69,10 @@ export const ManageTeamMembersList = ({ classes, user = null }) => {
|
||||
return (
|
||||
<Query
|
||||
query={GET_TEAMS_BY_OWNER}
|
||||
variables={{ authId }}
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
let errors = null
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
|
||||
@@ -12,8 +12,10 @@ import ManageTeamDetails from './ManageTeamDetails'
|
||||
import ManageTeamDelete from './ManageTeamDelete'
|
||||
import ManageTeamEdit from './ManageTeamEdit'
|
||||
|
||||
export const ManageTeamsItem = ({ classes, team, authId, ...props }) => {
|
||||
console.log('ManageTeamsItem', team, team.profile, team.profile.avatar)
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const ManageTeamsItem = ({ classes, team, ...props }) => {
|
||||
log.debug('ManageTeamsItem', team, team.profile, team.profile.avatar)
|
||||
let avatar
|
||||
if (team.profile.avatar !== undefined && team.profile.avatar !== 'a') {
|
||||
avatar = team.profile.avatar
|
||||
@@ -39,8 +41,8 @@ export const ManageTeamsItem = ({ classes, team, authId, ...props }) => {
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
<ManageTeamDetails team={team} />
|
||||
<ManageTeamEdit slug={team.slug} team={team} authId={authId} {...props} />
|
||||
<ManageTeamDelete slug={team.slug} authId={authId} />
|
||||
<ManageTeamEdit slug={team.slug} team={team} {...props} />
|
||||
<ManageTeamDelete slug={team.slug} botSlug={team.fb[0].slug} />
|
||||
</CardActions>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -50,8 +52,7 @@ export const ManageTeamsItem = ({ classes, team, authId, ...props }) => {
|
||||
|
||||
ManageTeamsItem.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
team: PropTypes.object.isRequired,
|
||||
authId: PropTypes.string.isRequired
|
||||
team: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
export default ManageTeamsItem
|
||||
@@ -1,20 +1,18 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Query } from 'react-apollo'
|
||||
import { withStateHandlers, lifecycle, compose } from 'recompose'
|
||||
|
||||
import Grid from '@material-ui/core/Grid'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
|
||||
import { isDefined, isString } from '../../../utils/js-helpers'
|
||||
import { getItem } from '../../../utils/local-storage'
|
||||
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import ManageTeamsItem from './ManageTeamsItem'
|
||||
import CreateTeamDialog from './CreateTeamDialog'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
heroContent: {
|
||||
maxWidth: 600,
|
||||
@@ -47,105 +45,66 @@ const styles = theme => ({
|
||||
}
|
||||
})
|
||||
|
||||
export const ManageTeamsList = ({ classes, user = null, ...props }) => {
|
||||
let owner
|
||||
let authId = null
|
||||
console.log('ManageTeamsList: ', user)
|
||||
if (user !== null && isString(user)) {
|
||||
owner = JSON.parse(user)
|
||||
if (isDefined(owner.authId)) authId = owner.authId
|
||||
}
|
||||
console.log('ManageTeamsList 2: ', owner, authId)
|
||||
if (authId === undefined || authId === null) {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid>
|
||||
<MessageCard message='Loading...' />
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<Query
|
||||
query={GET_TEAMS_BY_OWNER}
|
||||
variables={{ authId }}
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
console.log('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
export const ManageTeamsList = ({ classes, user = null, ...props }) => (
|
||||
<Query
|
||||
query={GET_TEAMS_BY_OWNER}
|
||||
fetchPolicy='network-only'
|
||||
>
|
||||
{({ loading, error, data }) => {
|
||||
log.debug('GET_TEAMS_BY_OWNER: ', loading, error, data)
|
||||
|
||||
let errors = null
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
return <MessageCard message={message} />
|
||||
})
|
||||
}
|
||||
if (!loading && !error) {
|
||||
if (data.teams_TeamsByOwner.length > 0) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Grid container spacing={40}>
|
||||
{!loading &&
|
||||
data.teams_TeamsByOwner.map(team => (
|
||||
<ManageTeamsItem
|
||||
key={team.id}
|
||||
team={team}
|
||||
classes={classes}
|
||||
authId={authId}
|
||||
{...props}
|
||||
/>
|
||||
))}
|
||||
{errors}
|
||||
</Grid>
|
||||
</React.Fragment>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={10}>
|
||||
<MessageCard message='You don’t have any teams. Create one!'>
|
||||
<CreateTeamDialog authId={authId} />
|
||||
</MessageCard>
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
let errors = null
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
return <MessageCard message={message} />
|
||||
})
|
||||
}
|
||||
if (!loading && !error) {
|
||||
if (data.teams_TeamsByOwner.length > 0) {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={12}>
|
||||
<MessageCard message='Loading...' />
|
||||
{errors !== null && <MessageCard message={errors} />}
|
||||
</Grid>
|
||||
{!loading &&
|
||||
data.teams_TeamsByOwner.map(team => (
|
||||
<ManageTeamsItem
|
||||
key={team.id}
|
||||
team={team}
|
||||
classes={classes}
|
||||
{...props}
|
||||
/>
|
||||
))}
|
||||
{errors}
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
}}
|
||||
</Query>
|
||||
)
|
||||
}
|
||||
}
|
||||
</React.Fragment>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={10}>
|
||||
<MessageCard message='You don’t have any teams. Create one!'>
|
||||
<CreateTeamDialog />
|
||||
</MessageCard>
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<Grid container spacing={40}>
|
||||
<Grid item xs={12}>
|
||||
<MessageCard message='Loading...' />
|
||||
{errors !== null && <MessageCard message={errors} />}
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
}}
|
||||
</Query>
|
||||
)
|
||||
|
||||
ManageTeamsList.propTypes = {
|
||||
user: PropTypes.any,
|
||||
classes: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
const getUserOnMount = lifecycle({
|
||||
componentDidMount () {
|
||||
getItem('user').then(user => {
|
||||
this.setState({ user })
|
||||
}) // Set user to state
|
||||
}
|
||||
})
|
||||
|
||||
const mapStateToProps = withStateHandlers(() => ({ user: null }), {
|
||||
user: ({ user }) => () => ({ user })
|
||||
})
|
||||
|
||||
const ManageTeamsListAuthId = compose(
|
||||
mapStateToProps,
|
||||
getUserOnMount
|
||||
)(ManageTeamsList)
|
||||
|
||||
export default withStyles(styles)(ManageTeamsListAuthId)
|
||||
export default withStyles(styles)(ManageTeamsList)
|
||||
@@ -15,6 +15,7 @@ import REMOVE_TEAM_MEMBER from '../../../graphql/teams/RemoveTeamMemberMutation'
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -54,7 +55,7 @@ export class ManageMemberDelete extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.teamId)
|
||||
log.debug(this.props, this.props.teamId)
|
||||
const { classes, teamId, authId } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -72,7 +73,7 @@ export class ManageMemberDelete extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
|
||||
@@ -17,6 +17,7 @@ import SET_TEAM_MEMBER_ROLE from '../../../graphql/teams/SetTeamMemberRoleMutati
|
||||
import GET_TEAMS_BY_OWNER from '../../../graphql/teams/GetTeamsByOwnerQuery'
|
||||
|
||||
import { checkGraphQLError } from '../../../utils/graphql-errors'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
@@ -62,7 +63,7 @@ export class ManageMemberRole extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.teamId)
|
||||
log.debug(this.props, this.props.teamId)
|
||||
const { classes, teamId, authId } = this.props
|
||||
return (
|
||||
<Mutation
|
||||
@@ -80,7 +81,7 @@ export class ManageMemberRole extends Component {
|
||||
if (error) {
|
||||
errors = error.graphQLErrors.map(({ message }, i) => {
|
||||
const displayMessage = checkGraphQLError(message)
|
||||
console.log('createTeam error:', displayMessage)
|
||||
log.debug('createTeam error:', displayMessage)
|
||||
return (
|
||||
<Typography key={i} variant='caption'>
|
||||
{message}
|
||||
|
||||
@@ -10,6 +10,8 @@ import Card from '@material-ui/core/Card'
|
||||
import CardContent from '@material-ui/core/CardContent'
|
||||
import CardActions from '@material-ui/core/CardActions'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
dialogContainer: {
|
||||
display: 'block',
|
||||
@@ -47,7 +49,7 @@ export class ManageMemberStatus extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(this.props, this.props.status)
|
||||
log.debug(this.props, this.props.status)
|
||||
const { classes, status } = this.props
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -9,8 +9,10 @@ import ManageMemberRole from './ManageMemberRole'
|
||||
import ManageMemberStatus from './ManageMemberStatus'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
export const ManageMembersItem = ({ classes, member, teamId, authId }) => {
|
||||
console.log('ManageMembersItem', member)
|
||||
log.debug('ManageMembersItem', member)
|
||||
let profile = null
|
||||
let email = null
|
||||
let memberStatus = null
|
||||
|
||||
@@ -12,6 +12,8 @@ import InviteMemberDialog from './InviteMemberDialog'
|
||||
import ManageMembersItem from './ManageMembersItem'
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
import log from '../../../utils/log'
|
||||
|
||||
const styles = theme => ({
|
||||
heroContent: {
|
||||
maxWidth: 600,
|
||||
@@ -56,7 +58,7 @@ const styles = theme => ({
|
||||
})
|
||||
|
||||
export const ManageMembersTeamItem = ({ classes, team, authId }) => {
|
||||
console.log('ManageMembersItem', team, team.profile, team.profile.avatar)
|
||||
log.debug('ManageMembersItem', team, team.profile, team.profile.avatar)
|
||||
let avatar
|
||||
if (team.profile.avatar !== undefined && team.profile.avatar !== 'a') {
|
||||
avatar = team.profile.avatar
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import { parse } from '../../utils/js-helpers'
|
||||
import log from '../../utils/log'
|
||||
|
||||
import { MessageCard } from '@advancedalgos/web-components'
|
||||
|
||||
@@ -9,7 +10,7 @@ class AcceptTeamInvite extends Component {
|
||||
render () {
|
||||
const { location, auth } = this.props
|
||||
const param = parse(location.search)
|
||||
console.log(param, auth)
|
||||
log.debug(param, auth)
|
||||
|
||||
if (auth === undefined) {
|
||||
return <MessageCard message='Loading...' />
|
||||
|
||||
@@ -10,6 +10,7 @@ import { MessageCard } from '@advancedalgos/web-components'
|
||||
import GET_ALL_TEAMS_QUERY from '../../../graphql/teams/GetAllTeamsQuery'
|
||||
|
||||
import { isEmpty } from '../../../utils/js-helpers'
|
||||
import log from '../../../utils/log'
|
||||
|
||||
import TeamsItem from './TeamsItem'
|
||||
import TeamsDetails from './TeamsDetails'
|
||||
@@ -42,7 +43,7 @@ const styles = theme => ({
|
||||
export const TeamsList = ({ classes, match }) => (
|
||||
<Query query={GET_ALL_TEAMS_QUERY} fetchPolicy='cache-and-network' >
|
||||
{({ loading, error, data, ...props }) => {
|
||||
console.log('GET_ALL_TEAMS: ', loading, error, data, match, props)
|
||||
log.debug('GET_ALL_TEAMS: ', loading, error, data, match, props)
|
||||
let slug = null
|
||||
if (!isEmpty(match.params) && match.params.slug) slug = match.params.slug
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import minilog from 'minilog'
|
||||
|
||||
minilog.enable()
|
||||
|
||||
const log = minilog('frontend')
|
||||
|
||||
let consoleLog = global.console.log
|
||||
|
||||
global.console.log = function () {
|
||||
consoleLog.apply(global.console, arguments)
|
||||
}
|
||||
|
||||
export default log
|
||||
Reference in new issue
Block a user