diff --git a/.changeset/change.md b/.changeset/change.md new file mode 100644 index 000000000..af4a088b2 --- /dev/null +++ b/.changeset/change.md @@ -0,0 +1,6 @@ +--- +'admin-api': major +'admin-web': major +--- + +init admin-api and admin-web diff --git a/.changeset/old-insects-sit.md b/.changeset/old-insects-sit.md new file mode 100644 index 000000000..a253222c4 --- /dev/null +++ b/.changeset/old-insects-sit.md @@ -0,0 +1,7 @@ +--- +'admin-web': patch +'admin-api': patch +'web': patch +--- + +fix broken build in previous release diff --git a/.changeset/pre.json b/.changeset/pre.json index 5cfbdd84e..89cd0651d 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -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" ] diff --git a/.changeset/spotty-gifts-flash.md b/.changeset/spotty-gifts-flash.md new file mode 100644 index 000000000..bb6127565 --- /dev/null +++ b/.changeset/spotty-gifts-flash.md @@ -0,0 +1,5 @@ +--- +'reg-scraper': minor +--- + +use cas url instead diff --git a/.changeset/thin-houses-rhyme.md b/.changeset/thin-houses-rhyme.md new file mode 100644 index 000000000..372a66c84 --- /dev/null +++ b/.changeset/thin-houses-rhyme.md @@ -0,0 +1,5 @@ +--- +'web': minor +--- + +feat: explicit warning not reg chula at first page (Close #623) diff --git a/apps/admin-api/CHANGELOG.md b/apps/admin-api/CHANGELOG.md index 98b8345ff..df85db1dd 100644 --- a/apps/admin-api/CHANGELOG.md +++ b/apps/admin-api/CHANGELOG.md @@ -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 diff --git a/apps/admin-api/package.json b/apps/admin-api/package.json index 9bc71c932..0423759f7 100644 --- a/apps/admin-api/package.json +++ b/apps/admin-api/package.json @@ -1,6 +1,6 @@ { "name": "admin-api", - "version": "0.2.0-beta.0", + "version": "1.0.0-beta.2", "description": "", "author": "", "private": true, diff --git a/apps/admin-api/src/app/app.controller.ts b/apps/admin-api/src/app/app.controller.ts index 2f3cc3564..215f9ed02 100644 --- a/apps/admin-api/src/app/app.controller.ts +++ b/apps/admin-api/src/app/app.controller.ts @@ -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 { diff --git a/apps/admin-api/src/auth/auth.controller.ts b/apps/admin-api/src/auth/auth.controller.ts index d089394ca..ab46584d0 100644 --- a/apps/admin-api/src/auth/auth.controller.ts +++ b/apps/admin-api/src/auth/auth.controller.ts @@ -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' diff --git a/apps/admin-api/src/auth/auth.guard.ts b/apps/admin-api/src/auth/auth.guard.ts index e6607c401..d1e860cda 100644 --- a/apps/admin-api/src/auth/auth.guard.ts +++ b/apps/admin-api/src/auth/auth.guard.ts @@ -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 { const ctx = GqlExecutionContext.create(context) diff --git a/apps/admin-api/src/auth/auth.service.ts b/apps/admin-api/src/auth/auth.service.ts index af6f6333b..c465723f2 100644 --- a/apps/admin-api/src/auth/auth.service.ts +++ b/apps/admin-api/src/auth/auth.service.ts @@ -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' @@ -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') } diff --git a/apps/admin-api/src/review/review.service.ts b/apps/admin-api/src/review/review.service.ts index 2bd5c5461..e4153c4da 100644 --- a/apps/admin-api/src/review/review.service.ts +++ b/apps/admin-api/src/review/review.service.ts @@ -39,10 +39,10 @@ export class ReviewService { if (!this.webhook) { return } - const dashBoardUrl = this.configService.get('dashBoardUrl') + const reviewDashboardUrl = this.configService.get('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>.`, }) } diff --git a/apps/admin-web/.env b/apps/admin-web/.env index f34af0363..d91fa43bd 100644 --- a/apps/admin-web/.env +++ b/apps/admin-web/.env @@ -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 diff --git a/apps/admin-web/CHANGELOG.md b/apps/admin-web/CHANGELOG.md index 14233f0e4..1a901d078 100644 --- a/apps/admin-web/CHANGELOG.md +++ b/apps/admin-web/CHANGELOG.md @@ -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 diff --git a/apps/admin-web/package.json b/apps/admin-web/package.json index 413958bd7..3071a4040 100644 --- a/apps/admin-web/package.json +++ b/apps/admin-web/package.json @@ -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", diff --git a/apps/admin-web/src/context/ProtectedRoutes.tsx b/apps/admin-web/src/context/ProtectedRoutes.tsx index c7eb1b216..f1781cb36 100644 --- a/apps/admin-web/src/context/ProtectedRoutes.tsx +++ b/apps/admin-web/src/context/ProtectedRoutes.tsx @@ -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 { diff --git a/apps/admin-web/src/module/genEd/index.tsx b/apps/admin-web/src/module/genEd/index.tsx index aa72fd254..410c12757 100644 --- a/apps/admin-web/src/module/genEd/index.tsx +++ b/apps/admin-web/src/module/genEd/index.tsx @@ -1,7 +1,5 @@ import { useEffect, useState } from 'react' -import { useRouter } from 'next/router' - import { useGetOverridesQuery } from '@cgr/codegen' import AddGenEdDialog from './components/AddGenEdDialog' diff --git a/apps/admin-web/src/module/pendingReviews/components/Topbar/components/SelectForm/index.tsx b/apps/admin-web/src/module/pendingReviews/components/Topbar/components/SelectForm/index.tsx index d14352b38..4f8ad3e54 100644 --- a/apps/admin-web/src/module/pendingReviews/components/Topbar/components/SelectForm/index.tsx +++ b/apps/admin-web/src/module/pendingReviews/components/Topbar/components/SelectForm/index.tsx @@ -1,5 +1,3 @@ -import { ReactNode } from 'react' - import { FormControl, MenuItem, SelectChangeEvent } from '@mui/material' import { StyledInputLabel, StyledSelect } from './styled' diff --git a/apps/admin-web/src/module/pendingReviews/index.tsx b/apps/admin-web/src/module/pendingReviews/index.tsx index ee375d6c1..5fe42c7a3 100644 --- a/apps/admin-web/src/module/pendingReviews/index.tsx +++ b/apps/admin-web/src/module/pendingReviews/index.tsx @@ -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' diff --git a/apps/admin-web/src/pages/generateToken/index.tsx b/apps/admin-web/src/pages/generateToken/index.tsx index f12f9d276..2dcc1f88a 100644 --- a/apps/admin-web/src/pages/generateToken/index.tsx +++ b/apps/admin-web/src/pages/generateToken/index.tsx @@ -1 +1 @@ -export { GenerateToken as default } from '@admin-web/module/generateToken' \ No newline at end of file +export { GenerateToken as default } from '@admin-web/module/generateToken' diff --git a/apps/admin-web/src/services/apollo/index.ts b/apps/admin-web/src/services/apollo/index.ts index 64b26e6f4..a4d61d3ee 100644 --- a/apps/admin-web/src/services/apollo/index.ts +++ b/apps/admin-web/src/services/apollo/index.ts @@ -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 = () => @@ -14,7 +14,7 @@ const createHttpLink = () => }) const authLink = setContext(async (_, { headers }) => { - const accessToken = ADMIN_ACCESS_TOKEN + const accessToken = 'ADMIN_ACCESS_TOKEN' return { headers: { ...headers, diff --git a/apps/reg-scraper/CHANGELOG.md b/apps/reg-scraper/CHANGELOG.md index 6129ad7da..80adfc71a 100644 --- a/apps/reg-scraper/CHANGELOG.md +++ b/apps/reg-scraper/CHANGELOG.md @@ -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 diff --git a/apps/reg-scraper/package.json b/apps/reg-scraper/package.json index 346b16ec2..6f7503a36 100644 --- a/apps/reg-scraper/package.json +++ b/apps/reg-scraper/package.json @@ -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", diff --git a/apps/reg-scraper/src/scraper/instance.ts b/apps/reg-scraper/src/scraper/instance.ts index f449f900d..2c65c6918 100644 --- a/apps/reg-scraper/src/scraper/instance.ts +++ b/apps/reg-scraper/src/scraper/instance.ts @@ -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({ diff --git a/apps/web/CHANGELOG.md b/apps/web/CHANGELOG.md index 9a5f61f04..e79c8daf6 100644 --- a/apps/web/CHANGELOG.md +++ b/apps/web/CHANGELOG.md @@ -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 diff --git a/apps/web/package.json b/apps/web/package.json index d48a1a9e0..e9ab8cacf 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -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", diff --git a/apps/web/src/common/components/TopBar/components/AnnouncementBar/announcements.ts b/apps/web/src/common/components/TopBar/components/AnnouncementBar/announcements.ts index 5bd4d5808..3c2ea782d 100644 --- a/apps/web/src/common/components/TopBar/components/AnnouncementBar/announcements.ts +++ b/apps/web/src/common/components/TopBar/components/AnnouncementBar/announcements.ts @@ -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', } } diff --git a/apps/web/src/common/components/TopBar/components/AnnouncementBar/index.tsx b/apps/web/src/common/components/TopBar/components/AnnouncementBar/index.tsx index df2872d00..9e09302dc 100644 --- a/apps/web/src/common/components/TopBar/components/AnnouncementBar/index.tsx +++ b/apps/web/src/common/components/TopBar/components/AnnouncementBar/index.tsx @@ -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 = ({ announcement }) => { const [show, setShow] = useState(false) useEffect(() => { const storage = new Storage('localStorage') - const seenAnnoucements = storage.get(StorageKey.SeenAnnoucements) ?? [] - const seen = seenAnnoucements.some(({ id }) => id === currentAnnoucement.id) + const seenAnnoucements = storage.get(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(StorageKey.SeenAnnoucements) ?? [] - storage.set(StorageKey.SeenAnnoucements, [ + const seenAnnoucements = storage.get(StorageKey.SeenAnnoucements) ?? [] + storage.set(StorageKey.SeenAnnoucements, [ ...seenAnnoucements, - currentAnnoucement, + announcement, ]) setShow(false) } @@ -41,8 +39,8 @@ export const AnnouncementBar: React.FC = () => { return ( - - {currentAnnoucement.label} + + {announcement.label} ) diff --git a/apps/web/src/common/components/TopBar/components/AnnouncementBar/types.ts b/apps/web/src/common/components/TopBar/components/AnnouncementBar/types.ts index b48242f3a..894fa69dd 100644 --- a/apps/web/src/common/components/TopBar/components/AnnouncementBar/types.ts +++ b/apps/web/src/common/components/TopBar/components/AnnouncementBar/types.ts @@ -1,4 +1,7 @@ -export interface AnnoucementItem { +import { AlertColor } from '@mui/material' + +export interface AnnouncementItem { id: string label: string + severity: AlertColor } diff --git a/apps/web/src/common/components/TopBar/index.tsx b/apps/web/src/common/components/TopBar/index.tsx index eaef0827f..34dde74ac 100644 --- a/apps/web/src/common/components/TopBar/index.tsx +++ b/apps/web/src/common/components/TopBar/index.tsx @@ -1,12 +1,22 @@ import { useRouter } from 'next/router' import { AnnouncementBar } from './components/AnnouncementBar' +import { getAnnouncement1, getNotRegChulaWarning } from './components/AnnouncementBar/announcements' import { ConfigBar } from './components/ConfigBar' import { ConfigBarLayout } from './components/ConfigBar/styled' import { NavBar } from './components/NavBar' import { NavBarLayout } from './components/NavBar/styled' import { StickyContainer, StickySpace, TopBarLayout } from './styled' +export function AnnouncementSection() { + return ( + <> + + + + ) +} + export function TopBar() { const { pathname } = useRouter() @@ -22,7 +32,7 @@ export function TopBar() { - + ) } @@ -33,7 +43,7 @@ export function TopBar() { - + ) }