-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(clerk-js): Cleanup org profile forms (#2391)
- Loading branch information
Showing
11 changed files
with
128 additions
and
99 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,2 @@ | ||
--- | ||
--- |
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 |
---|---|---|
@@ -1,52 +1,48 @@ | ||
import React from 'react'; | ||
|
||
import { Text } from '../customizables'; | ||
import { Form, FormButtons, FormContent, SuccessPage, useCardState, withCardStateProvider } from '../elements'; | ||
import type { FormProps } from '../elements'; | ||
import { Form, FormButtons, FormContent, useCardState, withCardStateProvider } from '../elements'; | ||
import { useActionContext } from '../elements/Action/ActionRoot'; | ||
import type { LocalizationKey } from '../localization'; | ||
import { handleError } from '../utils'; | ||
import { useWizard, Wizard } from './Wizard'; | ||
|
||
type RemovePageProps = { | ||
type RemovePageProps = Omit<FormProps, 'onSuccess'> & { | ||
title: LocalizationKey; | ||
breadcrumbTitle?: LocalizationKey; | ||
messageLine1: LocalizationKey; | ||
messageLine2: LocalizationKey; | ||
successMessage: LocalizationKey; | ||
successMessage?: LocalizationKey; | ||
deleteResource: () => Promise<any>; | ||
onSuccess?: () => void; | ||
Breadcrumbs?: React.ComponentType<any> | null; | ||
}; | ||
|
||
export const RemoveResourcePage = withCardStateProvider((props: RemovePageProps) => { | ||
const { title, messageLine1, messageLine2, successMessage, deleteResource } = props; | ||
const wizard = useWizard(); | ||
const card = useCardState(); | ||
const { title, messageLine1, messageLine2, deleteResource, onSuccess, onReset } = props; | ||
const { close } = useActionContext(); | ||
const card = useCardState(); | ||
|
||
const handleSubmit = async () => { | ||
try { | ||
await deleteResource().then(() => wizard.nextStep()); | ||
await deleteResource().then(() => { | ||
onSuccess?.(); | ||
}); | ||
} catch (e) { | ||
handleError(e, [], card.setError); | ||
} | ||
}; | ||
|
||
return ( | ||
<Wizard {...wizard.props}> | ||
<FormContent headerTitle={title}> | ||
<Form.Root onSubmit={handleSubmit}> | ||
<Text localizationKey={messageLine1} /> | ||
<Text localizationKey={messageLine2} /> | ||
<FormButtons | ||
variant='primaryDanger' | ||
onReset={close} | ||
/> | ||
</Form.Root> | ||
</FormContent> | ||
<SuccessPage | ||
title={title} | ||
text={successMessage} | ||
/> | ||
</Wizard> | ||
<FormContent headerTitle={title}> | ||
<Form.Root onSubmit={handleSubmit}> | ||
<Text localizationKey={messageLine1} /> | ||
<Text localizationKey={messageLine2} /> | ||
<FormButtons | ||
variant='primaryDanger' | ||
onReset={onReset || close} | ||
/> | ||
</Form.Root> | ||
</FormContent> | ||
); | ||
}); |
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
14 changes: 14 additions & 0 deletions
14
packages/clerk-js/src/ui/components/OrganizationProfile/RemoveDomainScreen.tsx
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 { useActionContext } from '../../elements/Action/ActionRoot'; | ||
import { RemoveDomainForm } from './RemoveDomainForm'; | ||
|
||
type RemoveDomainScreenProps = { domainId: string }; | ||
export const RemoveDomainScreen = (props: RemoveDomainScreenProps) => { | ||
const { close } = useActionContext(); | ||
return ( | ||
<RemoveDomainForm | ||
onSuccess={close} | ||
onReset={close} | ||
{...props} | ||
/> | ||
); | ||
}; |
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
14 changes: 14 additions & 0 deletions
14
packages/clerk-js/src/ui/components/OrganizationProfile/VerifiedDomainScreen.tsx
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 { useActionContext } from '../../elements/Action/ActionRoot'; | ||
import { VerifiedDomainForm } from './VerifiedDomainForm'; | ||
|
||
type VerifiedDomainScreenProps = { domainId: string }; | ||
export const VerifiedDomainScreen = (props: VerifiedDomainScreenProps) => { | ||
const { close } = useActionContext(); | ||
return ( | ||
<VerifiedDomainForm | ||
onSuccess={close} | ||
onReset={close} | ||
{...props} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.