From 0f006551f79d1a60e6ff083987c9e20a9a771595 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 02:33:17 +0000 Subject: [PATCH 01/14] Enter pre-release mode --- .changeset/pre.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .changeset/pre.json diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 000000000..97e297846 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,17 @@ +{ + "mode": "pre", + "tag": "beta", + "initialVersions": { + "admin-api": "1.3.1", + "admin-web": "1.3.0", + "api": "1.9.1", + "reg-scraper": "1.5.1", + "web": "1.10.1", + "web-e2e": "0.3.0", + "@cgr/codegen": "1.5.0", + "@cgr/course-utils": "1.3.0", + "@cgr/project-config": "1.3.0", + "@cgr/schema": "1.5.0" + }, + "changesets": [] +} From ef01a7c2a91f9ee3293653e2fff67e9e27072801 Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Wed, 10 Jul 2024 23:55:44 +0700 Subject: [PATCH 02/14] fix: disable referrer check --- .changeset/real-mails-beg.md | 5 ++++ .../[studyProgram]/schedule/import/index.tsx | 29 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 .changeset/real-mails-beg.md diff --git a/.changeset/real-mails-beg.md b/.changeset/real-mails-beg.md new file mode 100644 index 000000000..cb4f085a2 --- /dev/null +++ b/.changeset/real-mails-beg.md @@ -0,0 +1,5 @@ +--- +"web": minor +--- + +fix: disable referrer check diff --git a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx index d4060d625..6663ccd57 100644 --- a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx +++ b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx @@ -55,20 +55,20 @@ function ImportSchedulePage({ items }: ImportPageProps) { } // TODO: research security issues for importing from other 3rd party data sources -const whitelistedOrigins = ['https://esc.eng.chula.ac.th', 'http://localhost:8000'] +// const whitelistedOrigins = ['https://esc.eng.chula.ac.th', 'http://localhost:8000'] export async function getServerSideProps( context: GetServerSidePropsContext ): Promise> { - const referer = context.req.headers.referer as string - const isFromWhitelistedOrigins = whitelistedOrigins.some((origin) => { - return typeof referer === 'string' && referer.startsWith(origin) - }) - if (!isFromWhitelistedOrigins) { - return { - notFound: true, - } - } + // const referer = context.req.headers.referer as string + // const isFromWhitelistedOrigins = whitelistedOrigins.some((origin) => { + // return typeof referer === 'string' && referer.startsWith(origin) + // }) + // if (!isFromWhitelistedOrigins) { + // return { + // notFound: true, + // } + // } try { const client = createApolloServerClient() const q = context.query @@ -90,13 +90,20 @@ export async function getServerSideProps( } }) .filter((it) => it !== null) as RawScheduleItem[] - const items = await Promise.all(rawItems.map((it) => fetchItem(client, courseGroup, it))) + console.log({ rawItems, courseGroup }) + const items = await Promise.all( + rawItems.map((it) => { + console.log({ courseGroup, it }) + return fetchItem(client, courseGroup, it) + }) + ) return { props: { items, }, } } catch (e: unknown) { + console.log({ e }) if (isApolloError(e as Error)) { return { notFound: true, From 94a594eb9eeae7720657f37358159d1d0f1c4aa4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:57:09 +0700 Subject: [PATCH 03/14] Version Packages (beta) (#696) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 4 +++- apps/web/CHANGELOG.md | 6 ++++++ apps/web/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 97e297846..255e8c79f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -13,5 +13,7 @@ "@cgr/project-config": "1.3.0", "@cgr/schema": "1.5.0" }, - "changesets": [] + "changesets": [ + "real-mails-beg" + ] } diff --git a/apps/web/CHANGELOG.md b/apps/web/CHANGELOG.md index 7c125a42a..61661d5d8 100644 --- a/apps/web/CHANGELOG.md +++ b/apps/web/CHANGELOG.md @@ -1,5 +1,11 @@ # web +## 1.11.0-beta.0 + +### Minor Changes + +- ef01a7c: fix: disable referrer check + ## 1.10.1 ### Patch Changes diff --git a/apps/web/package.json b/apps/web/package.json index e15ba3e4d..3785a73b5 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.10.1", + "version": "1.11.0-beta.0", "private": true, "scripts": { "dev": "next dev -p 4200", From cd80cac6cd08b2994830d963895afdd36dfe9c67 Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Sat, 13 Jul 2024 01:54:42 +0700 Subject: [PATCH 04/14] feat: schedule import --- .changeset/rich-grapes-kiss.md | 5 + .../[studyProgram]/schedule/import/index.tsx | 104 ++++++++++-------- 2 files changed, 65 insertions(+), 44 deletions(-) create mode 100644 .changeset/rich-grapes-kiss.md diff --git a/.changeset/rich-grapes-kiss.md b/.changeset/rich-grapes-kiss.md new file mode 100644 index 000000000..de7c54ebb --- /dev/null +++ b/.changeset/rich-grapes-kiss.md @@ -0,0 +1,5 @@ +--- +"web": minor +--- + +feat: schedule import diff --git a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx index 6663ccd57..8d89cb81b 100644 --- a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx +++ b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { ApolloClient, NormalizedCacheObject, isApolloError } from '@apollo/client' +import { ApolloClient, NormalizedCacheObject } from '@apollo/client' import { observer } from 'mobx-react' import { GetServerSidePropsContext, GetServerSidePropsResult } from 'next' import { useRouter } from 'next/router' @@ -32,9 +32,10 @@ interface ScheduleItem { interface ImportPageProps { items: ScheduleItem[] + errorMessage: string[] } -function ImportSchedulePage({ items }: ImportPageProps) { +function ImportSchedulePage({ items, errorMessage }: ImportPageProps) { const router = useRouter() const { buildLink } = useLinkBuilder() @@ -46,12 +47,29 @@ function ImportSchedulePage({ items }: ImportPageProps) { items.forEach(({ course, sectionNo }) => { courseCartStore.addItem(course, sectionNo) }) - router.replace(buildLink(`/schedule`)) + + if (!errorMessage) router.replace(buildLink(`/schedule`)) } fn() - }, [items, router, buildLink]) + }, [items, router, buildLink, errorMessage]) + + return ( + <> + + + {errorMessage && ( +
+

ERROR

- return +
    + {errorMessage.map((msg, i) => ( +
  • {msg}
  • + ))} +
+
+ )} + + ) } // TODO: research security issues for importing from other 3rd party data sources @@ -69,48 +87,46 @@ export async function getServerSideProps( // notFound: true, // } // } - try { - const client = createApolloServerClient() - const q = context.query - const courseGroup = parseCourseGroup(q) - const itemsQuery = (q.items as string) ?? '' - const rawItems = itemsQuery - .split(',') - .map((it) => { - if (it.length === 0) { - return null - } - const parts = it.split(':') - if (parts.length !== 2) { - throw new Error('expected 2 parts for each item') - } - return { - courseNo: parts[0], - sectionNo: parts[1], - } - }) - .filter((it) => it !== null) as RawScheduleItem[] - console.log({ rawItems, courseGroup }) - const items = await Promise.all( + const client = createApolloServerClient() + const q = context.query + const courseGroup = parseCourseGroup(q) + const itemsQuery = (q.items as string) ?? '' + + const errorMessage: string[] = [] + + const rawItems = itemsQuery + .split(',') + .map((it) => { + if (it.length === 0) { + return null + } + const parts = it.split(':') + if (parts.length !== 2) { + errorMessage.push(`expected 2 parts for each item: ${it}`) + } + return { + courseNo: parts[0], + sectionNo: parts[1], + } + }) + .filter((it) => it !== null) as RawScheduleItem[] + + const items = ( + await Promise.all( rawItems.map((it) => { - console.log({ courseGroup, it }) - return fetchItem(client, courseGroup, it) + return fetchItem(client, courseGroup, it).catch(() => { + errorMessage.push(`error fetching item: ${it.courseNo} ${it.sectionNo}`) + return null + }) }) ) - return { - props: { - items, - }, - } - } catch (e: unknown) { - console.log({ e }) - if (isApolloError(e as Error)) { - return { - notFound: true, - } - } else { - throw e - } + ).filter((x) => x !== null) + + return { + props: { + items, + errorMessage, + }, } } From f4755787716dc96501629c5b1341a7c3814ab806 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 02:08:48 +0700 Subject: [PATCH 05/14] Version Packages (beta) (#697) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 3 ++- apps/web/CHANGELOG.md | 6 ++++++ apps/web/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 255e8c79f..7c466ecff 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -14,6 +14,7 @@ "@cgr/schema": "1.5.0" }, "changesets": [ - "real-mails-beg" + "real-mails-beg", + "rich-grapes-kiss" ] } diff --git a/apps/web/CHANGELOG.md b/apps/web/CHANGELOG.md index 61661d5d8..def637db0 100644 --- a/apps/web/CHANGELOG.md +++ b/apps/web/CHANGELOG.md @@ -1,5 +1,11 @@ # web +## 1.11.0-beta.1 + +### Minor Changes + +- cd80cac: feat: schedule import + ## 1.11.0-beta.0 ### Minor Changes diff --git a/apps/web/package.json b/apps/web/package.json index 3785a73b5..cf37a0400 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.11.0-beta.0", + "version": "1.11.0-beta.1", "private": true, "scripts": { "dev": "next dev -p 4200", From b80e54dcf2992467b44027622689ff6ee5122689 Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Sat, 13 Jul 2024 02:36:40 +0700 Subject: [PATCH 06/14] fix: build error --- .changeset/shikanoko-nokonoko-koshitantan.md | 5 +++++ apps/web/src/pages/[studyProgram]/schedule/import/index.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/shikanoko-nokonoko-koshitantan.md diff --git a/.changeset/shikanoko-nokonoko-koshitantan.md b/.changeset/shikanoko-nokonoko-koshitantan.md new file mode 100644 index 000000000..cbec7a73d --- /dev/null +++ b/.changeset/shikanoko-nokonoko-koshitantan.md @@ -0,0 +1,5 @@ +--- +"web": minor +--- + +feat: schedule import part 2 diff --git a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx index 8d89cb81b..1bbcb5d35 100644 --- a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx +++ b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx @@ -120,7 +120,7 @@ export async function getServerSideProps( }) }) ) - ).filter((x) => x !== null) + ).filter((x) => x !== null) as ScheduleItem[] return { props: { From 1ef5196814ddc9650a5347c5a4bffc77a54a6bb5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 03:20:43 +0700 Subject: [PATCH 07/14] Version Packages (beta) (#698) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 3 ++- apps/web/CHANGELOG.md | 6 ++++++ apps/web/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 7c466ecff..c2e1d4d83 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -15,6 +15,7 @@ }, "changesets": [ "real-mails-beg", - "rich-grapes-kiss" + "rich-grapes-kiss", + "shikanoko-nokonoko-koshitantan" ] } diff --git a/apps/web/CHANGELOG.md b/apps/web/CHANGELOG.md index def637db0..701851726 100644 --- a/apps/web/CHANGELOG.md +++ b/apps/web/CHANGELOG.md @@ -1,5 +1,11 @@ # web +## 1.11.0-beta.2 + +### Minor Changes + +- b80e54d: feat: schedule import part 2 + ## 1.11.0-beta.1 ### Minor Changes diff --git a/apps/web/package.json b/apps/web/package.json index cf37a0400..11da5db4c 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.11.0-beta.1", + "version": "1.11.0-beta.2", "private": true, "scripts": { "dev": "next dev -p 4200", From ff580ea9afc45c4538927c18fa48cbb72c880f25 Mon Sep 17 00:00:00 2001 From: leomotors Date: Fri, 12 Jul 2024 20:36:24 +0000 Subject: [PATCH 08/14] Configure pre-release mode --- .changeset/pre.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index c2e1d4d83..1b2ba6233 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,5 +1,5 @@ { - "mode": "pre", + "mode": "exit", "tag": "beta", "initialVersions": { "admin-api": "1.3.1", From ee7467b4cbe4f81f55c4a6471671097bcdf5dcb8 Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Sat, 13 Jul 2024 04:20:10 +0700 Subject: [PATCH 09/14] fix changeset that i just broke --- apps/web/CHANGELOG.md | 8 ++++++++ apps/web/package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/web/CHANGELOG.md b/apps/web/CHANGELOG.md index 701851726..8f413d0cd 100644 --- a/apps/web/CHANGELOG.md +++ b/apps/web/CHANGELOG.md @@ -1,5 +1,13 @@ # web +## 1.11.0 + +### Minor Changes + +- af8c1e2: fix: disable referrer check +- af8c1e2: feat: schedule import +- af8c1e2: feat: schedule import part 2 + ## 1.11.0-beta.2 ### Minor Changes diff --git a/apps/web/package.json b/apps/web/package.json index 11da5db4c..a3da0913e 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.11.0-beta.2", + "version": "1.11.0", "private": true, "scripts": { "dev": "next dev -p 4200", From d10493929eeca8fce86bdb514bb8bc28669d07ba Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Sat, 13 Jul 2024 04:23:10 +0700 Subject: [PATCH 10/14] Sync changeset --- .changeset/pre.json | 10 +++------- .changeset/real-mails-beg.md | 5 ----- .changeset/rich-grapes-kiss.md | 5 ----- .changeset/shikanoko-nokonoko-koshitantan.md | 5 ----- 4 files changed, 3 insertions(+), 22 deletions(-) delete mode 100644 .changeset/real-mails-beg.md delete mode 100644 .changeset/rich-grapes-kiss.md delete mode 100644 .changeset/shikanoko-nokonoko-koshitantan.md diff --git a/.changeset/pre.json b/.changeset/pre.json index 1b2ba6233..8effa6754 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,21 +1,17 @@ { - "mode": "exit", + "mode": "pre", "tag": "beta", "initialVersions": { "admin-api": "1.3.1", "admin-web": "1.3.0", "api": "1.9.1", "reg-scraper": "1.5.1", - "web": "1.10.1", + "web": "1.11.0", "web-e2e": "0.3.0", "@cgr/codegen": "1.5.0", "@cgr/course-utils": "1.3.0", "@cgr/project-config": "1.3.0", "@cgr/schema": "1.5.0" }, - "changesets": [ - "real-mails-beg", - "rich-grapes-kiss", - "shikanoko-nokonoko-koshitantan" - ] + "changesets": [] } diff --git a/.changeset/real-mails-beg.md b/.changeset/real-mails-beg.md deleted file mode 100644 index cb4f085a2..000000000 --- a/.changeset/real-mails-beg.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"web": minor ---- - -fix: disable referrer check diff --git a/.changeset/rich-grapes-kiss.md b/.changeset/rich-grapes-kiss.md deleted file mode 100644 index de7c54ebb..000000000 --- a/.changeset/rich-grapes-kiss.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"web": minor ---- - -feat: schedule import diff --git a/.changeset/shikanoko-nokonoko-koshitantan.md b/.changeset/shikanoko-nokonoko-koshitantan.md deleted file mode 100644 index cbec7a73d..000000000 --- a/.changeset/shikanoko-nokonoko-koshitantan.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"web": minor ---- - -feat: schedule import part 2 From e10506318eb21f71d399f025a96819b06a2ba660 Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Sat, 13 Jul 2024 04:24:25 +0700 Subject: [PATCH 11/14] fix: import course error --- .changeset/dont-deploy-prod-at-4am.md | 5 +++++ .changeset/pre.json | 4 +++- apps/web/src/pages/[studyProgram]/schedule/import/index.tsx | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/dont-deploy-prod-at-4am.md diff --git a/.changeset/dont-deploy-prod-at-4am.md b/.changeset/dont-deploy-prod-at-4am.md new file mode 100644 index 000000000..84027b407 --- /dev/null +++ b/.changeset/dont-deploy-prod-at-4am.md @@ -0,0 +1,5 @@ +--- +"web": minor +--- + +fix: import course error diff --git a/.changeset/pre.json b/.changeset/pre.json index 8effa6754..269a21a3f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -13,5 +13,7 @@ "@cgr/project-config": "1.3.0", "@cgr/schema": "1.5.0" }, - "changesets": [] + "changesets": [ + "dont-deploy-prod-at-4am" + ] } diff --git a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx index 1bbcb5d35..fa7b68a4c 100644 --- a/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx +++ b/apps/web/src/pages/[studyProgram]/schedule/import/index.tsx @@ -48,7 +48,7 @@ function ImportSchedulePage({ items, errorMessage }: ImportPageProps) { courseCartStore.addItem(course, sectionNo) }) - if (!errorMessage) router.replace(buildLink(`/schedule`)) + if (errorMessage.length === 0) router.replace(buildLink(`/schedule`)) } fn() }, [items, router, buildLink, errorMessage]) @@ -57,7 +57,7 @@ function ImportSchedulePage({ items, errorMessage }: ImportPageProps) { <> - {errorMessage && ( + {errorMessage.length > 0 && (

ERROR

From 30058873234f77c24dc5a97c150dbc6400e1f1ba Mon Sep 17 00:00:00 2001 From: Nutthapat Pongtanyavichai Date: Sat, 13 Jul 2024 04:27:24 +0700 Subject: [PATCH 12/14] i made same mistake again :skull: --- .changeset/pre.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 269a21a3f..8effa6754 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -13,7 +13,5 @@ "@cgr/project-config": "1.3.0", "@cgr/schema": "1.5.0" }, - "changesets": [ - "dont-deploy-prod-at-4am" - ] + "changesets": [] } From 8950759e344b4c607ee5927d3d65f38960176ebc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 04:29:14 +0700 Subject: [PATCH 13/14] Version Packages (beta) (#701) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 4 +++- apps/web/CHANGELOG.md | 6 ++++++ apps/web/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 8effa6754..269a21a3f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -13,5 +13,7 @@ "@cgr/project-config": "1.3.0", "@cgr/schema": "1.5.0" }, - "changesets": [] + "changesets": [ + "dont-deploy-prod-at-4am" + ] } diff --git a/apps/web/CHANGELOG.md b/apps/web/CHANGELOG.md index 8f413d0cd..d3cd0cf71 100644 --- a/apps/web/CHANGELOG.md +++ b/apps/web/CHANGELOG.md @@ -1,5 +1,11 @@ # web +## 1.12.0-beta.0 + +### Minor Changes + +- e105063: fix: import course error + ## 1.11.0 ### Minor Changes diff --git a/apps/web/package.json b/apps/web/package.json index a3da0913e..3d05fe34e 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,6 +1,6 @@ { "name": "web", - "version": "1.11.0", + "version": "1.12.0-beta.0", "private": true, "scripts": { "dev": "next dev -p 4200", From acf71fa8b2da4f59de6c534a020f503184cb713e Mon Sep 17 00:00:00 2001 From: leomotors Date: Fri, 12 Jul 2024 21:30:33 +0000 Subject: [PATCH 14/14] Configure pre-release mode --- .changeset/pre.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index 269a21a3f..eb79dd995 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,5 +1,5 @@ { - "mode": "pre", + "mode": "exit", "tag": "beta", "initialVersions": { "admin-api": "1.3.1",