//@ts-nocheck
import { action, observable } from 'mobx';
import { Alert } from 'react-native';
import { Api } from '../../services/api';

class Store {
  @observable isLoading = false;
  @observable data = [];

  @action
  async getNotification() {
    this.isLoading = true;
    try {
      const response = await Api.getInstance().getNotification();
      this.isLoading = false;
      if (response.kind === 'ok') {
        if (response.data.meta.errorCode === 200) {
          this.data = response.data.data;
        } else {
          Alert.alert('Thông báo', response.data.meta.errorMessage);
        }
      } else {
        // Alert.alert("Thông báo", "Có lỗi xảy ra. Vui lòng thử lại sau")
      }
    } catch (error) {
      this.isLoading = false;
      console.log(error);
    }
  }
}
const notificationStore = new Store();
export default notificationStore;
