Skip to content

Commit b280b84

Browse files
Merge Block user and project
2 parents 6ade46e + dccb14e commit b280b84

File tree

3 files changed

+77
-8
lines changed

3 files changed

+77
-8
lines changed

src/graphql/graphql.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const ALL_PROJECTS_QUERY = gql`
4444
dbId
4545
email
4646
}
47+
isBlocked
4748
}
4849
}
4950
pageInfo {
@@ -90,6 +91,7 @@ export const PROJECT_QUERY = gql`
9091
dbId
9192
username
9293
}
94+
isBlocked
9395
}
9496
}
9597
`
@@ -101,6 +103,7 @@ export const USER_QUERY = gql`
101103
email
102104
latitude
103105
longitude
106+
isBlocked
104107
}
105108
}
106109
`
@@ -116,3 +119,33 @@ export const CATEGORIES_QUERY = gql`
116119
}
117120
}
118121
`
122+
123+
export const BLOCK_USER_MUTATION = gql`
124+
mutation BlockUser($userId: Int!) {
125+
mutateBlockUser(userId: $userId) {
126+
isBlocked
127+
}
128+
}
129+
`
130+
131+
export const UNBLOCK_USER_MUTATION = gql`
132+
mutation UnblockUser($userId: Int!) {
133+
mutateUnblockUser(userId: $userId){
134+
isBlocked
135+
}
136+
}
137+
`
138+
export const BLOCK_PROJECT_MUTATION = gql`
139+
mutation BlockProject($idProject: Int!) {
140+
mutateBlockProject(idProject: $idProject){
141+
isBlocked
142+
}
143+
}
144+
`
145+
export const UNBLOCK_PROJECT_MUTATION = gql`
146+
mutation UnblockProject($idProject: Int!) {
147+
mutateUnblockProject(idProject: $idProject){
148+
isBlocked
149+
}
150+
}
151+
`

src/views/ProjectDetail.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309

310310
<script>
311311
import InvestorsTable from '@/components/InvestorsTable'
312-
import { PROJECT_QUERY } from '../graphql/graphql'
312+
import { PROJECT_QUERY, BLOCK_PROJECT_MUTATION, UNBLOCK_PROJECT_MUTATION } from '@/graphql/graphql'
313313
314314
export default {
315315
components: {
@@ -387,7 +387,7 @@ export default {
387387
return this.$route.params.id
388388
},
389389
isBlocked () {
390-
return this.mockProject.isBlocked
390+
return this.project.isBlocked
391391
},
392392
items () {
393393
return [{
@@ -407,12 +407,30 @@ export default {
407407
408408
methods: {
409409
blockProject () {
410-
this.mockProject.isBlocked = true
411410
this.dialog = false
411+
this.$apollo.mutate({
412+
mutation: BLOCK_PROJECT_MUTATION,
413+
variables: {
414+
idProject: this.id
415+
}
416+
}).then(() => {
417+
this.project.isBlocked = true
418+
}).catch((error) => {
419+
console.error(error)
420+
})
412421
},
413422
unblockProject () {
414-
this.mockProject.isBlocked = false
415423
this.dialog = false
424+
this.$apollo.mutate({
425+
mutation: UNBLOCK_PROJECT_MUTATION,
426+
variables: {
427+
idProject: this.id
428+
}
429+
}).then(() => {
430+
this.project.isBlocked = false
431+
}).catch((error) => {
432+
console.error(error)
433+
})
416434
}
417435
},
418436

src/views/UserDetail.vue

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
<script>
275275
import Map from '@/components/Map'
276276
import ProjectsTable from '@/components/ProjectsTable'
277-
import { USER_QUERY } from '../graphql/graphql'
277+
import { BLOCK_USER_MUTATION, UNBLOCK_USER_MUTATION, USER_QUERY } from '@/graphql/graphql'
278278
279279
export default {
280280
components: {
@@ -313,7 +313,7 @@ export default {
313313
return this.$route.params.id
314314
},
315315
isBlocked () {
316-
return this.mockUser.isBlocked
316+
return this.user.isBlocked
317317
},
318318
isSeeder () {
319319
return this.mockUser.isSeeder
@@ -342,12 +342,30 @@ export default {
342342
343343
methods: {
344344
blockUser () {
345-
this.mockUser.isBlocked = true
346345
this.dialog = false
346+
this.$apollo.mutate({
347+
mutation: BLOCK_USER_MUTATION,
348+
variables: {
349+
userId: this.id
350+
}
351+
}).then(() => {
352+
this.user.isBlocked = true
353+
}).catch((error) => {
354+
console.error(error)
355+
})
347356
},
348357
unblockUser () {
349-
this.mockUser.isBlocked = false
350358
this.dialog = false
359+
this.$apollo.mutate({
360+
mutation: UNBLOCK_USER_MUTATION,
361+
variables: {
362+
userId: this.id
363+
}
364+
}).then(() => {
365+
this.user.isBlocked = false
366+
}).catch((error) => {
367+
console.error(error)
368+
})
351369
}
352370
},
353371

0 commit comments

Comments
 (0)