Renaming from status to state
This commit is contained in:
1 parent
7347d472bd
commit
793b52e1d7
11 files changed
+42
-42
No files matched your search
@@ -3,7 +3,7 @@ import gql from 'graphql-tag';
|
||||
export const eventMinimalInfo = gql`
|
||||
fragment EventMinimalInfo on events_Event {
|
||||
id
|
||||
status
|
||||
state
|
||||
name
|
||||
startDatetime
|
||||
finishDatetime
|
||||
@@ -19,7 +19,7 @@ export const eventMinimalInfo = gql`
|
||||
export const eventFullInfo = gql`
|
||||
fragment EventFullInfo on events_Event {
|
||||
id
|
||||
status
|
||||
state
|
||||
name
|
||||
host{
|
||||
alias
|
||||
|
||||
@@ -6,7 +6,7 @@ export const INTERRUPTED = 'INTERRUPTED';
|
||||
export const FINISHED = 'FINISHED';
|
||||
export const ARCHIVED = 'ARCHIVED';
|
||||
|
||||
export const EventStatusEnum = [
|
||||
export const EventStateEnum = [
|
||||
UNPUBLISHED,
|
||||
PUBLISHED,
|
||||
CANCELLED,
|
||||
@@ -16,4 +16,4 @@ export const EventStatusEnum = [
|
||||
ARCHIVED,
|
||||
];
|
||||
|
||||
export default EventStatusEnum;
|
||||
export default EventStateEnum;
|
||||
@@ -3,15 +3,15 @@ import Plotter from './plotter';
|
||||
import Formula from './formula';
|
||||
import {
|
||||
UNPUBLISHED,
|
||||
EventStatusEnum,
|
||||
} from '../enums/EventStatus';
|
||||
EventStateEnum,
|
||||
} from '../enums/EventState';
|
||||
|
||||
const { ObjectId } = Schema.Types;
|
||||
|
||||
const eventSchema = new Schema({
|
||||
status: {
|
||||
state: {
|
||||
type: String,
|
||||
enum: EventStatusEnum,
|
||||
enum: EventStateEnum,
|
||||
default: UNPUBLISHED,
|
||||
},
|
||||
name: {
|
||||
|
||||
+5
-5
@@ -5,20 +5,20 @@ import {
|
||||
import { AuthentificationError } from '../../errors';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import EventStatusEnum from '../types/enum/EventStatus';
|
||||
import EventStateEnum from '../types/enum/EventState';
|
||||
|
||||
const args = {
|
||||
eventId: { type: new GraphQLNonNull(GraphQLID) },
|
||||
status: { type: EventStatusEnum },
|
||||
state: { type: EventStateEnum },
|
||||
};
|
||||
|
||||
const resolve = (parent, { eventId: _id, status }, { userId: hostId }) => {
|
||||
const resolve = (parent, { eventId: _id, state }, { userId: hostId }) => {
|
||||
if (!hostId) {
|
||||
throw new AuthentificationError();
|
||||
}
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
Event.findOneAndUpdate({ _id, hostId }, { status }, { new: true }, (err, modifiedEvent) => {
|
||||
Event.findOneAndUpdate({ _id, hostId }, { state }, { new: true }, (err, modifiedEvent) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
return;
|
||||
@@ -29,7 +29,7 @@ const resolve = (parent, { eventId: _id, status }, { userId: hostId }) => {
|
||||
};
|
||||
|
||||
const mutation = {
|
||||
changeEventStatus: {
|
||||
changeEventState: {
|
||||
type: EventType,
|
||||
args,
|
||||
resolve,
|
||||
@@ -8,7 +8,7 @@ import RegisterToEventMutation from './RegisterToEvent';
|
||||
import EditParticipantMutation from './EditParticipant';
|
||||
import CreateFormulaMutation from './CreateFormula';
|
||||
import CreatePlotterMutation from './CreatePlotter';
|
||||
import ChangeEventStatusMutation from './ChangeEventStatus';
|
||||
import ChangeEventStateMutation from './ChangeEventState';
|
||||
|
||||
const Mutation = new GraphQLObjectType({
|
||||
name: 'Mutation',
|
||||
@@ -19,7 +19,7 @@ const Mutation = new GraphQLObjectType({
|
||||
EditParticipantMutation,
|
||||
CreateFormulaMutation,
|
||||
CreatePlotterMutation,
|
||||
ChangeEventStatusMutation,
|
||||
ChangeEventStateMutation,
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
} from 'graphql';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventStatus';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventState';
|
||||
|
||||
const args = {
|
||||
minDate: { type: GraphQLInt },
|
||||
@@ -13,7 +13,7 @@ const args = {
|
||||
|
||||
const resolve = (parent, { minDate, maxDate }) => Event.find(
|
||||
Object.assign(
|
||||
{ status: { $nin: [UNPUBLISHED, ARCHIVED] } },
|
||||
{ state: { $nin: [UNPUBLISHED, ARCHIVED] } },
|
||||
minDate || maxDate
|
||||
? {
|
||||
startDatetime:
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from 'graphql';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventStatus';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventState';
|
||||
|
||||
const args = {
|
||||
hostId: { type: GraphQLString },
|
||||
@@ -15,7 +15,7 @@ const args = {
|
||||
|
||||
const resolve = (parent, { hostId, minDate, maxDate }, context) => Event.find(
|
||||
Object.assign(
|
||||
hostId ? { hostId, status: { $nin: [UNPUBLISHED, ARCHIVED] } } : { hostId: context.userId },
|
||||
hostId ? { hostId, state: { $nin: [UNPUBLISHED, ARCHIVED] } } : { hostId: context.userId },
|
||||
minDate || maxDate
|
||||
? {
|
||||
startDatetime:
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from 'graphql';
|
||||
import { EventType } from '../types';
|
||||
import { Event } from '../../models';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventStatus';
|
||||
import { UNPUBLISHED, ARCHIVED } from '../../enums/EventState';
|
||||
|
||||
const args = {
|
||||
teamId: { type: new GraphQLNonNull(GraphQLString) },
|
||||
@@ -18,7 +18,7 @@ const resolve = (parent, { teamId, minDate, maxDate }) => Event.find(
|
||||
Object.assign(
|
||||
{
|
||||
participants: { $elemMatch: { teamId } },
|
||||
status: { $nin: [UNPUBLISHED, ARCHIVED] },
|
||||
state: { $nin: [UNPUBLISHED, ARCHIVED] },
|
||||
},
|
||||
|
||||
minDate || maxDate
|
||||
|
||||
@@ -12,14 +12,14 @@ import {
|
||||
ParticipantType,
|
||||
PrizeType,
|
||||
} from './index';
|
||||
import EventStatusEnumType from './enum/EventStatus';
|
||||
import EventStateEnumType from './enum/EventState';
|
||||
|
||||
const EventType = new GraphQLObjectType({
|
||||
name: 'Event',
|
||||
description: 'Everything you need to know about an event',
|
||||
fields: () => ({
|
||||
id: { type: GraphQLID },
|
||||
status: { type: EventStatusEnumType },
|
||||
state: { type: EventStateEnumType },
|
||||
name: { type: GraphQLString },
|
||||
hostId: { type: GraphQLString },
|
||||
description: { type: GraphQLString },
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {
|
||||
GraphQLEnumType,
|
||||
} from 'graphql';
|
||||
|
||||
import { EventStateEnum } from '../../../enums/EventState';
|
||||
|
||||
const values = {};
|
||||
EventStateEnum.forEach((EventState) => {
|
||||
values[EventState] = { value: EventState };
|
||||
});
|
||||
|
||||
const EventStateEnumType = new GraphQLEnumType({
|
||||
name: 'EventStateEnum',
|
||||
values,
|
||||
});
|
||||
|
||||
export {
|
||||
EventStateEnumType as default,
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import {
|
||||
GraphQLEnumType,
|
||||
} from 'graphql';
|
||||
|
||||
import { EventStatusEnum } from '../../../enums/EventStatus';
|
||||
|
||||
const values = {};
|
||||
EventStatusEnum.forEach((EventStatus) => {
|
||||
values[EventStatus] = { value: EventStatus };
|
||||
});
|
||||
|
||||
const EventStatusEnumType = new GraphQLEnumType({
|
||||
name: 'EventStatusEnum',
|
||||
values,
|
||||
});
|
||||
|
||||
export {
|
||||
EventStatusEnumType as default,
|
||||
};
|
||||
Reference in new issue
Block a user