Skip to content

Commit

Permalink
Merge pull request #124 from fga-eps-mds/feat#67/subscribed_journey
Browse files Browse the repository at this point in the history
[FEAT] adiciona requisição subscribed_journey (fga-eps-mds/2024.2-ARANDU-DOC#67)
  • Loading branch information
GabrielCostaDeOliveira authored Feb 10, 2025
2 parents 4f119e2 + 571327a commit f079752
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/ui/journey/service/journey_service.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:aranduapp/core/log/log.dart';
import 'package:aranduapp/core/network/auth_api.dart';
import 'package:aranduapp/core/network/studio_maker_api.dart';
import 'package:aranduapp/core/network/token_manager/repository/auth_repository.dart';
import 'package:aranduapp/ui/journey/model/journey_request.dart';
import 'package:aranduapp/ui/journey/model/journey_model.dart';
import 'package:dio/dio.dart';
Expand All @@ -24,4 +26,12 @@ class JourneyService {

return res;
}

Future<void> subscribedJourney(String journeyId) async {
var userId = (await AuthRepository().getUser()).id;

await AuthApi.getInstance(auth: true).post(path:'/users/$userId/subscribe/$journeyId');


}
}
1 change: 1 addition & 0 deletions lib/ui/journey/view/journey_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class _JourneyScreen extends StatelessWidget {
size: 32,
),
onTap: () {
viewModel.subscribedJourney(journey.id);
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => Trails(journey: journey),
Expand Down
10 changes: 10 additions & 0 deletions lib/ui/journey/viewmodel/journey_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ import 'package:get_it/get_it.dart';

class JourneyViewModel extends ChangeNotifier {
late Command1<List<JourneyModel>, String> getJourneyCommand;
late Command1<void, String> subscribedJourneyCommand;

bool _isReloadingData = false;

JourneyViewModel() {
getJourneyCommand = Command1(getJourney);

subscribedJourneyCommand = Command1(subscribedJourney);
}

bool get isReloadingData => _isReloadingData;

Future<Result<void>> subscribedJourney(String journeyId) async {
await GetIt.instance<JourneyService>().subscribedJourney(journeyId);

return Result.value(null);
}

Future<Result<List<JourneyModel>>> getJourney(String subjectId) async {
_isReloadingData = true;
notifyListeners();
Expand Down

0 comments on commit f079752

Please sign in to comment.