2022-11-13 19:35:57 +00:00
|
|
|
import { createSignal } from 'solid-js'
|
|
|
|
|
2023-11-28 13:26:55 +00:00
|
|
|
import { authApiClient as apiClient } from '../graphql/client/_auth'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2022-11-13 19:35:57 +00:00
|
|
|
const [emailChecks, setEmailChecks] = createSignal<{ [email: string]: boolean }>({})
|
|
|
|
|
|
|
|
export const checkEmail = async (email: string): Promise<boolean> => {
|
|
|
|
if (emailChecks()[email]) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
const checkResult = await apiClient.authCheckEmail({ email })
|
|
|
|
|
|
|
|
if (checkResult) {
|
|
|
|
setEmailChecks((oldEmailChecks) => ({ ...oldEmailChecks, [email]: true }))
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
export const useEmailChecks = () => {
|
|
|
|
return { emailChecks }
|
|
|
|
}
|