package com.app.simplitend.patientprofile.setuproutine.mvvm;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;

import com.app.simplitend.patientprofile.ProfileContracts;

public class RoutineViewModel extends ViewModel {

    private final RoutinesRepository routinesRepository;

    // selected day of week
    public int selected_dow;

    public RoutineViewModel(){
        this.routinesRepository = RoutinesRepository.getRoutineRepository();

        // selection state default
        selected_dow = 0;
    }

    public void getRoutines(int patient_id,
                            String token,
                            int week_day,
                            @NonNull ProfileContracts.GetRoutinesCallback routinesCallback){
        routinesRepository.getRoutines(patient_id, token, week_day, routinesCallback);
    }

    public void addNUpdateRoutine(int patient_id,
                                  RoutineDetails routineDetails,
                                  String token,
                                  @NonNull ProfileContracts.AddNUpdateRoutineCallback routineCallback){
        routinesRepository.addNUpdateRoutine(patient_id, routineDetails, token, routineCallback);
    }

    public void deleteRoutine(int patient_id,
                              int patient_routine_id,
                              int adapterPosition,
                              String token,
                              @NonNull ProfileContracts.RoutineDeleteCallback deleteCallback){
        routinesRepository.deleteRoutine(patient_id, patient_routine_id, adapterPosition, token, deleteCallback);
    }


    public String getDayOfWeek(int position){
        switch (position){
            case 0:
                return "Sun";
            case 1:
                return "Mon";
            case 2:
                return "Tue";
            case 3:
                return "Wed";
            case 4:
                return "Thu";
            case 5:
                return "Fri";
            case 6:
                return "Sat";
        }

        return "";
    }

    public String getMonthOfYear(int month){
        switch (month){
            case 1:
                return "January";
            case 2:
                return "February";
            case 3:
                return "March";
            case 4:
                return "April";
            case 5:
                return "May";
            case 6:
                return "June";
            case 7:
                return "July";
            case 8:
                return "August";
            case 9:
                return "September";
            case 10:
                return "October";
            case 11:
                return "November";
            case 12:
                return "December";
        }

        return "";
    }
}
