diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e71bbf..eda12d49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,45 +1,45 @@ -## [0.50.3](https://github.com/upb-code-labs/react-client/compare/v0.50.2...v0.50.3) (2024-02-15) +## [0.50.5](https://github.com/upb-code-labs/react-client/compare/v0.50.4...v0.50.5) (2024-02-23) ### Bug Fixes -* Close mobile navbar when clicking blur layer ([#289](https://github.com/upb-code-labs/react-client/issues/289)) ([bf34b03](https://github.com/upb-code-labs/react-client/commit/bf34b03d480d1e80c0160113a0718c5ad5da7154)) +* **ui:** Add checkbox to accept terms and conditions ([#295](https://github.com/upb-code-labs/react-client/issues/295)) ([f4908ff](https://github.com/upb-code-labs/react-client/commit/f4908ff9b867a084b943f8d526c3400cad391d3a)) -## [0.50.2](https://github.com/upb-code-labs/react-client/compare/v0.50.1...v0.50.2) (2024-02-08) +## [0.50.4](https://github.com/upb-code-labs/react-client/compare/v0.50.3...v0.50.4) (2024-02-23) ### Bug Fixes -* Show confirmation dialog when deleting laboratory blocks ([#285](https://github.com/upb-code-labs/react-client/issues/285)) ([82bd210](https://github.com/upb-code-labs/react-client/commit/82bd210f5eeaec4c96a6bb476f1d0f95e8504e76)) +* Clear tanstack query cache after logging out ([#294](https://github.com/upb-code-labs/react-client/issues/294)) ([dbdd158](https://github.com/upb-code-labs/react-client/commit/dbdd15876ab08a5282b411db42dd4db5464b71cf)) -## [0.50.1](https://github.com/upb-code-labs/react-client/compare/v0.50.0...v0.50.1) (2024-02-06) +## [0.50.3](https://github.com/upb-code-labs/react-client/compare/v0.50.2...v0.50.3) (2024-02-15) ### Bug Fixes -* **perf:** Improve code splitting ([#282](https://github.com/upb-code-labs/react-client/issues/282)) ([48f2d4d](https://github.com/upb-code-labs/react-client/commit/48f2d4d4cd93b3cc46d00835d72773b4581926ad)) +* Close mobile navbar when clicking blur layer ([#289](https://github.com/upb-code-labs/react-client/issues/289)) ([bf34b03](https://github.com/upb-code-labs/react-client/commit/bf34b03d480d1e80c0160113a0718c5ad5da7154)) -# [0.50.0](https://github.com/upb-code-labs/react-client/compare/v0.49.1...v0.50.0) (2024-02-02) +## [0.50.2](https://github.com/upb-code-labs/react-client/compare/v0.50.1...v0.50.2) (2024-02-08) -### Features +### Bug Fixes -* Add update button to the students' progress bar chart ([be78362](https://github.com/upb-code-labs/react-client/commit/be7836290c19cffc562bf324614d8022711d5571)) +* Show confirmation dialog when deleting laboratory blocks ([#285](https://github.com/upb-code-labs/react-client/issues/285)) ([82bd210](https://github.com/upb-code-labs/react-client/commit/82bd210f5eeaec4c96a6bb476f1d0f95e8504e76)) -## [0.49.1](https://github.com/upb-code-labs/react-client/compare/v0.49.0...v0.49.1) (2024-02-02) +## [0.50.1](https://github.com/upb-code-labs/react-client/compare/v0.50.0...v0.50.1) (2024-02-06) ### Bug Fixes -* **ui:** Change grading view to a one column layout ([#279](https://github.com/upb-code-labs/react-client/issues/279)) ([32bd57d](https://github.com/upb-code-labs/react-client/commit/32bd57db260a16b738b78341b2710f3306554fa4)) +* **perf:** Improve code splitting ([#282](https://github.com/upb-code-labs/react-client/issues/282)) ([48f2d4d](https://github.com/upb-code-labs/react-client/commit/48f2d4d4cd93b3cc46d00835d72773b4581926ad)) diff --git a/e2e/courses/EnrollStudent.spec.ts b/e2e/courses/EnrollStudent.spec.ts index 09d61ca6..be92605d 100644 --- a/e2e/courses/EnrollStudent.spec.ts +++ b/e2e/courses/EnrollStudent.spec.ts @@ -57,6 +57,7 @@ test.describe.serial("Enroll student workflow", () => { await page.getByLabel("Institutional ID").fill(studentInstitutionalID); await page.getByLabel("Email").fill(studentEmail); await page.getByLabel("Password").fill(studentPassword); + await page.getByLabel("Accept terms and conditions").check(); await page.getByRole("button", { name: "Submit" }).click(); }); diff --git a/e2e/courses/JoinCourse.spec.ts b/e2e/courses/JoinCourse.spec.ts index 86bcb759..d615306f 100644 --- a/e2e/courses/JoinCourse.spec.ts +++ b/e2e/courses/JoinCourse.spec.ts @@ -142,7 +142,7 @@ test.describe.serial("Join courses workflow", () => { await page.getByLabel("Institutional ID").fill(studentInstitutionalID); await page.getByLabel("Email").fill(studentEmail); await page.getByLabel("Password").fill(studentPassword); - + await page.getByLabel("Accept terms and conditions").check(); await page.getByRole("button", { name: "Submit" }).click(); await page.waitForURL(/\/login$/); }); diff --git a/e2e/grades/grades-workflow.spec.ts b/e2e/grades/grades-workflow.spec.ts index 768ceae1..0da5a96f 100644 --- a/e2e/grades/grades-workflow.spec.ts +++ b/e2e/grades/grades-workflow.spec.ts @@ -49,6 +49,7 @@ test.describe.serial("Grades workflow", () => { await page.getByLabel("Institutional ID").fill(getRandomUniversityID()); await page.getByLabel("Email").fill(studentEmail); await page.getByLabel("Password").fill(getDefaultPassword()); + await page.getByLabel("Accept terms and conditions").check(); await page.getByRole("button", { name: "Submit" }).click(); }); diff --git a/e2e/register/RegisterStudents.spec.ts b/e2e/register/RegisterStudents.spec.ts index 62ee9a11..a4cb385d 100644 --- a/e2e/register/RegisterStudents.spec.ts +++ b/e2e/register/RegisterStudents.spec.ts @@ -25,6 +25,11 @@ test("The fields are validated", async ({ page }) => { "Must contain at least one letter, one number and one special character" ) ).toBeVisible(); + await expect( + page.getByText( + "You can't register without accepting the terms and conditions" + ) + ).toBeVisible(); }); test.describe.serial("Student registration", () => { @@ -38,6 +43,7 @@ test.describe.serial("Student registration", () => { await page.getByLabel("Email").fill(newStudentEmail); await page.getByLabel("Institutional ID").fill(newStudentID); await page.getByLabel("Password").fill(getDefaultPassword()); + await page.getByLabel("Accept terms and conditions").check(); await page.getByRole("button", { name: "Submit" }).click(); await expect( @@ -53,6 +59,7 @@ test.describe.serial("Student registration", () => { await page.getByLabel("Email").fill(newStudentEmail); await page.getByLabel("Institutional ID").fill(getRandomUniversityID()); await page.getByLabel("Password").fill(getDefaultPassword()); + await page.getByLabel("Accept terms and conditions").check(); await page.getByRole("button", { name: "Submit" }).click(); await expect( @@ -69,6 +76,7 @@ test.describe.serial("Student registration", () => { await page.getByLabel("Email").fill(getRandomEmail()); await page.getByLabel("Institutional ID").fill(newStudentID); await page.getByLabel("Password").fill(getDefaultPassword()); + await page.getByLabel("Accept terms and conditions").check(); await page.getByRole("button", { name: "Submit" }).click(); await expect( diff --git a/package.json b/package.json index 77f6f9a9..8f034244 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-client", "private": true, - "version": "0.50.3", + "version": "0.50.5", "type": "module", "scripts": { "dev": "vite", @@ -18,6 +18,7 @@ "dependencies": { "@hookform/resolvers": "3.3.4", "@radix-ui/react-alert-dialog": "1.0.5", + "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "1.0.5", "@radix-ui/react-dropdown-menu": "2.0.6", "@radix-ui/react-label": "2.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d788695..2d72aef1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@radix-ui/react-alert-dialog': specifier: 1.0.5 version: 1.0.5(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-checkbox': + specifier: ^1.0.4 + version: 1.0.4(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) '@radix-ui/react-dialog': specifier: 1.0.5 version: 1.0.5(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) @@ -755,6 +758,34 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false + /@radix-ui/react-checkbox@1.0.4(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-CBuGQa52aAYnADZVt/KBQzXrwx6TqnlwtcIPGtVt5JkkzQwMOLJjPukimhfKEr4GQNd43C+djUh5Ikopj8pSLg==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 + react-dom: ^16.8 || ^17.0 || ^18.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + dependencies: + '@babel/runtime': 7.23.9 + '@radix-ui/primitive': 1.0.1 + '@radix-ui/react-compose-refs': 1.0.1(@types/react@18.2.55)(react@18.2.0) + '@radix-ui/react-context': 1.0.1(@types/react@18.2.55)(react@18.2.0) + '@radix-ui/react-presence': 1.0.1(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-primitive': 1.0.3(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) + '@radix-ui/react-use-controllable-state': 1.0.1(@types/react@18.2.55)(react@18.2.0) + '@radix-ui/react-use-previous': 1.0.1(@types/react@18.2.55)(react@18.2.0) + '@radix-ui/react-use-size': 1.0.1(@types/react@18.2.55)(react@18.2.0) + '@types/react': 18.2.55 + '@types/react-dom': 18.2.19 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + dev: false + /@radix-ui/react-collection@1.0.3(@types/react-dom@18.2.19)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-3SzW+0PW7yBBoQlT8wNcGtaxaD0XSu0uLUFgrtHY08Acx05TaHaOmVLR73c0j/cqpDy53KBMO7s0dx2wmOIDIA==} peerDependencies: diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx new file mode 100644 index 00000000..4517f0ac --- /dev/null +++ b/src/components/ui/checkbox.tsx @@ -0,0 +1,27 @@ +import { cn } from "@/lib/utils"; +import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; +import { Check } from "lucide-react"; +import * as React from "react"; + +const Checkbox = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + +)); +Checkbox.displayName = CheckboxPrimitive.Root.displayName; + +export { Checkbox }; diff --git a/src/hooks/useSession.tsx b/src/hooks/useSession.tsx index ef9b53e8..1f4176bd 100644 --- a/src/hooks/useSession.tsx +++ b/src/hooks/useSession.tsx @@ -1,4 +1,5 @@ import { whoamiService } from "@/services/session/whoami.service"; +import { useQueryClient } from "@tanstack/react-query"; import { useEffect, useState } from "react"; export type SessionRole = "admin" | "student" | "teacher"; @@ -39,8 +40,13 @@ export const useSession = () => { setUser(user); }; + const queryClient = useQueryClient(); const logout = () => { + // Remove user from state setUser(null); + + // Clear the cache to prevent showing other user's data + queryClient.clear(); }; return { diff --git a/src/main.tsx b/src/main.tsx index 056f2cc2..60228370 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -100,8 +100,8 @@ const queryClient = new QueryClient({ }); ReactDOM.createRoot(document.getElementById("root")!).render( - - + + @@ -300,6 +300,6 @@ ReactDOM.createRoot(document.getElementById("root")!).render(