diff --git a/src/features/registration/registration-form.tsx b/src/features/registration/registration-form.tsx index 32ed4a0..1057b61 100644 --- a/src/features/registration/registration-form.tsx +++ b/src/features/registration/registration-form.tsx @@ -141,22 +141,26 @@ const RegistrationForm: React.FC = () => { return Promise.reject(error); }); + const body = new TextInputDto( + id, + registration.materialType, + auth.userInfo.name, + registration.font, + registration.language, + machineName, + registration.workingTitle, + numberOfPagesTransferred + ); + + await body.setVersion(); + return await fetch(`${papiPath}/v2/item`, { method: 'POST', headers: { 'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json' }, - body: JSON.stringify(new TextInputDto( - id, - registration.materialType, - auth.userInfo.name, - registration.font, - registration.language, - machineName, - registration.workingTitle, - numberOfPagesTransferred - )) + body: JSON.stringify(body) }) .then(async response => { if (response.ok) { diff --git a/src/model/text-input-dto.ts b/src/model/text-input-dto.ts index 446a6ca..0b71236 100644 --- a/src/model/text-input-dto.ts +++ b/src/model/text-input-dto.ts @@ -1,5 +1,5 @@ -import { getMaterialTypeAsKeyString, MaterialType, PublicationType } from './registration-enums.ts'; -import { getVersion } from '@tauri-apps/api/app'; +import {getMaterialTypeAsKeyString, MaterialType, PublicationType} from './registration-enums.ts'; +import {getVersion} from '@tauri-apps/api/app'; export class TextInputDto { id: string; @@ -31,7 +31,7 @@ export class TextInputDto { this.digital = false; this.font = font; this.language = language; - this.application = 'Trøkk ' + getVersion(); + this.application = 'Trøkk'; this.machineName = machineName; this.workName = workName; this.numberOfPages = numberOfPages; @@ -46,4 +46,12 @@ export class TextInputDto { return PublicationType.MONOGRAPHIC; } } + + async setVersion(): Promise { + try { + this.application = 'Trøkk ' + await getVersion(); + } catch (error) { + console.error('Failed to set version:', error); + } + } } \ No newline at end of file