-
Notifications
You must be signed in to change notification settings - Fork 1
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
dialog-subscription #152
dialog-subscription #152
Conversation
WalkthroughThe pull request introduces a building subscription feature. A new click event in the enterprise buildings component triggers a method that opens a subscription dialog. A dedicated modal component, along with accompanying TypeScript logic and HTML template, is implemented to handle user input for subscription details. Additionally, a new Changes
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🧹 Nitpick comments (5)
sep490-frontend/src/app/modules/enterprise/models/enterprise.dto.ts (1)
26-30
: LGTM! Consider adding JSDoc comments.The
Subscription
interface is well-structured with appropriate field types. Consider adding JSDoc comments to document the purpose of each field and any constraints (e.g., valid ranges for numbers).+/** + * Represents a building subscription. + */ export interface Subscription extends BaseDTO { + /** Number of months for the subscription (must be positive) */ numberOfMonths: number; + /** Maximum number of devices allowed (must be positive) */ numberOfDevices: number; + /** UUID of the associated building */ idBuilding: UUID; }sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html (1)
9-13
: Replace hardcoded avatar URL with a configurable value.The avatar image URL is hardcoded, which is not maintainable. Consider moving it to a configuration file or service.
sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.ts (1)
93-95
: Add error handling to dialog opening.The
showDialog
method should handle potential errors when opening the dialog. Also, consider making the building parameter non-nullable for type safety.-showDialog(building: Building): void { +showDialog(building: Building): void { + try { this.subscriptionDialog.openDialog(building); + } catch (error) { + console.error('Failed to open subscription dialog:', error); + // Handle error appropriately + } }sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts (2)
32-44
: Enhance form structure with type safety and comprehensive validation.The form structure could be improved with:
- Type-safe form controls using TypeScript's strict typing
- More comprehensive validation rules
- Custom error messages for validation failures
Consider applying these improvements:
protected readonly formStructure = { - id: new FormControl(''), - version: new FormControl(null), + id: new FormControl<string>(''), + version: new FormControl<number | null>(null), numberOfMonths: new FormControl(0, { nonNullable: true, - validators: [Validators.min(1), Validators.max(100), Validators.required] + validators: [ + Validators.min(1), + Validators.max(100), + Validators.required, + Validators.pattern(/^\d+$/) + ] }), numberOfDevices: new FormControl(0, { nonNullable: true, - validators: [Validators.min(100), Validators.required] + validators: [ + Validators.min(100), + Validators.required, + Validators.pattern(/^\d+$/) + ] }), - idBuilding: new FormControl('') + idBuilding: new FormControl<string>('', [Validators.required]) };Add validation error messages in the template:
getErrorMessage(controlName: string): string { const control = this.formGroup.get(controlName); if (!control?.errors) return ''; if (control.errors['required']) return 'This field is required'; if (control.errors['min']) return `Minimum value is ${control.errors['min'].min}`; if (control.errors['max']) return `Maximum value is ${control.errors['max'].max}`; if (control.errors['pattern']) return 'Please enter a valid number'; return 'Invalid value'; }
45-56
: Maintain consistency in service declarations.Some services are marked as readonly while others aren't. Consider applying readonly consistently to all injected services for better immutability guarantees.
constructor( - httpClient: HttpClient, - formBuilder: FormBuilder, - notificationService: MessageService, + private readonly httpClient: HttpClient, + private readonly formBuilder: FormBuilder, + private readonly notificationService: MessageService, private readonly buildingService: BuildingService, private readonly walletService: WalletService, - translate: TranslateService, + private readonly translate: TranslateService, private readonly router: Router, private readonly activatedRoute: ActivatedRoute ) { super(httpClient, formBuilder, notificationService, translate); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.html
(2 hunks)sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.ts
(4 hunks)sep490-frontend/src/app/modules/enterprise/models/enterprise.dto.ts
(2 hunks)sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html
(1 hunks)sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts
(1 hunks)sep490-frontend/src/app/modules/shared/shared.module.ts
(3 hunks)sep490-frontend/src/app/services/building.service.ts
(1 hunks)sep490-frontend/src/assets/i18n/en.json
(1 hunks)sep490-frontend/src/assets/i18n/vi.json
(1 hunks)sep490-frontend/src/assets/i18n/zh.json
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- sep490-frontend/src/app/services/building.service.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build Java Modules (sep490-enterprise)
🔇 Additional comments (6)
sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.html (1)
130-131
: LGTM! Clean integration of subscription dialog.The subscription dialog is well-integrated into the building component template. The click handler and dialog component are properly implemented.
Also applies to: 139-141
sep490-frontend/src/app/modules/shared/shared.module.ts (2)
102-103
: LGTM! Component properly declared and exported.The BuildingSubcriptionDialogComponent is correctly declared and exported in the SharedModule.
Also applies to: 116-117
105-105
: LGTM! PrimeNG modules properly imported.The InputNumber and Checkbox modules are correctly imported and added to the module's imports array.
sep490-frontend/src/assets/i18n/en.json (1)
237-257
: LGTM! Well-structured i18n translations.The subscription dialog translations are:
- Well-organized with clear sections (header, body, footer)
- Using consistent naming conventions
- Properly implementing dynamic placeholders
sep490-frontend/src/assets/i18n/vi.json (1)
237-257
: LGTM! Consistent Vietnamese translations.The Vietnamese translations for the subscription dialog:
- Match the structure of the English translations
- Maintain proper placeholder usage
- Use culturally appropriate language
sep490-frontend/src/assets/i18n/zh.json (1)
237-257
: LGTM! Consistent Chinese translations.The Chinese translations for the subscription dialog:
- Match the structure of other language files
- Maintain proper placeholder usage
- Use appropriate Chinese characters and terminology
...red/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html
Outdated
Show resolved
Hide resolved
...red/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html
Show resolved
Hide resolved
...hared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts
Show resolved
Hide resolved
...hared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts
Show resolved
Hide resolved
...hared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts
Outdated
Show resolved
Hide resolved
sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.html
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html (1)
100-110
: Add null checks for form control values.The string interpolation could fail if form controls are null. Use the nullish coalescing operator or safe navigation operator.
- numberOfMonths: formGroup.get("numberOfMonths")?.value, - numberOfDevices: formGroup.get("numberOfDevices")?.value, + numberOfMonths: formGroup.get("numberOfMonths")?.value ?? 0, + numberOfDevices: formGroup.get("numberOfDevices")?.value ?? 0,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.html
(1 hunks)sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.ts
(4 hunks)sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html
(1 hunks)sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- sep490-frontend/src/app/modules/enterprise/components/buildings/buildings.component.html
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build Java Modules (sep490-enterprise)
🔇 Additional comments (3)
sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.html (1)
42-59
: Add min/max validation for number inputs.The number inputs lack constraints. Add min/max validation to prevent invalid values.
Also applies to: 70-87
sep490-frontend/src/app/modules/shared/components/dialog/building-subcription-dialog/building-subcription-dialog.component.ts (2)
16-21
: Fix typo in component name and selector.The component name contains a typo: "Subcription" should be "Subscription".
58-68
: Implement required abstract methods.The abstract methods are incomplete and need proper implementation.
Summary by CodeRabbit