refactor: remove unused local and remote data sources, models, and tests for chicken and poultry features to streamline codebase
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.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/segmentation_model/segmentation_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/steward_remain_weight/steward_remain_weight.dart';
|
||||
import 'package:rasadyar_chicken/features/common/data/model/response/broadcast_price/broadcast_price.dart';
|
||||
import 'package:rasadyar_chicken/features/common/data/model/response/guild/guild_model.dart';
|
||||
import 'package:rasadyar_chicken/features/common/data/model/response/roles_products/roles_products.dart';
|
||||
import 'package:rasadyar_chicken/features/steward/data/model/response/segmentation_model/segmentation_model.dart';
|
||||
import 'package:rasadyar_chicken/features/steward/data/model/response/steward_remain_weight/steward_remain_weight.dart';
|
||||
import 'package:rasadyar_chicken/features/steward/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
@@ -48,7 +48,10 @@ class SegmentationLogic extends GetxController {
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
routesName = ['قطعهبندی'].toList();
|
||||
once(rootLogic.rolesProductsModel, (callback) => selectedProduct.value = callback.first);
|
||||
once(
|
||||
rootLogic.rolesProductsModel,
|
||||
(callback) => selectedProduct.value = callback.first,
|
||||
);
|
||||
getAllSegmentation();
|
||||
getGuilds();
|
||||
|
||||
@@ -65,7 +68,8 @@ class SegmentationLogic extends GetxController {
|
||||
}
|
||||
|
||||
void _updateGovernmentalProductionDateData() {
|
||||
List<RemainWeightDay> dates = rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
List<RemainWeightDay> dates =
|
||||
rootLogic.stewardRemainWeight.value?.governmental ?? [];
|
||||
governmentalProductionDateData = {
|
||||
for (var element in dates)
|
||||
element.day.toString().toJalali.formatCompactDate(): DayData(
|
||||
@@ -90,7 +94,6 @@ class SegmentationLogic extends GetxController {
|
||||
setUpListener();
|
||||
}
|
||||
|
||||
|
||||
void setSearchValue(String? value) {
|
||||
searchedValue.value = value?.trim();
|
||||
}
|
||||
@@ -134,14 +137,16 @@ class SegmentationLogic extends GetxController {
|
||||
hasWeight &&
|
||||
productionDate.value != null &&
|
||||
weight > 0 &&
|
||||
(segmentType.value == 1 || (segmentType.value == 2 && selectedGuildModel.value != null));
|
||||
(segmentType.value == 1 ||
|
||||
(segmentType.value == 2 && selectedGuildModel.value != null));
|
||||
}
|
||||
|
||||
Future<void> getAllSegmentation([bool isLoadingMore = false]) async {
|
||||
if (isLoadingMore) {
|
||||
isLoadingMoreAllocationsMade.value = true;
|
||||
} else {
|
||||
segmentationList.value = Resource<PaginationModel<SegmentationModel>>.loading();
|
||||
segmentationList.value =
|
||||
Resource<PaginationModel<SegmentationModel>>.loading();
|
||||
}
|
||||
|
||||
if (searchedValue.value != null &&
|
||||
@@ -152,7 +157,7 @@ class SegmentationLogic extends GetxController {
|
||||
|
||||
await safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.getSegmentation(
|
||||
call: () async => await rootLogic.commonRepository.getSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(
|
||||
pageSize: 20,
|
||||
@@ -167,19 +172,21 @@ class SegmentationLogic extends GetxController {
|
||||
|
||||
onSuccess: (result) {
|
||||
if ((result?.count ?? 0) == 0) {
|
||||
segmentationList.value = Resource<PaginationModel<SegmentationModel>>.empty();
|
||||
segmentationList.value =
|
||||
Resource<PaginationModel<SegmentationModel>>.empty();
|
||||
} else {
|
||||
segmentationList.value = Resource<PaginationModel<SegmentationModel>>.success(
|
||||
PaginationModel<SegmentationModel>(
|
||||
count: result?.count ?? 0,
|
||||
next: result?.next,
|
||||
previous: result?.previous,
|
||||
results: [
|
||||
...(segmentationList.value.data?.results ?? []),
|
||||
...(result?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
segmentationList.value =
|
||||
Resource<PaginationModel<SegmentationModel>>.success(
|
||||
PaginationModel<SegmentationModel>(
|
||||
count: result?.count ?? 0,
|
||||
next: result?.next,
|
||||
previous: result?.previous,
|
||||
results: [
|
||||
...(segmentationList.value.data?.results ?? []),
|
||||
...(result?.results ?? []),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
isLoadingMoreAllocationsMade.value = false;
|
||||
}
|
||||
@@ -191,7 +198,7 @@ class SegmentationLogic extends GetxController {
|
||||
await safeCall(
|
||||
showError: true,
|
||||
showSuccess: true,
|
||||
call: () => rootLogic.chickenRepository.deleteSegmentation(
|
||||
call: () => rootLogic.commonRepository.deleteSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
key: key,
|
||||
),
|
||||
@@ -202,12 +209,14 @@ class SegmentationLogic extends GetxController {
|
||||
var res = true;
|
||||
safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.editSegmentation(
|
||||
call: () async => await rootLogic.commonRepository.editSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
model: SegmentationModel(
|
||||
key: selectedSegment.value?.key,
|
||||
weight: int.tryParse(weightController.text.clearComma) ?? 0,
|
||||
productionDate: productionDate.value?.toDateTime().formattedDashedGregorian,
|
||||
productionDate: productionDate.value
|
||||
?.toDateTime()
|
||||
.formattedDashedGregorian,
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
@@ -230,14 +239,18 @@ class SegmentationLogic extends GetxController {
|
||||
quota: quotaType.value == 1 ? 'governmental' : 'free',
|
||||
);
|
||||
if (segmentType.value == 2) {
|
||||
segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
|
||||
segmentationModel = segmentationModel.copyWith(
|
||||
guildKey: selectedGuildModel.value?.key,
|
||||
);
|
||||
}
|
||||
segmentationModel = segmentationModel.copyWith(
|
||||
productionDate: productionDate.value?.toDateTime().formattedDashedGregorian,
|
||||
productionDate: productionDate.value
|
||||
?.toDateTime()
|
||||
.formattedDashedGregorian,
|
||||
);
|
||||
await safeCall(
|
||||
showError: true,
|
||||
call: () async => await rootLogic.chickenRepository.createSegmentation(
|
||||
call: () async => await rootLogic.commonRepository.createSegmentation(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
model: segmentationModel,
|
||||
),
|
||||
@@ -260,9 +273,12 @@ class SegmentationLogic extends GetxController {
|
||||
|
||||
Future<void> getGuilds() async {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getGuilds(
|
||||
call: () async => await rootLogic.commonRepository.getGuilds(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(queryParams: {'all': true}, role: 'Steward'),
|
||||
queryParameters: buildQueryParams(
|
||||
queryParams: {'all': true},
|
||||
role: 'Steward',
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
@@ -286,7 +302,7 @@ class SegmentationLogic extends GetxController {
|
||||
|
||||
Future<void> getBroadcastPrice() async {
|
||||
safeCall(
|
||||
call: () async => await rootLogic.chickenRepository.getBroadcastPrice(
|
||||
call: () async => await rootLogic.commonRepository.getBroadcastPrice(
|
||||
token: rootLogic.tokenService.accessToken.value!,
|
||||
),
|
||||
onSuccess: (result) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart';
|
||||
import 'package:rasadyar_chicken/features/steward/data/model/response/segmentation_model/segmentation_model.dart';
|
||||
import 'package:rasadyar_chicken/features/steward/presentation/pages/segmentation/widgets/cu_bottom_sheet.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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/features/common/data/model/response/guild/guild_model.dart';
|
||||
import 'package:rasadyar_chicken/features/common/data/model/response/roles_products/roles_products.dart';
|
||||
import 'package:rasadyar_chicken/features/steward/presentation/pages/segmentation/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user