feat: Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
const String updateStaffRatingMutationSchema = '''
|
||||
mutation updateStaffRating(\$input: RateClientStaffInput!) {
|
||||
rate_client_staff(input: \$input) {
|
||||
id
|
||||
}
|
||||
}
|
||||
''';
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:krow/core/application/clients/api/api_client.dart';
|
||||
import 'package:krow/features/rate_staff/data/gql.dart';
|
||||
|
||||
@singleton
|
||||
class ClientProfileApiProvider {
|
||||
ClientProfileApiProvider(this._client);
|
||||
|
||||
final ApiClient _client;
|
||||
|
||||
Future<void> updateStaffRating(
|
||||
{required String positionId,
|
||||
required int rating,
|
||||
String? reason,
|
||||
String? details,
|
||||
bool? isBlocked ,
|
||||
bool? isFavorite }) async {
|
||||
final QueryResult result = await _client.mutate(
|
||||
schema: updateStaffRatingMutationSchema,
|
||||
body: {
|
||||
'input': {
|
||||
'position_staff_id': positionId,
|
||||
'rating': rating,
|
||||
if (reason != null && reason.isNotEmpty) 'reason': reason,
|
||||
if (details != null && details.isNotEmpty) 'details': details.trim(),
|
||||
'is_blocked': isBlocked??false,
|
||||
'is_favorite': isFavorite??false,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (result.hasException) {
|
||||
throw Exception(result.exception.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
abstract class RatingStaffRepository {
|
||||
Future<void> rateStaff(
|
||||
{required String positionId,
|
||||
required int rating,
|
||||
String? reason,
|
||||
String? details,
|
||||
bool isBlocked = false,
|
||||
bool isFavorite = false});
|
||||
}
|
||||
Reference in New Issue
Block a user