Skip to content

Commit

Permalink
Some contact email logging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
futurGH committed Dec 21, 2023
1 parent 8659945 commit f333bea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/global/CustomSeo.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ export type CustomSeoProps = Partial<DefaultSeoProps> & {
};
export function CustomSeo(props: CustomSeoProps) {
const { data = {}, ...rest } = props;
const { data: { shop: { name, description } = {} } = {}, errors } = useShopQuery<ShopInfoQuery>({
const { data: shopData, errors } = useShopQuery<ShopInfoQuery>({
query: SHOP_INFO_QUERY,
cache: CacheLong(),
preload: "*",
});
const { shop } = shopData ?? {};
const { name, description } = shop ?? {};

if (errors) console.log(errors);

Expand Down
3 changes: 3 additions & 0 deletions src/routes/api/contact.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const client = new SESClient({
});

export async function api(request: HydrogenRequest) {
console.log(request);
if (request.method === "GET") return new Response(null, { status: 302, headers: { Location: "/contact-us" } });
if (request.method !== "POST") return new Response(null, { status: 405 });

Expand All @@ -26,6 +27,7 @@ export async function api(request: HydrogenRequest) {
)
return new Response(null, { status: 400 });

console.log("correct types", name, email, message, recaptchaToken);
let potentiallySpam = false;
if (recaptchaToken && typeof recaptchaToken === "string") {
const recaptchaResponse = await fetch("https://www.google.com/recaptcha/api/siteverify", {
Expand All @@ -44,6 +46,7 @@ export async function api(request: HydrogenRequest) {
} else {
potentiallySpam = true;
}
console.log(potentiallySpam, "potentially spam");
const date = new Intl.DateTimeFormat("en-US", {
month: "long",
day: "numeric",
Expand Down

0 comments on commit f333bea

Please sign in to comment.