@homeflow/next
Advanced tools
Comparing version 1.0.12 to 1.0.13
import HestiaHelper from './hestia-helper'; | ||
import { ModelError } from '../../models/model'; | ||
import { HestiaAgencyEmployeeData } from '../../models/agency-employee'; | ||
import { AgencyEmployeeSearchParams, HestiaAgencyEmployeeData } from '../../models/agency-employee'; | ||
export default class HestiaAgencyEmployeeHelper extends HestiaHelper<HestiaAgencyEmployeeData> { | ||
basePath: string; | ||
resourceName: string; | ||
findAll({ pageSize }?: { | ||
pageSize?: number | string; | ||
}): Promise<{ | ||
findAll(params: AgencyEmployeeSearchParams): Promise<{ | ||
results: HestiaAgencyEmployeeData[]; | ||
@@ -11,0 +9,0 @@ totalCount: number; |
@@ -15,2 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../../../utils"); | ||
const hestia_helper_1 = __importDefault(require("./hestia-helper")); | ||
@@ -23,3 +24,3 @@ class HestiaAgencyEmployeeHelper extends hestia_helper_1.default { | ||
} | ||
findAll({ pageSize } = {}) { | ||
findAll(params) { | ||
var _a, _b, _c, _d, _e, _f; | ||
@@ -29,7 +30,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
const query = { | ||
search: { | ||
agency_id: (_a = this.hestia.siteData) === null || _a === void 0 ? void 0 : _a.agency.agency_id, | ||
}, | ||
page: 1, | ||
page_size: pageSize || 500, | ||
search: Object.assign({ agency_id: (_a = this.hestia.siteData) === null || _a === void 0 ? void 0 : _a.agency.agency_id }, ((params === null || params === void 0 ? void 0 : params.search) && (0, utils_1.snakifyKeys)(params.search))), | ||
page: (params === null || params === void 0 ? void 0 : params.page) || 1, | ||
page_size: (params === null || params === void 0 ? void 0 : params.pageSize) || 500, | ||
}; | ||
@@ -36,0 +35,0 @@ const json = yield this.hestia.request({ path: this.basePath, query }, { cache: 'no-store' }); |
import 'server-only'; | ||
import Model, { ModelError } from './model'; | ||
import type { HestiaAgencyEmployeeData } from './agency-employee.types'; | ||
import type { AgencyEmployeeSearchParams, HestiaAgencyEmployeeData } from './agency-employee.types'; | ||
import type { HestiaBranchData } from './branch'; | ||
@@ -8,3 +8,4 @@ import Pagination from './helpers/pagination'; | ||
export default class AgencyEmployee extends Model<void, HestiaAgencyEmployeeData> { | ||
static findAll(): Promise<{ | ||
static pagination: Pagination | undefined; | ||
static findAll(params?: AgencyEmployeeSearchParams): Promise<{ | ||
results: AgencyEmployee[]; | ||
@@ -11,0 +12,0 @@ errors: ModelError[] | null; |
@@ -32,11 +32,24 @@ "use strict"; | ||
const model_1 = __importDefault(require("./model")); | ||
const pagination_1 = __importDefault(require("./helpers/pagination")); | ||
__exportStar(require("./agency-employee.types"), exports); | ||
class AgencyEmployee extends model_1.default { | ||
static findAll() { | ||
static findAll(params = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { results, errors } = yield model_1.default.hestia.agencyEmployee.findAll(); | ||
if (errors || !results.length) | ||
const { results, totalCount, errors } = yield model_1.default.hestia.agencyEmployee.findAll(params); | ||
if (errors || !results.length) { | ||
// reset the pagination on the class, otherwise it will hold on to the previous values | ||
AgencyEmployee.pagination = new pagination_1.default({ | ||
totalCount: 0, | ||
currentPage: Number((params === null || params === void 0 ? void 0 : params.page) || 1), | ||
pageSize: Number((params === null || params === void 0 ? void 0 : params.pageSize) || 12), | ||
}); | ||
return { results: [], errors, pagination: null }; | ||
} | ||
AgencyEmployee.pagination = new pagination_1.default({ | ||
totalCount, | ||
currentPage: Number(params.page || 1), | ||
pageSize: Number(params.pageSize || 12), | ||
}); | ||
const agencyEmployees = results.map((staff) => new AgencyEmployee({ hestiaData: staff })); | ||
return { results: agencyEmployees, pagination: null, errors }; | ||
return { results: agencyEmployees, pagination: AgencyEmployee.pagination, errors }; | ||
// Ctesius fetches staff members from the /branches Hestia endpoint. | ||
@@ -43,0 +56,0 @@ // This data doesn't return everything /agency_employees does but |
@@ -45,1 +45,9 @@ import { HestiaBranchData } from './branch.types'; | ||
} | ||
export interface AgencyEmployeeSearchParams { | ||
page?: number; | ||
pageSize?: number; | ||
search?: AgencyEmployeeHestiaSearch; | ||
} | ||
export interface AgencyEmployeeHestiaSearch { | ||
branchId: number; | ||
} |
@@ -10,2 +10,2 @@ /// <reference types="react/experimental" /> | ||
fallback?: React.ReactNode | JSX.Element; | ||
}): string | number | boolean | Iterable<React.ReactNode> | Promise<React.AwaitedReactNode> | JSX.Element | null | undefined; | ||
}): string | number | boolean | Iterable<React.ReactNode> | React.PromiseLikeOfReactNode | JSX.Element | null | undefined; |
@@ -15,7 +15,7 @@ import mongoose from 'mongoose'; | ||
export type GlobalConfig = IGlobalConfig & mongoose.Document; | ||
declare const GlobalConfigSchema: mongoose.Schema<GlobalConfig, mongoose.Model<GlobalConfig, any, any, any, mongoose.Document<unknown, any, GlobalConfig> & IGlobalConfig & mongoose.Document<unknown, any, any> & Required<{ | ||
_id: string | null; | ||
}>, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, GlobalConfig, mongoose.Document<unknown, {}, mongoose.FlatRecord<GlobalConfig>> & mongoose.FlatRecord<GlobalConfig> & Required<{ | ||
_id: string | null; | ||
}>>; | ||
declare const GlobalConfigSchema: mongoose.Schema<GlobalConfig, mongoose.Model<GlobalConfig, any, any, any, mongoose.Document<unknown, any, GlobalConfig> & IGlobalConfig & mongoose.Document<any, any, any> & { | ||
_id: mongoose.Types.ObjectId; | ||
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, GlobalConfig, mongoose.Document<unknown, {}, mongoose.FlatRecord<GlobalConfig>> & mongoose.FlatRecord<GlobalConfig> & { | ||
_id: mongoose.Types.ObjectId; | ||
}>; | ||
export default GlobalConfigSchema; |
@@ -22,6 +22,6 @@ import { ObjectId } from 'mongodb'; | ||
agencyId?: number | null | undefined; | ||
id?: string | null | undefined; | ||
name?: string | null | undefined; | ||
component?: string | null | undefined; | ||
id?: string | null | undefined; | ||
configuration?: any; | ||
name?: string | null | undefined; | ||
sharedSection?: mongoose.Types.ObjectId | null | undefined; | ||
@@ -33,6 +33,6 @@ }, mongoose.Document<unknown, {}, mongoose.FlatRecord<{ | ||
agencyId?: number | null | undefined; | ||
id?: string | null | undefined; | ||
name?: string | null | undefined; | ||
component?: string | null | undefined; | ||
id?: string | null | undefined; | ||
configuration?: any; | ||
name?: string | null | undefined; | ||
sharedSection?: mongoose.Types.ObjectId | null | undefined; | ||
@@ -44,6 +44,6 @@ }>> & mongoose.FlatRecord<{ | ||
agencyId?: number | null | undefined; | ||
id?: string | null | undefined; | ||
name?: string | null | undefined; | ||
component?: string | null | undefined; | ||
id?: string | null | undefined; | ||
configuration?: any; | ||
name?: string | null | undefined; | ||
sharedSection?: mongoose.Types.ObjectId | null | undefined; | ||
@@ -53,10 +53,10 @@ }> & { | ||
}>; | ||
declare const PageConfigSchema: mongoose.Schema<PageConfig, mongoose.Model<PageConfig, any, any, any, mongoose.Document<unknown, any, PageConfig> & IPageConfig & mongoose.Document<unknown, any, any> & { | ||
declare const PageConfigSchema: mongoose.Schema<PageConfig, mongoose.Model<PageConfig, any, any, any, mongoose.Document<unknown, any, PageConfig> & IPageConfig & mongoose.Document<any, any, any> & { | ||
populateSharedSections: () => Promise<void>; | ||
renderLiquid: () => Promise<void>; | ||
} & Required<{ | ||
_id: string | null; | ||
}>, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, PageConfig, mongoose.Document<unknown, {}, mongoose.FlatRecord<PageConfig>> & mongoose.FlatRecord<PageConfig> & Required<{ | ||
_id: string | null; | ||
}>>; | ||
} & { | ||
_id: mongoose.Types.ObjectId; | ||
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, PageConfig, mongoose.Document<unknown, {}, mongoose.FlatRecord<PageConfig>> & mongoose.FlatRecord<PageConfig> & { | ||
_id: mongoose.Types.ObjectId; | ||
}>; | ||
export default PageConfigSchema; |
@@ -10,7 +10,7 @@ import mongoose from 'mongoose'; | ||
} | ||
declare const SecretConfigSchema: mongoose.Schema<SecretConfig, mongoose.Model<SecretConfig, any, any, any, mongoose.Document<unknown, any, SecretConfig> & SecretConfig & { | ||
_id: mongoose.Types.ObjectId; | ||
}, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, SecretConfig, mongoose.Document<unknown, {}, mongoose.FlatRecord<SecretConfig>> & mongoose.FlatRecord<SecretConfig> & { | ||
_id: mongoose.Types.ObjectId; | ||
}>; | ||
declare const SecretConfigSchema: mongoose.Schema<SecretConfig, mongoose.Model<SecretConfig, any, any, any, mongoose.Document<unknown, any, SecretConfig> & SecretConfig & Required<{ | ||
_id: unknown; | ||
}>, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, SecretConfig, mongoose.Document<unknown, {}, mongoose.FlatRecord<SecretConfig>> & mongoose.FlatRecord<SecretConfig> & Required<{ | ||
_id: unknown; | ||
}>>; | ||
export default SecretConfigSchema; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { ConfigState } from './config.types'; | ||
@@ -127,6 +128,6 @@ import { MixedSection, PageConfig, Section } from './page-config.types'; | ||
config: ConfigState; | ||
}) => import("./config.types").SelectedItem | import("./global-config.types").FooterItem | null; | ||
}) => import("./global-config.types").FooterItem | import("./config.types").SelectedItem | null; | ||
export declare const selectSelectedSectionElement: (state: { | ||
config: ConfigState; | ||
}) => import("./config.types").SelectedElement | import("./global-config.types").FooterElement | null; | ||
}) => import("./global-config.types").FooterElement | import("./config.types").SelectedElement | null; | ||
export declare const selectSectionConfigField: (areaName: string, sectionId: string, field: string) => (state: { | ||
@@ -133,0 +134,0 @@ config: ConfigState; |
{ | ||
"name": "@homeflow/next", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"main": "./dist/main.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9498893
15985