feat(dashboard, js-sdk): reset password UI (#9451)
**What** - add password reset flow on Admin --- https://github.com/user-attachments/assets/3438ace2-c661-4121-a580-794a69ad4518 --- CLOSES CC-568 Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import { FetchError } from "@medusajs/js-sdk"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const useSignInWithEmailPassword = (
|
||||
export const useSignInWithEmailPass = (
|
||||
options?: UseMutationOptions<
|
||||
string,
|
||||
FetchError,
|
||||
@@ -35,9 +35,37 @@ export const useSignUpWithEmailPass = (
|
||||
})
|
||||
}
|
||||
|
||||
export const useResetPasswordForEmailPass = (
|
||||
options?: UseMutationOptions<void, FetchError, { email: string }>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) =>
|
||||
sdk.auth.resetPassword("user", "emailpass", {
|
||||
identifier: payload.email,
|
||||
}),
|
||||
onSuccess: async (data, variables, context) => {
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useLogout = (options?: UseMutationOptions<void, FetchError>) => {
|
||||
return useMutation({
|
||||
mutationFn: () => sdk.auth.logout(),
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export const useUpdateProviderForEmailPass = (
|
||||
options?: UseMutationOptions<void, FetchError, { password: string }>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) =>
|
||||
sdk.auth.updateProvider("user", "emailpass", payload),
|
||||
onSuccess: async (data, variables, context) => {
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user