}/>
diff --git a/src/components/form/data/apply.tsx b/src/components/form/data/apply.tsx
index e4577b6..a5a69ad 100644
--- a/src/components/form/data/apply.tsx
+++ b/src/components/form/data/apply.tsx
@@ -213,5 +213,6 @@ export const apply: FormData = {
other: Yup.string()
.max(2000, 'Please provide at most 2000 characters')
}),
- title: "Staff Application"
+ title: "Staff Application",
+ backendFormName: "StaffApplication",
};
\ No newline at end of file
diff --git a/src/components/form/data/contact.tsx b/src/components/form/data/contact.tsx
index aa93f61..53ae46f 100644
--- a/src/components/form/data/contact.tsx
+++ b/src/components/form/data/contact.tsx
@@ -48,5 +48,6 @@ export const contact: FormData = {
.max(2000, 'Question should not exceed 2000 characters')
.required('Question is required')
}),
- title: "Contact Form"
+ title: "Contact Form",
+ backendFormName: "ContactForm",
};
\ No newline at end of file
diff --git a/src/components/form/formActiveRedirect.tsx b/src/components/form/formActiveRedirect.tsx
new file mode 100644
index 0000000..4e45219
--- /dev/null
+++ b/src/components/form/formActiveRedirect.tsx
@@ -0,0 +1,35 @@
+import {FormData} from "./formInterfaces";
+import {useEffect, useState} from "react";
+import GenericForm from "./genericForm";
+
+const FormActiveRedirect = (formData: FormData) => {
+ const [isLoading, setLoading] = useState(true);
+ const [isFormActive, setFormActive] = useState(false);
+ const handleCheckForm = async () => {
+ const result = await fetch(`${process.env.REACT_APP_BACKEND_BASE_URL}/api/checks/formActive`, {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ formName: formData.backendFormName })
+ });
+ const response = await result.json();
+ setFormActive(response.isActive);
+ setLoading(false);
+ };
+
+ useEffect(() => {
+ handleCheckForm();
+ }, []);
+
+ if (isLoading) {
+ return Checking if form is active
;
+ }
+
+ if (!isFormActive) {
+ return The {formData.title} is not currently active
;
+ }
+
+ return (
+
+ );
+}
+export default FormActiveRedirect;
\ No newline at end of file
diff --git a/src/components/form/formInterfaces.tsx b/src/components/form/formInterfaces.tsx
index e574d25..f587ea1 100644
--- a/src/components/form/formInterfaces.tsx
+++ b/src/components/form/formInterfaces.tsx
@@ -22,6 +22,7 @@ export interface UserInput {
}
export type FormData = {
+ backendFormName: string;
steps: Step[];
backend: string;
userInput: UserInput;
diff --git a/src/components/form/genericForm.tsx b/src/components/form/genericForm.tsx
index 5f7b294..df5466f 100644
--- a/src/components/form/genericForm.tsx
+++ b/src/components/form/genericForm.tsx
@@ -11,6 +11,7 @@ const GenericForm = (formData: FormData) => {
const backend: string = formData.backend;
const userInput: UserInput = formData.userInput;
const spec: Yup.Schema = formData.spec;
+ const backendFormname = formData.backendFormName
const navigate = useNavigate();