diff --git a/src/components/forms/selector.jsx b/src/components/forms/selector.jsx
index 196bd72c..e578c199 100644
--- a/src/components/forms/selector.jsx
+++ b/src/components/forms/selector.jsx
@@ -16,7 +16,7 @@ export default function Selector({ param, title, options }) {
--Please choose an option--
{options.map((option) => (
-
+
))}
diff --git a/src/components/header.astro b/src/components/header.astro
index 0c53beb5..77766729 100644
--- a/src/components/header.astro
+++ b/src/components/header.astro
@@ -44,6 +44,14 @@ const headerClass = sticky
Register
+
+
+ Upload Project
+
+
+
+ ({
+ key: theme.company,
+ value: `${theme.company}: ${theme.theme}`
+ }))}
+ />
+
{showModal && (
)}
+ {showInfoModal && (
+
+ Your project has been successfully submitted!
+ Thank you for participating in Hackathon Bugsbyte. Good luck!
+ >
+ }
+ closeModal={goBack}
+ />
+ )}
+
);
diff --git a/src/components/registerForm.jsx b/src/components/registerForm.jsx
index bd309008..c811686d 100644
--- a/src/components/registerForm.jsx
+++ b/src/components/registerForm.jsx
@@ -127,7 +127,7 @@ export default function Form() {
({ key: uni, value: uni }))}
/>
{
const formData = await request.formData();
@@ -31,6 +35,7 @@ export const POST: APIRoute = async ({ request }) => {
name: formData.get("name")?.toString() ?? "",
description: formData.get("description")?.toString() ?? "",
link: formData.get("link")?.toString() ?? "",
+ theme: formData.get("theme")?.toString() ?? "",
};
const insertion_msg = await supabase.from("projects").insert([data]).select();
@@ -57,15 +62,27 @@ export const POST: APIRoute = async ({ request }) => {
};
const validateForms = async (formData: FormData, errors: String[]) => {
+ const team_code = formData.get("team_code")?.toString().replace("#", "");
+ const link = formData.get("link")?.toString();
+
+ if (!team_code || !link) {
+ errors.push("All fields are required.");
+ return false
+ }
+
+ const valid = (await validateTeamCode(team_code, errors) && await validateLink(link, errors))
+
+ return valid;
+};
+
+
+const validateTeamCode = async (team_code: string, errors: String[]) => {
let valid = true;
- // check if there's already a project with the same team code
- // if there is one, return an error
- const team_code = formData.get("team_code")?.toString().replace("#", "");
let { data: projects, error } = await supabase
- .from("projects")
- .select("*")
- .eq("team_code", team_code);
+ .from("projects")
+ .select("*")
+ .eq("team_code", team_code);
if (error) {
errors.push(
@@ -78,4 +95,31 @@ const validateForms = async (formData: FormData, errors: String[]) => {
}
return valid;
-};
+}
+
+const validateLink = async (link: string, errors: String[]) => {
+ const githubLinkRegex = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/;
+
+ const match = link.match(githubLinkRegex);
+ if (!match) {
+ errors.push("The link must be a valid GitHub repository URL.");
+ return false;
+ }
+
+ const [, username, repositoryName] = match;
+
+ const response = await fetch(apiGithub + `${username}/${repositoryName}`);
+ if (!response.ok) {
+ errors.push("The repository doesn't exist or is private.");
+ return false;
+ }
+
+ const data = await response.json();
+ const creationDate = new Date(data.created_at);
+ if (creationDate < beginContestDate) {
+ errors.push("The repository must be created after the contest start date.");
+ return false;
+ }
+
+ return true;
+}
\ No newline at end of file
diff --git a/src/hidden_pages/projects.astro b/src/pages/projects.astro
similarity index 100%
rename from src/hidden_pages/projects.astro
rename to src/pages/projects.astro
diff --git a/src/types.ts b/src/types.ts
index 6ddbdaed..ff647801 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -53,6 +53,7 @@ export interface SubmitProjectItem {
name: string;
description: string;
link: string;
+ theme: string;
}
export interface SideBarOption {
diff --git a/supabase/migrations/20250327150742_modify_projects_table.sql b/supabase/migrations/20250327150742_modify_projects_table.sql
new file mode 100644
index 00000000..bb6ac246
--- /dev/null
+++ b/supabase/migrations/20250327150742_modify_projects_table.sql
@@ -0,0 +1,11 @@
+-- Step 1: Drop the current primary key constraint
+ALTER TABLE public.projects
+DROP CONSTRAINT projects_pkey;
+
+-- Step 2: Drop the id column
+ALTER TABLE public.projects
+DROP COLUMN id;
+
+-- Step 3: Set the team_code column as the new primary key
+ALTER TABLE public.projects
+ADD CONSTRAINT projects_pkey PRIMARY KEY (team_code);
diff --git a/supabase/migrations/20250327170302_add_collum_theme_submission.sql b/supabase/migrations/20250327170302_add_collum_theme_submission.sql
new file mode 100644
index 00000000..394f5e74
--- /dev/null
+++ b/supabase/migrations/20250327170302_add_collum_theme_submission.sql
@@ -0,0 +1,2 @@
+ALTER TABLE public.projects
+ADD COLUMN theme text;