80d9f5d428
- Nuevo endpoint POST /companies/check-admin para verificar rol de admin - Componente HeaderEditPopup con color pickers e image picker - Botón flotante de editar sobre el header cuando el usuario es admin - Popup tipo drawer inferior con formulario de personalización - Reutiliza APIs existentes: companies/update y companies/upload-header
385 lines
10 KiB
TypeScript
385 lines
10 KiB
TypeScript
import { TextObjectFilterResult } from "../TextObjectFilter.model";
|
|
import { ICompanyDocument } from "./Companies.Adapter.Mongoose";
|
|
|
|
export enum COMPANY_PUBLISHED_STATUS {
|
|
PUBLISHED = "published",
|
|
PRIVATE = "private",
|
|
}
|
|
|
|
export type CreateCompanyParams = {
|
|
name: string;
|
|
description: string;
|
|
categoryId: number;
|
|
ownerId: string;
|
|
onboardingStep?: number;
|
|
};
|
|
|
|
export type UpdateCompanyParams = {
|
|
id: string;
|
|
name?: string;
|
|
description?: string;
|
|
categoryId?: number;
|
|
headerFile?: string;
|
|
iconFile?: string;
|
|
logoFile?: string;
|
|
headerColor?: string;
|
|
headerFontColor?: string;
|
|
headerFontShadowColor?: string;
|
|
street?: string;
|
|
streetNumber?: string;
|
|
builingFloor?: string;
|
|
buildingApartament?: string;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
phoneCountryCode?: string;
|
|
phoneAreaCode?: string;
|
|
phoneNumber?: string;
|
|
heatMapFraction?: number;
|
|
appointmentTime?: number;
|
|
cancellationTime?: number;
|
|
wapServerId?: string;
|
|
appointmentAlert?: string;
|
|
sessionUser: string;
|
|
templateWapNotifId?: string;
|
|
templateWapAltaId?: string;
|
|
templateWapCancellationId?: string;
|
|
templateEmailNotifId?: string;
|
|
templateEmailAltaId?: string;
|
|
templateEmailCancellationId?: string;
|
|
onboardingStep?: number;
|
|
onboardingCompleted?: boolean;
|
|
banned?: boolean;
|
|
showPublicScores?: boolean;
|
|
showPublicOpinions?: boolean;
|
|
showPublicProfessionals?: boolean;
|
|
};
|
|
|
|
export type SetCompanyFileParams = {
|
|
companyId: string;
|
|
sessionUser: string;
|
|
file: Express.Multer.File;
|
|
};
|
|
|
|
export type DeleteCompanyFileParams = {
|
|
companyId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type DeleteCompanyParams = {
|
|
companyId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type FindCompaniesParams = {
|
|
_id?: string;
|
|
name?: string;
|
|
slug?: string;
|
|
categoryId?: number;
|
|
street?: string;
|
|
streetNumber?: string;
|
|
builingFloor?: string;
|
|
buildingApartament?: string;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
phoneCountryCode?: string;
|
|
phoneAreaCode?: string;
|
|
phoneNumber?: string;
|
|
heatMapFraction?: number;
|
|
appointmentTime?: number;
|
|
cancellationTime?: number;
|
|
ownerId?: string;
|
|
wapServerId?: string;
|
|
};
|
|
|
|
export type SetOrganizationPublishedStatusParams = {
|
|
companyId: string;
|
|
published: COMPANY_PUBLISHED_STATUS;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type SetNotificationAutoParams = {
|
|
companyId: string;
|
|
status?: boolean;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export interface ICompany {
|
|
id?: string;
|
|
name: string;
|
|
slug: string;
|
|
description: string;
|
|
categoryId: number;
|
|
ownerId: string;
|
|
headerFile?: string;
|
|
iconFile?: string;
|
|
logoFile?: string;
|
|
headerColor?: string;
|
|
headerFontColor?: string;
|
|
headerFontShadowColor?: string;
|
|
street?: string;
|
|
streetNumber?: string;
|
|
builingFloor?: string;
|
|
buildingApartament?: string;
|
|
block?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
phoneCountryCode?: string;
|
|
phoneAreaCode?: string;
|
|
phoneNumber?: string;
|
|
heatMapFraction?: number;
|
|
appointmentTime?: number;
|
|
cancellationTime?: number;
|
|
wapServerId?: string;
|
|
appointmentAlert?: string;
|
|
published?: COMPANY_PUBLISHED_STATUS;
|
|
automaticNotifications?: boolean;
|
|
templateWapNotifId?: string;
|
|
templateWapAltaId?: string;
|
|
templateWapCancellationId?: string;
|
|
templateEmailNotifId?: string;
|
|
templateEmailAltaId?: string;
|
|
templateEmailCancellationId?: string;
|
|
onboardingStep?: number;
|
|
onboardingCompleted?: boolean;
|
|
fixedPostIds?: Array<string>;
|
|
banned?: boolean;
|
|
showPublicScores?: boolean;
|
|
showPublicOpinions?: boolean;
|
|
showPublicProfessionals?: boolean;
|
|
}
|
|
|
|
export interface MyOranizationsView {
|
|
id: string;
|
|
name: string;
|
|
slug: string;
|
|
description: string;
|
|
categoryId: number;
|
|
ownerId: string;
|
|
employeeId: string;
|
|
isOwner: boolean;
|
|
isAdmin: boolean;
|
|
hostOk: boolean;
|
|
guestOk: boolean;
|
|
fullOk: boolean;
|
|
headerFile?: string;
|
|
headerColor?: string;
|
|
headerFontColor?: string;
|
|
headerFontShadowColor?: string;
|
|
iconFile?: string;
|
|
logoFile?: string;
|
|
phoneAreaCode?: string;
|
|
phoneNumber?: string;
|
|
heatMapFraction?: number;
|
|
appointmentTime?: number;
|
|
cancellationTime?: number;
|
|
block?: string;
|
|
street?: string;
|
|
streetNumber?: string;
|
|
builingFloor?: string;
|
|
buildingApartament?: string;
|
|
city?: string;
|
|
state?: string;
|
|
country?: string;
|
|
zipCode?: string;
|
|
latitude?: number;
|
|
longitude?: number;
|
|
published?: COMPANY_PUBLISHED_STATUS;
|
|
automaticNotifications?: boolean;
|
|
appointmentAlert?: string;
|
|
templateWapNotifId?: string;
|
|
templateWapAltaId?: string;
|
|
templateWapCancellationId?: string;
|
|
templateEmailNotifId?: string;
|
|
templateEmailAltaId?: string;
|
|
templateEmailCancellationId?: string;
|
|
onboardingStep?: number;
|
|
onboardingCompleted?: boolean;
|
|
banned?: boolean;
|
|
showPublicScores?: boolean;
|
|
showPublicOpinions?: boolean;
|
|
showPublicProfessionals?: boolean;
|
|
}
|
|
|
|
export interface ClientOrganizationView {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
slug: string;
|
|
iconFile: string;
|
|
logoFile: string;
|
|
}
|
|
|
|
export interface MyOranizationsViewParams {
|
|
sessionUser: string;
|
|
}
|
|
|
|
export interface ClientOranizationsViewParams {
|
|
clientId: string;
|
|
sessionUser: string;
|
|
}
|
|
|
|
export interface OranizationsViewByIdParams {
|
|
id: string;
|
|
sessionUser: string;
|
|
}
|
|
|
|
export type PaginateCompaniesParams = FindCompaniesParams & {
|
|
page: number;
|
|
limit: number;
|
|
};
|
|
|
|
export type PaginateCompaniesResults = {
|
|
data: ICompany[];
|
|
page: number;
|
|
pages: number;
|
|
};
|
|
|
|
export type SysAdminPaginateCompaniesParams = PaginateCompaniesParams & {
|
|
banned?: boolean;
|
|
};
|
|
|
|
export type SysAdminUpdateCompanyParams = {
|
|
id: string;
|
|
name?: string;
|
|
description?: string;
|
|
categoryId?: number;
|
|
};
|
|
|
|
export type SysAdminSetCompanyBannedParams = {
|
|
id: string;
|
|
banned: boolean;
|
|
};
|
|
|
|
export type SysAdminCompanyInsightsParams = {
|
|
companyId: string;
|
|
};
|
|
|
|
export type SysAdminCompanyInsightsResult = {
|
|
organization: {
|
|
id: string;
|
|
name: string;
|
|
slug: string;
|
|
description: string;
|
|
categoryId: number;
|
|
banned: boolean;
|
|
published?: COMPANY_PUBLISHED_STATUS;
|
|
onboardingStep?: number;
|
|
onboardingCompleted?: boolean;
|
|
};
|
|
owner: {
|
|
id: string;
|
|
firstName?: string;
|
|
lastName?: string;
|
|
email?: string;
|
|
verificated?: boolean;
|
|
phoneCountryCode?: string;
|
|
phoneAreaCode?: string;
|
|
phoneNumber?: string;
|
|
} | null;
|
|
collaborators: {
|
|
id: string;
|
|
userId?: string;
|
|
firstName?: string;
|
|
lastName?: string;
|
|
fullName?: string;
|
|
email?: string;
|
|
roles?: string[];
|
|
removed?: boolean;
|
|
active: boolean;
|
|
avatar?: string;
|
|
}[];
|
|
subscription: {
|
|
id: string;
|
|
startDate: Date;
|
|
endDate: Date;
|
|
isActive: boolean;
|
|
autoRenew: boolean;
|
|
mpStatus?: string;
|
|
pendingPaymentType?: "extension" | "upgrade";
|
|
plan: {
|
|
id: string;
|
|
name: string;
|
|
code: string;
|
|
price: number;
|
|
limitOrganizations: number;
|
|
limitEmployees: number;
|
|
limitServices: number;
|
|
limitAppointments: number;
|
|
limitClients: number;
|
|
} | null;
|
|
} | null;
|
|
stats: {
|
|
employeesCount: number;
|
|
activeEmployeesCount: number;
|
|
servicesCount: number;
|
|
activeServicesCount: number;
|
|
clientsCount: number;
|
|
activeClientsCount: number;
|
|
reservationsLast30Days: number;
|
|
};
|
|
};
|
|
|
|
export type FixCompanyPostParams = {
|
|
companyId: string;
|
|
postId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type MoveCompanyFixedPostParams = {
|
|
companyId: string;
|
|
postId: string;
|
|
moveLength: number;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export interface ICompaniesAdapter {
|
|
create(company: ICompany): Promise<ICompany>;
|
|
delete(id: string): Promise<void>;
|
|
find(filters: FindCompaniesParams): Promise<ICompany[]>;
|
|
findOne(filters: FindCompaniesParams): Promise<ICompanyDocument | null>;
|
|
paginate(filters: PaginateCompaniesParams): Promise<PaginateCompaniesResults>;
|
|
sysAdminPaginate(data: SysAdminPaginateCompaniesParams): Promise<PaginateCompaniesResults>;
|
|
paginateFilterAll(data: PaginateCompaniesParams): Promise<PaginateCompaniesResults>;
|
|
update(data: UpdateCompanyParams): Promise<void>;
|
|
}
|
|
|
|
export interface ICompaniesManager {
|
|
companies: ICompaniesAdapter;
|
|
createCompany(data: CreateCompanyParams): Promise<ICompany>;
|
|
isValidName(data: FindCompaniesParams): Promise<boolean>;
|
|
updateCompany(data: UpdateCompanyParams): Promise<void>;
|
|
setCompanyHeader(data: SetCompanyFileParams): Promise<void>;
|
|
setCompanyIcon(data: SetCompanyFileParams): Promise<void>;
|
|
deleteCompanyHeader(data: DeleteCompanyFileParams): Promise<void>;
|
|
deleteCompanyIcon(data: DeleteCompanyFileParams): Promise<void>;
|
|
getByUserId(data: MyOranizationsViewParams): Promise<MyOranizationsView[]>;
|
|
getByClientId(data: ClientOranizationsViewParams): Promise<ClientOrganizationView[]>;
|
|
getById(data: OranizationsViewByIdParams): Promise<MyOranizationsView>;
|
|
filterAll(data: PaginateCompaniesParams): Promise<TextObjectFilterResult[]>;
|
|
getCompanyAddress(data: ICompany): string;
|
|
deleteCompany(data: DeleteCompanyParams): Promise<void>;
|
|
setPublishedStatus(data: SetOrganizationPublishedStatusParams): Promise<void>;
|
|
setNotificationAuto(data: SetNotificationAutoParams): Promise<void>;
|
|
toggleFixedPost(data: FixCompanyPostParams): Promise<void>;
|
|
moveFixedPost(data: MoveCompanyFixedPostParams): Promise<void>;
|
|
sysAdminPaginate(data: SysAdminPaginateCompaniesParams): Promise<PaginateCompaniesResults>;
|
|
sysAdminUpdate(data: SysAdminUpdateCompanyParams): Promise<void>;
|
|
sysAdminSetBanned(data: SysAdminSetCompanyBannedParams): Promise<void>;
|
|
sysAdminGetInsights(data: SysAdminCompanyInsightsParams): Promise<SysAdminCompanyInsightsResult>;
|
|
checkCompanyAdmin(data: { companyId: string; sessionUser: string }): Promise<boolean>;
|
|
}
|