Skip to content

Commit

Permalink
post items with username from cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikmonsen committed Sep 16, 2024
1 parent 49809fd commit a0aea07
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/models/CatalogMissingNewspaperDto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {newspaper} from '@prisma/client';
import {createCatalogDateString} from '@/utils/dateUtils';
import {getUserName} from '@/utils/cookieUtils';

export interface CatalogMissingNewspaperDto {
titleCatalogueId: string;
Expand All @@ -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 ?? ''
Expand Down
3 changes: 2 additions & 1 deletion src/models/CatalogNewspaperDto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {newspaper} from '@prisma/client';
import {createCatalogDateString} from '@/utils/dateUtils';
import {getUserName} from '@/utils/cookieUtils';

export interface CatalogNewspaperDto {
titleCatalogueId: string;
Expand All @@ -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 ?? '',
Expand Down
3 changes: 2 additions & 1 deletion src/models/CatalogNewspaperEditDto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {newspaper} from '@prisma/client';
import {getUserName} from '@/utils/cookieUtils';


export interface CatalogNewspaperEditDto {
Expand All @@ -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 ?? ''
Expand Down
4 changes: 4 additions & 0 deletions src/utils/cookieUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit a0aea07

Please sign in to comment.