Fix all features

This commit is contained in:
2024-07-30 02:15:04 +09:00
parent 9c98d3ed53
commit 3d7a5ae0c1
11 changed files with 268 additions and 69 deletions

View File

@ -466,6 +466,43 @@ class ApiService extends GetxService{
}
}
Future<void> updateUserInfo(int userId, Entry entry) async {
init();
getToken();
final entryId = entry.id;
DateTime? date = entry.date;
String? formattedDate;
if (date != null) {
formattedDate = DateFormat('yyyy-MM-dd').format(date);
}
final response = await http.put(
Uri.parse('$baseUrl/userinfo/$userId/'),
headers: {
'Authorization': 'Token $token',
'Content-Type': 'application/json; charset=UTF-8',
},
body: json.encode({
'zekken_number': entry.team.zekkenNumber,
'event_code': entry.event.eventName,
'group': entry.team.category.categoryName,
'team_name': entry.team.teamName,
'date': formattedDate,
}),
);
if (response.statusCode == 200) {
final decodedResponse = utf8.decode(response.bodyBytes);
final updatedUserInfo = json.decode(decodedResponse);
//Get.find<IndexController>().updateUserInfo(updatedUserInfo);
} else {
throw Exception('Failed to update entry');
}
}
Future<Entry> updateEntry(int entryId, int eventId, int categoryId, DateTime date) async {
init();
getToken();