-
Notifications
You must be signed in to change notification settings - Fork 52
Feat/invite user confirmation #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
853eda6
fa14d22
6020ab3
65f7cba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@asgardeo/react': patch | ||
| --- | ||
|
|
||
| Support sending invite links via email, with direct link sharing as a fallback. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,6 +103,11 @@ export interface BaseInviteUserRenderProps { | |
| */ | ||
| inviteLinkCopied: boolean; | ||
|
|
||
| /** | ||
| * Whether the invite email was sent successfully. | ||
| */ | ||
| isEmailSent: boolean; | ||
|
|
||
| /** | ||
| * Whether the invite link has been generated (admin flow complete). | ||
| */ | ||
|
|
@@ -267,6 +272,7 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({ | |
| const [touchedFields, setTouchedFields] = useState<Record<string, boolean>>({}); | ||
| const [inviteLink, setInviteLink] = useState<string | undefined>(); | ||
| const [inviteLinkCopied, setInviteLinkCopied] = useState(false); | ||
| const [emailSent, setEmailSent] = useState(false); | ||
| const [isFormValid, setIsFormValid] = useState(true); | ||
|
|
||
| const initializationAttemptedRef: any = useRef(false); | ||
|
|
@@ -437,6 +443,11 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({ | |
| onInviteLinkGenerated?.(inviteLinkValue, response.flowId); | ||
| } | ||
|
|
||
| // Check if email was sent successfully | ||
| if (response.data?.additionalData?.['emailSent'] === 'true') { | ||
| setEmailSent(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the server returns BOTH Move the |
||
| } | ||
|
|
||
| // Check for error status | ||
| if (response.flowStatus === 'ERROR') { | ||
| handleError(response); | ||
|
|
@@ -501,6 +512,7 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({ | |
| setTouchedFields({}); | ||
| setInviteLink(undefined); | ||
| setInviteLinkCopied(false); | ||
| setEmailSent(false); | ||
| initializationAttemptedRef.current = false; | ||
| }, []); | ||
|
|
||
|
|
@@ -624,6 +636,7 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({ | |
| const {title, subtitle} = extractHeadings(components); | ||
| const componentsWithoutHeadings: any = filterHeadings(components); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to your changes, but when you fix the above-mentioned issues, better to fix these |
||
| const isInviteGenerated: any = !!inviteLink; | ||
| const isEmailSent: boolean = emailSent; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Better to rename the state itself to |
||
|
|
||
| // Render props | ||
| const renderProps: BaseInviteUserRenderProps = { | ||
|
|
@@ -637,6 +650,7 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({ | |
| handleSubmit, | ||
| inviteLink, | ||
| inviteLinkCopied, | ||
| isEmailSent, | ||
| isInviteGenerated, | ||
| isLoading, | ||
| isValid: isFormValid, | ||
|
|
@@ -695,7 +709,33 @@ const BaseInviteUser: FC<BaseInviteUserProps> = ({ | |
| ); | ||
| } | ||
|
|
||
| // Invite link generated - success state | ||
| // Invite email sent successfully - show email sent confirmation | ||
| if (isInviteGenerated && isEmailSent) { | ||
| return ( | ||
| <CardPrimitive className={cx(className, styles.card)} variant={variant}> | ||
| <CardPrimitive.Header className={styles.header}> | ||
| <CardPrimitive.Title level={2} className={styles.title}> | ||
| Invite Email Sent! | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All user-facing strings should go through t() hook to support i18n and translations. The existing "Invite Link Generated!" block also hardcodes strings. That's a pre-existing bug, let's fix it with this effort as well.
Comment on lines
+715
to
+718
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your new email-sent block is nearly identical to the existing invite-link block. This is copy-paste with different text. Extract a shared |
||
| </CardPrimitive.Title> | ||
| </CardPrimitive.Header> | ||
| <CardPrimitive.Content> | ||
| <AlertPrimitive variant="success"> | ||
| <AlertPrimitive.Description> | ||
| An invitation email has been sent successfully. The user can complete their registration using the link in | ||
| the email. | ||
| </AlertPrimitive.Description> | ||
| </AlertPrimitive> | ||
| <div style={{display: 'flex', gap: '0.5rem', marginTop: '1.5rem'}}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file has a dedicated |
||
| <Button variant="outline" onClick={resetFlow}> | ||
| Invite Another User | ||
| </Button> | ||
| </div> | ||
| </CardPrimitive.Content> | ||
| </CardPrimitive> | ||
| ); | ||
| } | ||
|
Comment on lines
+712
to
+736
|
||
|
|
||
| // Invite link generated but email not sent - show copy link fallback | ||
| if (isInviteGenerated && inviteLink) { | ||
| return ( | ||
| <CardPrimitive className={cx(className, styles.card)} variant={variant}> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use types