Skip to content

Commit

Permalink
fix: use getVersion correctly (TT-1831) (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Østrem <[email protected]>
  • Loading branch information
fredrikmonsen and Sindrir authored Dec 13, 2024
1 parent 7ee4432 commit 58a9108
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
24 changes: 14 additions & 10 deletions src/features/registration/registration-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 11 additions & 3 deletions src/model/text-input-dto.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -46,4 +46,12 @@ export class TextInputDto {
return PublicationType.MONOGRAPHIC;
}
}

async setVersion(): Promise<void> {
try {
this.application = 'Trøkk ' + await getVersion();
} catch (error) {
console.error('Failed to set version:', error);
}
}
}

0 comments on commit 58a9108

Please sign in to comment.