@@ -4,7 +4,6 @@ import DialogContent from "@material-ui/core/DialogContent";
4
4
import DialogContentText from "@material-ui/core/DialogContentText" ;
5
5
import DialogTitle from "@material-ui/core/DialogTitle" ;
6
6
import { withTheme } from "@material-ui/core/styles" ;
7
- import gql from "graphql-tag" ;
8
7
import isEqual from "lodash/isEqual" ;
9
8
import pick from "lodash/pick" ;
10
9
import Avatar from "material-ui/Avatar" ;
@@ -26,6 +25,17 @@ import { camelCase, dataTest } from "../../lib/attributes";
26
25
import { DateTime } from "../../lib/datetime" ;
27
26
import theme from "../../styles/theme" ;
28
27
import { loadData } from "../hoc/with-operations" ;
28
+ import {
29
+ ARCHIVE_CAMPAIGN ,
30
+ DELETE_JOB ,
31
+ EDIT_CAMPAIGN ,
32
+ GET_CAMPAIGN_JOBS ,
33
+ GET_EDIT_CAMPAIGN_DATA ,
34
+ GET_ORGANIZATION_ACTIONS ,
35
+ GET_ORGANIZATION_DATA ,
36
+ START_CAMPAIGN ,
37
+ UNARCHIVE_CAMPAIGN
38
+ } from "./queries" ;
29
39
import CampaignAutoassignModeForm from "./sections/CampaignAutoassignModeForm" ;
30
40
import CampaignBasicsForm from "./sections/CampaignBasicsForm" ;
31
41
import CampaignCannedResponsesForm from "./sections/CampaignCannedResponsesForm" ;
@@ -38,44 +48,6 @@ import CampaignTeamsForm from "./sections/CampaignTeamsForm";
38
48
import CampaignTextersForm from "./sections/CampaignTextersForm" ;
39
49
import CampaignTextingHoursForm from "./sections/CampaignTextingHoursForm" ;
40
50
41
- const disableTexters = window . DISABLE_CAMPAIGN_EDIT_TEXTERS ;
42
-
43
- // TODO: replace with Fragment
44
- const campaignInfoFragment = `
45
- id
46
- title
47
- description
48
- dueBy
49
- isStarted
50
- isArchived
51
- datawarehouseAvailable
52
- customFields
53
- useDynamicAssignment
54
- logoImageUrl
55
- introHtml
56
- primaryColor
57
- textingHoursStart
58
- textingHoursEnd
59
- isAssignmentLimitedToTeams
60
- isAutoassignEnabled
61
- timezone
62
- teams {
63
- id
64
- title
65
- }
66
- interactionSteps {
67
- id
68
- questionText
69
- scriptOptions
70
- answerOption
71
- answerActions
72
- parentInteractionId
73
- isDeleted
74
- createdAt
75
- }
76
- editors
77
- ` ;
78
-
79
51
const extractStageAndStatus = ( percentComplete ) => {
80
52
if ( percentComplete > 100 ) {
81
53
return `Filtering out landlines. ${ percentComplete - 100 } % complete` ;
@@ -532,10 +504,7 @@ class AdminCampaignEdit extends React.Component {
532
504
}
533
505
] ;
534
506
535
- return ( disableTexters
536
- ? sections . filter ( ( section ) => section . title !== "Texters" )
537
- : sections
538
- ) . filter ( ( section ) => ! section . exclude ) ;
507
+ return sections . filter ( ( section ) => ! section . exclude ) ;
539
508
} ;
540
509
541
510
sectionSaveStatus = ( section ) => {
@@ -915,20 +884,7 @@ AdminCampaignEdit.propTypes = {
915
884
916
885
const queries = {
917
886
pendingJobsData : {
918
- query : gql `
919
- query getCampaignJobs($campaignId: String!) {
920
- campaign(id: $campaignId) {
921
- id
922
- pendingJobs {
923
- id
924
- jobType
925
- assigned
926
- status
927
- resultMessage
928
- }
929
- }
930
- }
931
- ` ,
887
+ query : GET_CAMPAIGN_JOBS ,
932
888
options : ( ownProps ) => ( {
933
889
variables : {
934
890
campaignId : ownProps . match . params . campaignId
@@ -937,11 +893,7 @@ const queries = {
937
893
} )
938
894
} ,
939
895
campaignData : {
940
- query : gql `query getCampaign($campaignId: String!) {
941
- campaign(id: $campaignId) {
942
- ${ campaignInfoFragment }
943
- }
944
- }` ,
896
+ query : GET_EDIT_CAMPAIGN_DATA ,
945
897
options : ( ownProps ) => ( {
946
898
variables : {
947
899
campaignId : ownProps . match . params . campaignId
@@ -950,54 +902,15 @@ const queries = {
950
902
} )
951
903
} ,
952
904
organizationData : {
953
- query : gql `
954
- query getOrganizationData($organizationId: String!) {
955
- organization(id: $organizationId) {
956
- id
957
- uuid
958
- teams {
959
- id
960
- title
961
- }
962
- ${
963
- disableTexters
964
- ? ""
965
- : `
966
- texters: people {
967
- id
968
- firstName
969
- lastName
970
- displayName
971
- }
972
- `
973
- }
974
- numbersApiKey
975
- campaigns(cursor: { offset: 0, limit: 5000 }) {
976
- campaigns {
977
- id
978
- title
979
- createdAt
980
- }
981
- }
982
- }
983
- }
984
- ` ,
905
+ query : GET_ORGANIZATION_DATA ,
985
906
options : ( ownProps ) => ( {
986
907
variables : {
987
908
organizationId : ownProps . match . params . organizationId
988
909
}
989
910
} )
990
911
} ,
991
912
availableActionsData : {
992
- query : gql `
993
- query getActions($organizationId: String!) {
994
- availableActions(organizationId: $organizationId) {
995
- name
996
- display_name
997
- instructions
998
- }
999
- }
1000
- ` ,
913
+ query : GET_ORGANIZATION_ACTIONS ,
1001
914
options : ( ownProps ) => ( {
1002
915
variables : {
1003
916
organizationId : ownProps . match . params . organizationId
@@ -1007,53 +920,28 @@ const queries = {
1007
920
}
1008
921
} ;
1009
922
1010
- // Right now we are copying the result fields instead of using a fragment because of https://github.com/apollostack/apollo-client/issues/451
1011
923
const mutations = {
1012
924
archiveCampaign : ( _ownProps ) => ( campaignId ) => ( {
1013
- mutation : gql `mutation archiveCampaign($campaignId: String!) {
1014
- archiveCampaign(id: $campaignId) {
1015
- ${ campaignInfoFragment }
1016
- }
1017
- }` ,
925
+ mutation : ARCHIVE_CAMPAIGN ,
1018
926
variables : { campaignId }
1019
927
} ) ,
1020
928
unarchiveCampaign : ( _ownProps ) => ( campaignId ) => ( {
1021
- mutation : gql `mutation unarchiveCampaign($campaignId: String!) {
1022
- unarchiveCampaign(id: $campaignId) {
1023
- ${ campaignInfoFragment }
1024
- }
1025
- }` ,
929
+ mutation : UNARCHIVE_CAMPAIGN ,
1026
930
variables : { campaignId }
1027
931
} ) ,
1028
932
startCampaign : ( _ownProps ) => ( campaignId ) => ( {
1029
- mutation : gql `mutation startCampaign($campaignId: String!) {
1030
- startCampaign(id: $campaignId) {
1031
- ${ campaignInfoFragment }
1032
- }
1033
- }` ,
933
+ mutation : START_CAMPAIGN ,
1034
934
variables : { campaignId }
1035
935
} ) ,
1036
936
editCampaign : ( _ownProps ) => ( campaignId , campaign ) => ( {
1037
- mutation : gql `
1038
- mutation editCampaign($campaignId: String!, $campaign: CampaignInput!) {
1039
- editCampaign(id: $campaignId, campaign: $campaign) {
1040
- ${ campaignInfoFragment }
1041
- }
1042
- },
1043
- ` ,
937
+ mutation : EDIT_CAMPAIGN ,
1044
938
variables : {
1045
939
campaignId,
1046
940
campaign
1047
941
}
1048
942
} ) ,
1049
943
deleteJob : ( ownProps ) => ( jobId ) => ( {
1050
- mutation : gql `
1051
- mutation deleteJob($campaignId: String!, $id: String!) {
1052
- deleteJob(campaignId: $campaignId, id: $id) {
1053
- id
1054
- }
1055
- }
1056
- ` ,
944
+ mutation : DELETE_JOB ,
1057
945
variables : {
1058
946
campaignId : ownProps . match . params . campaignId ,
1059
947
id : jobId
0 commit comments