Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hub-common): add inPersonCapacityType to IHubEvent #1591

Merged
merged 6 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 18 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions packages/common/src/core/types/IHubEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ export interface IHubEvent extends IHubItemEntity, IWithPermissions, IWithSlug {
/**
* The maximum capacity for in-person attendance
*/
inPersonCapacity?: number | null;
inPersonCapacity: number | null;

/**
* The capacity type for an in-person event, either `unlimited` or `fixed`
*/
inPersonCapacityType: HubEventCapacityType;

/**
* The current number of in-person registrants with a registration status of `accepted`
Expand Down Expand Up @@ -118,7 +123,7 @@ export interface IHubEvent extends IHubItemEntity, IWithPermissions, IWithSlug {
/**
* The maximum attendance capacity for an online event
*/
onlineCapacity?: number | null;
onlineCapacity: number | null;

/**
* The current number of online registrants with a registration status of `accepted`
Expand All @@ -128,7 +133,7 @@ export interface IHubEvent extends IHubItemEntity, IWithPermissions, IWithSlug {
/**
* The capacity type for an online event, either `unlimited` or `fixed`
*/
onlineCapacityType?: HubEventCapacityType;
onlineCapacityType: HubEventCapacityType;

/**
* The details for an online event
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/events/_internal/PropertyMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class EventPropertyMapper extends PropertyMapper<
obj.onlineCapacityType = store.onlineMeeting?.capacity
? HubEventCapacityType.Fixed
: HubEventCapacityType.Unlimited;
obj.inPersonCapacity = store.inPersonCapacity ?? null;
obj.inPersonCapacityType = store.inPersonCapacity
? HubEventCapacityType.Fixed
: HubEventCapacityType.Unlimited;
Expand Down Expand Up @@ -176,6 +177,8 @@ export class EventPropertyMapper extends PropertyMapper<
clonedEntity.inPersonCapacityType === HubEventCapacityType.Fixed
? clonedEntity.inPersonCapacity
: null;
} else {
obj.inPersonCapacity = null;
}

// override startTime & endTime for all-day events
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/events/_internal/getPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export function getPropertyMap(): IPropertyMap[] {
"startTime",
"endDate",
"endTime",
"inPersonCapacity",
];
return commonPropNames.reduce(
(acc, propName) => [...acc, { entityKey: propName, storeKey: propName }],
Expand Down
6 changes: 3 additions & 3 deletions packages/common/test/events/_internal/PropertyMapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("PropertyMapper", () => {
attendanceType: HubEventAttendanceType.InPerson,
inPersonCapacity: 30,
inPersonRegistrationCount: 0,
inPersonCapacityType: "fixed",
inPersonCapacityType: HubEventCapacityType.Fixed,
location: {
type: "none",
spatialReference: {},
Expand Down Expand Up @@ -433,7 +433,7 @@ describe("PropertyMapper", () => {
startTime: jasmine.any(String) as unknown as string,
endDate: jasmine.any(String) as unknown as string,
endTime: jasmine.any(String) as unknown as string,
inPersonCapacity: 30,
inPersonCapacity: null,
location: null,
readGroups: [],
editGroups: [],
Expand Down Expand Up @@ -480,7 +480,7 @@ describe("PropertyMapper", () => {
startTime: jasmine.any(String) as unknown as string,
endDate: jasmine.any(String) as unknown as string,
endTime: jasmine.any(String) as unknown as string,
inPersonCapacity: 30,
inPersonCapacity: null,
location: null,
readGroups: [],
editGroups: [],
Expand Down
Loading