File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -125,4 +125,34 @@ router.post(
125
125
}
126
126
) ;
127
127
128
+ router . post ( "/get-selected-csa-nps" ,
129
+ [
130
+ body ( "data" )
131
+ . isArray ( )
132
+ . withMessage ( "data is required and must be an array" ) ,
133
+ ] ,
134
+ async ( req , res ) => {
135
+ const errors = validationResult ( req ) ;
136
+ if ( ! errors . isEmpty ( ) ) {
137
+ return res . status ( 400 ) . json ( { errors : errors . array ( ) } ) ;
138
+ }
139
+
140
+ const { data } = matchedData ( req ) ;
141
+
142
+ const response = [ ] ;
143
+ const periodNpsObject = { } ;
144
+
145
+ data . forEach ( ( item ) => {
146
+ const { periodNps, ...rest } = item ;
147
+ response . push ( rest ) ;
148
+
149
+ if ( ! periodNpsObject [ item . customerSupportFullName ] ) {
150
+ periodNpsObject [ item . customerSupportFullName ] = periodNps ;
151
+ }
152
+ } ) ;
153
+
154
+ return res . status ( 200 ) . send ( { response, periodNpsByCsa : periodNpsObject } ) ;
155
+ }
156
+ )
157
+
128
158
export default router ;
You can’t perform that action at this time.
0 commit comments