import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/models/get_quotation_requests_list_model.dart';

class GetQuotationRequestsList extends StatefulWidget {
  const GetQuotationRequestsList({Key? key}) : super(key: key);

  @override
  State<GetQuotationRequestsList> createState() => _GetQuotationRequestsListState();
}

class _GetQuotationRequestsListState extends State<GetQuotationRequestsList> {

  bool isLoading = false;
  bool isSereverIssue = false;
  List<GetQuotationsRequsetListModel> quotationRequestsList = [];

  Future<void> getAllQuotationRequestsList() async {
    isLoading = true;
    try {
      var resopnse = await AppSettings.getAllQuotationRequests();

      setState(() {
        quotationRequestsList = ((jsonDecode(resopnse)) as List)
            .map((dynamic model) {
          return GetQuotationsRequsetListModel.fromJson(model);
        }).toList();

        isLoading = false;
      });
    } catch (e) {
      setState(() {
        isLoading = false;
        isSereverIssue = true;
      });
    }
  }


  @override
  void initState() {
    getAllQuotationRequestsList();
    super.initState();
  }

  Widget renderUi(){
    return Container();
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppSettings.appBar('Quotation Requests'),
      body: renderUi(),
    );
  }
}
