import { ref } from "vue";
import { defineStore } from "pinia";

export const useResultsPerformDataStore = defineStore(
  "resultPerformDataStore",
  () => {
    function textRangePoint(val: number | undefined) {
      if (val == undefined) val = -1;
      if (val < 60.0) return "(คะแนนต่ำกว่าร้อยละ 60.00)";
      if (val >= 60.0 && val <= 69.99) return "(คะแนนร้อยละ 60.00 - 69.99)";
      if (val >= 70.0 && val <= 79.99) return "(คะแนนร้อยละ 70.00 - 79.99)";
      if (val >= 80.0 && val <= 89.99) return " (คะแนนร้อยละ 80.00 - 89.99)";
      if (val >= 90.0) return " (คะแนนร้อยละ 90.00 ขึ้นไป)";
      else return "";
    }

    function textPoint(val: number | undefined) {
      if (val == undefined) val = -1;
      if (val < 60.0) return "ต้องปรับปรุง";
      if (val >= 60.0 && val <= 69.99) return "พอใช้";
      if (val >= 70.0 && val <= 79.99) return "ดี";
      if (val >= 80.0 && val <= 89.99) return "ดีมาก";
      if (val >= 90.0) return "ดีเด่น";
      else return "-";
    }

    return { textRangePoint, textPoint };
  }
);
