diff --git a/frontend/src/hackathon.css b/frontend/src/hackathon.css
new file mode 100644
index 0000000..e69de29
diff --git a/frontend/src/hackathon.jsx b/frontend/src/hackathon.jsx
index 2f00cdf..00ae521 100644
--- a/frontend/src/hackathon.jsx
+++ b/frontend/src/hackathon.jsx
@@ -1,16 +1,12 @@
-import Axios from 'axios'
+import Axios from 'axios';
import { Link } from 'react-router-dom';
-import { useEffect } from 'react';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
const Hackathon = () => {
const [Hackathonlist, setHackathonlist] = useState([]);
-
-
const getHackathon = async () => {
try {
-
const response = await Axios.get('http://localhost:3000/hackathon');
const data = response.data.map(hackathon => ({
HackathonID: hackathon.HackathonID,
@@ -28,11 +24,11 @@ const Hackathon = () => {
useEffect(() => {
getHackathon();
- }, []);
+ }, []);
return (
- {/* หัวรอใส่รูป */}
+ {/* Header */}
@@ -44,14 +40,17 @@ const Hackathon = () => {
- {/* เนื้อหา */}
+ {/* Content */}
-
+
กิจกรรมแนะนำ
{Hackathonlist.map((hackathon) => (
-
+
{
/>
{hackathon.Name}
-
เริ่มรับสมัคร {hackathon.StartDate}
-
-
สิ้นสุดรับสมัคร {hackathon.EndDate}
-
-
-
-
-
+
เริ่มรับสมัคร {hackathon.StartDate}
+
สิ้นสุดรับสมัคร {hackathon.EndDate}
+
+
+
- ))}
+
+ ))}
);
};
-export default Hackathon;
\ No newline at end of file
+export default Hackathon;
diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx
index 4ebca51..012a378 100644
--- a/frontend/src/main.jsx
+++ b/frontend/src/main.jsx
@@ -12,18 +12,15 @@ import Swipe from "./Swipe";
import Register from "./Register";
import LoginForm from "./LoginForm";
import Profile from "./profile";
-import EventDetail from './EventDetail';
-
-import Dashboard from "./Dashboard";
-
import EventDetail from "./EventDetail";
import Rating from "./Rating";
+import Dashboard from "./Dashboard";
import Hackathon from "./hackathon";
import AllUsers from "./all_user";
import Message from "./message";
import About_us from "./about_us";
-import Rating from "./Rating";
+import Add_hackathon from "./Add_Hackathon"
const router = createBrowserRouter([
{
@@ -147,11 +144,11 @@ const router = createBrowserRouter([
errorElement:
},
{
- path: "/rating",
+ path: "/Add_hackathon",
element: (
<>
-
+
>
),
errorElement:
diff --git a/frontend/src/profile.jsx b/frontend/src/profile.jsx
index 50b894a..660f8b8 100644
--- a/frontend/src/profile.jsx
+++ b/frontend/src/profile.jsx
@@ -4,7 +4,7 @@ import { MdEmail } from "react-icons/md";
import Axios from 'axios';
import PropTypes from 'prop-types';
import Swal from 'sweetalert2'
-import image from '../../public/uploads/profiles/5psgeommk-b1715b66-2c24-49ee-b16e-37ab0ba43ea0.jpeg'
+import image from '../../public/uploads/profiles/5psgeommk-b1715b66-2c24-49ee-b16e-37ab0ba43ea0.jpeg'
// EditProfileModal component
const EditProfileModal = ({ isOpen, onClose, onSave, user }) => {
diff --git a/public/uploads/profiles/2a4xlniyn-391db290-98da-45c5-b290-1f00757c26a4.png b/public/uploads/profiles/2a4xlniyn-391db290-98da-45c5-b290-1f00757c26a4.png
new file mode 100644
index 0000000..5898271
Binary files /dev/null and b/public/uploads/profiles/2a4xlniyn-391db290-98da-45c5-b290-1f00757c26a4.png differ
diff --git a/public/uploads/profiles/oion3wsp1-1835c8d5-3c92-4c40-b483-e419862d1e18.png b/public/uploads/profiles/oion3wsp1-1835c8d5-3c92-4c40-b483-e419862d1e18.png
new file mode 100644
index 0000000..921d423
Binary files /dev/null and b/public/uploads/profiles/oion3wsp1-1835c8d5-3c92-4c40-b483-e419862d1e18.png differ
diff --git a/src/controllers/hackathonController.ts b/src/controllers/hackathonController.ts
index 7575702..eeecb63 100644
--- a/src/controllers/hackathonController.ts
+++ b/src/controllers/hackathonController.ts
@@ -35,7 +35,7 @@ export const hackathonController = new Elysia({ prefix: "/hackathon" })
// Create a new hackathon
.post(
"/create",
- async ({ body: { name, description, location, startDate, endDate }, error }) => {
+ async ({ body: { name, description, location, startDate, endDate, hackathonImage }, error }) => {
// Validate the input
if (!name || !description || !location || !startDate || !endDate) {
return error(400, "Name and description are required");
@@ -47,7 +47,8 @@ export const hackathonController = new Elysia({ prefix: "/hackathon" })
Description: description,
StartDate: startDate,
EndDate: endDate,
- Location: location,
+ Location: location,
+ HackathonImage: hackathonImage,
},
});
@@ -60,6 +61,7 @@ export const hackathonController = new Elysia({ prefix: "/hackathon" })
location: t.String(),
startDate: t.String(),
endDate: t.String(),
+ hackathonImage: t.String(),
}),
}
)
diff --git a/src/controllers/swipeController.ts b/src/controllers/swipeController.ts
index e719968..7e598ea 100644
--- a/src/controllers/swipeController.ts
+++ b/src/controllers/swipeController.ts
@@ -4,31 +4,31 @@ import { prisma } from "../prisma";
// Controller for handling swipe-related routes
export const swipeController = new Elysia({ prefix: "/swipe" })
- // Fetch a profile to swipe on
+ // Fetch all profiles to swipe on except the current user
.get(
"/:userID",
async ({ params: { userID }, error }) => {
- // Fetch a user that the current user hasn't swiped on yet
- const potentialMatch = await prisma.user.findFirst({
+ // Fetch all users except the current user
+ const potentialMatches = await prisma.user.findMany({
where: {
- // Avoid users the current user has already swiped on
- SwipesReceived: {
- none: {
- SwipingUserID: userID,
- },
- },
UserID: {
not: userID, // Exclude the current user
},
},
- // You can add more complex logic here for filtering based on working style, location, etc.
+ include: {
+ UserSkills: {
+ include: {
+ Skill: true,
+ },
+ },
+ },
});
- if (!potentialMatch) {
+ if (potentialMatches.length === 0) {
return error(404, "No more profiles available to swipe");
}
- return potentialMatch; // Return the profile for swiping
+ return potentialMatches; // Return the profiles for swiping
},
{
params: t.Object({
@@ -78,7 +78,7 @@ export const swipeController = new Elysia({ prefix: "/swipe" })
NotificationContent: `You have a new match with ${userID}!`,
},
],
- })
+ });
await prisma.message.createMany({
data: [
@@ -114,4 +114,4 @@ export const swipeController = new Elysia({ prefix: "/swipe" })
swipeAction: t.String(), // "Like" or "Dislike"
}),
}
- );
+ );
\ No newline at end of file
diff --git a/src/controllers/teamController.ts b/src/controllers/teamController.ts
index be30f46..8c7883b 100644
--- a/src/controllers/teamController.ts
+++ b/src/controllers/teamController.ts
@@ -74,6 +74,28 @@ export const teamController = new Elysia({ prefix: "/team" })
TeamName: t.String(),
}),
})
+.get("/finduserteam/:teamID", async ({ params, error }) => {
+ const teamID = parseInt(params.teamID, 10); // Ensure teamID is a number
+ if (isNaN(teamID)) {
+ return error(400, "Invalid teamID");
+ }
+
+ const team = await prisma.userTeam.findMany({
+ where: {
+ TeamID: teamID,
+ },
+ });
+
+ if (!team || team.length === 0) {
+ return error(404, "Team not found");
+ }
+
+ return team;
+}, {
+ params: t.Object({
+ teamID: t.String(), // teamID is a string in the URL params
+ }),
+})
.get("/hackathon/:id", async ({ params: { id }, error }) => {
const teams = await prisma.team.findMany({
@@ -97,7 +119,7 @@ export const teamController = new Elysia({ prefix: "/team" })
.post("/create", async ({ body, error }) => {
const { teamName, hackathonID, maxMember } = body;
-
+ console.log('Creating team with:', { teamName, hackathonID, maxMember });
// Check if team and hackathonID exists
const hackathon = await prisma.hackathon.findUnique({
where: { HackathonID: hackathonID },