Compare commits

..

No commits in common. 'master' and 'fatima_dev' have entirely different histories.

File diff suppressed because it is too large Load Diff

@ -712,7 +712,7 @@ class AdVM extends BaseVM {
SelectionModel vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); SelectionModel vehicleTypeId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: "");
Future<void> updateSelectionVehicleTypeId(SelectionModel id, {bool isForSearch = false}) async { void updateSelectionVehicleTypeId(SelectionModel id, {bool isForSearch = false}) async {
if (isForSearch) { if (isForSearch) {
VehicleTypeModel vehicleTypeModel = vehicleTypesForFilters.firstWhere((element) => element.id == id.selectedId); VehicleTypeModel vehicleTypeModel = vehicleTypesForFilters.firstWhere((element) => element.id == id.selectedId);
DropValue vehicleTypeVValue = DropValue(vehicleTypeModel.id ?? 0, vehicleTypeModel.vehicleTypeName ?? "", ""); DropValue vehicleTypeVValue = DropValue(vehicleTypeModel.id ?? 0, vehicleTypeModel.vehicleTypeName ?? "", "");
@ -1368,14 +1368,24 @@ class AdVM extends BaseVM {
void onBackButtonPressed(BuildContext context) { void onBackButtonPressed(BuildContext context) {
switch (currentProgressStep) { switch (currentProgressStep) {
case AdCreationStepsEnum.vehicleDetails: case AdCreationStepsEnum.vehicleDetails:
// Only offer to save as a draft once both brand AND model are selected. Brand // Check if user has entered any data
// has no field of its own in the draft payload -- it's only ever recoverable by bool hasData = vehicleTypeId.selectedId != -1 ||
// looking up model.vehicleBrandID when a draft is reopened. Confirmed on a real vehicleBrandId.selectedId != -1 ||
// device: saving with a brand picked but no model meant the brand was silently vehicleModelId.selectedId != -1 ||
// lost on reopen, since there was nothing to derive it from. Any other field vehicleModelYearId.selectedId != -1 ||
// (description, images, etc.) being filled in isn't enough on its own -- a draft vehicleColorId.selectedId != -1 ||
// without a vehicle identified isn't meaningfully recoverable either. vehicleCategoryId.selectedId != -1 ||
bool hasData = vehicleBrandId.selectedId != -1 && vehicleModelId.selectedId != -1; vehicleConditionId.selectedId != -1 ||
vehicleMileageId.selectedId != -1 ||
vehicleTransmissionId.selectedId != -1 ||
vehicleCountryId.selectedId != -1 ||
vehicleCityId.selectedId != -1 ||
vehicleDemandAmount.isNotEmpty ||
vehicleVin.isNotEmpty ||
vehicleTitle.isNotEmpty ||
warrantyDuration.isNotEmpty ||
vehicleDescription.isNotEmpty ||
pickedPostingImages.isNotEmpty;
if (hasData) { if (hasData) {
// Skip save confirmation when extending ad // Skip save confirmation when extending ad
@ -2902,7 +2912,7 @@ class AdVM extends BaseVM {
return []; return [];
} }
Future<void> onEditUpdateAdPressed({required BuildContext context, required AdDetailsModel previousDetails, required bool isFromExtendAd, bool isForDraft = false}) async { void onEditUpdateAdPressed({required BuildContext context, required AdDetailsModel previousDetails, required bool isFromExtendAd, bool isForDraft = false}) {
log("previousDetails: ${previousDetails.vehiclePostingID}"); log("previousDetails: ${previousDetails.vehiclePostingID}");
log("previousDetails: ${previousDetails.vehicle?.id}"); log("previousDetails: ${previousDetails.vehicle?.id}");
@ -2913,16 +2923,10 @@ class AdVM extends BaseVM {
log("previousAdDetails: ${previousAdDetails?.vehicle?.id}"); log("previousAdDetails: ${previousAdDetails?.vehicle?.id}");
// These used to all fire without awaiting, so autoFillSelectedVehicleAdsDetails could autoFillSelectedVehicleType();
// start (and look up vehicleBrands/vehicleModels for this draft) before
// autoFillSelectedVehicleType had actually finished setting vehicleTypeId and fetching
// brands for it -- type must resolve before brand, which must resolve before
// model/year/color/etc, since each step's dropdown options are fetched using the
// previous step's selected id.
await autoFillSelectedVehicleType();
autoFillSelectedVehicleAdsDuration(); autoFillSelectedVehicleAdsDuration();
// if (isForDraft) { // if (isForDraft) {
await autoFillSelectedVehicleAdsDetails(context); autoFillSelectedVehicleAdsDetails(context);
// } // }
navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [AppState().currentAppType == AppType.provider, isFromExtendAd, previousDetails.id]); navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [AppState().currentAppType == AppType.provider, isFromExtendAd, previousDetails.id]);
} }
@ -2949,7 +2953,7 @@ class AdVM extends BaseVM {
} }
} }
Future<void> autoFillSelectedVehicleType() async { void autoFillSelectedVehicleType() async {
if (vehicleTypes.isEmpty) { if (vehicleTypes.isEmpty) {
await getVehicleTypes(); await getVehicleTypes();
// return; // return;
@ -2960,14 +2964,6 @@ class AdVM extends BaseVM {
if (vehicle.id == previousAdDetails!.vehicle?.vehicleType) { if (vehicle.id == previousAdDetails!.vehicle?.vehicleType) {
vehicle.isSelected = true; vehicle.isSelected = true;
log("Hi: ${vehicle.vehicleTypeName}"); log("Hi: ${vehicle.vehicleTypeName}");
// This used to only flip isSelected on the type-picker list item, never
// vehicleTypeId itself -- confirmed on a real device: that left vehicleTypeId
// at whatever stale value (or -1) it already had from a previous session, which
// then fed the wrong/empty vehicleTypeId into getVehicleBrandsByVehicleTypeId()
// -> getVehicleDetailsByVehicleBrandId() below, so the model/year/color/etc.
// dropdown option lists never matched the draft's actual selections even though
// their IDs were set correctly.
await updateSelectionVehicleTypeId(SelectionModel(selectedId: vehicle.id!, selectedOption: vehicle.vehicleTypeName ?? ""));
break; break;
} }
} }
@ -3008,7 +3004,7 @@ class AdVM extends BaseVM {
notifyListeners(); notifyListeners();
} }
Future<void> autoFillSelectedVehicleAdsDetails(BuildContext context) async { void autoFillSelectedVehicleAdsDetails(BuildContext context) async {
bool isArabic = AppState().isArabic(context); bool isArabic = AppState().isArabic(context);
if (vehicleBrands.isEmpty) { if (vehicleBrands.isEmpty) {

@ -181,7 +181,8 @@ class AdDurationSelectionSheet extends StatelessWidget {
if (adVM.isFetchingLists) { if (adVM.isFetchingLists) {
return; return;
} else { } else {
if (isFromExtendAd && !isUpdateAdSelected) { if (isFromExtendAd && !isUpdateAdSelected && AppState().currentAppType == AppType.provider) {
final subscriptionsVM = context.read<SubscriptionsVM>();
List<bool> statuses = List<bool> statuses =
await adVM.createAdExtensionOrder(context, adId: adsID, adsDurationId: adVM.vehicleAdDurationId.selectedId); // [0] Means API response [1] means isPaymentRequired await adVM.createAdExtensionOrder(context, adId: adsID, adsDurationId: adVM.vehicleAdDurationId.selectedId); // [0] Means API response [1] means isPaymentRequired
if (statuses[0] && statuses[1]) { if (statuses[0] && statuses[1]) {
@ -190,12 +191,7 @@ class AdDurationSelectionSheet extends StatelessWidget {
pop(context); pop(context);
pop(context); pop(context);
pop(context); pop(context);
// SubscriptionsVM is only registered in the provider app -- reading it await subscriptionsVM.getSubscriptionBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? "", true);
// for a customer would throw, since customers don't have subscriptions.
if (AppState().currentAppType == AppType.provider) {
final subscriptionsVM = context.read<SubscriptionsVM>();
await subscriptionsVM.getSubscriptionBySP(AppState().getUser.data?.userInfo?.providerId.toString() ?? "", true);
}
adVM.applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.active); adVM.applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.active);
} }
} else { } else {

@ -80,13 +80,8 @@ class BuildFooterButton extends StatelessWidget {
case AdCreationStepsEnum.vehicleDetails: case AdCreationStepsEnum.vehicleDetails:
return Row( return Row(
children: [ children: [
// Hide "Save as Draft" when extending ad, and until brand+model are both // Hide "Save as Draft" when extending ad
// selected -- brand has no field of its own in the draft payload, it's if (!adVm.isExtendAdEditEnabled) ...[
// only ever recoverable via model.vehicleBrandID on reload, so saving with
// a brand picked but no model silently loses the brand (confirmed on a
// real device). Same gate as the back-button confirmation in
// onBackButtonPressed.
if (!adVm.isExtendAdEditEnabled && adVm.vehicleBrandId.selectedId != -1 && adVm.vehicleModelId.selectedId != -1) ...[
Expanded( Expanded(
child: ShowFillButton( child: ShowFillButton(
txtColor: MyColors.black, txtColor: MyColors.black,

Loading…
Cancel
Save