Compare commits

..

No commits in common. '30a69b1ca64c2515d1f2b1ecb626f874742f12d2' and '86aa0f67d85fac53b33ee8424b71abc9278de745' have entirely different histories.

@ -72,7 +72,6 @@ class PpmProvider extends ChangeNotifier {
nextPage = true; nextPage = true;
stateCode = null; stateCode = null;
} }
List<StoreAvailability> _storeAvailability = []; List<StoreAvailability> _storeAvailability = [];
List<StoreAvailability> get storeAvailability => _storeAvailability; List<StoreAvailability> get storeAvailability => _storeAvailability;
@ -192,22 +191,24 @@ class PpmProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) { if (response.statusCode >= 200 && response.statusCode < 300) {
ppmPlanAttachments = []; ppmPlanAttachments = [];
planPreventiveVisit = PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]); planPreventiveVisit = PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]);
// Set isReadOnly based on visit status (1 or 3 means closed/completed) // Set isReadOnly based on visit status (1 or 3 means closed/completed)
if (planPreventiveVisit?.visitStatus?.value! == 1 || planPreventiveVisit?.visitStatus?.value == 3) { if (planPreventiveVisit?.visitStatus?.value! == 1 || planPreventiveVisit?.visitStatus?.value == 3) {
isReadOnly = true; isReadOnly = true;
} else { } else {
isReadOnly = false; isReadOnly = false;
} }
// Set isReadOnlyRequest based on visit status - same logic as CMDetailProvider // Set isReadOnlyRequest based on visit status - same logic as CMDetailProvider
//Need to confirm this with backend Status values: 3 = Closed, 5 = Completed, 6 = Cancelled (adjust based on your PM status values) //Need to confirm this with backend Status values: 3 = Closed, 5 = Completed, 6 = Cancelled (adjust based on your PM status values)
if (planPreventiveVisit?.visitStatus?.value == 3 || planPreventiveVisit?.visitStatus?.value == 5 || planPreventiveVisit?.visitStatus?.value == 6) { if (planPreventiveVisit?.visitStatus?.value == 3 ||
planPreventiveVisit?.visitStatus?.value == 5 ||
planPreventiveVisit?.visitStatus?.value == 6) {
isReadOnlyRequest = true; isReadOnlyRequest = true;
} else { } else {
isReadOnlyRequest = false; isReadOnlyRequest = false;
} }
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
return planPreventiveVisit; return planPreventiveVisit;
@ -427,23 +428,22 @@ class PpmProvider extends ChangeNotifier {
} }
} }
Future<String> updateActivitySparePart(BuildContext context) async { Future<bool> updateActivitySparePart() async {
isLoading = true;
Response response; Response response;
try { try {
response = await ApiManager.instance.post(URLs.updatePmActivitySparePart, body: sparePartHelperModel!.toPMJson(), showToast: false); response = await ApiManager.instance.post(URLs.updatePmActivitySparePart, body: sparePartHelperModel!.toPMJson());
stateCode = response.statusCode;
if (response.statusCode == 200) { isLoading = false;
final responseBody = jsonDecode(response.body); notifyListeners();
if (responseBody is Map<String, dynamic>) { if (stateCode == 200) {
final message = responseBody["message"]; // Reuse parsed body
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message, toastLength: Toast.LENGTH_LONG);
}
}
return true; return true;
} }
return false; return false;
} catch (error) { } catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
return false; return false;
} }
} }
@ -454,7 +454,8 @@ class PpmProvider extends ChangeNotifier {
try { try {
final response = await ApiManager.instance.delete('${URLs.deletePmActivitySparePart}?activitySparePartPPMId=$id', body: {}); final response = await ApiManager.instance.delete('${URLs.deletePmActivitySparePart}?activitySparePartPPMId=$id', body: {});
stateCode = response.statusCode; stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {} if (response.statusCode >= 200 && response.statusCode < 300) {
}
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
return response.statusCode; return response.statusCode;
@ -475,14 +476,16 @@ class PpmProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
if (stateCode == 200) { if (stateCode == 200) {
planPreventiveVisit = PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]); planPreventiveVisit = PlanPreventiveVisit.fromJson(json.decode(response.body)["data"]);
// Update isReadOnlyRequest after fetching updated data // Update isReadOnlyRequest after fetching updated data
if (planPreventiveVisit?.visitStatus?.value == 3 || planPreventiveVisit?.visitStatus?.value == 5 || planPreventiveVisit?.visitStatus?.value == 6) { if (planPreventiveVisit?.visitStatus?.value == 3 ||
planPreventiveVisit?.visitStatus?.value == 5 ||
planPreventiveVisit?.visitStatus?.value == 6) {
isReadOnlyRequest = true; isReadOnlyRequest = true;
} else { } else {
isReadOnlyRequest = false; isReadOnlyRequest = false;
} }
notifyListeners(); notifyListeners();
return true; return true;
} }

@ -377,7 +377,7 @@ class _SparePartRequestState extends State<SparePartRequest> {
if (mounted) Navigator.pop(context); // Close form if (mounted) Navigator.pop(context); // Close form
if (model?.id == 0 && widget.fromCm) { if (model?.id == 0&&widget.fromCm) {
ServiceRequestBottomSheet.addAnotherSpareRequestBottomSheet(context: context, fromCm: widget.fromCm); ServiceRequestBottomSheet.addAnotherSpareRequestBottomSheet(context: context, fromCm: widget.fromCm);
const SizedBox().flushBar( const SizedBox().flushBar(
context: context, context: context,
@ -403,37 +403,35 @@ class PartDetailBottomSheetSheet extends StatelessWidget {
return SizedBox( return SizedBox(
height: SizeConfig.screenHeight! / 2.2, height: SizeConfig.screenHeight! / 2.2,
width: SizeConfig.screenWidth, width: SizeConfig.screenWidth,
child: SafeArea( child: Column(
child: Column( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ 12.height,
12.height, 'Parts Availability'.heading4(context),
'Parts Availability'.heading4(context), Expanded(
Expanded( child: ListenableBuilder(
child: ListenableBuilder( listenable: provider,
listenable: provider, builder: (context, _) {
builder: (context, _) { return provider.isLoading
return provider.isLoading ? CircularProgressIndicator(
? CircularProgressIndicator( color: AppColor.loadingColor(context),
color: AppColor.loadingColor(context), ).center
).center : provider.storeAvailability.isEmpty
: provider.storeAvailability.isEmpty ? const NoDataFound().center
? const NoDataFound().center : ListView.separated(
: ListView.separated( padding: const EdgeInsets.only(top: 12),
padding: const EdgeInsets.only(top: 12,bottom: 12), itemCount: provider.storeAvailability.length,
itemCount: provider.storeAvailability.length, separatorBuilder: (czt, index) => 12.height,
separatorBuilder: (czt, index) => 12.height, itemBuilder: (context, index) {
itemBuilder: (context, index) { StoreAvailability model = provider.storeAvailability[index];
StoreAvailability model = provider.storeAvailability[index]; return _partAvailableQuantityCard(context: context, model: model);
return _partAvailableQuantityCard(context: context, model: model); },
}, );
); },
},
),
), ),
], ),
), ],
), ),
); );
} }

@ -287,7 +287,7 @@ class _UpdatePpmState extends State<UpdatePpm> with TickerProviderStateMixin {
onPressed: () async { onPressed: () async {
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const PmActivitiesListView())); Navigator.of(context).push(MaterialPageRoute(builder: (_) => const PmActivitiesListView()));
}, },
buttonColor: context.isDark ? AppColor.primary10 : AppColor.neutral50, buttonColor: AppColor.neutral50,
label: "View Spare Parts", label: "View Spare Parts",
), ),
], ],

Loading…
Cancel
Save