deepsource-autofix-76c6eb20
Dan Gowans 2024-10-28 15:07:43 -04:00
parent e849f5989a
commit 80c60d1a4a
18 changed files with 66 additions and 74 deletions

View File

@ -20,7 +20,7 @@ export default async function addLot(lotForm, user) {
await addOrUpdateLotField({ await addOrUpdateLotField({
lotId, lotId,
lotTypeFieldId, lotTypeFieldId,
lotFieldValue lotFieldValue: lotFieldValue ?? ''
}, user, database); }, user, database);
} }
} }

View File

@ -53,14 +53,14 @@ export default async function addLot(
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',') const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',')
for (const lotTypeFieldId of lotTypeFieldIds) { for (const lotTypeFieldId of lotTypeFieldIds) {
const lotFieldValue = lotForm[`lotFieldValue_${lotTypeFieldId}`] as string const lotFieldValue = lotForm[`lotFieldValue_${lotTypeFieldId}`] as string | undefined
if ((lotFieldValue ?? '') !== '') { if ((lotFieldValue ?? '') !== '') {
await addOrUpdateLotField( await addOrUpdateLotField(
{ {
lotId, lotId,
lotTypeFieldId, lotTypeFieldId,
lotFieldValue lotFieldValue: lotFieldValue ?? ''
}, },
user, user,
database database

View File

@ -27,24 +27,24 @@ export default async function addLotOccupancy(lotOccupancyForm, user, connectedD
await addOrUpdateLotOccupancyField({ await addOrUpdateLotOccupancyField({
lotOccupancyId, lotOccupancyId,
occupancyTypeFieldId, occupancyTypeFieldId,
lotOccupancyFieldValue lotOccupancyFieldValue: lotOccupancyFieldValue ?? ''
}, user, database); }, user, database);
} }
} }
if ((lotOccupancyForm.lotOccupantTypeId ?? '') !== '') { if ((lotOccupancyForm.lotOccupantTypeId ?? '') !== '') {
await addLotOccupancyOccupant({ await addLotOccupancyOccupant({
lotOccupancyId, lotOccupancyId,
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId, lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId ?? '',
occupantName: lotOccupancyForm.occupantName, occupantName: lotOccupancyForm.occupantName ?? '',
occupantFamilyName: lotOccupancyForm.occupantFamilyName, occupantFamilyName: lotOccupancyForm.occupantFamilyName ?? '',
occupantAddress1: lotOccupancyForm.occupantAddress1, occupantAddress1: lotOccupancyForm.occupantAddress1 ?? '',
occupantAddress2: lotOccupancyForm.occupantAddress2, occupantAddress2: lotOccupancyForm.occupantAddress2 ?? '',
occupantCity: lotOccupancyForm.occupantCity, occupantCity: lotOccupancyForm.occupantCity ?? '',
occupantProvince: lotOccupancyForm.occupantProvince, occupantProvince: lotOccupancyForm.occupantProvince ?? '',
occupantPostalCode: lotOccupancyForm.occupantPostalCode, occupantPostalCode: lotOccupancyForm.occupantPostalCode ?? '',
occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber, occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber ?? '',
occupantEmailAddress: lotOccupancyForm.occupantEmailAddress, occupantEmailAddress: lotOccupancyForm.occupantEmailAddress ?? '',
occupantComment: lotOccupancyForm.occupantComment occupantComment: lotOccupancyForm.occupantComment ?? ''
}, user, database); }, user, database);
} }
if (connectedDatabase === undefined) { if (connectedDatabase === undefined) {

View File

@ -78,14 +78,14 @@ export default async function addLotOccupancy(
for (const occupancyTypeFieldId of occupancyTypeFieldIds) { for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
const lotOccupancyFieldValue = lotOccupancyForm[ const lotOccupancyFieldValue = lotOccupancyForm[
`lotOccupancyFieldValue_${occupancyTypeFieldId}` `lotOccupancyFieldValue_${occupancyTypeFieldId}`
] as string ] as string | undefined
if ((lotOccupancyFieldValue ?? '') !== '') { if ((lotOccupancyFieldValue ?? '') !== '') {
await addOrUpdateLotOccupancyField( await addOrUpdateLotOccupancyField(
{ {
lotOccupancyId, lotOccupancyId,
occupancyTypeFieldId, occupancyTypeFieldId,
lotOccupancyFieldValue lotOccupancyFieldValue: lotOccupancyFieldValue ?? ''
}, },
user, user,
database database
@ -97,17 +97,17 @@ export default async function addLotOccupancy(
await addLotOccupancyOccupant( await addLotOccupancyOccupant(
{ {
lotOccupancyId, lotOccupancyId,
lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId!, lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId ?? '',
occupantName: lotOccupancyForm.occupantName!, occupantName: lotOccupancyForm.occupantName ?? '',
occupantFamilyName: lotOccupancyForm.occupantFamilyName!, occupantFamilyName: lotOccupancyForm.occupantFamilyName ?? '',
occupantAddress1: lotOccupancyForm.occupantAddress1!, occupantAddress1: lotOccupancyForm.occupantAddress1 ?? '',
occupantAddress2: lotOccupancyForm.occupantAddress2!, occupantAddress2: lotOccupancyForm.occupantAddress2 ?? '',
occupantCity: lotOccupancyForm.occupantCity!, occupantCity: lotOccupancyForm.occupantCity ?? '',
occupantProvince: lotOccupancyForm.occupantProvince!, occupantProvince: lotOccupancyForm.occupantProvince ?? '',
occupantPostalCode: lotOccupancyForm.occupantPostalCode!, occupantPostalCode: lotOccupancyForm.occupantPostalCode ?? '',
occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber!, occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber ?? '',
occupantEmailAddress: lotOccupancyForm.occupantEmailAddress!, occupantEmailAddress: lotOccupancyForm.occupantEmailAddress ?? '',
occupantComment: lotOccupancyForm.occupantComment! occupantComment: lotOccupancyForm.occupantComment ?? ''
}, },
user, user,
database database

View File

@ -1,4 +1,4 @@
import { type PoolConnection } from 'better-sqlite-pool'; import type { PoolConnection } from 'better-sqlite-pool';
export interface AddLotOccupancyFeeForm { export interface AddLotOccupancyFeeForm {
lotOccupancyId: number | string; lotOccupancyId: number | string;
feeId: number | string; feeId: number | string;

View File

@ -32,8 +32,8 @@ export default async function addLotOccupancyFee(lotOccupancyFeeForm, user, conn
where lotOccupancyId = ? where lotOccupancyId = ?
and feeId = ?`) and feeId = ?`)
.get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId); .get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId);
if (record) { if (record !== undefined) {
if (record.recordDelete_timeMillis) { if (record.recordDelete_timeMillis !== null) {
database database
.prepare(`delete from LotOccupancyFees .prepare(`delete from LotOccupancyFees
where recordDelete_timeMillis is not null where recordDelete_timeMillis is not null

View File

@ -1,4 +1,4 @@
import { type PoolConnection } from 'better-sqlite-pool' import type { PoolConnection } from 'better-sqlite-pool'
import { import {
calculateFeeAmount, calculateFeeAmount,
@ -60,14 +60,16 @@ export default async function addLotOccupancyFee(
where lotOccupancyId = ? where lotOccupancyId = ?
and feeId = ?` and feeId = ?`
) )
.get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId) as { .get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId) as
feeAmount?: number | {
taxAmount?: number feeAmount: number | null
recordDelete_timeMillis?: number taxAmount: number | null
} recordDelete_timeMillis: number | null
}
| undefined
if (record) { if (record !== undefined) {
if (record.recordDelete_timeMillis) { if (record.recordDelete_timeMillis !== null) {
database database
.prepare( .prepare(
`delete from LotOccupancyFees `delete from LotOccupancyFees

8
package-lock.json generated
View File

@ -80,7 +80,7 @@
"bulma-tooltip": "^3.0.2", "bulma-tooltip": "^3.0.2",
"cypress": "^13.15.1", "cypress": "^13.15.1",
"cypress-axe": "^1.5.0", "cypress-axe": "^1.5.0",
"eslint-config-cityssm": "^14.0.1", "eslint-config-cityssm": "^14.0.2",
"gulp": "^5.0.0", "gulp": "^5.0.0",
"gulp-sass": "^5.1.0", "gulp-sass": "^5.1.0",
"nodemon": "^3.1.7", "nodemon": "^3.1.7",
@ -8120,9 +8120,9 @@
} }
}, },
"node_modules/eslint-config-cityssm": { "node_modules/eslint-config-cityssm": {
"version": "14.0.1", "version": "14.0.2",
"resolved": "https://registry.npmjs.org/eslint-config-cityssm/-/eslint-config-cityssm-14.0.1.tgz", "resolved": "https://registry.npmjs.org/eslint-config-cityssm/-/eslint-config-cityssm-14.0.2.tgz",
"integrity": "sha512-pmqsNjS0cxznslzhZeihz1iGSOe/4LgJZdJzi7D8R3KE3N6dDSxiIay0T+q2u8BgmZJJwmmvrL6Qlk0924mNyA==", "integrity": "sha512-eCQHo5VoJGXvuhSYaJ6erZ7NS/KwDP+D9pkB0GtJMdk8NNBuN0NJyvJojJJwdwYTVFzG+Jhcc9LJvd05mpoufA==",
"dev": true, "dev": true,
"license": "Unlicense", "license": "Unlicense",
"dependencies": { "dependencies": {

View File

@ -104,7 +104,7 @@
"bulma-tooltip": "^3.0.2", "bulma-tooltip": "^3.0.2",
"cypress": "^13.15.1", "cypress": "^13.15.1",
"cypress-axe": "^1.5.0", "cypress-axe": "^1.5.0",
"eslint-config-cityssm": "^14.0.1", "eslint-config-cityssm": "^14.0.2",
"gulp": "^5.0.0", "gulp": "^5.0.0",
"gulp-sass": "^5.1.0", "gulp-sass": "^5.1.0",
"nodemon": "^3.1.7", "nodemon": "^3.1.7",

View File

@ -1,5 +1,4 @@
"use strict"; "use strict";
/* @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
const los = exports.los; const los = exports.los;

View File

@ -1,5 +1,3 @@
/* @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
import type { BulmaJS } from '@cityssm/bulma-js/types.js' import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
@ -24,7 +22,7 @@ declare const exports: Record<string, unknown>
} }
| { | {
success: false success: false
errorMessage: string errorMessage?: string
} }
if (responseJSON.success) { if (responseJSON.success) {
@ -59,7 +57,7 @@ declare const exports: Record<string, unknown>
} }
| { | {
success: false success: false
errorMessage: string errorMessage?: string
} }
if (responseJSON.success) { if (responseJSON.success) {

View File

@ -1,6 +1,4 @@
"use strict"; "use strict";
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
const los = exports.los; const los = exports.los;
@ -8,14 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
let feeCategories = exports.feeCategories; let feeCategories = exports.feeCategories;
delete exports.feeCategories; delete exports.feeCategories;
function getFeeCategory(feeCategoryId) { function getFeeCategory(feeCategoryId) {
return feeCategories.find((currentFeeCategory) => { return feeCategories.find((currentFeeCategory) => currentFeeCategory.feeCategoryId === feeCategoryId);
return currentFeeCategory.feeCategoryId === feeCategoryId;
});
} }
function getFee(feeCategory, feeId) { function getFee(feeCategory, feeId) {
return feeCategory.fees.find((currentFee) => { return feeCategory.fees.find((currentFee) => currentFee.feeId === feeId);
return currentFee.feeId === feeId;
});
} }
function renderFeeCategories() { function renderFeeCategories() {
if (feeCategories.length === 0) { if (feeCategories.length === 0) {
@ -551,8 +545,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
} }
function toggleQuantityFields() { function toggleQuantityFields() {
const includeQuanitityValue = editModalElement.querySelector('#feeEdit--includeQuantity').value; const includeQuantityValue = editModalElement.querySelector('#feeEdit--includeQuantity').value;
editModalElement.querySelector('#feeEdit--quantityUnit').disabled = includeQuanitityValue === ''; editModalElement.querySelector('#feeEdit--quantityUnit').disabled = includeQuantityValue === '';
} }
cityssm.openHtmlModal('adminFees-editFee', { cityssm.openHtmlModal('adminFees-editFee', {
onshow(modalElement) { onshow(modalElement) {

View File

@ -1,6 +1,3 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */
import type { BulmaJS } from '@cityssm/bulma-js/types.js' import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
@ -33,19 +30,19 @@ declare const exports: Record<string, unknown>
} }
| { | {
success: false success: false
errorMessage: string errorMessage?: string
} }
function getFeeCategory(feeCategoryId: number): FeeCategory { function getFeeCategory(feeCategoryId: number): FeeCategory {
return feeCategories.find((currentFeeCategory) => { return feeCategories.find(
return currentFeeCategory.feeCategoryId === feeCategoryId (currentFeeCategory) => currentFeeCategory.feeCategoryId === feeCategoryId
}) as FeeCategory ) as FeeCategory
} }
function getFee(feeCategory: FeeCategory, feeId: number): Fee { function getFee(feeCategory: FeeCategory, feeId: number): Fee {
return feeCategory.fees.find((currentFee) => { return feeCategory.fees.find(
return currentFee.feeId === feeId (currentFee) => currentFee.feeId === feeId
}) as Fee ) as Fee
} }
function renderFeeCategories(): void { function renderFeeCategories(): void {
@ -861,7 +858,7 @@ declare const exports: Record<string, unknown>
} }
function toggleQuantityFields(): void { function toggleQuantityFields(): void {
const includeQuanitityValue = ( const includeQuantityValue = (
editModalElement.querySelector( editModalElement.querySelector(
'#feeEdit--includeQuantity' '#feeEdit--includeQuantity'
) as HTMLSelectElement ) as HTMLSelectElement
@ -871,7 +868,7 @@ declare const exports: Record<string, unknown>
editModalElement.querySelector( editModalElement.querySelector(
'#feeEdit--quantityUnit' '#feeEdit--quantityUnit'
) as HTMLInputElement ) as HTMLInputElement
).disabled = includeQuanitityValue === '' ).disabled = includeQuantityValue === ''
} }
cityssm.openHtmlModal('adminFees-editFee', { cityssm.openHtmlModal('adminFees-editFee', {

View File

@ -17,7 +17,7 @@ type ResponseJSON =
} }
| { | {
success: false success: false
errorMessage: string errorMessage?: string
} }
;(() => { ;(() => {
const los = exports.los as LOS const los = exports.los as LOS

View File

@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
}, (rawResponseJSON) => { }, (rawResponseJSON) => {
const responseJSON = rawResponseJSON; const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
window.location.href = los.getWorkOrderURL(workOrderId, true, true); globalThis.location.href = los.getWorkOrderURL(workOrderId, true, true);
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({

View File

@ -30,7 +30,7 @@ declare const exports: Record<string, unknown>
} }
if (responseJSON.success) { if (responseJSON.success) {
window.location.href = los.getWorkOrderURL( globalThis.location.href = los.getWorkOrderURL(
workOrderId, workOrderId,
true, true,
true true

View File

@ -8,6 +8,7 @@ describe('Initialize Database', () => {
if (!useTestDatabases) { if (!useTestDatabases) {
assert.fail('Test database must be used!'); assert.fail('Test database must be used!');
} }
// eslint-disable-next-line security/detect-non-literal-fs-filename
await fs.unlink(databasePath); await fs.unlink(databasePath);
const success = await initializeCemeteryDatabase(); const success = await initializeCemeteryDatabase();
assert.ok(success); assert.ok(success);

View File

@ -15,6 +15,7 @@ describe('Initialize Database', () => {
assert.fail('Test database must be used!') assert.fail('Test database must be used!')
} }
// eslint-disable-next-line security/detect-non-literal-fs-filename
await fs.unlink(databasePath) await fs.unlink(databasePath)
const success = await initializeCemeteryDatabase() const success = await initializeCemeteryDatabase()