import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
import 'package:flutter/cupertino.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'dart:async';

import 'package:flutter/material.dart';

class SearchProvider with ChangeNotifier {
  bool isLogin = false;
  bool isLoading = true;
  dynamic pageData = {};
  static bool isNewSession = false;
  static var sessionID = new DateTime.now().millisecondsSinceEpoch;
  Future<dynamic> getBotPages(request) async {
    try {
      request['SessionID'] = '123';
      await BaseAppClient().post(SEARCH_BOT,
          onSuccess: (dynamic response, int statusCode) {
        pageData = response;

        // notifyListeners();
      }, onFailure: (String error, int statusCode) {
        throw error;
      }, body: request);

      return Future.value(pageData);
    } catch (error) {
      print(error);
      throw error;
    }
  }

  setLisener(data) {
    //SearchProvider.pageData = data;
    //projectProvider.setSearchValue(pageData);
    notifyListeners();
  }

  getSessionID() {
    if (isNewSession == true) {
      return new DateTime.now().millisecondsSinceEpoch;
    } else {
      return sessionID;
    }
  }
}
