132 lines
3.9 KiB
Dart
132 lines
3.9 KiB
Dart
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
|
import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
|
|
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
class SaleLogic extends GetxController {
|
|
Rxn<List<AllocatedMadeModel>?> allocatedMadeModel = Rxn<List<AllocatedMadeModel>?>();
|
|
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
|
|
|
|
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
|
|
|
|
Rxn<StewardFreeBarDashboard> stewardFreeDashboard = Rxn<StewardFreeBarDashboard>();
|
|
|
|
RootLogic rootLogic = Get.find<RootLogic>();
|
|
|
|
List<String> routesName = ['فروش'];
|
|
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
getStewardDashBord();
|
|
getRolesProducts();
|
|
}
|
|
|
|
Future<void> getAllocatedMade() async {
|
|
safeCall(
|
|
call: () async => await rootLogic.chickenRepository.getAllocatedMade(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
queryParameters: buildQueryParams(page: 1, pageSize: 20, search: 'filter', role: 'Steward'),
|
|
),
|
|
onSuccess: (result) {
|
|
if (result != null) {
|
|
allocatedMadeModel.value = result.results;
|
|
}
|
|
},
|
|
onError: (error, stacktrace) {},
|
|
);
|
|
}
|
|
|
|
void checkVerfication() {}
|
|
|
|
void confirmAllocation(ConformAllocation allocation) {
|
|
safeCall(
|
|
call: () async => await rootLogic.chickenRepository.confirmAllocation(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
allocation: allocation.toJson(),
|
|
),
|
|
onSuccess: (result) {
|
|
getAllocatedMade();
|
|
},
|
|
onError: (error, stacktrace) {},
|
|
);
|
|
}
|
|
|
|
void denyAllocation(String token) {
|
|
safeCall(
|
|
call: () async => await rootLogic.chickenRepository.denyAllocation(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
allocationToken: token,
|
|
),
|
|
onSuccess: (result) {
|
|
getAllocatedMade();
|
|
},
|
|
onError: (error, stacktrace) {},
|
|
);
|
|
}
|
|
|
|
Future<void> confirmAllAllocations() async {
|
|
safeCall(
|
|
call: () async => await rootLogic.chickenRepository.confirmAllAllocation(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
allocationTokens: allocatedMadeModel.value?.map((e) => e.key!).toList() ?? [],
|
|
),
|
|
onSuccess: (result) {
|
|
getAllocatedMade();
|
|
},
|
|
onError: (error, stacktrace) {},
|
|
);
|
|
}
|
|
|
|
Future<void> getRolesProducts() async {
|
|
safeCall(
|
|
call: () async => await rootLogic.chickenRepository.getRolesProducts(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
),
|
|
onSuccess: (result) {
|
|
if (result != null) {
|
|
rolesProductsModel.value = result;
|
|
}
|
|
},
|
|
onError: (error, stacktrace) {},
|
|
);
|
|
}
|
|
|
|
Future<void> getGuilds() async {}
|
|
|
|
Future<void> addSale() async {}
|
|
|
|
void setSelectedGuild(GuildModel value) {}
|
|
|
|
void setSelectedProduct(ProductModel value) {}
|
|
|
|
Future<void> getStewardDashBord() async {
|
|
safeCall(
|
|
call: () async => await rootLogic.chickenRepository.getStewardDashboard(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
stratDate: DateTime.now().formattedDashedGregorian,
|
|
endDate: DateTime.now().formattedDashedGregorian,
|
|
),
|
|
onSuccess: (result) {
|
|
if (result != null) {
|
|
stewardFreeDashboard.value = result;
|
|
}
|
|
},
|
|
onError: (error, stacktrace) {},
|
|
);
|
|
}
|
|
|
|
Future<void> submitAllocation() async {}
|
|
|
|
@override
|
|
void dispose() {
|
|
rootLogic.inventoryExpandedList.clear();
|
|
super.dispose();
|
|
}
|
|
}
|