Skip to content

Commit 4296566

Browse files
committed
fix update user data and settings
1 parent 65b9b42 commit 4296566

15 files changed

Lines changed: 229 additions & 125 deletions

lib/app/data/models/profile_dto.dart

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,74 @@ class ProfileDto {
1616
final bool interestFemales;
1717
final bool interestOtherGenres;
1818
final List<MemoryImage> images;
19+
final bool enableMessageNotification;
20+
final bool enableMatchNotification;
21+
final int referredFriendMinAge;
22+
final int referredFriendMaxAge;
1923

20-
ProfileDto(
21-
{this.interestMales,
22-
this.interestFemales,
23-
this.interestOtherGenres,
24-
this.city,
25-
this.activityState,
26-
this.latLng,
27-
this.refferedFriendMaxDistance,
28-
this.profile_description,
29-
this.music_genre_ids,
30-
this.music_skill_id,
31-
this.function,
32-
this.birthdate_date,
33-
this.gender,
34-
this.images});
24+
ProfileDto({
25+
this.interestMales,
26+
this.interestFemales,
27+
this.interestOtherGenres,
28+
this.city,
29+
this.activityState,
30+
this.latLng,
31+
this.refferedFriendMaxDistance,
32+
this.profile_description,
33+
this.music_genre_ids,
34+
this.music_skill_id,
35+
this.function,
36+
this.birthdate_date,
37+
this.gender,
38+
this.images,
39+
this.enableMessageNotification,
40+
this.enableMatchNotification,
41+
this.referredFriendMinAge,
42+
this.referredFriendMaxAge,
43+
});
3544

3645
factory ProfileDto.fromJson(Map<String, dynamic> json) {
3746
return ProfileDto(
38-
birthdate_date:
39-
json['birthdate_date'] is! bool ? json['birthdate_date'] : null,
40-
function: json['function'] is! bool ? json['function'] : null,
41-
gender: json['gender'] is! bool ? json['gender'] : null,
42-
music_genre_ids: json['music_genre_ids'] is! bool
43-
? List<int>.from(json['music_genre_ids'])
44-
: null,
45-
music_skill_id:
46-
json['music_skill_id'] is! bool ? json['music_skill_id'][0] : null,
47-
profile_description: json['profile_description'] is! bool
48-
? json['profile_description']
49-
: null,
50-
refferedFriendMaxDistance: json['referred_friend_max_distance'] is! bool
51-
? json['referred_friend_max_distance']
52-
: 0,
53-
city: json["city"] is! bool ? json["city"] : "N/A",
54-
activityState:
55-
json["activity_state"] is! bool ? json["activity_state"] : "N/A",
56-
latLng: json["partner_current_latitude"] is! bool &&
57-
json["partner_current_longitude"] is! bool
58-
? LatLng(
59-
json["partner_current_latitude"],
60-
json["partner_current_longitude"],
61-
)
62-
: null,
63-
interestFemales: json["interest_female_gender"],
64-
interestMales: json["interest_male_gender"],
65-
interestOtherGenres: json["interest_other_genres"],
66-
images: json["images"].map<MemoryImage>((e) => MemoryImage.fromJson(e)).toList());
47+
birthdate_date: json['birthdate_date'] is! bool
48+
? DateTime.parse(json['birthdate_date'])
49+
: null,
50+
function: json['function'] is! bool ? json['function'] : null,
51+
gender: json['gender'] is! bool ? json['gender'] : null,
52+
music_genre_ids: json['music_genre_ids'] is! bool
53+
? List<int>.from(json['music_genre_ids'])
54+
: null,
55+
music_skill_id:
56+
json['music_skill_id'] is! bool ? json['music_skill_id'][0] : null,
57+
profile_description: json['profile_description'] is! bool
58+
? json['profile_description']
59+
: null,
60+
refferedFriendMaxDistance: json['referred_friend_max_distance'] is! bool
61+
? json['referred_friend_max_distance']
62+
: 0,
63+
city: json["city"] is! bool ? json["city"] : "N/A",
64+
activityState:
65+
json["activity_state"] is! bool ? json["activity_state"] : "N/A",
66+
latLng: json["partner_current_latitude"] is! bool &&
67+
json["partner_current_longitude"] is! bool
68+
? LatLng(
69+
json["partner_current_latitude"],
70+
json["partner_current_longitude"],
71+
)
72+
: null,
73+
interestFemales: json["interest_female_gender"],
74+
interestMales: json["interest_male_gender"],
75+
interestOtherGenres: json["interest_other_genres"],
76+
images: json["images"]
77+
?.map<MemoryImage>((e) => MemoryImage.fromJson(e))
78+
?.toList(),
79+
enableMatchNotification: json["enable_match_notification"],
80+
enableMessageNotification: json["enable_message_notification"],
81+
referredFriendMaxAge: json["referred_friend_max_age"] is! bool
82+
? json["referred_friend_max_age"]
83+
: null,
84+
referredFriendMinAge: json["referred_friend_min_age"] is! bool
85+
? json["referred_friend_min_age"]
86+
: null,
87+
);
6788
}
6889
}

lib/app/data/models/update_profile_dto.dart

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@ class UpdateProfileDto {
1010
final bool interestMaleGender;
1111
final bool interestFemaleGender;
1212
final bool interestOtherGenres;
13+
final bool enableMessageNotification;
14+
final bool enableMatchNotification;
15+
final int referredFriendMinAge;
16+
final int referredFriendMaxAge;
1317

14-
UpdateProfileDto({
15-
this.interestMaleGender,
16-
this.interestFemaleGender,
17-
this.interestOtherGenres,
18-
this.refferedFriendMaxDistance,
19-
this.profile_description,
20-
this.music_genre_ids,
21-
this.music_skill_id,
22-
this.function,
23-
this.birthdate_date,
24-
this.gender,
25-
this.partnerId,
26-
});
18+
UpdateProfileDto(
19+
{this.interestMaleGender,
20+
this.interestFemaleGender,
21+
this.interestOtherGenres,
22+
this.refferedFriendMaxDistance,
23+
this.profile_description,
24+
this.music_genre_ids,
25+
this.music_skill_id,
26+
this.function,
27+
this.birthdate_date,
28+
this.gender,
29+
this.partnerId,
30+
this.enableMessageNotification,
31+
this.enableMatchNotification,
32+
this.referredFriendMinAge,
33+
this.referredFriendMaxAge});
2734

2835
Map<String, dynamic> toJson() => {
2936
if (refferedFriendMaxDistance != null)
30-
'reffered_friend_max_distance': refferedFriendMaxDistance,
37+
'referred_friend_max_distance': refferedFriendMaxDistance,
3138
if (interestMaleGender != null)
3239
'interest_male_gender': interestMaleGender,
3340
if (interestFemaleGender != null)
@@ -36,10 +43,21 @@ class UpdateProfileDto {
3643
'interest_other_genres': interestOtherGenres,
3744
if (profile_description != null)
3845
'profile_description': profile_description,
39-
if (music_genre_ids != null) 'music_genre_ids': music_genre_ids,
46+
if (music_genre_ids != null)
47+
'music_genre_ids': [
48+
[6, 0, music_genre_ids]
49+
],
4050
if (music_skill_id != null) 'music_skill_id': music_skill_id,
4151
if (function != null) 'function': function,
42-
if (birthdate_date != null) 'birthdate_date': birthdate_date,
43-
if (gender != null) 'gender': gender
52+
if (birthdate_date != null) 'birthdate_date': birthdate_date.toString(),
53+
if (gender != null) 'gender': gender,
54+
if (enableMessageNotification != null)
55+
'enable_message_notification': enableMessageNotification,
56+
if (enableMatchNotification != null)
57+
'enable_match_notification': enableMatchNotification,
58+
if (referredFriendMinAge != null)
59+
'referred_friend_min_age': referredFriendMinAge,
60+
if (referredFriendMaxAge != null)
61+
'referred_friend_max_age': referredFriendMaxAge,
4462
};
4563
}

lib/app/data/pojo/partners.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ class Partner {
2424
name = json["name"];
2525
birthdate =
2626
json["birthdate_date"] is! bool && json["birthdate_date"] != null
27-
? DateTime.parse(json["birthdate"])
27+
? DateTime.parse(json["birthdate_date"])
2828
: null;
29+
2930
imageUrl =
3031
'https://assets.b9.com.br/wp-content/uploads/2020/09/Batman-issue86-heder-1280x677.jpg';
3132

lib/app/data/services/login_facade_impl.dart

Lines changed: 70 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ class LoginFacadeImpl implements LoginFacade {
4141
sessionId: userData.sessionId,
4242
uid: userData.uid,
4343
userCompanies: userData.userCompanies,
44-
webBaseUrl: userData.webBaseUrl);
44+
webBaseUrl: userData.webBaseUrl,
45+
enableMatchNotification: userProfile.enableMatchNotification,
46+
enableMessageNotification: userProfile.enableMessageNotification,
47+
referredFriendMaxAge: userProfile.referredFriendMaxAge,
48+
referredFriendMinAge: userProfile.referredFriendMinAge
49+
50+
);
4551
final musicSkills = await _musicSkillService.findAll();
4652
final musicGenres = await _musicGenreService.findAll();
4753

@@ -70,28 +76,37 @@ class UserProfile {
7076
final bool interestFemales;
7177
final bool interestOtherGenres;
7278
final int refferedMaxFriendDistance;
79+
final bool enableMessageNotification;
80+
final bool enableMatchNotification;
81+
final int referredFriendMinAge;
82+
final int referredFriendMaxAge;
7383

74-
UserProfile(
75-
{this.interestMales,
76-
this.interestFemales,
77-
this.interestOtherGenres,
78-
this.refferedMaxFriendDistance,
79-
this.name,
80-
this.sessionId,
81-
this.uid,
82-
this.isAdmin,
83-
this.partnerDisplayName,
84-
this.companyId,
85-
this.partnerId,
86-
this.userCompanies,
87-
this.webBaseUrl,
88-
this.odoobotInitialized,
89-
this.profile_description,
90-
this.music_genre_ids,
91-
this.music_skill_id,
92-
this.function,
93-
this.birthdate_date,
94-
this.gender});
84+
UserProfile({
85+
this.interestMales,
86+
this.interestFemales,
87+
this.interestOtherGenres,
88+
this.refferedMaxFriendDistance,
89+
this.name,
90+
this.sessionId,
91+
this.uid,
92+
this.isAdmin,
93+
this.partnerDisplayName,
94+
this.companyId,
95+
this.partnerId,
96+
this.userCompanies,
97+
this.webBaseUrl,
98+
this.odoobotInitialized,
99+
this.profile_description,
100+
this.music_genre_ids,
101+
this.music_skill_id,
102+
this.function,
103+
this.birthdate_date,
104+
this.gender,
105+
this.enableMatchNotification,
106+
this.enableMessageNotification,
107+
this.referredFriendMinAge,
108+
this.referredFriendMaxAge,
109+
});
95110

96111
UserProfile copyWith({
97112
String sessionId,
@@ -114,29 +129,40 @@ class UserProfile {
114129
bool interestFemales,
115130
bool interestOtherGenres,
116131
int refferedMaxFriendDistance,
132+
bool enableMessageNotification,
133+
bool enableMatchNotification,
134+
int referredFriendMinAge,
135+
int referredFriendMaxAge,
117136
}) {
118137
return UserProfile(
119-
sessionId: sessionId ?? this.sessionId,
120-
uid: uid ?? this.uid,
121-
isAdmin: isAdmin ?? this.isAdmin,
122-
partnerDisplayName: partnerDisplayName ?? this.partnerDisplayName,
123-
companyId: companyId ?? this.companyId,
124-
partnerId: partnerId ?? this.partnerId,
125-
userCompanies: userCompanies ?? this.userCompanies,
126-
webBaseUrl: webBaseUrl ?? this.webBaseUrl,
127-
odoobotInitialized: odoobotInitialized ?? this.odoobotInitialized,
128-
profile_description: profile_description ?? this.profile_description,
129-
music_genre_ids: music_genre_ids ?? this.music_genre_ids,
130-
music_skill_id: music_skill_id ?? this.music_skill_id,
131-
function: function ?? this.function,
132-
birthdate_date: birthdate_date ?? this.birthdate_date,
133-
gender: gender ?? this.gender,
134-
name: name ?? this.name,
135-
interestMales: interestMales ?? this.interestMales,
136-
interestFemales: interestFemales ?? this.interestFemales,
137-
interestOtherGenres: interestOtherGenres ?? this.interestOtherGenres,
138-
refferedMaxFriendDistance:
139-
refferedMaxFriendDistance ?? this.refferedMaxFriendDistance,
140-
);
138+
sessionId: sessionId ?? this.sessionId,
139+
uid: uid ?? this.uid,
140+
isAdmin: isAdmin ?? this.isAdmin,
141+
partnerDisplayName: partnerDisplayName ?? this.partnerDisplayName,
142+
companyId: companyId ?? this.companyId,
143+
partnerId: partnerId ?? this.partnerId,
144+
userCompanies: userCompanies ?? this.userCompanies,
145+
webBaseUrl: webBaseUrl ?? this.webBaseUrl,
146+
odoobotInitialized: odoobotInitialized ?? this.odoobotInitialized,
147+
profile_description: profile_description ?? this.profile_description,
148+
music_genre_ids: music_genre_ids ?? this.music_genre_ids,
149+
music_skill_id: music_skill_id ?? this.music_skill_id,
150+
function: function ?? this.function,
151+
birthdate_date: birthdate_date ?? this.birthdate_date,
152+
gender: gender ?? this.gender,
153+
name: name ?? this.name,
154+
interestMales: interestMales ?? this.interestMales,
155+
interestFemales: interestFemales ?? this.interestFemales,
156+
interestOtherGenres: interestOtherGenres ?? this.interestOtherGenres,
157+
refferedMaxFriendDistance:
158+
refferedMaxFriendDistance ?? this.refferedMaxFriendDistance,
159+
enableMatchNotification:
160+
enableMatchNotification ?? this.enableMatchNotification,
161+
enableMessageNotification:
162+
enableMessageNotification ?? this.enableMessageNotification,
163+
referredFriendMaxAge:
164+
referredFriendMaxAge ?? this.referredFriendMaxAge,
165+
referredFriendMinAge:
166+
referredFriendMinAge ?? this.referredFriendMinAge);
141167
}
142168
}

lib/app/data/services/partner_service_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class PartnerServiceImpl implements PartnerService {
1414
Future<List<Partner>> finAll() async {
1515
final response = await _odoo.searchRead('res.partner', [], [
1616
'name',
17-
'birthdate_date'
18-
'partner_current_latitude',
17+
'birthdate_date',
18+
'partner_current_latitude',
1919
'partner_current_longitude',
2020
]);
2121
final items =

lib/app/data/services/relation_service_impl.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ class RelationServiceImpl implements RelationService {
2525
'id',
2626
'name'
2727
]);
28+
2829
final relationTypeId = relationTypeResponse.getRecords()[0]["id"];
2930

3031
final createRelationResponse = await _odoo.create('res.partner.relation', {
3132
'left_partner_id': deslikeDto.currentUserPartnerId,
3233
'right_partner_id': deslikeDto.friendPartnerId,
3334
'type_id': relationTypeId,
3435
});
36+
print(createRelationResponse);
3537
}
3638

3739
@override

lib/app/data/services/user_service_impl.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ class UserServiceImpl implements UserService {
3939
'partner_current_longitude',
4040
'interest_male_gender',
4141
'interest_female_gender',
42-
'interest_other_genres'
42+
"interest_other_genres",
43+
'referred_friend_min_age',
44+
'referred_friend_max_age',
45+
'enable_message_notification',
46+
'enable_match_notification'
4347
]);
4448

4549
final photosResponse = await _odoo.searchRead('res.partner.image', [

0 commit comments

Comments
 (0)