feat: Refactor code structure and optimize performance across multiple modules

This commit is contained in:
Achintha Isuru
2025-11-17 23:29:28 -05:00
parent 831570f2e0
commit a64cbd9edf
1508 changed files with 105319 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
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/core/application/clients/api/api_exception.dart';
import 'package:krow/features/clock_manual/data/clock_manual_gql.dart';
@singleton
class ClockManualApiProvider {
final ApiClient _client;
ClockManualApiProvider({required ApiClient client}) : _client = client;
Future<void> trackClientClockin(String positionStaffId) async {
final QueryResult result = await _client.mutate(
schema: trackClientClockinMutation,
body: {'position_staff_id': positionStaffId},
);
if (result.hasException) {
throw parseBackendError(result.exception!);
}
}
Future<void> trackClientClockout(String positionStaffId) async {
final QueryResult result = await _client.mutate(
schema: trackClientClockoutMutation,
body: {'position_staff_id': positionStaffId},
);
if (result.hasException) {
throw parseBackendError(result.exception!);
}
}
Future<void> cancelClockin(String positionStaffId) async {
final QueryResult result = await _client.mutate(
schema: cancelClockinMutation,
body: {'position_staff_id': positionStaffId},
);
if (result.hasException) {
throw parseBackendError(result.exception!);
}
}
}

View File

@@ -0,0 +1,23 @@
const String trackClientClockinMutation = r'''
mutation track_client_clockin($position_staff_id: ID!) {
track_client_clockin(position_staff_id: $position_staff_id) {
id
}
}
''';
const String trackClientClockoutMutation = r'''
mutation track_client_clockout($position_staff_id: ID!) {
track_client_clockout(position_staff_id: $position_staff_id) {
id
}
}
''';
const String cancelClockinMutation = r'''
mutation cancel_client_clockin($position_staff_id: ID!) {
cancel_client_clockin(position_staff_id: $position_staff_id) {
id
}
}
''';

View File

@@ -0,0 +1,43 @@
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import 'package:krow/features/clock_manual/data/clock_manual_api_provider.dart';
import 'package:krow/features/clock_manual/domain/clock_manual_repository.dart';
@Singleton(as: ClockManualRepository)
class ClockManualRepositoryImpl implements ClockManualRepository {
final ClockManualApiProvider apiProvider;
ClockManualRepositoryImpl({required this.apiProvider});
@override
Future<void> trackClientClockin(String positionStaffId) async {
try {
await apiProvider.trackClientClockin(positionStaffId);
} catch (exception) {
debugPrint(exception.toString());
rethrow;
}
}
@override
Future<void> trackClientClockout(String positionStaffId) async {
try {
await apiProvider.trackClientClockout(positionStaffId);
} catch (exception) {
debugPrint(exception.toString());
rethrow;
}
}
@override
Future<void> cancelClockin(String positionStaffId) async{
try {
await apiProvider.cancelClockin(positionStaffId);
} catch (exception) {
debugPrint(exception.toString());
rethrow;
}
}
}