Skip to content

Commit

Permalink
Merge branch 'beta' into feat/backoffice
Browse files Browse the repository at this point in the history
  • Loading branch information
khajornritdacha committed Sep 18, 2023
2 parents c169e54 + 7fd8fd8 commit 947dd90
Show file tree
Hide file tree
Showing 30 changed files with 139 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .changeset/change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'admin-api': major
'admin-web': major
---

init admin-api and admin-web
7 changes: 7 additions & 0 deletions .changeset/old-insects-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'admin-web': patch
'admin-api': patch
'web': patch
---

fix broken build in previous release
4 changes: 4 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
"@cgr/schema": "1.1.1"
},
"changesets": [
"change",
"enhance-search-engine",
"old-insects-sit",
"spotty-gifts-flash",
"thin-houses-rhyme",
"unlucky-cars-hang",
"violet-sloths-reply"
]
Expand Down
5 changes: 5 additions & 0 deletions .changeset/spotty-gifts-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'reg-scraper': minor
---

use cas url instead
5 changes: 5 additions & 0 deletions .changeset/thin-houses-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'web': minor
---

feat: explicit warning not reg chula at first page (Close #623)
12 changes: 12 additions & 0 deletions apps/admin-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# admin-api

## 1.0.0-beta.2

### Patch Changes

- 02c4acbe: fix broken build in previous release

## 1.0.0-beta.1

### Major Changes

- f771ad38: init admin-api and admin-web

## 0.2.0-beta.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admin-api",
"version": "0.2.0-beta.0",
"version": "1.0.0-beta.2",
"description": "",
"author": "",
"private": true,
Expand Down
5 changes: 4 additions & 1 deletion apps/admin-api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { AppService } from './app.service'

@Controller()
export class AppController {
constructor(private readonly appService: AppService, private readonly authService: AuthService) {}
constructor(
private readonly appService: AppService,
private readonly authService: AuthService
) {}

@Get()
getHello(): string {
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-api/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BadRequestException, Controller, Get, Logger, Post, Query, Req, Res } from '@nestjs/common'
import { BadRequestException, Controller, Get, Logger, Query, Req, Res } from '@nestjs/common'

import { Request, Response } from 'express'

Expand Down
5 changes: 4 additions & 1 deletion apps/admin-api/src/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { SKIP_AUTH } from '@admin-api/common/decorators/SkipAuth'

@Injectable()
export class AuthGuard implements CanActivate {
constructor(private jwtService: JwtService, private reflector: Reflector) {}
constructor(
private jwtService: JwtService,
private reflector: Reflector
) {}

async canActivate(context: ExecutionContext): Promise<boolean> {
const ctx = GqlExecutionContext.create(context)
Expand Down
7 changes: 5 additions & 2 deletions apps/admin-api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BadRequestException, Injectable, Logger } from '@nestjs/common'
import { Injectable, Logger } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { JwtService } from '@nestjs/jwt'

Expand All @@ -10,7 +10,10 @@ import { TokenUrlResponse, UserInfoDto } from './auth.dto'
export class AuthService {
logger: Logger

constructor(private configService: ConfigService, private jwtService: JwtService) {
constructor(
private configService: ConfigService,
private jwtService: JwtService
) {
this.logger = new Logger('Auth Service')
}

Expand Down
4 changes: 2 additions & 2 deletions apps/admin-api/src/review/review.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export class ReviewService {
if (!this.webhook) {
return
}
const dashBoardUrl = this.configService.get<string>('dashBoardUrl')
const reviewDashboardUrl = this.configService.get<string>('reviewDashboardUrl')
this.logger.log(`sent alert`)
return this.webhook.send({
text: `A new review is created for course ${review.courseNo} ${review.studyProgram} ${review.semester}/${review.academicYear}. Review them now in <${dashBoardUrl}|Review Dashboard>.`,
text: `A new review is created for course ${review.courseNo} ${review.studyProgram} ${review.semester}/${review.academicYear}. Review them now in <${reviewDashboardUrl}|Review Dashboard>.`,
})
}

Expand Down
4 changes: 2 additions & 2 deletions apps/admin-web/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
NEXT_PUBLIC_ENVIRONMENT=local

# Backend
NEXT_PUBLIC_BACKEND_URL=http://localhost:3333
NEXT_PUBLIC_BACKEND_URL_BASE=http://localhost:3333

# GraphQL
NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL}/_api/graphql
NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL_BASE}/_api/graphql

# Sitemap (Frontend URL)
NEXT_PUBLIC_SITE_URL=http://localhost:4201
Expand Down
12 changes: 12 additions & 0 deletions apps/admin-web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# admin-web

## 1.0.0-beta.2

### Patch Changes

- 02c4acbe: fix broken build in previous release

## 1.0.0-beta.1

### Major Changes

- f771ad38: init admin-api and admin-web

## 0.1.2-beta.0

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admin-web",
"version": "0.1.2-beta.0",
"version": "1.0.0-beta.2",
"private": true,
"scripts": {
"dev": "next dev -p 4201",
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-web/src/context/ProtectedRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ProtectedRoutes = (props: ProctectedRoutesProps) => {
useEffect(() => {
if (!router) return
if (unProtectedRoutes.includes(router.pathname)) return
if (!!user) return
if (user) return

const loadUserData = async () => {
try {
Expand Down
2 changes: 0 additions & 2 deletions apps/admin-web/src/module/genEd/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { useEffect, useState } from 'react'

import { useRouter } from 'next/router'

import { useGetOverridesQuery } from '@cgr/codegen'

import AddGenEdDialog from './components/AddGenEdDialog'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ReactNode } from 'react'

import { FormControl, MenuItem, SelectChangeEvent } from '@mui/material'

import { StyledInputLabel, StyledSelect } from './styled'
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-web/src/module/pendingReviews/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react-hooks/rules-of-hooks */
import { useEffect, useState } from 'react'
import { useEffect } from 'react'

import { Container } from '@mui/material'

Expand Down
2 changes: 1 addition & 1 deletion apps/admin-web/src/pages/generateToken/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { GenerateToken as default } from '@admin-web/module/generateToken'
export { GenerateToken as default } from '@admin-web/module/generateToken'
4 changes: 2 additions & 2 deletions apps/admin-web/src/services/apollo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApolloClient, InMemoryCache } from '@apollo/client'
import { BatchHttpLink } from '@apollo/client/link/batch-http'
import { setContext } from '@apollo/client/link/context'

import { ADMIN_ACCESS_TOKEN, ENVIRONMENT } from '@admin-web/env'
import { ENVIRONMENT } from '@admin-web/env'
import { apiUrl } from '@admin-web/services/httpClient'

const createHttpLink = () =>
Expand All @@ -14,7 +14,7 @@ const createHttpLink = () =>
})

const authLink = setContext(async (_, { headers }) => {
const accessToken = ADMIN_ACCESS_TOKEN
const accessToken = 'ADMIN_ACCESS_TOKEN'
return {
headers: {
...headers,
Expand Down
6 changes: 6 additions & 0 deletions apps/reg-scraper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# reg-scraper

## 1.2.0-beta.1

### Minor Changes

- bfda7a77: use cas url instead

## 1.2.0-beta.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/reg-scraper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reg-scraper",
"version": "1.2.0-beta.0",
"version": "1.2.0-beta.1",
"private": true,
"scripts": {
"dev": "nest start --watch",
Expand Down
2 changes: 1 addition & 1 deletion apps/reg-scraper/src/scraper/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import tough from 'tough-cookie'

// make instance for collecting cookie
export const instance = axios.create({
baseURL: 'https://www2.reg.chula.ac.th',
baseURL: 'https://cas.reg.chula.ac.th',
withCredentials: true,
responseType: 'arraybuffer',
httpsAgent: new HttpsCookieAgent({
Expand Down
12 changes: 12 additions & 0 deletions apps/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# web

## 1.7.0-beta.2

### Patch Changes

- 02c4acbe: fix broken build in previous release

## 1.7.0-beta.1

### Minor Changes

- 46e520b2: feat: explicit warning not reg chula at first page (Close #623)

## 1.6.1-beta.0

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web",
"version": "1.6.1-beta.0",
"version": "1.7.0-beta.2",
"private": true,
"scripts": {
"dev": "next dev -p 4200",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { AnnoucementItem } from '@web/common/components/TopBar/components/AnnouncementBar/types'
import { AnnouncementItem } from '@web/common/components/TopBar/components/AnnouncementBar/types'

// TODO Admin should b able to change the annoucement
export function getCurrentAnnoucement(): AnnoucementItem {
// TODO Admin should be able to change the annoucement

export function getAnnouncement1(): AnnouncementItem {
return {
id: 'annoucement_1',
label: 'CU Get Reg เป็นเว็บไซต์ที่จัดทำโดยนิสิต ซึ่งได้รับการสนับสนุนเซิฟเวอร์จาก Reg Chula',
severity: 'info',
}
}

export function getNotRegChulaWarning(): AnnouncementItem {
return {
id: 'not_reg_chula',
label:
'CU Get Reg เป็นเพียงเครื่องมือที่ช่วยให้การวางแผนลงทะเบียนเรียนง่ายขึ้น แต่ไม่ใช่การลงทะเบียนเรียนจริง คุณสามารถลงทะเบียนเรียนได้ที่ https://www2.reg.chula.ac.th/ เพียงช่องทางเดียวเท่านั้น',
severity: 'warning',
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
import React from 'react'
import { useEffect, useState } from 'react'
import { FC, useEffect, useState } from 'react'

import { Alert, Container, styled } from '@mui/material'

import { Storage } from '@web/common/storage'
import { StorageKey } from '@web/common/storage/constants'

import { getCurrentAnnoucement } from './announcements'
import { AnnoucementItem } from './types'
import { AnnouncementItem } from './types'

const AlertContainer = styled(Container)`
padding-top: 16px;
`

export const AnnouncementBar: React.FC = () => {
const currentAnnoucement = getCurrentAnnoucement()
type AnnouncementBarProps = { announcement: AnnouncementItem }

export const AnnouncementBar: FC<AnnouncementBarProps> = ({ announcement }) => {
const [show, setShow] = useState(false)

useEffect(() => {
const storage = new Storage('localStorage')
const seenAnnoucements = storage.get<AnnoucementItem[]>(StorageKey.SeenAnnoucements) ?? []
const seen = seenAnnoucements.some(({ id }) => id === currentAnnoucement.id)
const seenAnnoucements = storage.get<AnnouncementItem[]>(StorageKey.SeenAnnoucements) ?? []
const seen = seenAnnoucements.some(({ id }) => id === announcement.id)
setShow(!seen)
}, [currentAnnoucement])
}, [announcement])

const handleClose = () => {
const storage = new Storage('localStorage')
const seenAnnoucements = storage.get<AnnoucementItem[]>(StorageKey.SeenAnnoucements) ?? []
storage.set<AnnoucementItem[]>(StorageKey.SeenAnnoucements, [
const seenAnnoucements = storage.get<AnnouncementItem[]>(StorageKey.SeenAnnoucements) ?? []
storage.set<AnnouncementItem[]>(StorageKey.SeenAnnoucements, [
...seenAnnoucements,
currentAnnoucement,
announcement,
])
setShow(false)
}
Expand All @@ -41,8 +39,8 @@ export const AnnouncementBar: React.FC = () => {

return (
<AlertContainer>
<Alert onClose={handleClose} severity="info">
{currentAnnoucement.label}
<Alert onClose={handleClose} severity={announcement.severity}>
{announcement.label}
</Alert>
</AlertContainer>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export interface AnnoucementItem {
import { AlertColor } from '@mui/material'

export interface AnnouncementItem {
id: string
label: string
severity: AlertColor
}
Loading

0 comments on commit 947dd90

Please sign in to comment.