mirror of
https://github.com/XFox111/my-website.git
synced 2026-04-22 07:28:01 +03:00
chore(deps): dependency bumps + related refactoring (fixes #19)
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { useFormStatus } from "react-dom";
|
||||
|
||||
// Since useFormStatus requires to be inside of the form, I moved it to a separate helper component.
|
||||
// Could it be done better? Probably.
|
||||
// Did I do it? No.
|
||||
|
||||
/** Renders a React component that tracks the form status and calls the provided callback function when the form status changes. */
|
||||
const FormStatusTracker: React.FC<FormStatusTrackerProps> = ({ onPendingChanged }) =>
|
||||
{
|
||||
const { pending } = useFormStatus();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
onPendingChanged(pending);
|
||||
}, [pending, onPendingChanged]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default FormStatusTracker;
|
||||
|
||||
/** Props for the `FormStatusTracker` component. */
|
||||
export type FormStatusTrackerProps =
|
||||
{
|
||||
/** The callback function that is called when the form status changes. */
|
||||
// For some reason ESLint shows a warning for "unused" "pending" parameter.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
onPendingChanged: (pending: boolean) => void;
|
||||
};
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
declare global
|
||||
{
|
||||
interface Window
|
||||
|
||||
@@ -35,9 +35,9 @@ function setCookie(name: string, value: string | number, maxAge: number): void
|
||||
|
||||
function getCookie(name: string): string | undefined
|
||||
{
|
||||
let cookieName = name + "=";
|
||||
let rawCookies = decodeURIComponent(window.document.cookie);
|
||||
let cookies = rawCookies.split(";");
|
||||
const cookieName = name + "=";
|
||||
const rawCookies = decodeURIComponent(window.document.cookie);
|
||||
const cookies = rawCookies.split(";");
|
||||
|
||||
for (const cookie of cookies)
|
||||
if (cookie.trim().startsWith(cookieName))
|
||||
|
||||
@@ -43,8 +43,6 @@ export default async function sendInquiry(_: FormStatus, formData: FormData): Pr
|
||||
message: "Challenge has expired. Try again"
|
||||
};
|
||||
|
||||
console.error(error);
|
||||
|
||||
return {
|
||||
status: "error",
|
||||
message: "Something went wrong"
|
||||
|
||||
@@ -13,12 +13,11 @@ export async function verifyTurnstile(token: string): Promise<[false, TurnstileE
|
||||
return [true];
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
console.log(headers().get("CF-Connecting-IP"));
|
||||
const headerList = await headers();
|
||||
|
||||
formData.append("secret", process.env.CF_SECRET);
|
||||
formData.append("response", token);
|
||||
formData.append("remoteip", headers().get("CF-Connecting-IP") ?? "");
|
||||
formData.append("remoteip", headerList.get("CF-Connecting-IP") ?? "");
|
||||
|
||||
const response = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify",
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user