Bugfix/userdrawer changestatus (#2469)

* fix date formatting breaking user details popvoer

* update mutation return fields for user status changes
This commit is contained in:
Tessa Thornton
2019-08-14 08:32:03 -04:00
committed by GitHub
parent e76fddd13c
commit c37ee12e57
4 changed files with 60 additions and 0 deletions
@@ -25,6 +25,13 @@ const BanUserMutation = createMutation(
current
ban {
active
history {
active
createdAt
createdBy {
username
}
}
}
}
}
@@ -49,6 +56,12 @@ const BanUserMutation = createMutation(
)!.status.current.concat(GQLUSER_STATUS.BANNED),
ban: {
active: true,
history: [
{
active: true,
createdAt: new Date(),
},
],
},
},
},
@@ -25,6 +25,13 @@ const RemoveUserBanMutation = createMutation(
current
ban {
active
history {
active
createdAt
createdBy {
username
}
}
}
}
}
@@ -49,6 +56,7 @@ const RemoveUserBanMutation = createMutation(
)!.status.current.filter(s => s !== GQLUSER_STATUS.BANNED),
ban: {
active: false,
history: [],
},
},
},
@@ -27,6 +27,16 @@ const RemoveUserSuspensionMutation = createMutation(
current
suspension {
active
history {
active
from {
start
finish
}
createdBy {
username
}
}
}
}
}
@@ -51,6 +61,11 @@ const RemoveUserSuspensionMutation = createMutation(
)!.status.current.concat(GQLUSER_STATUS.SUSPENDED),
suspension: {
active: false,
history: [
{
active: false,
},
],
},
},
},
@@ -1,3 +1,4 @@
import { DateTime } from "luxon";
import { graphql } from "react-relay";
import { Environment } from "relay-runtime";
@@ -15,6 +16,10 @@ let clientMutationId = 0;
const SuspendUserMutation = createMutation(
"suspendUser",
(environment: Environment, input: MutationInput<MutationTypes>) => {
const now = new Date();
const finish = DateTime.fromJSDate(now).plus({
seconds: input.timeout,
});
return commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation SuspendUserMutation($input: SuspendUserInput!) {
@@ -25,6 +30,16 @@ const SuspendUserMutation = createMutation(
current
suspension {
active
history {
active
from {
start
finish
}
createdBy {
username
}
}
}
}
}
@@ -49,6 +64,15 @@ const SuspendUserMutation = createMutation(
)!.status.current.concat(GQLUSER_STATUS.SUSPENDED),
suspension: {
active: true,
history: [
{
active: true,
from: {
start: now,
finish,
},
},
],
},
},
},