-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: contact sales submission (#1473)
# Description Epic: #1232 US: #1446 Send email address and message content to the backend. Display a loader in loading state and a toast message on error.
- Loading branch information
1 parent
85530d4
commit f91247c
Showing
8 changed files
with
68 additions
and
15 deletions.
There are no files selected for viewing
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,33 @@ | ||
import { useMutation, UseMutationResult } from "@tanstack/react-query"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { useAxios } from "@/lib/hooks"; | ||
import { useToast } from "@/lib/hooks/useToast"; | ||
|
||
interface ContactSalesDto { | ||
customer_email: string; | ||
content: string; | ||
} | ||
|
||
export const usePostContactSales = (): UseMutationResult< | ||
void, | ||
unknown, | ||
ContactSalesDto | ||
> => { | ||
const { axiosInstance } = useAxios(); | ||
const toast = useToast(); | ||
const { t } = useTranslation("contact", { keyPrefix: "form" }); | ||
|
||
return useMutation({ | ||
mutationKey: ["contactSales"], | ||
mutationFn: async (data) => { | ||
await axiosInstance.post("/contact", data); | ||
}, | ||
onError: () => { | ||
toast.publish({ | ||
text: t("sending_mail_error"), | ||
variant: "danger", | ||
}); | ||
}, | ||
}); | ||
}; |
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
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
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