Skip to content

Commit

Permalink
feat: explore page (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaspet authored Dec 3, 2024
1 parent 12c08c3 commit 5b4798d
Show file tree
Hide file tree
Showing 35 changed files with 18,280 additions and 27,666 deletions.
28 changes: 27 additions & 1 deletion backend/internal/handlers/friendship/friendship.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package friendship

import (
"fmt"
"log"

"github.com/GenerateNU/nightlife/internal/models"
"github.com/gofiber/fiber/v2"
"log"
"github.com/google/uuid"
)

// POST endpoint to create friendship between two users in DB
Expand All @@ -26,3 +28,27 @@ func (s *Service) CreateFriendship(c *fiber.Ctx) error {

return c.Status(fiber.StatusCreated).JSON(req)
}

func (s *Service) GetFriendshipsByUserID(c *fiber.Ctx) error {
fmt.Println("Getting friendships by user ID")

var userID uuid.UUID

fmt.Print(c.Params("userID"))

if err := userID.UnmarshalText([]byte(c.Params("userID"))); err != nil {
log.Printf("Error parsing UUID: %v, Request: %+v", err, userID)
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": "Cannot parse UUID",
})
}

friendships, err := s.store.GetFriendshipsByUserID(c.Context(), userID)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"error": "Failed to get friendships",
})
}

return c.Status(fiber.StatusOK).JSON(friendships)
}
8 changes: 2 additions & 6 deletions backend/internal/handlers/friendship/routes.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package friendship

import (
//"github.com/GenerateNU/nightlife/internal/auth"
"github.com/GenerateNU/nightlife/internal/types"
"github.com/gofiber/fiber/v2"
)

func Routes(app *fiber.App, params types.Params) {

//create a service
service := newService(params.Store)

//create a grouping
protected := app.Group("/friendships")
//.Use(auth.Protected(&params.Supabase))

//create a route
protected.Post("/api/friendship", service.CreateFriendship)
protected.Post("/", service.CreateFriendship)
protected.Get("/:userID", service.GetFriendshipsByUserID)

}
23 changes: 23 additions & 0 deletions backend/internal/storage/postgres/friendship.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/GenerateNU/nightlife/internal/models"
"github.com/google/uuid"
)

func (db *DB) CreateFriendship(ctx context.Context, friendship models.Friendship) error {
Expand All @@ -14,3 +15,25 @@ func (db *DB) CreateFriendship(ctx context.Context, friendship models.Friendship
_, err := db.conn.Exec(ctx, query, friendship.UserID1, friendship.UserID2, friendship.FriendshipStatus, friendship.CreatedAt)
return err
}

func (db *DB) GetFriendshipsByUserID(ctx context.Context, userID uuid.UUID) ([]models.Friendship, error) {
var query = `
SELECT * FROM friendship WHERE user_id1 = $1 OR user_id2 = $1;
`
rows, err := db.conn.Query(ctx, query, userID)
if err != nil {
return nil, err
}
defer rows.Close()

var friendships []models.Friendship
for rows.Next() {
var friendship models.Friendship
err = rows.Scan(&friendship.UserID1, &friendship.UserID2, &friendship.FriendshipStatus, &friendship.CreatedAt)
if err != nil {
return nil, err
}
friendships = append(friendships, friendship)
}
return friendships, nil
}
1 change: 1 addition & 0 deletions backend/internal/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type VenueRatings interface {

type Friendship interface {
CreateFriendship(context.Context, models.Friendship) error
GetFriendshipsByUserID(context.Context, uuid.UUID) ([]models.Friendship, error)
}

type Event interface {
Expand Down
2 changes: 0 additions & 2 deletions frontend/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
import { NavigationContainer } from '@react-navigation/native';
import { BottomNavigator } from "@/navigation/BottomNavigator";
import { createNativeStackNavigator } from '@react-navigation/native-stack';
Expand All @@ -15,7 +14,6 @@ import PersonalityScreenReveal2 from './components/OnboardingCards/PersonalitySc
import HowFarFromYou from './components/OnboardingCards/HowFarFromYou';

import { Archivo_400Regular, Archivo_500Medium, Archivo_700Bold, useFonts } from "@expo-google-fonts/archivo";
//import EditProfile from './screens/profile/EditProfile';

const Stack = createNativeStackNavigator();

Expand Down
94 changes: 94 additions & 0 deletions frontend/assets/personas/BIRD.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions frontend/assets/personas/CAT.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions frontend/assets/personas/GIRL.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5b4798d

Please sign in to comment.