Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added loading state to button #11624

Merged
merged 18 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ffe6928
added loading state to button
ashishsurya Sep 29, 2023
6d1f12e
rolled back on yarn.lock
ashishsurya Sep 30, 2023
9e4e4e1
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Sep 30, 2023
2171856
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 1, 2023
e3585e6
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 3, 2023
c7c563e
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 4, 2023
dcb321a
Merge branch 'main' into ashishsurya/logout-button-loading
Udit-takkar Oct 6, 2023
647c9c9
Merge branch 'main' into ashishsurya/logout-button-loading
PeerRich Oct 9, 2023
d5e29b5
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 10, 2023
9563200
Merge branch 'main' into ashishsurya/logout-button-loading
PeerRich Oct 11, 2023
f2d642e
changed e2e test for logout page
ashishsurya Oct 13, 2023
5358d1d
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 13, 2023
3949d60
chore: use data-testid
Udit-takkar Oct 13, 2023
5d98123
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 13, 2023
be62ad0
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 14, 2023
ef32374
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 16, 2023
2763271
Merge branch 'main' into ashishsurya/logout-button-loading
ashishsurya Oct 16, 2023
32be425
Merge branch 'main' into ashishsurya/logout-button-loading
PeerRich Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions apps/web/pages/auth/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GetServerSidePropsContext } from "next";
import { signOut, useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { useEffect, useState } from "react";

import { WEBSITE_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
Expand All @@ -18,6 +18,7 @@ import { ssrInit } from "@server/lib/ssr";
type Props = inferSSRProps<typeof getServerSideProps>;

export function Logout(props: Props) {
const [btnLoading, setBtnLoading] = useState<boolean>(false);
const { status } = useSession();
if (status === "authenticated") signOut({ redirect: false });
const router = useRouter();
Expand All @@ -35,6 +36,11 @@ export function Logout(props: Props) {
return "hope_to_see_you_soon";
};

const navigateToLogin = () => {
setBtnLoading(true);
router.push("/auth/login");
};

return (
<AuthContainer title={t("logged_out")} description={t("youve_been_logged_out")} showLogo>
<div className="mb-4">
Expand All @@ -50,7 +56,11 @@ export function Logout(props: Props) {
</div>
</div>
</div>
<Button href="/auth/login" className="flex w-full justify-center">
<Button
data-testid="logout-btn"
onClick={navigateToLogin}
className="flex w-full justify-center"
loading={btnLoading}>
{t("go_back_login")}
</Button>
</AuthContainer>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/playwright/login.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test.describe("user can login & logout succesfully", async () => {
const signOutBtn = await page.locator(`text=${signOutLabel}`);
await signOutBtn.click();

await page.locator('a[href="/auth/login"]').click();
await page.locator("[data-testid=logout-btn]").click();

// Reroute to the home page to check if the login form shows up
await expect(page.locator(`[data-testid=login-form]`)).toBeVisible();
Expand Down