소스 검색

getActionsByStatus 失败返回 undefined

visuddhinanda 2 년 전
부모
커밋
d6e3ad03f5
1개의 변경된 파일35개의 추가작업 그리고 3개의 파일을 삭제
  1. 35 3
      dashboard/src/components/course/RolePower.ts

+ 35 - 3
dashboard/src/components/course/RolePower.ts

@@ -19,7 +19,8 @@ export const getStudentActionsByStatus = (
   startAt?: string,
   endAt?: string
 ): TCourseMemberAction[] | undefined => {
-  return getActionsByStatus(studentData, status, mode, startAt, endAt);
+  const output = getActionsByStatus(studentData, status, mode, startAt, endAt);
+  return output;
 };
 const getActionsByStatus = (
   data: IAction[],
@@ -47,7 +48,7 @@ const getActionsByStatus = (
         }
       }
     }
-    return false;
+    return undefined;
   });
 
   if (actions) {
@@ -117,6 +118,30 @@ export const studentCanDo = (
   return test(studentData, action, startAt, endAt, mode, status);
 };
 
+interface IStatusColor {
+  status: TCourseMemberStatus;
+  color: string;
+}
+export const getStatusColor = (status?: TCourseMemberStatus): string => {
+  let color = "unset";
+  const setting: IStatusColor[] = [
+    { status: "applied", color: "blue" },
+    { status: "invited", color: "blue" },
+    { status: "accepted", color: "green" },
+    { status: "agreed", color: "green" },
+    { status: "rejected", color: "orange" },
+    { status: "disagreed", color: "red" },
+    { status: "left", color: "red" },
+    { status: "blocked", color: "orange" },
+  ];
+  const CourseStatusColor = setting.find((value) => value.status === status);
+
+  if (CourseStatusColor) {
+    color = CourseStatusColor.color;
+  }
+  return color;
+};
+
 const studentData: IAction[] = [
   {
     mode: ["open"],
@@ -128,7 +153,14 @@ const studentData: IAction[] = [
   {
     mode: ["open"],
     status: "applied",
-    before: [],
+    before: ["leave"],
+    duration: ["leave"],
+    after: [],
+  },
+  {
+    mode: ["open"],
+    status: "joined",
+    before: ["leave"],
     duration: ["leave"],
     after: [],
   },