Link articlehistory to companyuser; store Google picture and sub on google_auth

This commit is contained in:
seb
2026-08-05 10:57:50 +02:00
parent 46c85fe29e
commit d1eb2716ae
12 changed files with 1284 additions and 1191 deletions

View File

@@ -14,6 +14,7 @@ export default function getHistoryBySku(pool) {
return result.recordset.map((row) => ({
id: row.id,
companyuserId: row.companyuserId ?? null,
date: row.date,
text: row.text,
}));

View File

@@ -26,6 +26,7 @@ export default function resolveArticleBySku(pool) {
companyId: row.companyId,
rootCategoryId: row.rootCategoryId,
posCustomerGroupId: row.posCustomerGroupId ?? null,
companyuserId: row.companyuserId,
};
};
}

View File

@@ -41,7 +41,10 @@ export default function updateBySku(pool) {
throw new Error('Invalid unitamount');
}
const { articleId, languageId, companyId } = await resolve(googleAuthId, sku);
const { articleId, languageId, companyId, companyuserId } = await resolve(
googleAuthId,
sku,
);
const currentResult = await pool
.request()
@@ -134,6 +137,7 @@ export default function updateBySku(pool) {
if (historyLines.length) {
await request(pool, tx)
.input('articleId', articleId)
.input('companyuserId', companyuserId)
.input('text', historyLines.join('\n'))
.query(INSERT_HISTORY);
}

View File

@@ -0,0 +1,16 @@
import { SET_PROFILE } from '../../sql/google_auth.js';
export default function setProfile(pool) {
return async (googleAuthId, { picture = null, sub = null } = {}) => {
const result = await pool
.request()
.input('googleAuthId', googleAuthId)
.input('picture', picture)
.input('sub', sub)
.query(SET_PROFILE);
if (!result.rowsAffected[0]) {
throw new Error('User not found');
}
};
}