Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lucca93 committed Oct 29, 2023
2 parents 140ea96 + 7a4ba10 commit 9c98a43
Show file tree
Hide file tree
Showing 13 changed files with 340 additions and 297 deletions.
Binary file modified backend/__pycache__/main.cpython-311.pyc
Binary file not shown.
Binary file modified backend/__pycache__/supabase_client.cpython-311.pyc
Binary file not shown.
12 changes: 7 additions & 5 deletions backend/main.py
@@ -1,8 +1,9 @@


import lunchheros

from fastapi.encoders import jsonable_encoder
from src.lunchheros.db.dbFetcher import get_encoded_data
from src.routes.users.userFunctions import getAllUsers, getUserWithId
from src.routes.users.userFunctions import getAllQueryListData, getAllUsers, getUserWithId
from fastapi import FastAPI
from supabase_client import supabase_client

Expand All @@ -27,7 +28,8 @@ def load_current_user(userId):
@app.get("/button_trigger/{userId}")
def load_current_user(userId: str):
userData = getUserWithId(userId)
print("asdas")
#test = get_encoded_data(1,1,userData)
queryList = getAllQueryListData()

test = lunchheros.match.match(userData)

return { "currentUser" : userData}
return { "currentUser" : userData, "query": queryList}
5 changes: 4 additions & 1 deletion backend/src/__init__.py
@@ -1 +1,4 @@
"""Lunchheros: Backend to match people for lunch based on their interests."""
"""Lunchheros: Backend to match people for lunch based on their interests."""
from lunchheros import match

__all__ = ["match"]
4 changes: 4 additions & 0 deletions backend/src/lunchheros/match/__init__.py
@@ -1 +1,5 @@
"""Subpackage related to matching between users into groups."""

from lunchheros.match import matching

__all__ = ["matching"]
14 changes: 14 additions & 0 deletions backend/src/lunchheros/match/_randomize.py
@@ -1,5 +1,7 @@
import random

from lunchheros.db.dbFetcher import parse_user_id_tolist


def _randomize_groups(group_size: int, users: list[str]) -> list[list]:
"""Randomize the groups of users.
Expand Down Expand Up @@ -37,4 +39,16 @@ def _randomize_groups(group_size: int, users: list[str]) -> list[list]:
return groups


def match(userids):

# convert userids to list
userids = parse_user_id_tolist(userids)
# group size
groupsize = 5
# randomize the groups
groups = _randomize_groups(groupsize, userids)
# return the groups
return groups



Binary file modified backend/src/routes/users/__pycache__/userFunctions.cpython-311.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions backend/src/routes/users/userFunctions.py
Expand Up @@ -10,3 +10,7 @@ def getUserWithId(userId):
def getAllUsers():
return supabase_client.table("users").select(users_select).execute()


def getAllQueryListData():
return supabase_client.table("waiting_query").select(f"*, user({users_select}), time_range(*), company(*), age_range(*)").execute()

12 changes: 1 addition & 11 deletions frontend/src/Components/ProfileButton.js
@@ -1,22 +1,17 @@
import React, { useState, useEffect, useRef } from "react";

import { logout } from "../store/session";
import { useNavigate } from "react-router-dom";
import "../SCSS/navigation.css";

function ProfileButton({ user }) {
const [showMenu, setShowMenu] = useState(false);
const ulRef = useRef();
const navigate= useNavigate()

const openMenu = () => {
if (showMenu) return;
setShowMenu(true);
};

useEffect(() => {
if (!showMenu) return;

const closeMenu = (e) => {
if (!ulRef.current.contains(e.target)) {
setShowMenu(false);
Expand All @@ -25,21 +20,17 @@ function ProfileButton({ user }) {
document.addEventListener("click", closeMenu);
return () => document.removeEventListener("click", closeMenu);
}, [showMenu]);

const handleLogout = (e) => {
e.preventDefault();
logout();
navigate("/");
};

const navUserProfile = (e) => {
e.preventDefault();
navigate('/profile')
}

const ulClassName = "profile-dropdown" + (showMenu ? "" : " hidden");
const closeMenu = () => setShowMenu(false);

return (
<>
<button onClick={openMenu} className="user-profile-dropdown-button">
Expand All @@ -63,5 +54,4 @@ function ProfileButton({ user }) {
</>
);
}

export default ProfileButton;
export default ProfileButton;
141 changes: 72 additions & 69 deletions frontend/src/Components/Scheduling.js
@@ -1,73 +1,76 @@
import React from "react";
import "../SCSS/scheduling.css";

import React from 'react';
import '../SCSS/scheduling.css';
const Scheduling = (props) => {
const generateTimeSlots = () => {
let slots = [];
for (let i = 11; i <= 14; i++) {
for (let j = 0; j < 60; j += 30) {
if (i === 14 && j > 0) break; // Avoid adding 14:30
const hour = String(i).padStart(2, '0');
const minute = String(j).padStart(2, '0');
slots.push(`${hour}:${minute}`);
const generateTimeSlots = () => {
let slots = [];
for (let i = 11; i <= 14; i++) {
for (let j = 0; j < 60; j += 30) {
if (i === 14 && j > 0) break; // Avoid adding 14:30
const hour = String(i).padStart(2, '0');
const minute = String(j).padStart(2, '0');
slots.push(`${hour}:${minute}`);
}
}
}
return slots;
};

const featureSoon = () => {
window.alert("Feature coming soon!");
}
return (
<div className="scheduling-container">
<div className="scheduling-header">
Fancy having lunch together with interesting people?
</div>
<div className="time-dropdown-guests-slider">
<div className="time-dropdown">
<div>
<strong>Time Slot:</strong>
<select
value={props.timeSlot}
onChange={(e) => props.onTimeSlotChange(e.target.value)}
>
{generateTimeSlots().map((slot, index) => (
<option key={index} value={slot}>
{slot}
</option>
))}
</select>
</div>
</div>
<div className="guests-slider">
<div className="slider">
<strong>Group Size:</strong>
<input
type="range"
min="2"
max="4"
value={props.groupSize}
onChange={(e) => props.onGroupSizeChange(e.target.value)}
/>
{props.groupSize} Persons
</div>
</div>
return slots;
};
const featureSoon = () => {
window.alert('Feature coming soon!');
};
return (
<div className="scheduling-container">
<div className="scheduling-header">
Fancy having lunch together with interesting people?
</div>
<div className="time-dropdown-guests-slider">
<div className="time-dropdown">
<div>
<strong>Time Slot:</strong>
<select
value={props.timeSlot}
onChange={(e) =>
props.onTimeSlotChange(e.target.value)
}
>
{generateTimeSlots().map((slot, index) => (
<option key={index} value={slot}>
{slot}
</option>
))}
</select>
</div>
</div>
<div className="guests-slider">
<div className="slider">
<strong>Group Size:</strong>
<input
type="range"
min="2"
max="4"
value={props.groupSize}
onChange={(e) =>
props.onGroupSizeChange(e.target.value)
}
/>
{props.groupSize} Persons
</div>
</div>
</div>
<div className="actions-container">
<div className="quick-actions">
<button className="view-all-button">Randomize</button>
<p>Use default settings for a quick match.</p>
</div>
<div className="advanced-actions">
<button className="view-all-button" onClick={featureSoon}>
Customize
</button>
<p>Adjust settings to find your perfect match.</p>
</div>
</div>
<div className="view-all-container">
<button className="view-all-button">View All Matches</button>
</div>
</div>
<div className="actions-container">
<div className="quick-actions">
<button className="randomize-button">Randomize</button>
<p>Use default settings for a quick match.</p>
</div>
<div className="advanced-actions">
<button className="customize-button" onClick={featureSoon}>Customize</button>
<p>Adjust settings to find your perfect match.</p>
</div>
</div>
<div className="view-all-container">
<button className="view-all-button">View All Matches</button>
</div>
</div>
);
);
};

export default Scheduling;
export default Scheduling;
51 changes: 24 additions & 27 deletions frontend/src/SCSS/Profile.css
@@ -1,28 +1,25 @@
.profile-container {
border: 1px solid #e0e0e0;
padding: 20px;
border-radius: 10px;
max-width: 400px;
margin: 20px auto;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

.profile-container h2 {
color: black
}
.profile-picture {
width: 300px;
height: 300px;
border-radius: 50%;
margin-bottom: 15px;
}

.profile-detail, .profile-interests {
margin: 10px 0;
}

.profile-interests ul {
list-style-type: none;
padding: 0;
}
border: 1px solid #E0E0E0;
padding: 20px;
border-radius: 10px;
max-width: 400px;
margin: 20px auto;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
.profile-container h2 {
color: black
}
.profile-picture {
width: 300px;
height: 300px;
border-radius: 50%;
margin-bottom: 15px;
}
.profile-detail, .profile-interests {
margin: 10px 0;
}
.profile-interests ul {
list-style-type: none;
padding: 0;
}

0 comments on commit 9c98a43

Please sign in to comment.