@rentcheck/biz 1.0.237 → 1.0.239

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { AccountSettings, ApiSubscription, Inspection, InspectionEdit, PermissionGroup, Profile } from '@rentcheck/types';
1
+ import { AccountSettings, ApiInspection, ApiSubscription, ApiUser, Inspection, InspectionEdit, PermissionGroup, Profile } from '@rentcheck/types';
2
2
  export declare const canRecordVideo: (subscription?: ApiSubscription | null) => boolean;
3
3
  export declare const canTake360Photos: (subscription?: ApiSubscription | null) => boolean;
4
4
  export declare const canRenterReportMaintenance: (accountSettings?: AccountSettings | null, subscription?: ApiSubscription | null) => boolean;
@@ -23,4 +23,9 @@ type CanEditParams = {
23
23
  changeset: InspectionEdit;
24
24
  };
25
25
  export declare const canEdit: ({ changeset }: CanEditParams) => RulesResult;
26
+ type CanCreateFlagsParams = {
27
+ inspection: ApiInspection;
28
+ user: ApiUser;
29
+ };
30
+ export declare const canCreateFlags: ({ user }: CanCreateFlagsParams) => boolean;
26
31
  export {};
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.canEdit = exports.canSign = exports.canSubmit = exports.canAccess = exports.areFlagDefaultPhotosEnabled = exports.canRenterReportMaintenance = exports.canTake360Photos = exports.canRecordVideo = void 0;
36
+ exports.canCreateFlags = exports.canEdit = exports.canSign = exports.canSubmit = exports.canAccess = exports.areFlagDefaultPhotosEnabled = exports.canRenterReportMaintenance = exports.canTake360Photos = exports.canRecordVideo = void 0;
37
37
  const Utils = __importStar(require("../utils"));
38
38
  const canRecordVideo = (subscription) => {
39
39
  if (!subscription) {
@@ -144,3 +144,7 @@ const canEdit = ({ changeset }) => {
144
144
  return { value: true };
145
145
  };
146
146
  exports.canEdit = canEdit;
147
+ const canCreateFlags = ({ user }) => {
148
+ return !Utils.Users.isRenter(user);
149
+ };
150
+ exports.canCreateFlags = canCreateFlags;
@@ -1,4 +1,4 @@
1
1
  import { ApiInspectionWithTemplate, Feature } from '@rentcheck/types';
2
- export declare const anAnswerRequiresPhoto: (feature: Feature) => boolean;
2
+ export declare const anAnswerRequiresMedia: (feature: Feature) => boolean;
3
3
  export declare const noteIsRequired: (feature: Feature, inspection?: ApiInspectionWithTemplate) => boolean;
4
4
  export declare const canRotateImage: (image: string) => boolean;
@@ -36,22 +36,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.canRotateImage = exports.noteIsRequired = exports.anAnswerRequiresPhoto = void 0;
39
+ exports.canRotateImage = exports.noteIsRequired = exports.anAnswerRequiresMedia = void 0;
40
40
  const lodash_1 = __importDefault(require("lodash"));
41
41
  const types_1 = require("@rentcheck/types");
42
42
  const Utils = __importStar(require("../../utils"));
43
- const anAnswerRequiresPhoto = (feature) => {
43
+ const anAnswerRequiresMedia = (feature) => {
44
44
  return feature.questions.some((q, idx) => {
45
45
  var _a, _b, _c;
46
46
  const responsesForQuestion = (_b = (_a = feature.responses[idx]) === null || _a === void 0 ? void 0 : _a.split(types_1.MULTIPLE_CHOICE_RESPONSE_SEPARATOR)) !== null && _b !== void 0 ? _b : '';
47
- const answersThatRequireNotes = (_c = q.answers) === null || _c === void 0 ? void 0 : _c.filter((a) => a.requires_photo).map((a) => a.title);
48
- if (lodash_1.default.intersection(responsesForQuestion, answersThatRequireNotes).length === 0) {
47
+ const answersThatRequireMedia = (_c = q.answers) === null || _c === void 0 ? void 0 : _c.filter((a) => a.requires_photo).map((a) => a.title);
48
+ if (lodash_1.default.intersection(responsesForQuestion, answersThatRequireMedia).length === 0) {
49
49
  return false;
50
50
  }
51
51
  return true;
52
52
  });
53
53
  };
54
- exports.anAnswerRequiresPhoto = anAnswerRequiresPhoto;
54
+ exports.anAnswerRequiresMedia = anAnswerRequiresMedia;
55
55
  const anAnswerRequiresNote = (feature) => {
56
56
  return feature.questions.some((q, idx) => {
57
57
  var _a, _b, _c;
@@ -1,8 +1,8 @@
1
- import { APIProperty, ApiAutomation, ApiInspection, ApiInspectionWithTemplate, Feature, InspectionTemplate, MaintenanceFlag, Profile, Property } from '@rentcheck/types';
1
+ import { ApiAutomation, ApiInspection, ApiInspectionWithTemplate, APIProperty, ApiUser, Feature, ImageMetadata, InspectionTemplate, MaintenanceFlag, Property } from '@rentcheck/types';
2
2
  import { UserIsInvitedTeammateParams } from '../../utils/inspections';
3
- export declare const shouldShowLibraryOption: (inspection?: ApiInspection, profile?: Profile) => boolean;
3
+ export declare const shouldShowLibraryOption: (inspection?: ApiInspection, profile?: ApiUser) => boolean;
4
4
  export declare const shouldShow360Option: (inspection?: ApiInspection) => boolean;
5
- export declare const shouldShowVideoOption: (inspection?: ApiInspection, profile?: Profile, feature?: Feature) => boolean;
5
+ export declare const shouldShowVideoOption: (inspection?: ApiInspection, profile?: ApiUser, feature?: Feature) => boolean;
6
6
  export declare const canReview: (inspection: ApiInspection) => boolean;
7
7
  export declare const canApprove: (inspection: ApiInspection, ignoreTwoStepReviewRequired?: boolean) => boolean;
8
8
  export declare const canCompleteFirstStepReview: (inspection: ApiInspection) => boolean;
@@ -51,5 +51,6 @@ export declare const inspectionIsInProgress: (inspection: Pick<ApiInspection, "i
51
51
  export declare const canEditFeature: (inspection: ApiInspection, feature: Feature) => boolean;
52
52
  export declare const findConflictingAutomation: (template: InspectionTemplate, automations: ApiAutomation[], units: Property[]) => ApiAutomation;
53
53
  export declare const canShowAIDamage: (inspection: ApiInspectionWithTemplate | null) => boolean;
54
+ export declare const canShowAIDamageFilterPanel: (inspection: ApiInspectionWithTemplate | null, imageMetadata: ImageMetadata[]) => boolean;
54
55
  export declare const canShowFeatureRatingSummary: (inspection: Pick<ApiInspection, "inspection_status">) => boolean;
55
56
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canShowFeatureRatingSummary = exports.canShowAIDamage = exports.findConflictingAutomation = exports.canEditFeature = exports.inspectionIsInProgress = exports.canReOpen = exports.canShowViewModeToggle = exports.canMakeUnitEdits = exports.canPerformFeatureActions = exports.canShowFlaggedItems = exports.canShowSyncStatus = exports.canManualSync = exports.canCopyInspectionDeeplink = exports.canDownloadReport = exports.canShare = exports.canEditDueDate = exports.canShowHyperlinkToPropertyPage = exports.canShowReviewDueDate = exports.canShowRevisionDueDate = exports.canShowInviteDate = exports.canEditAssignee = exports.canShowAssignee = exports.canShowDueDate = exports.canShowCompletedBy = exports.canShowCompletedDate = exports.canCreateMaintenanceReport = exports.canRequestSignatures = exports.canDownloadMaintenanceFlags = exports.canDownloadImages = exports.canMarkAsComplete = exports.canSendReminder = exports.canDelete = exports.canUnarchive = exports.canArchive = exports.canCancelRevisionRequest = exports.canCancelReviewRequest = exports.canEditLabel = exports.canSetRevisionNotes = exports.canReject = exports.canUndoFirstStepReview = exports.canCompleteFirstStepReview = exports.canApprove = exports.canReview = exports.shouldShowVideoOption = exports.shouldShow360Option = exports.shouldShowLibraryOption = void 0;
3
+ exports.canShowFeatureRatingSummary = exports.canShowAIDamageFilterPanel = exports.canShowAIDamage = exports.findConflictingAutomation = exports.canEditFeature = exports.inspectionIsInProgress = exports.canReOpen = exports.canShowViewModeToggle = exports.canMakeUnitEdits = exports.canPerformFeatureActions = exports.canShowFlaggedItems = exports.canShowSyncStatus = exports.canManualSync = exports.canCopyInspectionDeeplink = exports.canDownloadReport = exports.canShare = exports.canEditDueDate = exports.canShowHyperlinkToPropertyPage = exports.canShowReviewDueDate = exports.canShowRevisionDueDate = exports.canShowInviteDate = exports.canEditAssignee = exports.canShowAssignee = exports.canShowDueDate = exports.canShowCompletedBy = exports.canShowCompletedDate = exports.canCreateMaintenanceReport = exports.canRequestSignatures = exports.canDownloadMaintenanceFlags = exports.canDownloadImages = exports.canMarkAsComplete = exports.canSendReminder = exports.canDelete = exports.canUnarchive = exports.canArchive = exports.canCancelRevisionRequest = exports.canCancelReviewRequest = exports.canEditLabel = exports.canSetRevisionNotes = exports.canReject = exports.canUndoFirstStepReview = exports.canCompleteFirstStepReview = exports.canApprove = exports.canReview = exports.shouldShowVideoOption = exports.shouldShow360Option = exports.shouldShowLibraryOption = void 0;
4
4
  const utils_1 = require("../../utils");
5
5
  const inspections_1 = require("../../utils/inspections");
6
6
  const shouldShowLibraryOption = (inspection, profile) => {
@@ -89,7 +89,11 @@ exports.canSetRevisionNotes = canSetRevisionNotes;
89
89
  const canEditLabel = (inspection) => {
90
90
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
91
91
  return true;
92
- const validRoles = ['creator', 'self-perform'];
92
+ const validRoles = [
93
+ 'creator',
94
+ 'self-perform-write',
95
+ 'self-perform-read',
96
+ ];
93
97
  if (!validRoles.includes(inspection.role))
94
98
  return false;
95
99
  return true;
@@ -118,7 +122,11 @@ exports.canCancelRevisionRequest = canCancelRevisionRequest;
118
122
  const canArchive = (inspection) => {
119
123
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
120
124
  return true;
121
- const validRoles = ['creator', 'self-perform'];
125
+ const validRoles = [
126
+ 'creator',
127
+ 'self-perform-write',
128
+ 'self-perform-read',
129
+ ];
122
130
  if (!validRoles.includes(inspection.role))
123
131
  return false;
124
132
  if (inspection.archived)
@@ -129,7 +137,11 @@ exports.canArchive = canArchive;
129
137
  const canUnarchive = (inspection) => {
130
138
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
131
139
  return true;
132
- const validRoles = ['creator', 'self-perform'];
140
+ const validRoles = [
141
+ 'creator',
142
+ 'self-perform-write',
143
+ 'self-perform-read',
144
+ ];
133
145
  if (!validRoles.includes(inspection.role))
134
146
  return false;
135
147
  if (!inspection.archived)
@@ -138,7 +150,11 @@ const canUnarchive = (inspection) => {
138
150
  };
139
151
  exports.canUnarchive = canUnarchive;
140
152
  const canDelete = (inspection) => {
141
- const validRoles = ['creator', 'self-perform'];
153
+ const validRoles = [
154
+ 'creator',
155
+ 'self-perform-write',
156
+ 'self-perform-read',
157
+ ];
142
158
  const validStatuses = [
143
159
  'Scheduled',
144
160
  'Not Started',
@@ -168,7 +184,11 @@ const canSendReminder = (inspection) => {
168
184
  };
169
185
  exports.canSendReminder = canSendReminder;
170
186
  const canMarkAsComplete = (inspection) => {
171
- const validRoles = ['creator', 'self-perform'];
187
+ const validRoles = [
188
+ 'creator',
189
+ 'self-perform-write',
190
+ 'self-perform-read',
191
+ ];
172
192
  const validStatuses = [
173
193
  'Started',
174
194
  'Revision Requested',
@@ -210,14 +230,22 @@ const canDownloadMaintenanceFlags = (inspection, features) => {
210
230
  return false;
211
231
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
212
232
  return true;
213
- const validRoles = ['creator', 'self-perform'];
233
+ const validRoles = [
234
+ 'creator',
235
+ 'self-perform-write',
236
+ 'self-perform-read',
237
+ ];
214
238
  if (!validRoles.includes(inspection.role))
215
239
  return false;
216
240
  return true;
217
241
  };
218
242
  exports.canDownloadMaintenanceFlags = canDownloadMaintenanceFlags;
219
243
  const canRequestSignatures = (inspection) => {
220
- const validRoles = ['creator', 'self-perform'];
244
+ const validRoles = [
245
+ 'creator',
246
+ 'self-perform-write',
247
+ 'self-perform-read',
248
+ ];
221
249
  const validStatuses = [
222
250
  'In Review',
223
251
  'Completed',
@@ -233,7 +261,11 @@ const canRequestSignatures = (inspection) => {
233
261
  };
234
262
  exports.canRequestSignatures = canRequestSignatures;
235
263
  const canCreateMaintenanceReport = (inspection, features) => {
236
- const validRoles = ['creator', 'self-perform'];
264
+ const validRoles = [
265
+ 'creator',
266
+ 'self-perform-write',
267
+ 'self-perform-read',
268
+ ];
237
269
  const validStatuses = [
238
270
  'In Review',
239
271
  'Completed',
@@ -310,7 +342,11 @@ const canEditAssignee = (inspection) => {
310
342
  return false;
311
343
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
312
344
  return true;
313
- const validRoles = ['creator', 'self-perform'];
345
+ const validRoles = [
346
+ 'creator',
347
+ 'self-perform-write',
348
+ 'self-perform-read',
349
+ ];
314
350
  if (!validRoles.includes(inspection.role))
315
351
  return false;
316
352
  return true;
@@ -355,7 +391,11 @@ exports.canShowReviewDueDate = canShowReviewDueDate;
355
391
  const canShowHyperlinkToPropertyPage = (inspection) => {
356
392
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
357
393
  return true;
358
- const validRoles = ['creator', 'self-perform'];
394
+ const validRoles = [
395
+ 'creator',
396
+ 'self-perform-write',
397
+ 'self-perform-read',
398
+ ];
359
399
  if (!validRoles.includes(inspection.role))
360
400
  return false;
361
401
  return true;
@@ -364,7 +404,11 @@ exports.canShowHyperlinkToPropertyPage = canShowHyperlinkToPropertyPage;
364
404
  const canEditDueDate = (inspection) => {
365
405
  if (!(0, exports.canShowDueDate)(inspection))
366
406
  return false;
367
- const validRoles = ['creator', 'self-perform'];
407
+ const validRoles = [
408
+ 'creator',
409
+ 'self-perform-write',
410
+ 'self-perform-read',
411
+ ];
368
412
  if (!validRoles.includes(inspection.role))
369
413
  return false;
370
414
  return true;
@@ -443,7 +487,11 @@ const canManualSync = (inspection, property) => {
443
487
  return false;
444
488
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
445
489
  return true;
446
- const validRoles = ['creator', 'self-perform'];
490
+ const validRoles = [
491
+ 'creator',
492
+ 'self-perform-write',
493
+ 'self-perform-read',
494
+ ];
447
495
  if (!validRoles.includes(inspection.role))
448
496
  return false;
449
497
  return true;
@@ -463,7 +511,11 @@ const canShowSyncStatus = (inspection) => {
463
511
  return false;
464
512
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
465
513
  return true;
466
- const validRoles = ['creator', 'self-perform'];
514
+ const validRoles = [
515
+ 'creator',
516
+ 'self-perform-read',
517
+ 'self-perform-write',
518
+ ];
467
519
  if (!validRoles.includes(inspection.role))
468
520
  return false;
469
521
  return true;
@@ -474,7 +526,11 @@ const canShowFlaggedItems = (inspection, flags) => {
474
526
  return false;
475
527
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
476
528
  return true;
477
- const validRoles = ['creator', 'self-perform'];
529
+ const validRoles = [
530
+ 'creator',
531
+ 'self-perform-read',
532
+ 'self-perform-write',
533
+ ];
478
534
  if (!validRoles.includes(inspection.role))
479
535
  return false;
480
536
  return true;
@@ -483,7 +539,11 @@ exports.canShowFlaggedItems = canShowFlaggedItems;
483
539
  const canPerformFeatureActions = (inspection) => {
484
540
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
485
541
  return true;
486
- const validRoles = ['creator', 'self-perform'];
542
+ const validRoles = [
543
+ 'creator',
544
+ 'self-perform-write',
545
+ 'self-perform-read',
546
+ ];
487
547
  if (!validRoles.includes(inspection.role))
488
548
  return false;
489
549
  const validStatuses = [
@@ -510,7 +570,11 @@ const canMakeUnitEdits = (inspection) => {
510
570
  return false;
511
571
  if ((0, inspections_1.userIsInvitedTeammate)(inspection))
512
572
  return true;
513
- const validRoles = ['creator', 'self-perform'];
573
+ const validRoles = [
574
+ 'creator',
575
+ 'self-perform-write',
576
+ 'self-perform-read',
577
+ ];
514
578
  if (!validRoles.includes(inspection.role))
515
579
  return false;
516
580
  return true;
@@ -531,7 +595,7 @@ const canShowViewModeToggle = (inspection) => {
531
595
  };
532
596
  exports.canShowViewModeToggle = canShowViewModeToggle;
533
597
  const canReOpen = (inspection) => {
534
- const selfPerformValidRoles = ['self-perform'];
598
+ const selfPerformValidRoles = ['self-perform-write'];
535
599
  const selfPerformValidStatuses = ['Completed'];
536
600
  if (selfPerformValidRoles.includes(inspection.role) &&
537
601
  selfPerformValidStatuses.includes(inspection.inspection_status)) {
@@ -625,10 +689,23 @@ exports.findConflictingAutomation = findConflictingAutomation;
625
689
  const canShowAIDamage = (inspection) => {
626
690
  if (!inspection)
627
691
  return false;
628
- const validRoles = ['creator', 'self-perform'];
692
+ const validRoles = [
693
+ 'creator',
694
+ 'self-perform-read',
695
+ 'self-perform-write',
696
+ ];
629
697
  return (validRoles.includes(inspection.role) || (0, inspections_1.userIsInvitedTeammate)(inspection));
630
698
  };
631
699
  exports.canShowAIDamage = canShowAIDamage;
700
+ const canShowAIDamageFilterPanel = (inspection, imageMetadata) => {
701
+ if (!(0, exports.canShowAIDamage)(inspection))
702
+ return false;
703
+ return imageMetadata.some((meta) => {
704
+ var _a;
705
+ return ((_a = meta.damage_items) !== null && _a !== void 0 ? _a : []).some((item) => item.damage_type && item.user_feedback !== 'incorrect');
706
+ });
707
+ };
708
+ exports.canShowAIDamageFilterPanel = canShowAIDamageFilterPanel;
632
709
  const canShowFeatureRatingSummary = (inspection) => {
633
710
  const validStatuses = [
634
711
  'Revision Requested',
@@ -0,0 +1,13 @@
1
+ interface PropertyAddressProps {
2
+ address: string;
3
+ city: string;
4
+ zipcode?: string;
5
+ zip_code?: string;
6
+ }
7
+ interface InspectionPropertyAddressProps {
8
+ property_address: string;
9
+ property_city: string;
10
+ property_zipcode: string;
11
+ }
12
+ export declare const formattedAddress: (property?: PropertyAddressProps | InspectionPropertyAddressProps) => string;
13
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formattedAddress = void 0;
4
+ const formattedAddress = (property) => {
5
+ if (!property) {
6
+ return '-';
7
+ }
8
+ const inspectionProperty = property;
9
+ const regularProperty = property;
10
+ if (inspectionProperty.property_address) {
11
+ return `${inspectionProperty.property_address}, ${inspectionProperty.property_city}
12
+ ${inspectionProperty.property_zipcode}`;
13
+ }
14
+ return `${regularProperty.address}, ${regularProperty.city} ${regularProperty.zipcode || regularProperty.zip_code}`;
15
+ };
16
+ exports.formattedAddress = formattedAddress;
@@ -7,3 +7,9 @@
7
7
  * word needs to be provided
8
8
  */
9
9
  export declare const numberAndPluralizedWord: (count: number | Array<unknown>, baseWord: string, pluralWord?: string) => string;
10
+ /**
11
+ * Formats a number as a USD currency string.
12
+ * Returns "$0.00" if value is 0 and `showZeroAsValue` is true,
13
+ * otherwise "-" for falsy values.
14
+ */
15
+ export declare const formatCurrency: (value: number | undefined, showZeroAsValue?: boolean) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.numberAndPluralizedWord = void 0;
3
+ exports.formatCurrency = exports.numberAndPluralizedWord = void 0;
4
4
  /**
5
5
  * Returns a string built using the count provided and appending
6
6
  * the singular or plural form of the original word. For words
@@ -22,3 +22,18 @@ const numberAndPluralizedWord = (count, baseWord, pluralWord) => {
22
22
  return `${count} ${baseWord}s`;
23
23
  };
24
24
  exports.numberAndPluralizedWord = numberAndPluralizedWord;
25
+ /**
26
+ * Formats a number as a USD currency string.
27
+ * Returns "$0.00" if value is 0 and `showZeroAsValue` is true,
28
+ * otherwise "-" for falsy values.
29
+ */
30
+ const formatCurrency = (value, showZeroAsValue) => {
31
+ if (value === 0 && showZeroAsValue) {
32
+ return '$0.00';
33
+ }
34
+ if (!value) {
35
+ return '-';
36
+ }
37
+ return `$${value.toFixed(2)}`;
38
+ };
39
+ exports.formatCurrency = formatCurrency;
@@ -1,3 +1,4 @@
1
+ export * as Address from './address';
1
2
  export * as Dates from './dates';
2
3
  export * as FileRequests from './file-requests';
3
4
  export * as Filters from './filters';
@@ -33,7 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Users = exports.Tenants = exports.Subscriptions = exports.Sections = exports.Rooms = exports.QueryParams = exports.Properties = exports.PermissionGroups = exports.Media = exports.Integrations = exports.Inspections = exports.InspectionTemplates = exports.InspectionFeatures = exports.Imports = exports.Helpers = exports.Flags = exports.Filters = exports.FileRequests = exports.Dates = void 0;
36
+ exports.Users = exports.Tenants = exports.Subscriptions = exports.Sections = exports.Rooms = exports.QueryParams = exports.Properties = exports.PermissionGroups = exports.Media = exports.Integrations = exports.Inspections = exports.InspectionTemplates = exports.InspectionFeatures = exports.Imports = exports.Helpers = exports.Flags = exports.Filters = exports.FileRequests = exports.Dates = exports.Address = void 0;
37
+ exports.Address = __importStar(require("./address"));
37
38
  exports.Dates = __importStar(require("./dates"));
38
39
  exports.FileRequests = __importStar(require("./file-requests"));
39
40
  exports.Filters = __importStar(require("./filters"));
@@ -1,3 +1,4 @@
1
+ import { OfflineFeature } from '@rentcheck/types';
1
2
  /**
2
3
  * Checks if a section can be created multiple times.
3
4
  *
@@ -25,3 +26,4 @@ export declare const addOrdinalToFloor: (number: number) => string;
25
26
  * @returns the updated section name, e.g. "First Floor", "Second Bedroom"
26
27
  */
27
28
  export declare const addOrdinal: (sectionName: string, number: number) => string;
29
+ export declare const areEqualSections: (s1: OfflineFeature["section"], s2: OfflineFeature["section"]) => boolean;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.addOrdinal = exports.addOrdinalToFloor = exports.isFloor = exports.isBedroomOrBathroom = exports.isBedroom = exports.isBathroom = exports.isHalfBathroom = exports.isFullBathroom = exports.canExistMultipleTimes = void 0;
36
+ exports.areEqualSections = exports.addOrdinal = exports.addOrdinalToFloor = exports.isFloor = exports.isBedroomOrBathroom = exports.isBedroom = exports.isBathroom = exports.isHalfBathroom = exports.isFullBathroom = exports.canExistMultipleTimes = void 0;
37
37
  const Constants = __importStar(require("../../constants"));
38
38
  /**
39
39
  * Checks if a section can be created multiple times.
@@ -101,3 +101,9 @@ const addOrdinal = (sectionName, number) => {
101
101
  return `${Constants.Rooms.ordinalPrefixes[number]} ${sectionName}`;
102
102
  };
103
103
  exports.addOrdinal = addOrdinal;
104
+ const areEqualSections = (s1, s2) => {
105
+ return (s1.name === s2.name &&
106
+ s1.name_with_ordinal === s2.name_with_ordinal &&
107
+ s1.type === s2.type);
108
+ };
109
+ exports.areEqualSections = areEqualSections;
@@ -32,6 +32,10 @@ const isOnEssentialsPlan = (subscription) => {
32
32
  }
33
33
  planId = subscription.plan.plan_id;
34
34
  }
35
+ else if ('virtual_chargebee_plan' in subscription) {
36
+ // We have a Virtual Trial from firebase
37
+ planId = subscription.chargebee.plan_id;
38
+ }
35
39
  else if ('chargebee' in subscription) {
36
40
  // We have a Subscription from firebase
37
41
  planId = subscription.chargebee.plan_id;
@@ -51,6 +55,10 @@ const isOnProPlan = (subscription) => {
51
55
  }
52
56
  planId = subscription.plan.plan_id;
53
57
  }
58
+ else if ('virtual_chargebee_plan' in subscription) {
59
+ // We have a Virtual Trial from firebase
60
+ planId = subscription.virtual_chargebee_plan.plan_id;
61
+ }
54
62
  else if ('chargebee' in subscription) {
55
63
  // We have a Subscription from firebase
56
64
  planId = subscription.chargebee.plan_id;
@@ -29,7 +29,7 @@ function isSystem(userOrType) {
29
29
  return checkValue(userOrType, ['System']);
30
30
  }
31
31
  const canPerformInspection = (inspection) => {
32
- return ['self-perform', 'invitee-write'].includes(inspection.role);
32
+ return ['self-perform-write', 'invitee-write'].includes(inspection.role);
33
33
  };
34
34
  exports.canPerformInspection = canPerformInspection;
35
35
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rentcheck/biz",
3
- "version": "1.0.237",
3
+ "version": "1.0.239",
4
4
  "description": "RC biz",
5
5
  "author": "engineering@getrentcheck.com",
6
6
  "license": "MIT",
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  AccountSettings,
3
+ ApiInspection,
3
4
  ApiSubscription,
5
+ ApiUser,
4
6
  Inspection,
5
7
  InspectionEdit,
6
8
  InspectionEdited,
@@ -183,3 +185,12 @@ export const canEdit = ({ changeset }: CanEditParams): RulesResult => {
183
185
 
184
186
  return { value: true };
185
187
  };
188
+
189
+ type CanCreateFlagsParams = {
190
+ inspection: ApiInspection;
191
+ user: ApiUser;
192
+ };
193
+
194
+ export const canCreateFlags = ({ user }: CanCreateFlagsParams): boolean => {
195
+ return !Utils.Users.isRenter(user);
196
+ };
@@ -7,17 +7,17 @@ import {
7
7
  } from '@rentcheck/types';
8
8
  import * as Utils from '../../utils';
9
9
 
10
- export const anAnswerRequiresPhoto = (feature: Feature) => {
10
+ export const anAnswerRequiresMedia = (feature: Feature) => {
11
11
  return feature.questions.some((q, idx) => {
12
12
  const responsesForQuestion =
13
13
  feature.responses[idx]?.split(MULTIPLE_CHOICE_RESPONSE_SEPARATOR) ?? '';
14
14
 
15
- const answersThatRequireNotes = q.answers
15
+ const answersThatRequireMedia = q.answers
16
16
  ?.filter((a) => a.requires_photo)
17
17
  .map((a) => a.title);
18
18
 
19
19
  if (
20
- _.intersection(responsesForQuestion, answersThatRequireNotes).length === 0
20
+ _.intersection(responsesForQuestion, answersThatRequireMedia).length === 0
21
21
  ) {
22
22
  return false;
23
23
  }