-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add send email verification button
- Loading branch information
1 parent
81923a9
commit 1249b5a
Showing
5 changed files
with
90 additions
and
3 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
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,47 @@ | ||
import { useAlert } from '@dhis2/app-runtime' | ||
import { getInstance as getD2 } from 'd2' | ||
import { blue400 } from 'material-ui/styles/colors.js' | ||
import React from 'react' | ||
|
||
export function VerifyEmail() { | ||
const errorAlert = useAlert(({ message }) => message, { critical: true }) | ||
const successAlert = useAlert(({ message }) => message, { success: true }) | ||
|
||
const handleEmailVerification = async () => { | ||
try { | ||
const d2 = await getD2() | ||
const api = d2.Api.getApi() | ||
api.baseUrl = 'http://localhost:8080/' | ||
|
||
const res = await api.post('account/sendEmailVerification') | ||
console.log('Response:', res) | ||
successAlert.show({ | ||
message: 'Email verification link sent successfully!', | ||
}) | ||
} catch (err) { | ||
console.error('Error:', err) | ||
errorAlert.show({ | ||
message: | ||
err.message || 'Failed to send email verification link.', | ||
}) | ||
} | ||
} | ||
|
||
return ( | ||
<button | ||
type="button" | ||
style={{ | ||
marginTop: '10px', | ||
background: 'white', | ||
border: '1px solid', | ||
borderColor: blue400, | ||
color: blue400, | ||
padding: '10px', | ||
cursor: 'pointer', | ||
}} | ||
onClick={handleEmailVerification} | ||
> | ||
Verify Email | ||
</button> | ||
) | ||
} |
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