feat: legacy mobile apps created
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const String getStaffInclusivityInfoSchema = '''
|
||||
query GetPersonalInfo {
|
||||
me {
|
||||
id
|
||||
accessibility {
|
||||
has_car
|
||||
can_relocate
|
||||
requires_accommodations
|
||||
accommodation_details
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
const String updateStaffInclusivityMutationSchema = '''
|
||||
mutation UpdateStaffAccessibilityInfo(\$input: UpdateStaffAccessibilitiesInput!) {
|
||||
update_staff_accessibilities(input: \$input) {
|
||||
accessibility {
|
||||
requires_accommodations
|
||||
accommodation_details
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
@immutable
|
||||
class InclusiveInfoModel {
|
||||
const InclusiveInfoModel({
|
||||
required this.areAccommodationsRequired,
|
||||
required this.accommodationsDetails,
|
||||
});
|
||||
|
||||
factory InclusiveInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
return InclusiveInfoModel(
|
||||
areAccommodationsRequired:
|
||||
json['requires_accommodations'] as bool? ?? false,
|
||||
accommodationsDetails: json['accommodation_details'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
final bool areAccommodationsRequired;
|
||||
final String accommodationsDetails;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'requires_accommodations': areAccommodationsRequired,
|
||||
'accommodation_details': accommodationsDetails,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:krow/core/application/clients/api/api_client.dart';
|
||||
import 'package:krow/features/profile/inclusive/data/gql_shemas.dart';
|
||||
import 'package:krow/features/profile/inclusive/data/models/inclusive_info_model.dart';
|
||||
|
||||
@injectable
|
||||
class StaffInclusivityApiProvider {
|
||||
StaffInclusivityApiProvider(this._client);
|
||||
|
||||
final ApiClient _client;
|
||||
|
||||
Stream<InclusiveInfoModel> getStaffInclusivityInfoWithCache() async* {
|
||||
await for (var response in _client.queryWithCache(
|
||||
schema: getStaffInclusivityInfoSchema,
|
||||
)) {
|
||||
if (response == null || response.data == null) continue;
|
||||
|
||||
if (response.hasException) {
|
||||
throw Exception(response.exception.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
yield InclusiveInfoModel.fromJson(
|
||||
(response.data?['me'] as Map<String, dynamic>?)?['accessibility'] ??
|
||||
{},
|
||||
);
|
||||
} catch (except) {
|
||||
log(
|
||||
'Exception in StaffInclusivityApiProvider '
|
||||
'on getStaffInclusivityInfoWithCache()',
|
||||
error: except,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<InclusiveInfoModel?> updateStaffInclusivityInfoInfo(
|
||||
InclusiveInfoModel data,
|
||||
) async {
|
||||
var result = await _client.mutate(
|
||||
schema: updateStaffInclusivityMutationSchema,
|
||||
body: {
|
||||
'input': data.toJson(),
|
||||
},
|
||||
);
|
||||
|
||||
if (result.hasException) {
|
||||
throw Exception(result.exception.toString());
|
||||
}
|
||||
|
||||
if (result.data == null || result.data!.isEmpty) return null;
|
||||
|
||||
return InclusiveInfoModel.fromJson(
|
||||
(result.data?['update_staff_accessibilities']
|
||||
as Map<String, dynamic>?)?['accessibility'] ??
|
||||
{},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:krow/features/profile/inclusive/data/models/inclusive_info_model.dart';
|
||||
|
||||
abstract class StaffInclusivityRepository {
|
||||
Stream<InclusiveInfoModel> getStaffInclusivityInfo();
|
||||
|
||||
Future<InclusiveInfoModel?> updateStaffMobilityInfo(
|
||||
InclusiveInfoModel data,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user