first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
41
apps/web/modules/marketing/home/lib/api.ts
Normal file
41
apps/web/modules/marketing/home/lib/api.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { apiClient } from "@shared/lib/api-client";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import type { InferRequestType } from "hono";
|
||||
|
||||
export const newsletterSignupMutationKey = ["newsletter-signup"] as const;
|
||||
export const useNewsletterSignupMutation = () => {
|
||||
return useMutation({
|
||||
mutationKey: newsletterSignupMutationKey,
|
||||
mutationFn: async (
|
||||
form: InferRequestType<
|
||||
typeof apiClient.newsletter.signup.$post
|
||||
>["form"],
|
||||
) => {
|
||||
const response = await apiClient.newsletter.signup.$post({
|
||||
form,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to sign up to newsletter");
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const contactFormMutationKey = ["contact-form"] as const;
|
||||
export const useContactFormMutation = () => {
|
||||
return useMutation({
|
||||
mutationKey: contactFormMutationKey,
|
||||
mutationFn: async (
|
||||
form: InferRequestType<typeof apiClient.contact.$post>["form"],
|
||||
) => {
|
||||
const response = await apiClient.contact.$post({
|
||||
form,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to send contact form");
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue