sendlink-template-patch

This commit is contained in:
tonyrewin 2022-11-27 22:19:06 +03:00
parent 238449ba1d
commit 013bdd48d0
5 changed files with 18 additions and 8 deletions

View File

@ -54,7 +54,7 @@ export const ForgotPasswordForm = () => {
setIsSubmitting(true)
try {
await signSendLink({ email: email(), lang: locale() })
await signSendLink({ email: email(), lang: locale(), template: 'forgot_password' })
} catch (error) {
if (error instanceof ApiError && error.code === 'user_not_found') {
setIsUserNotFound(true)

View File

@ -50,7 +50,7 @@ export const LoginForm = () => {
setIsEmailNotConfirmed(false)
setSubmitError('')
setIsLinkSent(true)
const result = await signSendLink({ email: email(), lang: locale() })
const result = await signSendLink({ email: email(), lang: locale(), template: 'email_confirmation' })
if (result.error) setSubmitError(result.error)
}

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core'
export default gql`
mutation SendLinkQuery($email: String!, $lang: String) {
sendLink(email: $email, lang: $lang) {
mutation SendLinkQuery($email: String!, $lang: String, $template: String) {
sendLink(email: $email, lang: $lang, template: $template) {
error
}
}

View File

@ -16,6 +16,14 @@ export const register = async ({
})
}
export const signSendLink = async ({ email, lang }: { email: string; lang: string }) => {
return await apiClient.authSendLink({ email, lang })
export const signSendLink = async ({
email,
lang,
template
}: {
email: string
lang: string
template: string
}) => {
return await apiClient.authSendLink({ email, lang, template })
}

View File

@ -112,9 +112,11 @@ export const apiClient = {
const response = await publicGraphQLClient.query(authCheckEmailQuery, { email }).toPromise()
return response.data.isEmailUsed
},
authSendLink: async ({ email, lang }) => {
authSendLink: async ({ email, lang, template }) => {
// send link with code on email
const response = await publicGraphQLClient.mutation(authSendLinkMutation, { email, lang }).toPromise()
const response = await publicGraphQLClient
.mutation(authSendLinkMutation, { email, lang, template })
.toPromise()
if (response.error) {
if (response.error.message === '[GraphQL] User not found') {