Refactor API endpoint usage across multiple repositories to use ClientEndpoints and StaffEndpoints

- Updated ClientOrderQueryRepositoryImpl to replace V2ApiEndpoints with ClientEndpoints for vendor, role, hub, and manager retrieval methods.
- Modified ViewOrdersRepositoryImpl to utilize ClientEndpoints for order viewing, editing, and vendor retrieval.
- Refactored ReportsRepositoryImpl to switch from V2ApiEndpoints to ClientEndpoints for various report fetching methods.
- Changed SettingsRepositoryImpl to use AuthEndpoints for sign-out functionality.
- Adjusted AuthRepositoryImpl to replace V2ApiEndpoints with AuthEndpoints for phone authentication and sign-out processes.
- Updated ProfileSetupRepositoryImpl to utilize StaffEndpoints for profile setup.
- Refactored AvailabilityRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for availability management.
- Changed ClockInRepositoryImpl to use StaffEndpoints for clock-in and clock-out functionalities.
- Updated HomeRepositoryImpl to replace V2ApiEndpoints with StaffEndpoints for dashboard and profile completion retrieval.
- Refactored PaymentsRepositoryImpl to utilize StaffEndpoints for payment summaries and history.
- Changed ProfileRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for staff profile and section status retrieval.
- Updated CertificatesRepositoryImpl to use StaffEndpoints for certificate management.
- Refactored DocumentsRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for document management.
- Changed TaxFormsRepositoryImpl to utilize StaffEndpoints for tax form management.
- Updated BankAccountRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for bank account management.
- Refactored TimeCardRepositoryImpl to use StaffEndpoints for time card retrieval.
- Changed AttireRepositoryImpl to utilize StaffEndpoints for attire management.
- Updated EmergencyContactRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for emergency contact management.
- Refactored ExperienceRepositoryImpl to use StaffEndpoints for industry and skill retrieval.
- Changed PersonalInfoRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for personal information management.
- Updated FaqsRepositoryImpl to utilize StaffEndpoints for FAQs retrieval.
- Refactored PrivacySettingsRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for privacy settings management.
- Changed ShiftsRepositoryImpl to use StaffEndpoints for shift management and retrieval.
- Updated StaffMainRepositoryImpl to switch from V2ApiEndpoints to StaffEndpoints for profile completion checks.
This commit is contained in:
Achintha Isuru
2026-03-17 11:40:15 -04:00
parent 31231c1e6d
commit 57bba8ab4e
46 changed files with 134 additions and 544 deletions

View File

@@ -5,7 +5,7 @@ import 'package:staff_shifts/src/domain/repositories/shifts_repository_interface
/// V2 API implementation of [ShiftsRepositoryInterface].
///
/// Uses [BaseApiService] with [V2ApiEndpoints] for all network access.
/// Uses [BaseApiService] with [StaffEndpoints] for all network access.
class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
/// Creates a [ShiftsRepositoryImpl].
ShiftsRepositoryImpl({required BaseApiService apiService})
@@ -34,7 +34,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
required DateTime end,
}) async {
final ApiResponse response = await _apiService.get(
V2ApiEndpoints.staffShiftsAssigned,
StaffEndpoints.shiftsAssigned.path,
params: <String, dynamic>{
'startDate': start.toIso8601String(),
'endDate': end.toIso8601String(),
@@ -59,7 +59,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
params['search'] = search;
}
final ApiResponse response = await _apiService.get(
V2ApiEndpoints.staffShiftsOpen,
StaffEndpoints.shiftsOpen.path,
params: params,
);
final List<dynamic> items = _extractItems(response.data);
@@ -72,7 +72,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
@override
Future<List<PendingAssignment>> getPendingAssignments() async {
final ApiResponse response =
await _apiService.get(V2ApiEndpoints.staffShiftsPending);
await _apiService.get(StaffEndpoints.shiftsPending.path);
final List<dynamic> items = _extractItems(response.data);
return items
.map((dynamic json) =>
@@ -83,7 +83,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
@override
Future<List<CancelledShift>> getCancelledShifts() async {
final ApiResponse response =
await _apiService.get(V2ApiEndpoints.staffShiftsCancelled);
await _apiService.get(StaffEndpoints.shiftsCancelled.path);
final List<dynamic> items = _extractItems(response.data);
return items
.map((dynamic json) =>
@@ -94,7 +94,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
@override
Future<List<CompletedShift>> getCompletedShifts() async {
final ApiResponse response =
await _apiService.get(V2ApiEndpoints.staffShiftsCompleted);
await _apiService.get(StaffEndpoints.shiftsCompleted.path);
final List<dynamic> items = _extractItems(response.data);
return items
.map((dynamic json) =>
@@ -105,7 +105,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
@override
Future<ShiftDetail?> getShiftDetail(String shiftId) async {
final ApiResponse response =
await _apiService.get(V2ApiEndpoints.staffShiftDetails(shiftId));
await _apiService.get(StaffEndpoints.shiftDetails(shiftId).path);
if (response.data == null) {
return null;
}
@@ -119,7 +119,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
bool instantBook = false,
}) async {
await _apiService.post(
V2ApiEndpoints.staffShiftApply(shiftId),
StaffEndpoints.shiftApply(shiftId).path,
data: <String, dynamic>{
if (roleId != null) 'roleId': roleId,
'instantBook': instantBook,
@@ -129,18 +129,18 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
@override
Future<void> acceptShift(String shiftId) async {
await _apiService.post(V2ApiEndpoints.staffShiftAccept(shiftId));
await _apiService.post(StaffEndpoints.shiftAccept(shiftId).path);
}
@override
Future<void> declineShift(String shiftId) async {
await _apiService.post(V2ApiEndpoints.staffShiftDecline(shiftId));
await _apiService.post(StaffEndpoints.shiftDecline(shiftId).path);
}
@override
Future<void> requestSwap(String shiftId, {String? reason}) async {
await _apiService.post(
V2ApiEndpoints.staffShiftRequestSwap(shiftId),
StaffEndpoints.shiftRequestSwap(shiftId).path,
data: <String, dynamic>{
if (reason != null) 'reason': reason,
},
@@ -150,7 +150,7 @@ class ShiftsRepositoryImpl implements ShiftsRepositoryInterface {
@override
Future<bool> getProfileCompletion() async {
final ApiResponse response =
await _apiService.get(V2ApiEndpoints.staffProfileCompletion);
await _apiService.get(StaffEndpoints.profileCompletion.path);
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
final ProfileCompletion completion = ProfileCompletion.fromJson(data);
return completion.completed;

View File

@@ -3,7 +3,7 @@ import 'package:krow_domain/krow_domain.dart';
/// Contract for accessing shift-related data from the V2 API.
///
/// Implementations reside in the data layer and use [BaseApiService]
/// with V2ApiEndpoints.
/// with [StaffEndpoints].
abstract interface class ShiftsRepositoryInterface {
/// Retrieves assigned shifts for the current staff within a date range.
Future<List<AssignedShift>> getAssignedShifts({

View File

@@ -1,13 +1,10 @@
import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:intl/intl.dart';
import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart';
import 'package:staff_shifts/src/presentation/blocs/shifts/shifts_bloc.dart';
import 'package:staff_shifts/src/presentation/widgets/shared/empty_state_view.dart';
/// Tab showing open shifts available for the worker to browse and apply.