more linting and cleanup
parent
55ffb3118d
commit
302875ee57
|
|
@ -17,7 +17,7 @@ import type * as recordTypes from "../types/recordTypes";
|
|||
* Lot Occupant Types
|
||||
*/
|
||||
|
||||
let lotOccupantTypes: recordTypes.LotOccupantType[];
|
||||
let lotOccupantTypes: recordTypes.LotOccupantType[] | undefined;
|
||||
|
||||
export function getLotOccupantTypes() {
|
||||
if (!lotOccupantTypes) {
|
||||
|
|
@ -53,7 +53,7 @@ export function clearLotOccupantTypesCache() {
|
|||
* Lot Statuses
|
||||
*/
|
||||
|
||||
let lotStatuses: recordTypes.LotStatus[];
|
||||
let lotStatuses: recordTypes.LotStatus[] | undefined;
|
||||
|
||||
export function getLotStatuses() {
|
||||
if (!lotStatuses) {
|
||||
|
|
@ -89,7 +89,7 @@ export function clearLotStatusesCache() {
|
|||
* Lot Types
|
||||
*/
|
||||
|
||||
let lotTypes: recordTypes.LotType[];
|
||||
let lotTypes: recordTypes.LotType[] | undefined;
|
||||
|
||||
export function getLotTypes() {
|
||||
if (!lotTypes) {
|
||||
|
|
@ -125,8 +125,8 @@ export function clearLotTypesCache() {
|
|||
* Occupancy Types
|
||||
*/
|
||||
|
||||
let occupancyTypes: recordTypes.OccupancyType[];
|
||||
let allOccupancyTypeFields: recordTypes.OccupancyTypeField[];
|
||||
let occupancyTypes: recordTypes.OccupancyType[] | undefined;
|
||||
let allOccupancyTypeFields: recordTypes.OccupancyTypeField[] | undefined;
|
||||
|
||||
export function getOccupancyTypes() {
|
||||
if (!occupancyTypes) {
|
||||
|
|
@ -170,7 +170,7 @@ export function clearOccupancyTypesCache() {
|
|||
* Work Order Types
|
||||
*/
|
||||
|
||||
let workOrderTypes: recordTypes.WorkOrderType[];
|
||||
let workOrderTypes: recordTypes.WorkOrderType[] | undefined;
|
||||
|
||||
export function getWorkOrderTypes() {
|
||||
if (!workOrderTypes) {
|
||||
|
|
@ -188,7 +188,7 @@ export function clearWorkOrderTypesCache() {
|
|||
* Work Order Milestone Types
|
||||
*/
|
||||
|
||||
let workOrderMilestoneTypes: recordTypes.WorkOrderMilestoneType[];
|
||||
let workOrderMilestoneTypes: recordTypes.WorkOrderMilestoneType[] | undefined;
|
||||
|
||||
export function getWorkOrderMilestoneTypes() {
|
||||
if (!workOrderMilestoneTypes) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type * as recordTypes from "../types/recordTypes";
|
||||
export declare const filterOccupantsByLotOccupantType: (lotOccupancy: recordTypes.LotOccupancy, lotOccupantType: string) => recordTypes.LotOccupancyOccupant[];
|
||||
export declare const getFieldValueByOccupancyTypeField: (lotOccupancy: recordTypes.LotOccupancy, occupancyTypeField: string) => string;
|
||||
export declare const getFieldValueByOccupancyTypeField: (lotOccupancy: recordTypes.LotOccupancy, occupancyTypeField: string) => string | undefined;
|
||||
export declare const getFeesByFeeCategory: (lotOccupancy: recordTypes.LotOccupancy, feeCategory: string, feeCategoryContains?: boolean) => recordTypes.LotOccupancyFee[];
|
||||
export declare const getTransactionTotal: (lotOccupancy: recordTypes.LotOccupancy) => number;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
export const filterOccupantsByLotOccupantType = (lotOccupancy, lotOccupantType) => {
|
||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
||||
const occupants = lotOccupancy.lotOccupancyOccupants.filter((possibleOccupant) => {
|
||||
return possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
|
||||
const occupants = (lotOccupancy.lotOccupancyOccupants || []).filter((possibleOccupant) => {
|
||||
return (possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase);
|
||||
});
|
||||
return occupants;
|
||||
};
|
||||
export const getFieldValueByOccupancyTypeField = (lotOccupancy, occupancyTypeField) => {
|
||||
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
|
||||
const field = lotOccupancy.lotOccupancyFields.find((possibleField) => {
|
||||
const field = (lotOccupancy.lotOccupancyFields || []).find((possibleField) => {
|
||||
return possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase;
|
||||
});
|
||||
if (field) {
|
||||
|
|
@ -17,7 +17,7 @@ export const getFieldValueByOccupancyTypeField = (lotOccupancy, occupancyTypeFie
|
|||
};
|
||||
export const getFeesByFeeCategory = (lotOccupancy, feeCategory, feeCategoryContains = false) => {
|
||||
const feeCategoryLowerCase = feeCategory.toLowerCase();
|
||||
const fees = lotOccupancy.lotOccupancyFees.filter((possibleFee) => {
|
||||
const fees = (lotOccupancy.lotOccupancyFees || []).filter((possibleFee) => {
|
||||
return feeCategoryContains
|
||||
? possibleFee.feeCategory.toLowerCase().includes(feeCategoryLowerCase)
|
||||
: possibleFee.feeCategory.toLowerCase() === feeCategoryLowerCase;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ export const filterOccupantsByLotOccupantType = (
|
|||
): recordTypes.LotOccupancyOccupant[] => {
|
||||
const lotOccupantTypeLowerCase = lotOccupantType.toLowerCase();
|
||||
|
||||
const occupants = lotOccupancy.lotOccupancyOccupants.filter((possibleOccupant) => {
|
||||
return possibleOccupant.lotOccupantType.toLowerCase() === lotOccupantTypeLowerCase;
|
||||
const occupants = (lotOccupancy.lotOccupancyOccupants || []).filter((possibleOccupant) => {
|
||||
return (
|
||||
(possibleOccupant.lotOccupantType as string).toLowerCase() === lotOccupantTypeLowerCase
|
||||
);
|
||||
});
|
||||
|
||||
return occupants;
|
||||
|
|
@ -16,11 +18,11 @@ export const filterOccupantsByLotOccupantType = (
|
|||
export const getFieldValueByOccupancyTypeField = (
|
||||
lotOccupancy: recordTypes.LotOccupancy,
|
||||
occupancyTypeField: string
|
||||
): string => {
|
||||
): string | undefined => {
|
||||
const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase();
|
||||
|
||||
const field = lotOccupancy.lotOccupancyFields.find((possibleField) => {
|
||||
return possibleField.occupancyTypeField.toLowerCase() === occupancyTypeFieldLowerCase;
|
||||
const field = (lotOccupancy.lotOccupancyFields || []).find((possibleField) => {
|
||||
return (possibleField.occupancyTypeField as string).toLowerCase() === occupancyTypeFieldLowerCase;
|
||||
});
|
||||
|
||||
if (field) {
|
||||
|
|
@ -37,10 +39,10 @@ export const getFeesByFeeCategory = (
|
|||
) => {
|
||||
const feeCategoryLowerCase = feeCategory.toLowerCase();
|
||||
|
||||
const fees = lotOccupancy.lotOccupancyFees.filter((possibleFee) => {
|
||||
const fees = (lotOccupancy.lotOccupancyFees || []).filter((possibleFee) => {
|
||||
return feeCategoryContains
|
||||
? possibleFee.feeCategory.toLowerCase().includes(feeCategoryLowerCase)
|
||||
: possibleFee.feeCategory.toLowerCase() === feeCategoryLowerCase;
|
||||
? (possibleFee.feeCategory as string).toLowerCase().includes(feeCategoryLowerCase)
|
||||
: (possibleFee.feeCategory as string).toLowerCase() === feeCategoryLowerCase;
|
||||
});
|
||||
|
||||
return fees;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ interface PrintConfig {
|
|||
}
|
||||
export declare const getScreenPrintConfig: (printName: string) => PrintConfig;
|
||||
export declare const getPdfPrintConfig: (printName: string) => PrintConfig;
|
||||
export declare const getPrintConfig: (screenOrPdf_printName: string) => PrintConfig;
|
||||
export declare const getPrintConfig: (screenOrPdf_printName: string) => PrintConfig | undefined;
|
||||
export declare const getReportData: (printConfig: PrintConfig, requestQuery: {
|
||||
[paramName: string]: unknown;
|
||||
}) => {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export const getScreenPrintConfig = (printName) => {
|
|||
return screenPrintConfigs[printName];
|
||||
};
|
||||
const pdfPrintConfigs = {
|
||||
"workOrder": {
|
||||
workOrder: {
|
||||
title: "Work Order Field Sheet",
|
||||
params: ["workOrderId"]
|
||||
},
|
||||
|
|
@ -38,11 +38,14 @@ export const getPdfPrintConfig = (printName) => {
|
|||
export const getPrintConfig = (screenOrPdf_printName) => {
|
||||
const printNameSplit = screenOrPdf_printName.split("/");
|
||||
switch (printNameSplit[0]) {
|
||||
case "screen":
|
||||
case "screen": {
|
||||
return getScreenPrintConfig(printNameSplit[1]);
|
||||
case "pdf":
|
||||
}
|
||||
case "pdf": {
|
||||
return getPdfPrintConfig(printNameSplit[1]);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
export const getReportData = (printConfig, requestQuery) => {
|
||||
const reportData = {
|
||||
|
|
@ -50,11 +53,11 @@ export const getReportData = (printConfig, requestQuery) => {
|
|||
};
|
||||
if (printConfig.params.includes("lotOccupancyId") &&
|
||||
typeof requestQuery.lotOccupancyId === "string") {
|
||||
reportData.lotOccupancy = getLotOccupancy(requestQuery.lotOccupancyId);
|
||||
if (reportData.lotOccupancy &&
|
||||
reportData.lotOccupancy.lotId) {
|
||||
reportData.lot = getLot(reportData.lotOccupancy.lotId);
|
||||
const lotOccupancy = getLotOccupancy(requestQuery.lotOccupancyId);
|
||||
if (lotOccupancy && lotOccupancy.lotId) {
|
||||
reportData.lot = getLot(lotOccupancy.lotId);
|
||||
}
|
||||
reportData.lotOccupancy = lotOccupancy;
|
||||
}
|
||||
if (printConfig.params.includes("workOrderId") &&
|
||||
typeof requestQuery.workOrderId === "string") {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import { getLot } from "./lotOccupancyDB/getLot.js";
|
|||
import { getLotOccupancy } from "./lotOccupancyDB/getLotOccupancy.js";
|
||||
import { getWorkOrder } from "./lotOccupancyDB/getWorkOrder.js";
|
||||
|
||||
import type * as recordTypes from "../types/recordTypes";
|
||||
|
||||
interface PrintConfig {
|
||||
title: string;
|
||||
params: string[];
|
||||
|
|
@ -27,7 +25,7 @@ export const getScreenPrintConfig = (printName: string): PrintConfig => {
|
|||
};
|
||||
|
||||
const pdfPrintConfigs: { [printName: string]: PrintConfig } = {
|
||||
"workOrder": {
|
||||
workOrder: {
|
||||
title: "Work Order Field Sheet",
|
||||
params: ["workOrderId"]
|
||||
},
|
||||
|
|
@ -51,16 +49,19 @@ export const getPdfPrintConfig = (printName: string): PrintConfig => {
|
|||
return pdfPrintConfigs[printName];
|
||||
};
|
||||
|
||||
export const getPrintConfig = (screenOrPdf_printName: string): PrintConfig => {
|
||||
export const getPrintConfig = (screenOrPdf_printName: string): PrintConfig | undefined => {
|
||||
const printNameSplit = screenOrPdf_printName.split("/");
|
||||
|
||||
switch (printNameSplit[0]) {
|
||||
case "screen":
|
||||
case "screen": {
|
||||
return getScreenPrintConfig(printNameSplit[1]);
|
||||
|
||||
case "pdf":
|
||||
}
|
||||
case "pdf": {
|
||||
return getPdfPrintConfig(printNameSplit[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const getReportData = (
|
||||
|
|
@ -75,14 +76,13 @@ export const getReportData = (
|
|||
printConfig.params.includes("lotOccupancyId") &&
|
||||
typeof requestQuery.lotOccupancyId === "string"
|
||||
) {
|
||||
reportData.lotOccupancy = getLotOccupancy(requestQuery.lotOccupancyId);
|
||||
const lotOccupancy = getLotOccupancy(requestQuery.lotOccupancyId);
|
||||
|
||||
if (
|
||||
reportData.lotOccupancy &&
|
||||
(reportData.lotOccupancy as recordTypes.LotOccupancy).lotId
|
||||
) {
|
||||
reportData.lot = getLot((reportData.lotOccupancy as recordTypes.LotOccupancy).lotId);
|
||||
if (lotOccupancy && lotOccupancy.lotId) {
|
||||
reportData.lot = getLot(lotOccupancy.lotId);
|
||||
}
|
||||
|
||||
reportData.lotOccupancy = lotOccupancy;
|
||||
}
|
||||
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as configFunctions from "./functions.config.js";
|
|||
export const userIsAdmin = (request) => {
|
||||
var _a;
|
||||
const user = (_a = request.session) === null || _a === void 0 ? void 0 : _a.user;
|
||||
if (!user) {
|
||||
if (!user || !user.userProperties) {
|
||||
return false;
|
||||
}
|
||||
return user.userProperties.isAdmin;
|
||||
|
|
@ -11,7 +11,7 @@ export const userIsAdmin = (request) => {
|
|||
export const userCanUpdate = (request) => {
|
||||
var _a;
|
||||
const user = (_a = request.session) === null || _a === void 0 ? void 0 : _a.user;
|
||||
if (!user) {
|
||||
if (!user || !user.userProperties) {
|
||||
return false;
|
||||
}
|
||||
return user.userProperties.canUpdate;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export interface APIRequest {
|
|||
export const userIsAdmin = (request: UserRequest): boolean => {
|
||||
const user = request.session?.user;
|
||||
|
||||
if (!user) {
|
||||
if (!user || !user.userProperties) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ export const userIsAdmin = (request: UserRequest): boolean => {
|
|||
export const userCanUpdate = (request: UserRequest): boolean => {
|
||||
const user = request.session?.user;
|
||||
|
||||
if (!user) {
|
||||
if (!user || !user.userProperties) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ export interface Map extends Record {
|
|||
lotCount?: number;
|
||||
}
|
||||
export interface LotType extends Record {
|
||||
lotTypeId?: number;
|
||||
lotType?: string;
|
||||
lotTypeId: number;
|
||||
lotType: string;
|
||||
orderNumber?: number;
|
||||
lotTypeFields?: LotTypeField[];
|
||||
}
|
||||
|
|
@ -44,8 +44,8 @@ export interface LotTypeField extends Record {
|
|||
orderNumber?: number;
|
||||
}
|
||||
export interface LotStatus extends Record {
|
||||
lotStatusId?: number;
|
||||
lotStatus?: string;
|
||||
lotStatusId: number;
|
||||
lotStatus: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export interface Lot extends Record {
|
||||
|
|
@ -76,8 +76,8 @@ export interface LotComment extends Record {
|
|||
lotComment?: string;
|
||||
}
|
||||
export interface OccupancyType extends Record {
|
||||
occupancyTypeId?: number;
|
||||
occupancyType?: string;
|
||||
occupancyTypeId: number;
|
||||
occupancyType: string;
|
||||
orderNumber?: number;
|
||||
occupancyTypeFields?: OccupancyTypeField[];
|
||||
}
|
||||
|
|
@ -93,8 +93,8 @@ export interface OccupancyTypeField {
|
|||
orderNumber?: number;
|
||||
}
|
||||
export interface LotOccupantType extends Record {
|
||||
lotOccupantTypeId?: number;
|
||||
lotOccupantType?: string;
|
||||
lotOccupantTypeId: number;
|
||||
lotOccupantType: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export interface FeeCategory extends Record {
|
||||
|
|
@ -137,7 +137,7 @@ export interface LotOccupancyTransaction extends Record {
|
|||
transactionDateString?: string;
|
||||
transactionTime?: number;
|
||||
transactionTimeString?: string;
|
||||
transactionAmount?: number;
|
||||
transactionAmount: number;
|
||||
externalReceiptNumber?: string;
|
||||
transactionNote?: string;
|
||||
}
|
||||
|
|
@ -197,8 +197,8 @@ export interface WorkOrderType extends Record {
|
|||
orderNumber?: number;
|
||||
}
|
||||
export interface WorkOrderMilestoneType extends Record {
|
||||
workOrderMilestoneTypeId?: number;
|
||||
workOrderMilestoneType?: string;
|
||||
workOrderMilestoneTypeId: number;
|
||||
workOrderMilestoneType: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
export interface WorkOrderComment extends Record {
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ export interface Map extends Record {
|
|||
}
|
||||
|
||||
export interface LotType extends Record {
|
||||
lotTypeId?: number;
|
||||
lotType?: string;
|
||||
lotTypeId: number;
|
||||
lotType: string;
|
||||
orderNumber?: number;
|
||||
lotTypeFields?: LotTypeField[];
|
||||
}
|
||||
|
|
@ -60,8 +60,8 @@ export interface LotTypeField extends Record {
|
|||
}
|
||||
|
||||
export interface LotStatus extends Record {
|
||||
lotStatusId?: number;
|
||||
lotStatus?: string;
|
||||
lotStatusId: number;
|
||||
lotStatus: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
|
||||
|
|
@ -104,8 +104,8 @@ export interface LotComment extends Record {
|
|||
}
|
||||
|
||||
export interface OccupancyType extends Record {
|
||||
occupancyTypeId?: number;
|
||||
occupancyType?: string;
|
||||
occupancyTypeId: number;
|
||||
occupancyType: string;
|
||||
orderNumber?: number;
|
||||
occupancyTypeFields?: OccupancyTypeField[];
|
||||
}
|
||||
|
|
@ -123,8 +123,8 @@ export interface OccupancyTypeField {
|
|||
}
|
||||
|
||||
export interface LotOccupantType extends Record {
|
||||
lotOccupantTypeId?: number;
|
||||
lotOccupantType?: string;
|
||||
lotOccupantTypeId: number;
|
||||
lotOccupantType: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ export interface LotOccupancyTransaction extends Record {
|
|||
transactionDateString?: string;
|
||||
transactionTime?: number;
|
||||
transactionTimeString?: string;
|
||||
transactionAmount?: number;
|
||||
transactionAmount: number;
|
||||
externalReceiptNumber?: string;
|
||||
transactionNote?: string;
|
||||
}
|
||||
|
|
@ -265,8 +265,8 @@ export interface WorkOrderType extends Record {
|
|||
}
|
||||
|
||||
export interface WorkOrderMilestoneType extends Record {
|
||||
workOrderMilestoneTypeId?: number;
|
||||
workOrderMilestoneType?: string;
|
||||
workOrderMilestoneTypeId: number;
|
||||
workOrderMilestoneType: string;
|
||||
orderNumber?: number;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue