Skip to content

Commit

Permalink
Adapt to changes to the TOSTI api (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeD1rk authored Apr 26, 2023
1 parent 22c8adc commit 313bf4e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/tosti/blocs/home_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TostiHomeCubit extends Cubit<TostiHomeState> {

final venues = venuesResponse.results.map((final venue) {
final shift = shiftsResponse.results.firstWhereOrNull(
(final shift) => shift.venue == venue.id,
(final shift) => shift.venue.venue.id == venue.id,
);

return shift != null ? venue.copyWithShift(shift) : venue;
Expand Down
5 changes: 2 additions & 3 deletions lib/tosti/models/shift.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:reaxit/tosti/models/user.dart';
import 'package:reaxit/tosti/models/venue.dart';

part 'shift.g.dart';

@JsonSerializable(fieldRename: FieldRename.snake)
class TostiShift {
final int id;
final int venue;
final String venueName;
final TostiOrderVenue venue;
final DateTime start;
final DateTime end;
final bool canOrder;
Expand All @@ -21,7 +21,6 @@ class TostiShift {
TostiShift(
this.id,
this.venue,
this.venueName,
this.start,
this.end,
this.canOrder,
Expand Down
4 changes: 1 addition & 3 deletions lib/tosti/models/shift.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/tosti/models/venue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ class TostiVenue {
TostiVenue copyWithPlayer(ThaliedjePlayer? player) =>
TostiVenue(id, name, slug, colorInCalendar, canBeReserved, shift, player);
}

@JsonSerializable(fieldRename: FieldRename.snake)
class TostiOrderVenue {
final TostiVenue venue;

TostiOrderVenue(this.venue);

factory TostiOrderVenue.fromJson(Map<String, dynamic> json) =>
_$TostiOrderVenueFromJson(json);
}
10 changes: 10 additions & 0 deletions lib/tosti/models/venue.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/tosti/tosti_shift_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TostiShiftScreen extends StatelessWidget {
children: [
const SizedBox(height: 16),
Text(
shift.venueName.toUpperCase(),
shift.venue.venue.name.toUpperCase(),
style: textTheme.titleLarge,
),
const Divider(height: 24),
Expand Down

0 comments on commit 313bf4e

Please sign in to comment.