Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cc41bd9
feat: FEATURETHON.md
garrettladley Mar 29, 2025
1183892
chore: refactor frontend hierarchy
benjaspet Mar 29, 2025
0f9b89f
chore: menu item view styling fixes
benjaspet Mar 29, 2025
fb53bfa
chore: format code
benjaspet Mar 29, 2025
a95778e
Merge branch 'featurethon-frontend-hierarchy' of github.com:GenerateN…
benjaspet Mar 29, 2025
9043ab2
feat: connect user profiles & reviews to detail pages
benjaspet Mar 29, 2025
aca835b
chore(font): add Source Sans 3
benjaspet Mar 29, 2025
3274cce
feat: review & menu items backend integration
benjaspet Mar 29, 2025
b66cd64
feat: featurethon misc. schema (#83)
abhikaboy Mar 29, 2025
0663042
Featurethon reccomendations (#85)
abhikaboy Mar 29, 2025
d20f89a
feat: onboarding integration
danctila Mar 29, 2025
6c7338d
feat: connect components
benjaspet Mar 29, 2025
0372d25
Merge branch 'featurethon' into featurethon-onboarding
danctila Mar 29, 2025
b5a24d1
chore: lint frontend
danctila Mar 29, 2025
0c0b9d4
chore: invert scroll orientation
benjaspet Mar 29, 2025
e03167b
Merge branch 'featurethon-onboarding' of github.com:GenerateNU/platem…
benjaspet Mar 29, 2025
a465acf
fix: prevent registering on login
benjaspet Mar 29, 2025
187c3b0
fix: linting errors
benjaspet Mar 30, 2025
8ed2ed9
feat: review flow component backend integration (#87)
DavidYu75 Mar 30, 2025
ea4c8d7
feat: filters feed (#89)
michelleli04 Mar 30, 2025
1c048d3
chore: linting
danctila Mar 30, 2025
516f0ea
Merge branch 'featurethon' into featurethon-onboarding
danctila Mar 30, 2025
a191c94
chore: fix linter errors
danctila Apr 1, 2025
ecb9ab9
Merge branch 'main' into featurethon-onboarding
danctila Apr 2, 2025
29e961d
merge into main
danctila Apr 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions backend/internal/handlers/auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package auth

import (
"strings"

"github.com/GenerateNU/platemate/internal/xerr"
"github.com/GenerateNU/platemate/internal/xvalidator"
"github.com/gofiber/fiber/v2"
"go.mongodb.org/mongo-driver/bson/primitive"
"strings"
)

/*
Expand Down Expand Up @@ -85,14 +86,40 @@ func (h *Handler) Register(c *fiber.Ctx) error {
return err
}

// Convert string array to ObjectID array for followers and following
var followingOIDs []primitive.ObjectID = make([]primitive.ObjectID, 0)
var followersOIDs []primitive.ObjectID = make([]primitive.ObjectID, 0)
var reviewsOIDs []primitive.ObjectID = make([]primitive.ObjectID, 0)

// Initialize empty arrays for preferences and restrictions if they're nil
if req.Preferences == nil {
req.Preferences = make([]string, 0)
}
if req.Restrictions == nil {
req.Restrictions = make([]string, 0)
}
if req.TasteProfile == nil {
req.TasteProfile = make([]float64, 1536)
}

user := User{
ID: oidHex,
Name: req.Name,
Email: req.Email,
Password: req.Password,
FollowingCount: 0,
FollowersCount: 0,
ProfilePictureURL: "",
Username: req.Username,
FollowingCount: req.FollowingCount,
FollowersCount: req.FollowersCount,
ProfilePictureURL: req.ProfilePicture,
Count: req.Count,
RefreshToken: req.RefreshToken,
TokenUsed: req.TokenUsed,
Preferences: req.Preferences,
Restrictions: req.Restrictions,
Following: followingOIDs,
Followers: followersOIDs,
Reviews: reviewsOIDs,
TasteProfile: req.TasteProfile,
}

if err = user.Validate(); err != nil {
Expand Down
32 changes: 25 additions & 7 deletions backend/internal/handlers/auth/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ type User struct {
Name string `bson:"name"`
Email string `bson:"email"`
Password string `bson:"password"`
FollowingCount int `bson:"followingCount"`
FollowersCount int `bson:"followersCount"`
Username string `bson:"username"`
FollowingCount int64 `bson:"followingCount"`
FollowersCount int64 `bson:"followerCount"`
ProfilePictureURL string `bson:"profile_picture"`
RefreshToken string `bson:"refresh_token"`
TokenUsed bool `bson:"token_used"`
Reviews []primitive.ObjectID `bson:"reviews"`
Count int `bson:"count"`
RefreshToken string `bson:"refresh_token"`
TokenUsed bool `bson:"token_used"`
Preferences []string `bson:"preferences"`
Restrictions []string `bson:"restrictions"`
Following []primitive.ObjectID `bson:"following"`
Followers []primitive.ObjectID `bson:"followers"`
TasteProfile []float64 `bson:"taste_profile"`
}

type LoginRequest struct {
Expand All @@ -45,9 +51,21 @@ type LoginRequest struct {
}

type RegisterRequest struct {
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=8"`
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=8"`
Username string `json:"username" validate:"required"`
FollowingCount int64 `json:"followingCount"`
FollowersCount int64 `json:"followerCount"`
ProfilePicture string `json:"profile_picture"`
Count int `json:"count"`
RefreshToken string `json:"refresh_token"`
TokenUsed bool `json:"token_used"`
Preferences []string `json:"preferences"`
Restrictions []string `json:"restrictions"`
Following []string `json:"following"`
Followers []string `json:"followers"`
TasteProfile []float64 `json:"taste_profile"`
}

type RefreshRequestBody struct {
Expand Down
31 changes: 21 additions & 10 deletions backend/internal/handlers/users/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,35 @@ type User struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Email string `bson:"email"`
Username string `bson:"username"`
Name string `bson:"name,omitempty"`
Password string `bson:"password"`
Reviews []primitive.ObjectID `bson:"reviews"`
Count int `bson:"count"`
Following []primitive.ObjectID `bson:"following,omitempty"`
Followers []primitive.ObjectID `bson:"followers,omitempty"`
FollowingCount int `bson:"followingCount"`
FollowersCount int `bson:"followersCount"`
FollowersCount int `bson:"followerCount"`
ProfilePicture string `bson:"profile_picture,omitempty"`
Name string `bson:"name,omitempty"`
RefreshToken string `bson:"refresh_token"`
TokenUsed bool `bson:"token_used"`
Preferences []string `bson:"preferences,omitempty"`
Restrictions []string `bson:"restrictions,omitempty"`
TasteProfile []float64 `bson:"taste_profile,omitempty"`
}

type UserResponse struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
ProfilePicture string `json:"profile_picture,omitempty"`
FollowersCount int `json:"followersCount"`
FollowingCount int `json:"followingCount"`
Reviews []string `json:"reviews,omitempty"`
Name string `json:"name,omitempty"`
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Name string `json:"name,omitempty"`
ProfilePicture string `json:"profile_picture,omitempty"`
FollowersCount int `json:"followerCount"`
FollowingCount int `json:"followingCount"`
Reviews []string `json:"reviews,omitempty"`
Count int `json:"count"`
Preferences []string `json:"preferences,omitempty"`
Restrictions []string `json:"restrictions,omitempty"`
TasteProfile []float64 `json:"taste_profile,omitempty"`
}

type FollowRequest struct {
Expand Down
2 changes: 0 additions & 2 deletions frontend/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { makeRequest } from "@/api/base";
import { LoginRequestBody, RegisterRequestBody } from "@/types/auth";

const BASE_URL = process.env.EXPO_PUBLIC_BASE_URL;

export async function getUserById(userId: string) {
return await makeRequest(`/api/v1/users/${userId}`, "GET");
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Text } from "react-native";
import { Redirect, Slot, Stack } from "expo-router";
import { Redirect, Slot } from "expo-router";
import useAuthStore from "@/auth/store";

export default function AppLayout() {
const { isAuthenticated, isLoading } = useAuthStore();
const { isAuthenticated, loading } = useAuthStore();

// You can keep the splash screen open, or render a loading screen like we do here.
if (isLoading) {
if (loading) {
return <Text>Loading...</Text>;
}

Expand Down
35 changes: 30 additions & 5 deletions frontend/app/(onboarding)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OnboardingFlow } from "@/components/Onboarding/OnboardingFlow";
import useAuthStore from "@/auth/store";

export default function OnboardingScreen() {
const { isAuthenticated } = useAuthStore();
const { isAuthenticated, register } = useAuthStore();

// Use useEffect to handle navigation logic
useEffect(() => {
Expand All @@ -14,10 +14,35 @@ export default function OnboardingScreen() {
}
}, [isAuthenticated]);

const handleOnboardingComplete = () => {
// TODO: Handle actual auth here
router.replace("/(tabs)");
console.log("called");
const handleOnboardingComplete = async (data: {
name: string;
email: string;
password: string;
username: string;
restrictions: string[];
preferences: string[];
profilePicture: string;
followers: string[];
following: string[];
followersCount: number;
followingCount: number;
reviews: string[];
count: number;
refreshToken: string;
tokenUsed: boolean;
tasteProfile: number[];
dietaryRestrictions?: string[];
cuisinePreferences?: string[];
}) => {
try {
// Register the user with the collected data
await register(data.email, data.password, data.name, data.username, data.preferences, data.restrictions);
// The registration will automatically set isAuthenticated to true
// which will trigger the navigation in the useEffect
} catch (error) {
console.error("Registration failed:", error);
// TODO: Handle registration error (show error message to user)
}
};

// If authenticated, return null to avoid rendering anything
Expand Down
Loading
Loading