Skip to content

Commit 4fab506

Browse files
asithadeclaude
andcommitted
fix(profile): cleanup type improvements and comments
LFXV2-633 LFXV2-636 LFXV2-637 - Remove outdated field mapping comments from profile-edit component - Add proper type imports for ProfileUpdateRequest and UserMetadata - Fix error message accuracy (Username vs User ID) - Replace any type with proper UserMetadata type in validation 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Asitha de Silva <asithade@gmail.com>
1 parent c0e2bdd commit 4fab506

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

apps/lfx-one/src/app/modules/profile/edit/profile-edit.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,9 @@ export class ProfileEditComponent implements OnInit {
221221
const countryValue = profile.profile?.country || '';
222222

223223
this.profileForm.patchValue({
224-
// User fields - map from old backend response to new form field names
225224
given_name: profile.user.first_name || '',
226225
family_name: profile.user.last_name || '',
227226
username: profile.user.username || '',
228-
229-
// Profile fields - map from old backend response to new form field names
230227
job_title: profile.profile?.job_title || '',
231228
organization: profile.profile?.organization || '',
232229
country: countryValue,

apps/lfx-one/src/server/controllers/profile.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The Linux Foundation and each contributor to LFX.
22
// SPDX-License-Identifier: MIT
33

4-
import { AddEmailRequest, CombinedProfile, UpdateEmailPreferencesRequest, UserMetadataUpdateRequest } from '@lfx-one/shared/interfaces';
4+
import { AddEmailRequest, CombinedProfile, ProfileUpdateRequest, UpdateEmailPreferencesRequest, UserMetadataUpdateRequest } from '@lfx-one/shared/interfaces';
55
import { NextFunction, Request, Response } from 'express';
66

77
import { AuthenticationError, AuthorizationError, MicroserviceError, ResourceNotFoundError, ServiceValidationError } from '../errors';
@@ -123,7 +123,7 @@ export class ProfileController {
123123
}
124124

125125
// Extract and validate request body
126-
const { user_metadata } = req.body;
126+
const { user_metadata }: ProfileUpdateRequest = req.body;
127127

128128
// Validate at least one field to update is provided
129129
if (!user_metadata) {

apps/lfx-one/src/server/services/user.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { NATS_CONFIG } from '@lfx-one/shared/constants';
55
import { NatsSubjects } from '@lfx-one/shared/enums';
6-
import { UserMetadataUpdateRequest, UserMetadataUpdateResponse } from '@lfx-one/shared/interfaces';
6+
import { UserMetadata, UserMetadataUpdateRequest, UserMetadataUpdateResponse } from '@lfx-one/shared/interfaces';
77
import { Request } from 'express';
88

99
import { serverLogger } from '../server';
@@ -22,16 +22,14 @@ export class UserService {
2222
/**
2323
* Update user metadata through NATS
2424
* @param req - Express request object
25-
* @param userId - The user ID to update
2625
* @param updates - The user metadata updates
27-
* @param token - Authentication token
2826
* @returns Promise with the update response
2927
*/
3028
public async updateUserMetadata(req: Request, updates: UserMetadataUpdateRequest): Promise<UserMetadataUpdateResponse> {
3129
try {
3230
// Validate required fields
3331
if (!updates.username) {
34-
throw new Error('User ID is required');
32+
throw new Error('Username is required');
3533
}
3634

3735
if (!updates.token) {
@@ -96,7 +94,7 @@ export class UserService {
9694
* @param metadata - The user metadata to validate
9795
* @returns true if valid, throws error if invalid
9896
*/
99-
public validateUserMetadata(metadata: any): boolean {
97+
public validateUserMetadata(metadata: UserMetadata): boolean {
10098
// Validate t-shirt size if provided
10199
if (metadata?.t_shirt_size) {
102100
const validSizes = ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'];

0 commit comments

Comments
 (0)