@@ -6,10 +6,13 @@ import {
6
6
import { Prisma } from '@prisma/client' ;
7
7
import {
8
8
mapScorecardRequestToDto ,
9
+ ScorecardGroupBaseDto ,
9
10
ScorecardPaginatedResponseDto ,
10
11
ScorecardQueryDto ,
12
+ ScorecardQuestionBaseDto ,
11
13
ScorecardRequestDto ,
12
14
ScorecardResponseDto ,
15
+ ScorecardSectionBaseDto ,
13
16
ScorecardWithGroupResponseDto ,
14
17
} from 'src/dto/scorecard.dto' ;
15
18
import { PrismaService } from 'src/shared/modules/global/prisma.service' ;
@@ -204,30 +207,22 @@ export class ScoreCardService {
204
207
} ,
205
208
} ,
206
209
} ,
207
- } )
208
- . catch ( ( error ) => {
209
- if ( error . code !== 'P2025' ) {
210
- throw new NotFoundException ( { message : `Scorecard not found.` } ) ;
211
- }
212
- throw new InternalServerErrorException ( {
213
- message : `Error: ${ error . code } ` ,
214
- } ) ;
215
210
} ) ;
216
211
217
212
if ( ! original ) {
218
213
throw new NotFoundException ( { message : `Scorecard not found.` } ) ;
219
214
}
220
215
221
216
// Remove id fields from nested objects for cloning
222
- const cloneGroups = original . scorecardGroups . map ( ( group : any ) => ( {
217
+ const cloneGroups = original . scorecardGroups . map ( ( group : ScorecardGroupBaseDto ) => ( {
223
218
...group ,
224
219
id : undefined ,
225
220
scorecardId : undefined ,
226
- sections : group . sections . map ( ( section : any ) => ( {
221
+ sections : group . sections . map ( ( section : ScorecardSectionBaseDto ) => ( {
227
222
...section ,
228
223
id : undefined ,
229
224
scorecardGroupId : undefined ,
230
- questions : section . questions . map ( ( question : any ) => ( {
225
+ questions : section . questions . map ( ( question : ScorecardQuestionBaseDto ) => ( {
231
226
...question ,
232
227
id : undefined ,
233
228
sectionId : undefined ,
@@ -244,25 +239,7 @@ export class ScoreCardService {
244
239
createdAt : undefined ,
245
240
updatedAt : undefined ,
246
241
scorecardGroups : {
247
- create : cloneGroups . map ( ( group : any ) => ( {
248
- ...group ,
249
- createdAt : undefined ,
250
- updatedAt : undefined ,
251
- sections : {
252
- create : group . sections . map ( ( section : any ) => ( {
253
- ...section ,
254
- createdAt : undefined ,
255
- updatedAt : undefined ,
256
- questions : {
257
- create : section . questions . map ( ( question : any ) => ( {
258
- ...question ,
259
- createdAt : undefined ,
260
- updatedAt : undefined ,
261
- } ) ) ,
262
- } ,
263
- } ) ) ,
264
- } ,
265
- } ) ) ,
242
+ create : cloneGroups ,
266
243
} ,
267
244
} ,
268
245
include : {
0 commit comments