linting
parent
a8981e8154
commit
4f683e7432
|
|
@ -1,3 +1,3 @@
|
|||
import type { Request, Response } from 'express';
|
||||
export declare function handler(request: Request, response: Response, next: any): Promise<void>;
|
||||
import type { Request, Response, NextFunction } from 'express';
|
||||
export declare function handler(request: Request, response: Response, next: NextFunction): Promise<void>;
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export async function handler(request, response, next) {
|
|||
return;
|
||||
}
|
||||
const printConfig = getPdfPrintConfig(printName);
|
||||
if (!printConfig) {
|
||||
if (printConfig === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/dashboard/?error=printConfigNotFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Request, Response } from 'express'
|
||||
import type { Request, Response, NextFunction } from 'express'
|
||||
|
||||
import path from 'node:path'
|
||||
import * as ejs from 'ejs'
|
||||
|
|
@ -22,7 +22,7 @@ const attachmentOrInline = configFunctions.getProperty(
|
|||
export async function handler(
|
||||
request: Request,
|
||||
response: Response,
|
||||
next
|
||||
next: NextFunction
|
||||
): Promise<void> {
|
||||
const printName = request.params.printName
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ export async function handler(
|
|||
|
||||
const printConfig = getPdfPrintConfig(printName)
|
||||
|
||||
if (!printConfig) {
|
||||
if (printConfig === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/dashboard/?error=printConfigNotFound'
|
||||
|
|
@ -58,7 +58,7 @@ export async function handler(
|
|||
function pdfCallbackFunction(pdf: Buffer): void {
|
||||
response.setHeader(
|
||||
'Content-Disposition',
|
||||
`${attachmentOrInline}; filename=${camelcase(printConfig.title)}.pdf`
|
||||
`${attachmentOrInline}; filename=${camelcase(printConfig!.title)}.pdf`
|
||||
)
|
||||
|
||||
response.setHeader('Content-Type', 'application/pdf')
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export async function handler(request, response) {
|
|||
return;
|
||||
}
|
||||
const printConfig = getScreenPrintConfig(printName);
|
||||
if (!printConfig) {
|
||||
if (printConfig === undefined) {
|
||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/dashboard/?error=printConfigNotFound');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export async function handler(
|
|||
|
||||
const printConfig = getScreenPrintConfig(printName)
|
||||
|
||||
if (!printConfig) {
|
||||
if (printConfig === undefined) {
|
||||
response.redirect(
|
||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||
'/dashboard/?error=printConfigNotFound'
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export async function handler(request, response) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!rows) {
|
||||
if (rows === undefined) {
|
||||
response.status(404).json({
|
||||
success: false,
|
||||
message: 'Report Not Found'
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export async function handler(
|
|||
}
|
||||
}
|
||||
|
||||
if (!rows) {
|
||||
if (rows === undefined) {
|
||||
response.status(404).json({
|
||||
success: false,
|
||||
message: 'Report Not Found'
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ interface PrintConfig {
|
|||
title: string;
|
||||
params: string[];
|
||||
}
|
||||
export declare function getScreenPrintConfig(printName: string): PrintConfig;
|
||||
export declare function getPdfPrintConfig(printName: string): PrintConfig;
|
||||
export declare function getScreenPrintConfig(printName: string): PrintConfig | undefined;
|
||||
export declare function getPdfPrintConfig(printName: string): PrintConfig | undefined;
|
||||
export declare function getPrintConfig(screenOrPdfPrintName: string): PrintConfig | undefined;
|
||||
export declare function getReportData(printConfig: PrintConfig, requestQuery: Record<string, unknown>): Promise<Record<string, unknown>>;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const screenPrintConfigs: Record<string, PrintConfig> = {
|
|||
}
|
||||
}
|
||||
|
||||
export function getScreenPrintConfig(printName: string): PrintConfig {
|
||||
export function getScreenPrintConfig(printName: string): PrintConfig | undefined {
|
||||
return screenPrintConfigs[printName]
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ const pdfPrintConfigs: Record<string, PrintConfig> = {
|
|||
}
|
||||
}
|
||||
|
||||
export function getPdfPrintConfig(printName: string): PrintConfig {
|
||||
export function getPdfPrintConfig(printName: string): PrintConfig | undefined {
|
||||
return pdfPrintConfigs[printName]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,18 @@
|
|||
import { getUserNameFromApiKey } from './functions.api.js';
|
||||
import * as configFunctions from './functions.config.js';
|
||||
export function userIsAdmin(request) {
|
||||
const user = request.session?.user;
|
||||
if (!user?.userProperties) {
|
||||
return false;
|
||||
}
|
||||
return user.userProperties.isAdmin;
|
||||
return request.session?.user?.userProperties?.isAdmin ?? false;
|
||||
}
|
||||
export function userCanUpdate(request) {
|
||||
const user = request.session?.user;
|
||||
if (!user?.userProperties) {
|
||||
return false;
|
||||
}
|
||||
return user.userProperties.canUpdate;
|
||||
return request.session?.user?.userProperties?.canUpdate ?? false;
|
||||
}
|
||||
export async function apiKeyIsValid(request) {
|
||||
const apiKey = request.params?.apiKey;
|
||||
if (!apiKey) {
|
||||
if (apiKey === undefined) {
|
||||
return false;
|
||||
}
|
||||
const userName = await getUserNameFromApiKey(apiKey);
|
||||
if (!userName) {
|
||||
if (userName === undefined) {
|
||||
return false;
|
||||
}
|
||||
const canLogin = configFunctions
|
||||
|
|
|
|||
|
|
@ -16,35 +16,23 @@ export interface APIRequest {
|
|||
}
|
||||
|
||||
export function userIsAdmin(request: UserRequest): boolean {
|
||||
const user = request.session?.user
|
||||
|
||||
if (!user?.userProperties) {
|
||||
return false
|
||||
}
|
||||
|
||||
return user.userProperties.isAdmin
|
||||
return request.session?.user?.userProperties?.isAdmin ?? false
|
||||
}
|
||||
|
||||
export function userCanUpdate(request: UserRequest): boolean {
|
||||
const user = request.session?.user
|
||||
|
||||
if (!user?.userProperties) {
|
||||
return false
|
||||
}
|
||||
|
||||
return user.userProperties.canUpdate
|
||||
return request.session?.user?.userProperties?.canUpdate ?? false
|
||||
}
|
||||
|
||||
export async function apiKeyIsValid(request: APIRequest): Promise<boolean> {
|
||||
const apiKey = request.params?.apiKey
|
||||
|
||||
if (!apiKey) {
|
||||
if (apiKey === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
const userName = await getUserNameFromApiKey(apiKey)
|
||||
|
||||
if (!userName) {
|
||||
if (userName === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ type RecordTable =
|
|||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordIdColumns: Map<RecordTable, string> = new Map()
|
||||
const recordIdColumns = new Map<RecordTable, string>()
|
||||
recordIdColumns.set('FeeCategories', 'feeCategoryId')
|
||||
recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId')
|
||||
recordIdColumns.set('LotStatuses', 'lotStatusId')
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ export async function updateLot(lotForm, requestSession) {
|
|||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',');
|
||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId];
|
||||
await (lotFieldValue && lotFieldValue !== ''
|
||||
? addOrUpdateLotField({
|
||||
await ((lotFieldValue ?? '') === ''
|
||||
? deleteLotField(lotForm.lotId, lotTypeFieldId, requestSession, database)
|
||||
: addOrUpdateLotField({
|
||||
lotId: lotForm.lotId,
|
||||
lotTypeFieldId,
|
||||
lotFieldValue
|
||||
}, requestSession, database)
|
||||
: deleteLotField(lotForm.lotId, lotTypeFieldId, requestSession, database));
|
||||
lotFieldValue: lotFieldValue
|
||||
}, requestSession, database));
|
||||
}
|
||||
}
|
||||
database.release();
|
||||
|
|
|
|||
|
|
@ -62,21 +62,23 @@ export async function updateLot(
|
|||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',')
|
||||
|
||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as string
|
||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as
|
||||
| string
|
||||
| undefined
|
||||
|
||||
await (lotFieldValue && lotFieldValue !== ''
|
||||
? addOrUpdateLotField(
|
||||
{
|
||||
lotId: lotForm.lotId,
|
||||
await ((lotFieldValue ?? '') === ''
|
||||
? deleteLotField(
|
||||
lotForm.lotId,
|
||||
lotTypeFieldId,
|
||||
lotFieldValue
|
||||
},
|
||||
requestSession,
|
||||
database
|
||||
)
|
||||
: deleteLotField(
|
||||
lotForm.lotId,
|
||||
: addOrUpdateLotField(
|
||||
{
|
||||
lotId: lotForm.lotId,
|
||||
lotTypeFieldId,
|
||||
lotFieldValue: lotFieldValue!
|
||||
},
|
||||
requestSession,
|
||||
database
|
||||
))
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ export async function updateLotOccupancy(lotOccupancyForm, requestSession) {
|
|||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||
const lotOccupancyFieldValue = lotOccupancyForm['lotOccupancyFieldValue_' + occupancyTypeFieldId];
|
||||
await (lotOccupancyFieldValue && lotOccupancyFieldValue !== ''
|
||||
? addOrUpdateLotOccupancyField({
|
||||
await ((lotOccupancyFieldValue ?? '') === ''
|
||||
? deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId, occupancyTypeFieldId, requestSession, database)
|
||||
: addOrUpdateLotOccupancyField({
|
||||
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
lotOccupancyFieldValue
|
||||
}, requestSession, database)
|
||||
: deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId, occupancyTypeFieldId, requestSession, database));
|
||||
}, requestSession, database));
|
||||
}
|
||||
}
|
||||
database.release();
|
||||
|
|
|
|||
|
|
@ -64,8 +64,14 @@ export async function updateLotOccupancy(
|
|||
'lotOccupancyFieldValue_' + occupancyTypeFieldId
|
||||
] as string
|
||||
|
||||
await (lotOccupancyFieldValue && lotOccupancyFieldValue !== ''
|
||||
? addOrUpdateLotOccupancyField(
|
||||
await ((lotOccupancyFieldValue ?? '') === ''
|
||||
? deleteLotOccupancyField(
|
||||
lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
requestSession,
|
||||
database
|
||||
)
|
||||
: addOrUpdateLotOccupancyField(
|
||||
{
|
||||
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
|
|
@ -73,12 +79,6 @@ export async function updateLotOccupancy(
|
|||
},
|
||||
requestSession,
|
||||
database
|
||||
)
|
||||
: deleteLotOccupancyField(
|
||||
lotOccupancyForm.lotOccupancyId,
|
||||
occupancyTypeFieldId,
|
||||
requestSession,
|
||||
database
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ type RecordTable =
|
|||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordNameIdColumns: Map<RecordTable, string[]> = new Map()
|
||||
const recordNameIdColumns = new Map<RecordTable, string[]>()
|
||||
recordNameIdColumns.set('FeeCategories', ['feeCategory', 'feeCategoryId'])
|
||||
recordNameIdColumns.set('LotStatuses', ['lotStatus', 'lotStatusId'])
|
||||
recordNameIdColumns.set('LotTypes', ['lotType', 'lotTypeId'])
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ type RecordTable =
|
|||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordIdColumns: Map<RecordTable, string> = new Map()
|
||||
const recordIdColumns = new Map<RecordTable, string>()
|
||||
recordIdColumns.set('FeeCategories', 'feeCategoryId')
|
||||
recordIdColumns.set('Fees', 'feeId')
|
||||
recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId')
|
||||
|
|
|
|||
Loading…
Reference in New Issue