-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from sparcs-kaist/migration@utils
migrate util functions
- Loading branch information
Showing
20 changed files
with
418 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import type Lecture from '@/shapes/model/subject/Lecture'; | ||
|
||
interface LectureGroups { | ||
lectureGroups: Lecture[][]; | ||
} | ||
export default interface LectureLists { | ||
search: { | ||
lectureGroups: Lecture[][]; | ||
}; | ||
basic: { | ||
lectureGroups: Lecture[][]; | ||
}; | ||
humanity: { | ||
lectureGroups: Lecture[][]; | ||
}; | ||
cart: { | ||
lectureGroups: Lecture[][]; | ||
}; | ||
search: LectureGroups; | ||
basic: LectureGroups; | ||
humanity: LectureGroups; | ||
cart: LectureGroups; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Course from '@/shapes/model/subject/Course'; | ||
import User from '@/shapes/model/session/User'; | ||
import CourseFocus from '@/shapes/state/dictionary/CourseFocus'; | ||
import { getTranslatedString } from '@/utils/translationUtils'; | ||
|
||
//Dictionary Page 에서 사용되는 유틸들입니다. | ||
|
||
// Dictionary Page 의 Course List Section 에서 포커싱된 Course가 현재 Course이면 True를 반환합니다. | ||
export const isFocused = (course: Course, courseFocus: CourseFocus) => | ||
Boolean(courseFocus.course) && courseFocus.course?.id === course.id; | ||
|
||
// Dictionary Page 의 Course List Section 에서 포커싱된 Course가 있고, 포커싱된 Course가 현재 Course가 아니면 True를 반환합니다. | ||
export const isDimmedCourse = (course: Course, courseFocus: CourseFocus) => | ||
Boolean(courseFocus.course) && courseFocus.course?.id !== course.id; | ||
|
||
// Dictionary Page의 Course List Section에서 이미 수강한 Course 이면 True를 반환합니다. | ||
// isTaken 이 True 이면 리뷰 작성하기 블록이 보여집니다. | ||
export const isTaken = (courseId: number, user: User) => | ||
user.review_writable_lectures.some((l) => l.course === courseId); | ||
|
||
// Dictionary Page의 Course Block 에서 교수님들의 이름 리스트를 가져오기 위해 사용합니다. | ||
export const getProfessorsFullStr = (course: Course) => { | ||
const professors = course.professors.slice().sort((a, b) => (a.name < b.name ? -1 : 1)); | ||
const professorNames = professors.map((p) => getTranslatedString(p, 'name')); | ||
return professorNames.join(', '); | ||
}; | ||
|
||
export const isSpecialLectureCourse = (course: Course) => | ||
course.title.includes('특강') || | ||
course.title_en.includes('Special Lectures') || | ||
course.title_en.includes('Special Topics'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Examtime from '@/shapes/model/subject/Examtime'; | ||
import { getTranslatedString } from '@/utils/translationUtils'; | ||
|
||
export const getStr = (examtime: Examtime) => getTranslatedString(examtime, 'str'); | ||
|
||
export const getTimeStr = (examtime: Examtime) => { | ||
const fullStr = getStr(examtime); | ||
return fullStr?.slice(fullStr.indexOf(' ')); | ||
}; |
Oops, something went wrong.