Test.js 1.03 KB
import { subForage, scheForage } from "./LocalForage";

const initTempSubjects = async () => {
  scheForage.setItem("20220503", [
    { type: "zoom", category: "과목A", label: "", start: [9, 30] },
    { type: "ecampus", category: "과목B", label: "과제", end: [23, 59] },
  ]);

  let tcolors = [
    "red",
    "green",
    "blue",
    "orange",
    "gold",
    "aqua",
    "chartreuse",
  ];
  const subCodeLst = ["1", "2"];
  const subObj = {
    1: {
      name: "과목A",
      color: tcolors[0],
      selected: true,
    },
    2: {
      name: "과목B",
      color: tcolors[1],
      selected: true,
    },
  };

  await subForage.setItem("1", subObj["1"]);
  await subForage.setItem("2", subObj["2"]);

  for (let i = 2; i < 7; i++) {
    let code = (i + 1).toString();
    let tsub = {
      name: "과목" + code,
      color: tcolors[i],
      selected: true,
    };
    subCodeLst.push(code);
    await subForage.setItem(code, tsub);
  }
  localStorage.setItem("Subjects", JSON.stringify(subCodeLst));
};

export { initTempSubjects };