-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clerk-js,nextjs,react,types): Introduce <Waitlist /> component
- Loading branch information
1 parent
7a63290
commit fb7aedf
Showing
50 changed files
with
813 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
"@clerk/localizations": minor | ||
"@clerk/clerk-js": minor | ||
"@clerk/nextjs": minor | ||
"@clerk/clerk-react": minor | ||
"@clerk/types": minor | ||
--- | ||
|
||
Show `Join waitlist` promt from `<SignIn />` component when mode is `waitlist` | ||
Change the text in `RestrictedAccess` component when mode is `waitlist` | ||
Introduce `<Waitlist />` component to allow users to join in the waitlist via email | ||
Introduce `joinWaitlist` method in `clerk` class | ||
Introduce `redirectToWaitlist` function in `clerk` class to allow user to redirect to waitlist page | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { JoinWaitlistParams, WaitlistJSON, WaitlistResource } from '@clerk/types'; | ||
|
||
import { unixEpochToDate } from '../../utils/date'; | ||
import { BaseResource } from './internal'; | ||
|
||
export class Waitlist extends BaseResource implements WaitlistResource { | ||
pathRoot = '/waitlist'; | ||
|
||
id = ''; | ||
updatedAt: Date | null = null; | ||
createdAt: Date | null = null; | ||
|
||
constructor(data: WaitlistJSON) { | ||
super(); | ||
this.fromJSON(data); | ||
} | ||
|
||
protected fromJSON(data: WaitlistJSON | null): this { | ||
if (!data) { | ||
return this; | ||
} | ||
|
||
this.id = data.id; | ||
this.updatedAt = unixEpochToDate(data.updated_at); | ||
this.createdAt = unixEpochToDate(data.created_at); | ||
return this; | ||
} | ||
|
||
static async join(params: JoinWaitlistParams): Promise<WaitlistResource> { | ||
const json = ( | ||
await BaseResource._fetch<WaitlistJSON>({ | ||
path: '/waitlist', | ||
method: 'POST', | ||
body: params as any, | ||
}) | ||
)?.response as unknown as WaitlistJSON; | ||
|
||
return new Waitlist(json); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/clerk-js/src/core/resources/__tests__/Waitlist.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Waitlist } from '../internal'; | ||
|
||
describe('Organization', () => { | ||
it('has the same initial properties', () => { | ||
const organization = new Waitlist({ | ||
object: 'waitlist', | ||
id: 'test_id', | ||
created_at: 12345, | ||
updated_at: 5678, | ||
}); | ||
|
||
expect(organization).toMatchSnapshot(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/clerk-js/src/core/resources/__tests__/__snapshots__/Waitlist.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Organization has the same initial properties 1`] = ` | ||
Waitlist { | ||
"createdAt": 1970-01-01T00:00:12.345Z, | ||
"id": "test_id", | ||
"pathRoot": "/waitlist", | ||
"updatedAt": 1970-01-01T00:00:05.678Z, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.