-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enum for familyname and api base route
- Loading branch information
Showing
4 changed files
with
13 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enum FamilyName { snap, deb } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,17 @@ | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
import '../models/artefact.dart'; | ||
import '../models/family_name.dart'; | ||
import '../models/stage.dart'; | ||
import 'dio.dart'; | ||
|
||
part 'stages.g.dart'; | ||
|
||
@riverpod | ||
Future<List<Stage>> stages(StagesRef ref, String familyName) async { | ||
// final dio = ref.watch(dioProvider); | ||
Future<List<Stage>> stages(StagesRef ref, FamilyName familyName) async { | ||
final dio = ref.watch(dioProvider); | ||
|
||
// final response = await dio.get('/family/$familyName/stages'); | ||
// final List stagesJson = response.data; | ||
// final stages = stagesJson.map((json) => Stage.fromJson(json)).toList(); | ||
// return stages; | ||
|
||
if (familyName != 'snap') { | ||
throw Exception('Invalid familyName "$familyName"'); | ||
} | ||
|
||
return Future.delayed( | ||
const Duration(seconds: 2), | ||
() => const [ | ||
Stage( | ||
name: 'Stage 1', | ||
artefacts: [ | ||
Artefact(name: 'Artefact 1'), | ||
Artefact(name: 'Artefact 2'), | ||
Artefact(name: 'Artefact 3'), | ||
Artefact(name: 'Artefact 4'), | ||
], | ||
), | ||
Stage( | ||
name: 'Stage 2', | ||
artefacts: [ | ||
Artefact(name: 'Artefact 11'), | ||
Artefact(name: 'Artefact 12'), | ||
], | ||
), | ||
Stage( | ||
name: 'Stage 3', | ||
artefacts: [ | ||
Artefact(name: 'Artefact 21'), | ||
Artefact(name: 'Artefact 22'), | ||
Artefact(name: 'Artefact 23'), | ||
Artefact(name: 'Artefact 24'), | ||
Artefact(name: 'Artefact 24'), | ||
], | ||
), | ||
Stage( | ||
name: 'Stage 4', | ||
artefacts: [], | ||
), | ||
], | ||
); | ||
final response = await dio.get('/families/${familyName.name}'); | ||
final List stagesJson = response.data; | ||
final stages = stagesJson.map((json) => Stage.fromJson(json)).toList(); | ||
return stages; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters