Skip to content

Commit

Permalink
feat: Add loading text to waitlist success step
Browse files Browse the repository at this point in the history
  • Loading branch information
nikospapcom committed Oct 23, 2024
1 parent 40923a6 commit 61b3d19
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
39 changes: 36 additions & 3 deletions packages/clerk-js/src/ui/components/Waitlist/WaitlistForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import type { JoinWaitlistParams } from '@clerk/types';

import { useWizard, Wizard } from '../../common';
import { useWaitlistContext } from '../../contexts';
import { Col, descriptors, Flex, localizationKeys } from '../../customizables';
import { Col, descriptors, Flex, Icon, localizationKeys, Text } from '../../customizables';
import { Card, Form, Header, useCardState } from '../../elements';
import { useLoadingStatus } from '../../hooks';
import { SpinnerJumbo } from '../../icons';
import { useRouter } from '../../router';
import { animations } from '../../styledSystem';
import { type FormControlState, handleError } from '../../utils';
import type { Fields } from './Waitlist';

Expand Down Expand Up @@ -41,11 +43,14 @@ export const WaitlistForm = (props: WaitlistFormProps) => {
await clerk
.joinWaitlist(joinWaitlistParams)
.then(() => {
wizard.nextStep();

if (ctx.redirectUrl) {
void navigate(ctx.redirectUrl);
setTimeout(() => {
void navigate(ctx.redirectUrl);
}, 2000);
return;
}
wizard.nextStep();
})
.catch(error => {
handleError(error, [], card.setError);
Expand Down Expand Up @@ -94,6 +99,34 @@ export const WaitlistForm = (props: WaitlistFormProps) => {
<Header.Title localizationKey={localizationKeys('waitlist.success.title')} />
<Header.Subtitle localizationKey={localizationKeys('waitlist.success.subtitle')} />
</Header.Root>
{ctx.redirectUrl && (
<Flex
direction='col'
elementDescriptor={descriptors.main}
gap={6}
>
<Col center>
<Flex
gap={2}
align='center'
>
<Icon
icon={SpinnerJumbo}
sx={t => ({
margin: 'auto',
width: t.sizes.$6,
height: t.sizes.$6,
animation: `${animations.spinning} 1s linear infinite`,
})}
/>
<Text
colorScheme='secondary'
localizationKey={localizationKeys('waitlist.success.message')}
/>
</Flex>
</Col>
</Flex>
)}
</Col>
</Wizard>
);
Expand Down
1 change: 1 addition & 0 deletions packages/clerk-js/src/ui/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ export { default as Organization } from './organization.svg';
export { default as Users } from './users.svg';
export { default as Fingerprint } from './fingerprint.svg';
export { default as Block } from './block.svg';
export { default as SpinnerJumbo } from './spinner-jumbo.svg';
11 changes: 11 additions & 0 deletions packages/clerk-js/src/ui/icons/spinner-jumbo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ export const enUS: LocalizationResource = {
success: {
title: 'Thanks for joining the waitlist!',
subtitle: 'We’ll be in touch when your spot is ready',
message: 'You will be redirected soon...',
},
},
} as const;
1 change: 1 addition & 0 deletions packages/types/src/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ type _LocalizationResource = {
success: {
title: LocalizationValue;
subtitle: LocalizationValue;
message: LocalizationValue;
};
};
};
Expand Down

0 comments on commit 61b3d19

Please sign in to comment.