Skip to content

Commit

Permalink
chore(clerk-js,localizations,types): Enhance localization for Restric…
Browse files Browse the repository at this point in the history
…tedAccess texts,add support btn (#4335)
  • Loading branch information
nikospapcom authored Oct 16, 2024
1 parent ce40ff6 commit 99cdf9b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .changeset/new-bananas-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@clerk/localizations": minor
"@clerk/clerk-js": minor
"@clerk/types": minor
---

The "Restricted access" screen has been improved for visual consistency and the ability to contact support. The displayed texts have been made more clear and the sign-in button has been moved to the bottom.
4 changes: 2 additions & 2 deletions integration/tests/restricted-mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export default function Page() {
await u.po.signUp.goTo();
await u.po.signUp.waitForMounted();

await expect(u.page.getByText(/Restricted access/i).first()).toBeVisible();
const backToSignIn = u.page.getByRole('link', { name: /Back to sign in/i });
await expect(u.page.getByText(/Access restricted/i).first()).toBeVisible();
const backToSignIn = u.page.getByRole('link', { name: /Sign in/i });
await backToSignIn.click();

await u.po.signUp.waitForMounted();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { useClerk } from '@clerk/shared/react';

import { useSignUpContext } from '../../contexts';
import { Icon, localizationKeys } from '../../customizables';
import { Button, Flex, Icon, localizationKeys } from '../../customizables';
import { Card, Header } from '../../elements';
import { useCardState } from '../../elements/contexts';
import { useSupportEmail } from '../../hooks/useSupportEmail';
import { Block } from '../../icons';

export const SignUpRestrictedAccess = () => {
const clerk = useClerk();
const card = useCardState();
const { signInUrl } = useSignUpContext();
const supportEmail = useSupportEmail();

const handleEmailSupport = () => {
window.location.href = `mailto:${supportEmail}`;
};

return (
<Card.Root>
Expand All @@ -18,22 +25,36 @@ export const SignUpRestrictedAccess = () => {
icon={Block}
sx={t => ({
margin: 'auto',
width: t.sizes.$12,
height: t.sizes.$12,
width: t.sizes.$10,
height: t.sizes.$10,
})}
/>
<Header.Title localizationKey={localizationKeys('signUp.restrictedAccess.title')} />
<Header.Subtitle localizationKey={localizationKeys('signUp.restrictedAccess.subtitle')} />
</Header.Root>
<Card.Alert>{card.error}</Card.Alert>
{supportEmail && (
<Flex
direction='col'
gap={4}
>
<Button
localizationKey={localizationKeys('signUp.restrictedAccess.blockButton__emailSupport')}
onClick={handleEmailSupport}
hasArrow
/>
</Flex>
)}
</Card.Content>
<Card.Footer>
<Card.Action elementId='signUp'>
<Card.ActionText localizationKey={localizationKeys('signUp.restrictedAccess.actionText')} />
<Card.ActionLink
localizationKey={localizationKeys('signUp.restrictedAccess.actionLink')}
to={clerk.buildUrlWithAuth(signInUrl)}
/>
</Card.Action>
</Card.Content>
<Card.Footer />
</Card.Footer>
</Card.Root>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('SignUpStart', () => {
});

render(<SignUpStart />, { wrapper });
screen.getByText('Restricted access');
screen.getByText('Access restricted');
});
});

Expand Down
8 changes: 5 additions & 3 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,11 @@ export const enUS: LocalizationResource = {
title: 'Create your account',
},
restrictedAccess: {
title: 'Restricted access',
subtitle: 'Access to this app is limited, and an invitation is required to sign up.',
actionLink: 'Back to sign in',
title: 'Access restricted',
subtitle: 'Sign ups are currently disabled. If you believe you should have access, please contact support.',
actionLink: 'Sign in',
actionText: 'Already have an account?',
blockButton__emailSupport: 'Email support',
},
},
socialButtonsBlockButton: 'Continue with {{provider|titleize}}',
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ type _LocalizationResource = {
title: LocalizationValue;
subtitle: LocalizationValue;
actionLink: LocalizationValue;
actionText: LocalizationValue;
blockButton__emailSupport: LocalizationValue;
};
};
signIn: {
Expand Down

0 comments on commit 99cdf9b

Please sign in to comment.