Skip to content

Commit 6f03d1e

Browse files
committed
feat: updated applications
1 parent 2721d27 commit 6f03d1e

4 files changed

Lines changed: 66 additions & 31 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</div>
2121

2222
<br />
23-
23+
Note: does path aliases work?
2424
## About
2525
Welcome to the GitHub repository for the official website for [**Matrix Development**](https://github.com/MatrixDevelopment-GH) written in TypeScript using [NextJS](https://nextjs.org/) and [Tailwind CSS](https://tailwindcss.com/). If contributing to the repository, please ensure you have prior knowledge in TypeScript/CSS and responsive web design (media queries and flexbox) and of React and/or NextJS and Tailwind CSS. This repository is primarily maintained by [unk0wn](https://github.com/unkn0wnF).
2626

components/layout/forms/Form.tsx

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from "../../../lib/util/formhandler";
1616
import { Response as APIResponse } from "../../../types/api";
1717
import type { NextComponent } from "../../../types/main";
18+
import { NextRouter, useRouter } from "next/router";
1819
import { Starter } from "./Starter";
1920

2021
import { useSession } from "next-auth/react";
@@ -31,12 +32,26 @@ export const Form: NextComponent<FormProps> = ({
3132
children
3233
}: FormProps): JSX.Element => {
3334
const { data: session } = useSession();
35+
const router: NextRouter = useRouter();
36+
const [cooldown, setCooldown]: [
37+
boolean,
38+
Dispatch<SetStateAction<boolean>>
39+
] = useState<boolean>(false);
3440
const [member, setMember]: [
3541
GuildMember | null,
3642
Dispatch<SetStateAction<GuildMember | null>>
3743
] = useState<GuildMember | null>(null);
3844

3945
useEffect((): void => {
46+
const storedCooldown: string | null = localStorage.getItem(
47+
"application-cooldown"
48+
);
49+
if (!storedCooldown)
50+
localStorage.setItem("application-cooldown", "false");
51+
52+
const onCooldown: boolean = JSON.parse(storedCooldown!);
53+
setCooldown(onCooldown);
54+
4055
session &&
4156
fetch(
4257
`/api/v${process.env.API_VERSION}/get/members/` +
@@ -66,33 +81,38 @@ export const Form: NextComponent<FormProps> = ({
6681
onSubmit={(e: FormEvent<HTMLFormElement>): void => {
6782
e.preventDefault();
6883

69-
const questions: string[] = [];
70-
71-
e.currentTarget
72-
.querySelectorAll("label")
73-
.forEach((label: HTMLLabelElement): void => {
74-
questions.push(`**${label.innerText}**`);
75-
});
84+
if (cooldown)
85+
return window.alert(
86+
"Please wait a week after you last submitted an application form before reapplying."
87+
);
7688

77-
const answers: FormAnswer[] = [];
89+
const questions: string[] = Array.from(
90+
e.currentTarget.querySelectorAll("label")
91+
).map(
92+
(label: HTMLLabelElement): string =>
93+
`**${label.innerText}**`
94+
);
7895

79-
e.currentTarget
80-
.querySelectorAll(
96+
const answers: FormAnswer[] = Array.from(
97+
e.currentTarget.querySelectorAll(
8198
"input[type=email], input[type=range], input[type=text], textarea, select"
8299
)
83-
.forEach(
84-
(element: Element, index: number): void => {
85-
answers.push({
86-
question: questions[index],
87-
answer:
88-
(
89-
element as
90-
| HTMLInputElement
91-
| HTMLTextAreaElement
92-
).value ?? "N/A"
93-
});
94-
}
95-
);
100+
).map(
101+
(
102+
element: Element,
103+
index: number
104+
): FormAnswer => {
105+
return {
106+
question: questions[index],
107+
answer:
108+
(
109+
element as
110+
| HTMLInputElement
111+
| HTMLTextAreaElement
112+
).value ?? "N/A"
113+
};
114+
}
115+
);
96116

97117
new FormHandler().postApplication(
98118
type,
@@ -104,6 +124,23 @@ export const Form: NextComponent<FormProps> = ({
104124
window.alert(
105125
"Thanks for submitting your application! You will be contacted once we review your application via our Discord server."
106126
);
127+
128+
localStorage.setItem(
129+
"application-cooldown",
130+
"true"
131+
);
132+
setTimeout(
133+
(): void =>
134+
localStorage.setItem(
135+
"application-cooldown",
136+
"false"
137+
),
138+
1000 * 60 * 60 * 24 * 7
139+
);
140+
141+
if (e.currentTarget) e.currentTarget.reset();
142+
143+
router.push("/");
107144
}}>
108145
<h2 className="text-2xl font-black tracking-tighter dark:text-mtxWhite">
109146
Submit your {type} application

lib/constants.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,14 @@ export const channel = {
7777
*/
7878
export const applicationWebhooks = {
7979
developer:
80-
"https://discord.com/api/webhooks/908932551794638899/QQz8HP3HU-cz4DzNhzEDStUyRpgIA9pM-3636LgegwkcSBtK41mdhNJs1MlgVPolC8p_",
80+
"https://discord.com/api/webhooks/908932774449258586/O5oNqzCcDEFcaV-K7_PLSPG8lmHzu0DgewPI28FsshSD8PCiW0RM8V1-n8-KmmOqaP_M",
8181
support:
82-
"https://discord.com/api/webhooks/908932865729904670/VjLgSoEWSyVUlM1AGivcucXv8Gvj3IVZS9Y9oFGcDxAge8tWAmoE4E-3aicCRzSbYws9",
83-
supervisor:
8482
"https://discord.com/api/webhooks/908932774449258586/O5oNqzCcDEFcaV-K7_PLSPG8lmHzu0DgewPI28FsshSD8PCiW0RM8V1-n8-KmmOqaP_M",
8583
moderator:
86-
"https://discord.com/api/webhooks/908933132714139659/4g7O9lkW5gsz3VffxAUQdL7ON5KYli0le-WqzG0NkYDBxtfq4e7EdMfXNlhHKIXAh5Xt",
84+
"https://discord.com/api/webhooks/908932774449258586/O5oNqzCcDEFcaV-K7_PLSPG8lmHzu0DgewPI28FsshSD8PCiW0RM8V1-n8-KmmOqaP_M",
8785
marketing:
88-
"https://discord.com/api/webhooks/908933334141394954/jAxj-gC-vfyoGlQjWtxdO5qTXjMEsVmfhPhNElvg_ovx034URBgami3VA_gUH9I5qPxN",
89-
public: "https://discord.com/api/webhooks/1046729408771268668/XIjJbcge4yqYS_a_Af4kOEtqQ9U3FbYRshO1wnF3JDNsHIOFGBb8TjBs05sAzREO4pdt",
90-
DSA: "https://discord.com/api/webhooks/908933518887878716/U5XAZVMTsJScCLXxezkeXgb6b6b9lnKJUskrV05UmQfiE9w1NtG1We-wd6sMZFf6odZ9"
86+
"https://discord.com/api/webhooks/908932774449258586/O5oNqzCcDEFcaV-K7_PLSPG8lmHzu0DgewPI28FsshSD8PCiW0RM8V1-n8-KmmOqaP_M",
87+
public: "https://discord.com/api/webhooks/908932774449258586/O5oNqzCcDEFcaV-K7_PLSPG8lmHzu0DgewPI28FsshSD8PCiW0RM8V1-n8-KmmOqaP_M"
9188
};
9289

9390
/**

lib/util/formhandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class FormHandler {
3434
})
3535
| undefined
3636
): Promise<void> {
37+
console.log(user);
3738
const message: { embeds?: Embed[] } = {
3839
embeds: [
3940
{

0 commit comments

Comments
 (0)