Fix always show login button
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
IconClock,
|
IconClock,
|
||||||
IconLock,
|
IconLock,
|
||||||
} from "@probo/ui";
|
} from "@probo/ui";
|
||||||
import { useNavigate } from "react-router";
|
import { Link, useNavigate } from "react-router";
|
||||||
import { graphql } from "relay-runtime";
|
import { graphql } from "relay-runtime";
|
||||||
import { useFragment, useMutation } from "react-relay";
|
import { useFragment, useMutation } from "react-relay";
|
||||||
import type { MembershipCardFragment$key } from "./__generated__/MembershipCardFragment.graphql";
|
import type { MembershipCardFragment$key } from "./__generated__/MembershipCardFragment.graphql";
|
||||||
@@ -60,7 +60,7 @@ export function MembershipCard(props: MembershipCardProps) {
|
|||||||
|
|
||||||
const { lastSession, organization } = useFragment<MembershipCardFragment$key>(
|
const { lastSession, organization } = useFragment<MembershipCardFragment$key>(
|
||||||
fragment,
|
fragment,
|
||||||
fKey,
|
fKey
|
||||||
);
|
);
|
||||||
const isAuthenticated = !!lastSession;
|
const isAuthenticated = !!lastSession;
|
||||||
const isExpired =
|
const isExpired =
|
||||||
@@ -68,7 +68,7 @@ export function MembershipCard(props: MembershipCardProps) {
|
|||||||
|
|
||||||
const [assumeOrganizationSession] =
|
const [assumeOrganizationSession] =
|
||||||
useMutation<MembershipCard_assumeMutation>(
|
useMutation<MembershipCard_assumeMutation>(
|
||||||
assumeOrganizationSessionMutation,
|
assumeOrganizationSessionMutation
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleAssumeOrganizationSession = useCallback(() => {
|
const handleAssumeOrganizationSession = useCallback(() => {
|
||||||
@@ -139,9 +139,15 @@ export function MembershipCard(props: MembershipCardProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
|
{isAuthenticated ? (
|
||||||
|
<Link to={`/organizations/${organization.id}`}>
|
||||||
|
<Button variant="secondary">{__("View organization")}</Button>
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
<Button onClick={handleAssumeOrganizationSession}>
|
<Button onClick={handleAssumeOrganizationSession}>
|
||||||
{__("Login")}
|
{__("Login")}
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user