Skip to content

Commit

Permalink
release: v0.50.5 (#296)
Browse files Browse the repository at this point in the history
* fix: Clear tanstack query cache after logging out (#294)

* fix(ui): Add checkbox to accept terms and conditions (#295)

* fix(ui): Add checkbox for students to accept terms and conditions

* test: Mark terms and conditions checkbox on tests
  • Loading branch information
PedroChaparro authored Feb 23, 2024
1 parent 1985d8b commit 06c70a1
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 19 deletions.
22 changes: 11 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))



1 change: 1 addition & 0 deletions e2e/courses/EnrollStudent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/courses/JoinCourse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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$/);
});
Expand Down
1 change: 1 addition & 0 deletions e2e/grades/grades-workflow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
8 changes: 8 additions & 0 deletions e2e/register/RegisterStudents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-client",
"private": true,
"version": "0.50.3",
"version": "0.50.5",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -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",
Expand Down
31 changes: 31 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/components/ui/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -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<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;

export { Checkbox };
6 changes: 6 additions & 0 deletions src/hooks/useSession.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const queryClient = new QueryClient({
});

ReactDOM.createRoot(document.getElementById("root")!).render(
<AuthContextProvider>
<QueryClientProvider client={queryClient}>
<QueryClientProvider client={queryClient}>
<AuthContextProvider>
<BrowserRouter>
<Toaster expand closeButton richColors />
<Navbar />
Expand Down Expand Up @@ -300,6 +300,6 @@ ReactDOM.createRoot(document.getElementById("root")!).render(
<Footer />
</BrowserRouter>
<ReactQueryDevtools initialIsOpen={false} buttonPosition="bottom-right" />
</QueryClientProvider>
</AuthContextProvider>
</AuthContextProvider>
</QueryClientProvider>
);
47 changes: 45 additions & 2 deletions src/screens/session/register-student/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import {
Form,
FormControl,
Expand Down Expand Up @@ -30,7 +31,10 @@ const RegisterStudentSchema = z.object({
.regex(
/^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?])[A-Za-z\d[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]{8,}$/,
"Must contain at least one letter, one number and one special character"
)
),
accept_terms: z.boolean().refine((value) => !!value, {
message: "You can't register without accepting the terms and conditions"
})
});

export const RegisterStudentForm = () => {
Expand All @@ -43,7 +47,8 @@ export const RegisterStudentForm = () => {
full_name: "",
email: "",
institutional_id: "",
password: ""
password: "",
accept_terms: false
}
});

Expand Down Expand Up @@ -144,6 +149,44 @@ export const RegisterStudentForm = () => {
</FormItem>
)}
></FormField>
<FormField
control={form.control}
name="accept_terms"
render={({ field }) => (
<FormItem>
<div className="items-top flex space-x-2">
<FormControl>
<Checkbox
id="terms1"
checked={field.value}
onCheckedChange={() => field.onChange(!field.value)}
/>
</FormControl>
<div className="grid space-y-1.5">
<FormLabel htmlFor="terms1">
Accept terms and conditions
</FormLabel>
<p className="text-sm text-muted-foreground">
By checking this box, you agree to{" "}
<a
href="/POLITICA_TRATAMIENTO_INFORMACION_PROTECCION_DATOS_PERSONALES.pdf"
target="_blank"
rel="noreferrer,noopener"
className="text-red-upb underline"
>
our terms and conditions.
</a>
</p>
</div>
</div>
{form.formState.errors.accept_terms && (
<FormMessage>
{form.formState.errors.accept_terms.message}
</FormMessage>
)}
</FormItem>
)}
></FormField>
<Button
type="submit"
className="w-full"
Expand Down

0 comments on commit 06c70a1

Please sign in to comment.