diff --git a/src/models/CatalogMissingNewspaperDto.ts b/src/models/CatalogMissingNewspaperDto.ts index 28b4f63..95a84c8 100644 --- a/src/models/CatalogMissingNewspaperDto.ts +++ b/src/models/CatalogMissingNewspaperDto.ts @@ -1,5 +1,6 @@ import {newspaper} from '@prisma/client'; import {createCatalogDateString} from '@/utils/dateUtils'; +import {getUserName} from '@/utils/cookieUtils'; export interface CatalogMissingNewspaperDto { titleCatalogueId: string; @@ -17,7 +18,7 @@ export function createCatalogMissingNewspaperDtoFromIssue( return { titleCatalogueId: titleId, date: createCatalogDateString(issue.date), - username: 'hugin stage', // TODO replace with actual username when auth is present + username: getUserName() ?? '', notes: issue.notes ?? '', // eslint-disable-next-line id-denylist number: issue.edition ?? '' diff --git a/src/models/CatalogNewspaperDto.ts b/src/models/CatalogNewspaperDto.ts index 113b68f..e1971bf 100644 --- a/src/models/CatalogNewspaperDto.ts +++ b/src/models/CatalogNewspaperDto.ts @@ -1,5 +1,6 @@ import {newspaper} from '@prisma/client'; import {createCatalogDateString} from '@/utils/dateUtils'; +import {getUserName} from '@/utils/cookieUtils'; export interface CatalogNewspaperDto { titleCatalogueId: string; @@ -21,7 +22,7 @@ export function createCatalogNewspaperDtoFromIssue( return { titleCatalogueId: titleId, date: createCatalogDateString(issue.date), - username: 'hugin stage', // TODO replace with actual username when auth is present + username: getUserName() ?? '', digital: false, containerId: issue.box_id, notes: issue.notes ?? '', diff --git a/src/models/CatalogNewspaperEditDto.ts b/src/models/CatalogNewspaperEditDto.ts index b416eab..77af047 100644 --- a/src/models/CatalogNewspaperEditDto.ts +++ b/src/models/CatalogNewspaperEditDto.ts @@ -1,4 +1,5 @@ import {newspaper} from '@prisma/client'; +import {getUserName} from '@/utils/cookieUtils'; export interface CatalogNewspaperEditDto { @@ -14,7 +15,7 @@ export function createCatalogNewspaperEditDtoFromIssue( ): CatalogNewspaperEditDto { return { manifestationId: issue.catalog_id, - username: 'Hugin stage', // TODO replace with actual username when auth is present + username: getUserName() ?? '', notes: issue.notes ?? '', // eslint-disable-next-line id-denylist number: issue.edition ?? '' diff --git a/src/utils/cookieUtils.ts b/src/utils/cookieUtils.ts index 7a00699..ccd4685 100644 --- a/src/utils/cookieUtils.ts +++ b/src/utils/cookieUtils.ts @@ -13,6 +13,10 @@ export function getRefreshToken(): string | undefined { return getUserToken()?.refreshToken; } +export function getUserName(): string | undefined { + return getUserToken()?.name; +} + export function deleteUserToken() { cookies().delete('user'); }