This commit is contained in:
seb
2026-07-31 05:57:23 +02:00
parent b99c3a9ec7
commit 02bca8e236
14 changed files with 93 additions and 132 deletions

View File

@@ -19,11 +19,10 @@ import taxGetByRate from './store/tax/getByRate.js';
import taxEnsure from './store/tax/ensure.js';
import taxList from './store/tax/list.js';
import googleAuthAdd from './store/google_auth/add.js';
import googleAuthGetById from './store/google_auth/getById.js';
import googleAuthGetByEmail from './store/google_auth/getByEmail.js';
import googleAuthListAllowedEmails from './store/google_auth/listAllowedEmails.js';
import googleAuthRemoveAllowedEmail from './store/google_auth/removeAllowedEmail.js';
import googleAuthSetSelectedCompany from './store/google_auth/setSelectedCompany.js';
import googleAuthList from './store/google_auth/list.js';
import googleAuthDel from './store/google_auth/del.js';
import storePurge from './store/purge.js';
import storeInitialize from './store/initialize.js';
@@ -68,11 +67,10 @@ export default class LibDashStore {
this.google_auth = {
add: googleAuthAdd(pool),
getById: googleAuthGetById(pool),
getByEmail: googleAuthGetByEmail(pool),
listAllowedEmails: googleAuthListAllowedEmails(pool),
removeAllowedEmail: googleAuthRemoveAllowedEmail(pool),
setSelectedCompany: googleAuthSetSelectedCompany(pool),
list: googleAuthList(pool),
del: googleAuthDel(pool),
};
this.purge = storePurge(pool);

View File

@@ -10,7 +10,7 @@ WITH tree AS (
FROM category c
INNER JOIN tree t ON c.parent_id = t.id
)
SELECT id, parent_id, sort
SELECT id, parent_id AS parentId, sort
FROM tree
ORDER BY sort, id
`;

View File

@@ -43,11 +43,11 @@ WHERE id = @id
export const LIST = `
SELECT
id,
root_category_id,
default_language_id AS language_id,
taxrate AS taxrate_id,
reducedtaxrate AS reducedtaxrate_id,
taxfreerate AS taxfreerate_id
root_category_id AS rootCategoryId,
default_language_id AS languageId,
taxrate AS taxrateId,
reducedtaxrate AS reducedtaxrateId,
taxfreerate AS taxfreerateId
FROM company
`;

View File

@@ -4,27 +4,21 @@ OUTPUT INSERTED.id
VALUES (@email)
`;
export const GET_BY_ID = `
SELECT id, email, created_at, selected_company
FROM google_auth
WHERE id = @id
`;
export const GET_BY_EMAIL = `
SELECT id, email, created_at, selected_company
SELECT id, email, created_at AS createdAt, selected_company AS selectedCompanyId
FROM google_auth
WHERE email = @email
`;
export const LIST = `
SELECT id, email, created_at, selected_company
export const LIST_ALLOWED_EMAILS = `
SELECT id, email, created_at AS createdAt, selected_company AS selectedCompanyId
FROM google_auth
ORDER BY id
ORDER BY email
`;
export const DEL = `
export const REMOVE_ALLOWED_EMAIL = `
DELETE FROM google_auth
WHERE id = @id
WHERE email = @email
`;
export const SET_SELECTED_COMPANY = `

View File

@@ -2,10 +2,10 @@ import sql from 'mssql';
import { CREATE } from '../../sql/category.js';
export default function create(pool) {
return async ({ parent_id, sort }) => {
return async ({ parentId, sort }) => {
const result = await pool
.request()
.input('parentId', sql.Int, parent_id)
.input('parentId', sql.Int, parentId)
.input('sort', sql.Int, sort)
.query(CREATE);

View File

@@ -46,11 +46,11 @@ export default function create(pool) {
return {
id: result.recordset[0].id,
root_category_id: rootCategoryId,
language_id: languageId,
taxrate_id: taxrateId,
reducedtaxrate_id: reducedtaxrateId,
taxfreerate_id: taxfreerateId,
rootCategoryId,
languageId,
taxrateId,
reducedtaxrateId,
taxfreerateId,
};
} catch (err) {
try {

View File

@@ -45,11 +45,11 @@ export default function update(pool) {
return {
id,
root_category_id: company.root_category_id,
language_id: languageId,
taxrate_id: taxrateId,
reducedtaxrate_id: reducedtaxrateId,
taxfreerate_id: company.taxfreerate,
rootCategoryId: company.root_category_id,
languageId,
taxrateId,
reducedtaxrateId,
taxfreerateId: company.taxfreerate,
};
} catch (err) {
try {

View File

@@ -1,11 +0,0 @@
import sql from 'mssql';
import { DEL } from '../../sql/google_auth.js';
export default function del(pool) {
return async (id) => {
await pool
.request()
.input('id', sql.Int, id)
.query(DEL);
};
}

View File

@@ -1,13 +0,0 @@
import sql from 'mssql';
import { GET_BY_ID } from '../../sql/google_auth.js';
export default function getById(pool) {
return async (id) => {
const result = await pool
.request()
.input('id', sql.Int, id)
.query(GET_BY_ID);
return result.recordset[0];
};
}

View File

@@ -1,8 +0,0 @@
import { LIST } from '../../sql/google_auth.js';
export default function list(pool) {
return async () => {
const result = await pool.request().query(LIST);
return result.recordset;
};
}

View File

@@ -0,0 +1,8 @@
import { LIST_ALLOWED_EMAILS } from '../../sql/google_auth.js';
export default function listAllowedEmails(pool) {
return async () => {
const result = await pool.request().query(LIST_ALLOWED_EMAILS);
return result.recordset;
};
}

View File

@@ -0,0 +1,11 @@
import sql from 'mssql';
import { REMOVE_ALLOWED_EMAIL } from '../../sql/google_auth.js';
export default function removeAllowedEmail(pool) {
return async (email) => {
await pool
.request()
.input('email', sql.NVarChar(320), email)
.query(REMOVE_ALLOWED_EMAIL);
};
}