-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(services): webmail added (#481)
* feat(webmail): add the webmail button and the hooks for the authentication,Ref #473 * fix(webmail): webmail improvements --------- Co-authored-by: FabrizioCostaMedich <fabrizio.costamedich@gmail.com> Co-authored-by: Emanuele Coricciati <ema@MacBook-Air-di-Emanuele.local>
- Loading branch information
1 parent
a02334d
commit 5e5152a
Showing
4 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 @@ | ||
import { WebmailApi } from '@polito/api-client'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { pluckData } from '../../utils/queries'; | ||
|
||
export const WEBMAIL_LINK_QUERY_KEY = ['webmailLink']; | ||
|
||
const UNREAD_MAIL_QUERY_KEY = ['unreadEmails']; | ||
|
||
const useWebmailClient = (): WebmailApi => { | ||
return new WebmailApi(); | ||
}; | ||
|
||
export const GetWebmailLink = async () => { | ||
const webmailClient = useWebmailClient(); | ||
|
||
return webmailClient.getWebmailLink().then(pluckData); | ||
}; | ||
|
||
export const useGetUnreadEmails = () => { | ||
const webmailClient = useWebmailClient(); | ||
|
||
return useQuery( | ||
UNREAD_MAIL_QUERY_KEY, | ||
() => webmailClient.getUnreadEmailslNumber().then(pluckData), | ||
{ | ||
refetchInterval: 5 * 60 * 1000, // 5 minutes | ||
}, | ||
); | ||
}; |
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