Skip to content

Commit

Permalink
Merge pull request #280 from thinc-org/beta
Browse files Browse the repository at this point in the history
Deploy to Production (14th Dec 2021)
  • Loading branch information
saenyakorn authored Dec 14, 2021
2 parents 12ce06a + 75205e3 commit 06b9a26
Show file tree
Hide file tree
Showing 141 changed files with 5,461 additions and 437 deletions.
3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.next
src/lib/*
.next
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"importOrder": ["^@/(.*)$", "^[./]"],
"importOrder": ["^react*", "^@/(.*)$", "^[./]"],
"importOrderSeparation": true
}
22 changes: 21 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,30 @@ module.exports = {
},
],
['@babel/plugin-proposal-decorators', { legacy: true }],
[
'@emotion',
{
importMap: {
'@mui/system': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: ['@mui/system', 'styled'],
},
},
'@mui/material/styles': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: ['@mui/material/styles', 'styled'],
},
},
},
},
],
],

env: {
production: {
plugins: [['transform-remove-console', { "exclude": ["error", "warn"] }]],
plugins: [['transform-remove-console', { exclude: ['error', 'warn'] }]],
},
},
}
13 changes: 13 additions & 0 deletions custom-test-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable */
const Environment = require('jest-environment-jsdom')

module.exports = class CustomTestEnvironment extends Environment {
async setup() {
await super.setup()
if (typeof this.global.TextEncoder === 'undefined') {
const { TextEncoder, TextDecoder } = require('util')
this.global.TextEncoder = TextEncoder
this.global.TextDecoder = TextDecoder
}
}
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
testEnvironment: 'jsdom',
testEnvironment: '<rootDir>/custom-test-env.js',
moduleNameMapper: {
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
Expand Down
8 changes: 4 additions & 4 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// DOM rendering
import '@testing-library/jest-dom'

// Shallow rendering
import { configure } from 'enzyme';
import { configure } from 'enzyme'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const Adapter = require('enzyme-adapter-react-16')
configure({ adapter: new Adapter() });
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
configure({ adapter: new Adapter() })
14 changes: 9 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const withPlugins = require('next-compose-plugins')
const withOptimizedImages = require('next-optimized-images')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

module.exports = withOptimizedImages({
module.exports = withPlugins([[withBundleAnalyzer], [withOptimizedImages]], {
// other options here
env: {
IS_PULL_REQUEST: process.env.IS_PULL_REQUEST,
Expand All @@ -17,9 +21,9 @@ module.exports = withOptimizedImages({
async rewrites() {
return [
{
source: '/api/:path*',
destination: `${process.env.NEXT_PUBLIC_BACKEND_URL}/:path*`
}
source: '/apiProxy/:path*',
destination: `${process.env.NEXT_PUBLIC_BACKEND_URL}/:path*`,
},
]
}
},
})
34 changes: 31 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
"dependencies": {
"@apollo/client": "^3.4.x",
"@date-io/date-fns": "1.x",
"@emotion/babel-plugin": "^11.3.0",
"@emotion/cache": "^11.5.0",
"@emotion/react": "^11.5.0",
"@emotion/server": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@mui/icons-material": "^5.1.0",
"@mui/lab": "^5.0.0-alpha.54",
"@mui/material": "^5.1.0",
"@mui/material": "5.1.0",
"@next/bundle-analyzer": "^12.0.7",
"@react-hook/google-optimize": "^1.2.1",
"@thinc-org/chula-courses": "^2.3.0",
"@types/gapi": "^0.0.39",
Expand All @@ -32,20 +34,38 @@
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-measure": "^2.0.6",
"@types/uuid": "^8.3.0",
"@udecode/plate-autoformat": "^8.3.0",
"@udecode/plate-basic-marks": "^8.3.0",
"@udecode/plate-block-quote": "^8.3.0",
"@udecode/plate-block-quote-ui": "^8.3.0",
"@udecode/plate-break": "^8.3.0",
"@udecode/plate-code-block-ui": "^8.3.0",
"@udecode/plate-core": "^8.3.0",
"@udecode/plate-heading": "^8.3.0",
"@udecode/plate-indent": "^8.3.0",
"@udecode/plate-list": "^8.3.0",
"@udecode/plate-list-ui": "^8.3.0",
"@udecode/plate-paragraph": "^8.3.0",
"@udecode/plate-reset-node": "^8.3.0",
"@udecode/plate-styled-components": "^8.3.0",
"@udecode/plate-toolbar": "^8.3.0",
"axios": "^0.21.1",
"babel-plugin-macros": "^3.0.1",
"broadcast-channel": "^4.2.0",
"date-fns": "^2.16.1",
"escape-html": "^1.0.3",
"framer-motion": "^4.1.17",
"graphql": "^15.5.0",
"html2canvas": "^1.0.0-rc.7",
"i18next": "^19.8.4",
"imagemin-svgo": "^8.0.0",
"isomorphic-dompurify": "^0.17.0",
"lodash": "^4.17.21",
"mobx": "^6.1.7",
"mobx-react": "^7.1.0",
"mobx-utils": "^6.0.3",
"next": "10.0.5",
"next-compose-plugins": "^2.2.1",
"next-optimized-images": "^2.6.2",
"next-seo": "^4.28.1",
"next-sitemap": "^1.6.179",
Expand All @@ -54,10 +74,17 @@
"react-beautiful-dnd": "^13.1.0",
"react-dom": "17.0.1",
"react-gtm-module": "^2.0.11",
"react-hook-form": "^7.18.1",
"react-hot-toast": "^2.1.1",
"react-i18next": "^11.8.5",
"react-icons": "^4.2.0",
"react-loading": "^2.0.3",
"react-measure": "^2.5.2",
"slate": "^0.72.0",
"slate-history": "^0.66.0",
"slate-hyperscript": "^0.67.0",
"slate-react": "0.72.1",
"styled-components": "^5.3.3",
"use-react-screenshot": "^1.0.2",
"uuid": "^8.3.2"
},
Expand All @@ -74,9 +101,10 @@
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.7",
"@testing-library/react-hooks": "^5.0.3",
"@trivago/prettier-plugin-sort-imports": "^2.0.2",
"@trivago/prettier-plugin-sort-imports": "^3.1.1",
"@types/babel-plugin-macros": "^2.8.4",
"@types/enzyme": "^3.10.9",
"@types/escape-html": "^1.0.1",
"@types/gapi.auth2": "^0.0.55",
"@types/jest": "^27.0.1",
"@types/node": "^14.14.20",
Expand All @@ -85,11 +113,11 @@
"@types/react-gtm-module": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"babel-plugin-transform-remove-console": "^6.9.4",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.6.2",
"eslint": "^7.17.0",
"eslint-plugin-import": "^2.24.2",
Expand Down
27 changes: 20 additions & 7 deletions src/__mock__/overlap.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import { mockCourseData } from '@/__mock__/courses'
import { ExamClass } from '@/common/utils/types'
import { CourseOverlap, CourseOverlapMap, ScheduleClass } from '@/modules/Schedule/components/Schedule/utils'

const mockCourse = mockCourseData[0]
export const mockItem = {
...mockCourse,
color: 'pink',
isHidden: false,
selectedSectionNo: '1',
} as const
export const courseTemplate: Omit<ScheduleClass, 'classIndex'> = {
courseNo: '2110316',
abbrName: 'PROG LANG PRIN',
genEdType: 'NO',
building: 'ENG3',
room: '318',
teachers: ['NNN'],
courseNo: mockCourse.courseNo,
abbrName: mockCourse.abbrName,
studyProgram: mockCourse.studyProgram,
academicYear: mockCourse.academicYear,
semester: mockCourse.semester,
genEdType: mockCourse.genEdType,
teachers: [],
sectionNo: '1',
section: mockCourse.sections[0],
color: 'pink',
position: {
start: 0,
end: 0,
},
hasOverlap: false,
overlaps: [],
item: mockItem,
}

export const examTemplate: ExamClass = {
Expand All @@ -30,7 +43,7 @@ export const examTemplate: ExamClass = {
period: { start: '', end: '' },
},
isHidden: false,

color: 'pink',
hasOverlap: false,
overlaps: [],
}
Expand Down
112 changes: 112 additions & 0 deletions src/__mock__/review.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { Review } from '@/common/types/reviews'

export const mockReviews: Review[] = [
{
_id: '61ab376cea2d0aeded10dc2b',
rating: 8,
courseNo: '0201109',
semester: '2',
academicYear: '2564',
studyProgram: 'S',
content: 'เหนื่อยากเลยค่าแงงงงง',
likeCount: 0,
dislikeCount: 0,
myInteraction: null,
status: 'APPROVED' as Review['status'],
isOwner: false,
},
{
_id: '61ab389bea2d0aeded10dc6a',
rating: 9,
courseNo: '0201109',
semester: '1',
academicYear: '2563',
studyProgram: 'S',
content: 'อยากนอน',
likeCount: 0,
dislikeCount: 0,
myInteraction: null,
status: 'APPROVED' as Review['status'],
isOwner: false,
},
{
_id: '61ab39d457ff6cbfc0e4b809',
rating: 7,
courseNo: '0201109',
semester: '3',
academicYear: '2563',
studyProgram: 'S',
content:
'วิชานี้เกี่ยวกับแนวคิดและพัฒนาการของการบูรณาการยุโรป ตั้งแต่ช่วงสงครามโลกครั้งที่ 2 จนถึงปัจจุบัน ปัญหาความขัดแย้งต่างๆ ที่ส่งผลต่อการบูรณาการ ความร่วมมือ ผลกระทบและกลยุทธ์ด้านวัฒนธรรม การเมือง เศรษฐกิจ สังคม วิทยาศาสตร์และเทคโนโลยี ภายในกลุ่มสหภาพยุโรป และระหว่างสหภาพยุโรปกับไทย ประเทศในกลุ่มอาเซียนและเอเชีย \nสนุกดีนะ',
likeCount: 0,
dislikeCount: 0,
myInteraction: null,
status: 'APPROVED' as Review['status'],
isOwner: false,
},
{
_id: '61ab5096811ca6c9769f5bed',
rating: 10,
courseNo: '0201109',
semester: '2',
academicYear: '2564',
studyProgram: 'S',
content: 'ดีครับ อาจารย์น่ารักมาก ๆ ',
likeCount: 0,
dislikeCount: 0,
myInteraction: null,
status: 'APPROVED' as Review['status'],
isOwner: false,
},
]

export const mockMyReviews: Review[] = [
{
_id: '61ab376cea2d0aeded10dc2b',
rating: 8,
courseNo: '0201109',
semester: '2',
academicYear: '2564',
studyProgram: 'S',
content: 'เหนื่อยากเลยค่าแงงงงง',
likeCount: 0,
dislikeCount: 0,
myInteraction: null,
status: 'APPROVED' as Review['status'],
isOwner: true,
},
]

export const mockMyPendingReviews: Review[] = [
{
_id: '61ab59632d5b971a45ca3238',
rating: 3,
courseNo: '0201109',
semester: '2',
academicYear: '2564',
studyProgram: 'S',
content: 'เขียนดี ๆ แล้ว อิอิ',
likeCount: 1,
dislikeCount: 0,
myInteraction: 'L' as Review['myInteraction'],
status: 'PENDING' as Review['status'],
isOwner: true,
},
]

export const mockMyRejectedReviews: Review[] = [
{
_id: '61ab59632d5b971a45ca3238',
rating: 3,
courseNo: '0201109',
semester: '2',
academicYear: '2564',
studyProgram: 'S',
content: 'เขียนดี ๆ แล้ว อิอิ',
likeCount: 1,
dislikeCount: 0,
myInteraction: 'L' as Review['myInteraction'],
status: 'REJECTED' as Review['status'],
isOwner: true,
},
]
8 changes: 5 additions & 3 deletions src/common/components/Chips/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ export const dayChipConfig: DayChipConfigProps = {
export enum OtherEnum {
open = 'open',
close = 'close',
reviewPending = 'reviewPending',
reviewRejected = 'reviewRejected',
chula = 'chula',
other = 'other',
noConflict = 'noConflict',
}
export type OtherChipKey = OtherEnum
export type OtherChipKey = keyof typeof OtherEnum
export type OtherChipConfigProps = Record<OtherChipKey, ChipConfigProps>
export const otherChipConfig: OtherChipConfigProps = {
open: createDefaultChipConfig('เปิด'),
close: createDefaultChipConfig('ปิด'),
reviewPending: { label: 'รอการอนุมัติ', color: 'yellowFilled' },
reviewRejected: { label: 'ไม่ได้รับการอนุมัติ', color: 'redFilled' },
chula: createDefaultChipConfig('เกี่ยวกับจุฬาฯ'),
other: createDefaultChipConfig('อื่น ๆ'),
noConflict: createDefaultChipConfig('เวลาไม่ชนกับวิชาที่เลือก'),
// Add more Chips here; don't forget to add key into `OtherChipKey` too
}

Expand Down
Loading

0 comments on commit 06b9a26

Please sign in to comment.