// ignore_for_file: unnecessary_overrides

import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:get/get.dart';
import 'package:IQ/app/modules/home/providers/add_new_ticket.dart';
import 'package:IQ/app/routes/app_pages.dart';

class NewTicketController extends GetxController {
  final formKey = GlobalKey<FormBuilderState>();
  bool inputsEntered = false;
  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  sendTicket() async {
    if ((formKey.currentState?.validate())!) {
      inputsEntered = true;
      update();
      await getUseraddedTicketInforms(subjectStr, messageStr);
      if (getUseraddedTicketInformsLoads) {
        inputsEntered = false;
        update();
        Get.offAllNamed(Routes.SUPPORT);
      } else {
        inputsEntered = false;
        update();
        Get.snackbar('Error', 'Please try again later');
      }
    } else {
      inputsEntered = false;
      update();
    }
  }

  String? subjectStr;
  onChangeSubject(String? subjectInput) {
    subjectStr = subjectInput;
    update();
  }

  String? messageStr;
  onChangeMessage(String? messageInput) {
    messageStr = messageInput;
    update();
  }
}
