| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- "use server";
- import {FORGET_PASSWORD} from "@/graphql/customer/mutations";
- import { serverGraphqlFetch } from "@utils/bagisto";
- interface ForgetPasswordData{
- createForgotPassword: {
- forgotPassword: {
- success: boolean;
- message: string;
- }
- }
- }
- export async function recoverPasswordAction(formData: {
- email: string;
- }): Promise<{ success: boolean; msg: string;}> {
- try {
- const response = await serverGraphqlFetch<ForgetPasswordData,{email: string;}>({
- query: FORGET_PASSWORD,
- variables: {
- email: formData.email
- }
- });
- if(!response.error) {
- const resData = response?.data?.createForgotPassword?.forgotPassword;
- return {
- success: resData?.success ?? false,
- msg: resData?.message ?? '',
- };
- } else {
- return {
- success: false,
- msg: response.error.message,
- }
- }
- } catch(error) {
- return {
- success: false,
- msg: error instanceof Error ? error.message : 'Add product to cart failed!',
- }
- }
- }
|