@@ -5,37 +5,14 @@ import applicationService from './applicationService';
5
5
import frontPageService from './frontPageService' ;
6
6
import { mergeFiles } from './gotenbergService' ;
7
7
8
- interface FrontPageProps {
8
+ interface FrontPageAndApplicationProps {
9
9
accessToken : string ;
10
10
form : NavFormType ;
11
+ submissionMethod : string ;
11
12
submission : Submission ;
12
13
language : string ;
13
- unitNumber : string ;
14
- }
15
-
16
- const frontPage = async ( props : FrontPageProps ) => {
17
- const { accessToken, form, submission, language, unitNumber } = props ;
18
-
19
- const frontPageResponse : any = frontPageService . createPdf ( {
20
- accessToken,
21
- form,
22
- submission,
23
- language,
24
- unitNumber,
25
- } ) ;
26
-
27
- const frontPagePdf = base64Decode ( frontPageResponse . foersteside ) ;
28
-
29
- if ( frontPagePdf === undefined ) {
30
- throw htmlResponseError ( 'Generering av førstesideark feilet' ) ;
31
- }
32
-
33
- return Buffer . from ( new Uint8Array ( frontPagePdf ) ) ;
34
- } ;
35
-
36
- interface FrontPageAndApplicationProps extends FrontPageProps {
37
14
translations : I18nTranslationMap ;
38
- submissionMethod : string ;
15
+ unitNumber : string ;
39
16
}
40
17
41
18
const frontPageAndApplication = async ( props : FrontPageAndApplicationProps ) => {
@@ -51,6 +28,10 @@ const frontPageAndApplication = async (props: FrontPageAndApplicationProps) => {
51
28
52
29
const frontPagePdf = base64Decode ( frontPageResponse . foersteside ) ;
53
30
31
+ if ( frontPagePdf === undefined ) {
32
+ throw htmlResponseError ( 'Generering av førstesideark PDF feilet' ) ;
33
+ }
34
+
54
35
const applicationResponse : any = await applicationService . createPdf (
55
36
accessToken ,
56
37
form ,
@@ -62,8 +43,8 @@ const frontPageAndApplication = async (props: FrontPageAndApplicationProps) => {
62
43
63
44
const applicationPdf = base64Decode ( applicationResponse . data ) ;
64
45
65
- if ( applicationPdf === undefined || frontPagePdf === undefined ) {
66
- throw htmlResponseError ( 'Generering av førstesideark eller søknads PDF feilet' ) ;
46
+ if ( applicationPdf === undefined ) {
47
+ throw htmlResponseError ( 'Generering av søknads PDF feilet' ) ;
67
48
}
68
49
69
50
const documents = [ frontPagePdf , applicationPdf ] ;
@@ -80,7 +61,6 @@ const frontPageAndApplication = async (props: FrontPageAndApplicationProps) => {
80
61
} ;
81
62
82
63
const documentsService = {
83
- frontPage,
84
64
frontPageAndApplication,
85
65
} ;
86
66
0 commit comments