getUserProfile method
Get user profile
Implementation
Future<Map<String, dynamic>> getUserProfile({
required String userId,
required String tenantId,
}) async {
const query = r'''
query GetTenantUser($id: UUID!, $tenantID: UUID!) {
tenantUser(id: $id, tenantID: $tenantID) {
success
message
tenantUser {
id
tenantID
username
email
firstName
lastName
phoneNumber
language
location
profile_Photo
image
video
createdAt
updatedAt
tenant {
id
name
}
}
}
}
''';
try {
final res = await _api.graphql(query, {
'id': userId,
'tenantID': tenantId,
});
final data = res['tenantUser'];
if (data == null) {
return {
'success': false,
'message': 'No data returned from server',
};
}
return Map<String, dynamic>.from(data);
} catch (e) {
print("ERROR fetching user profile: $e");
return {
'success': false,
'message': 'Failed to fetch user profile: $e',
};
}
}