[go: nahoru, domu]

Skip to content

Commit

Permalink
fix: signinwithredirect
Browse files Browse the repository at this point in the history
  • Loading branch information
HYACCCINT committed Jun 26, 2024
1 parent b066256 commit 0823b91
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 68 deletions.
60 changes: 30 additions & 30 deletions dataconnect/dataconnect/4_user_favorites_review_insert.gql
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
mutation {
user1: user_insert(data: {
id: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
username: "c_w"
id: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",
username: "cynthia_w"
})

user2: user_insert(data: {
id: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
username: "a_w"
id: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",
username: "momo_h"
})

user3: user_insert(data: {
id: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
username: "r_f"
id: "TBedjwCX0Jf955Uuoxk6k74sY0l1",
username: "siyi_w"
})

review1: review_insert(data: {
id: "345e4567-e89b-12d3-a456-426614174000",

userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",
movieId: "550e8400-e29b-41d4-a716-446655440000",
rating: 5,
reviewText: "An incredible movie with a mind-blowing plot!",
Expand All @@ -26,7 +26,7 @@ mutation {

review2: review_insert(data: {
id: "345e4567-e89b-12d3-a456-426614174001",
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

movieId: "550e8400-e29b-41d4-a716-446655440001",
rating: 5,
Expand All @@ -36,7 +36,7 @@ mutation {

review3: review_insert(data: {
id: "345e4567-e89b-12d3-a456-426614174002",
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

movieId: "550e8400-e29b-41d4-a716-446655440002",
rating: 5,
Expand All @@ -46,7 +46,7 @@ mutation {

review4: review_insert(data: {
id: "345e4567-e89b-12d3-a456-426614174003",
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

movieId: "550e8400-e29b-41d4-a716-446655440003",
rating: 4,
Expand All @@ -56,7 +56,7 @@ mutation {

review5: review_insert(data: {
id: "345e4567-e89b-12d3-a456-426614174004",
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

movieId: "550e8400-e29b-41d4-a716-446655440004",
rating: 5,
Expand All @@ -66,7 +66,7 @@ mutation {

review6: review_insert(data: {
id: "345e4567-e89b-12d3-a456-426614174005",
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

movieId: "550e8400-e29b-41d4-a716-446655440005",
rating: 5,
Expand All @@ -75,109 +75,109 @@ mutation {
})

favoriteMovie1: favoriteMovie_insert(data: {
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

movieId: "550e8400-e29b-41d4-a716-446655440000"
})

favoriteMovie2: favoriteMovie_insert(data: {
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

movieId: "550e8400-e29b-41d4-a716-446655440001"
})

favoriteMovie3: favoriteMovie_insert(data: {
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

movieId: "550e8400-e29b-41d4-a716-446655440002"
})

favoriteMovie4: favoriteMovie_insert(data: {
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

movieId: "550e8400-e29b-41d4-a716-446655440003"
})

favoriteMovie5: favoriteMovie_insert(data: {
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

movieId: "550e8400-e29b-41d4-a716-446655440004"
})

favoriteMovie6: favoriteMovie_insert(data: {
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

movieId: "550e8400-e29b-41d4-a716-446655440005"
})

favoriteActor1: favoriteActor_insert(data: {
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

actorId: "123e4567-e89b-12d3-a456-426614174000"
})

favoriteActor2: favoriteActor_insert(data: {
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

actorId: "123e4567-e89b-12d3-a456-426614174001"
})

favoriteActor3: favoriteActor_insert(data: {
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

actorId: "123e4567-e89b-12d3-a456-426614174002"
})

favoriteActor4: favoriteActor_insert(data: {
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

actorId: "123e4567-e89b-12d3-a456-426614174003"
})

favoriteActor5: favoriteActor_insert(data: {
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

actorId: "123e4567-e89b-12d3-a456-426614174004"
})

favoriteActor6: favoriteActor_insert(data: {
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

actorId: "123e4567-e89b-12d3-a456-426614174005"
})

watchedMovie1: watchedMovie_insert(data: {
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

movieId: "550e8400-e29b-41d4-a716-446655440000"
})

watchedMovie2: watchedMovie_insert(data: {
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

movieId: "550e8400-e29b-41d4-a716-446655440001"
})

watchedMovie3: watchedMovie_insert(data: {
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

movieId: "550e8400-e29b-41d4-a716-446655440002"
})

watchedMovie4: watchedMovie_insert(data: {
userId: "SnLgOC3lN4hcIl69e53cW0Q8R1T2",
userId: "SnLgOC3lN4hcIl69s53cW0Q8R1T2",

movieId: "550e8400-e29b-41d4-a716-446655440003"
})

watchedMovie5: watchedMovie_insert(data: {
userId: "fep4fXpGWsaRpiphq9CIrBIXQ0S2",
userId: "fep4fXpGWsaRpuphq9CIrBIXQ0S2",

movieId: "550e8400-e29b-41d4-a716-446655440004"
})

watchedMovie6: watchedMovie_insert(data: {
userId: "TBedjwCX1Jf955Uuoxk6k74sY0l1",
userId: "TBedjwCX0Jf955Uuoxk6k74sY0l1",

movieId: "550e8400-e29b-41d4-a716-446655440005"
})
Expand Down
69 changes: 33 additions & 36 deletions dataconnect/dataconnect/schema/schema.gql
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
# Movies
type Movie
# The below parameter values are generated by default with @table, and can be edited manually.
@table(name: "Movies", singular: "movie", plural: "movies", key: ["id"]) {
id: UUID! @col(name: "movie_id") @default(expr: "uuidV4()")
# implicitly calls @col to generates a column name. ex: @col(name: "movie_id")
# for UUID fields, @default(expr: "uuidV4()") is implicitly called
id: UUID!
title: String!
imageUrl: String! @col(name: "image_url")
releaseYear: Int @col(name: "release_year")
imageUrl: String!
releaseYear: Int
genre: String
rating: Float @col(name: "rating")
description: String @col(name: "description")
tags: [String] @col(name: "tags")
rating: Float
description: String
tags: [String]
# Vectors
descriptionEmbedding: Vector @col(size:768) # vector
# Self Joins
sequelTo: Movie
}

# Movie Metadata
# Movie - MovieMetadata is a one-to-one relationship
type MovieMetadata
@table(
name: "MovieMetadata"
) {
@table {
# @ref creates a field in the current table (MovieMetadata) that holds the primary key of the referenced type
# In this case, @ref(fields: "id") is implied
movie: Movie! @ref
# movieId: UUID <- this is created by the above @ref
director: String @col(name: "director")
director: String
# TODO: optional other fields
}

# Actors
# Suppose an actor can participate in multiple movies and movies can have multiple actors
# Movie - Actors (or vice versa) is a many to many relationship
type Actor @table(name: "Actors", singular: "actor", plural: "actors") {
id: UUID! @col(name: "actor_id") @default(expr: "uuidV4()")
imageUrl: String! @col(name: "image_url")
type Actor @table {
id: UUID!
imageUrl: String!
name: String! @col(name: "name", dataType: "varchar(30)")
biography: String @col(name: "biography")
biography: String
}

# Join table for many-to-many relationship for movies and actors
Expand All @@ -43,22 +46,21 @@ type Actor @table(name: "Actors", singular: "actor", plural: "actors") {
type MovieActor @table(key: ["movie", "actor"]) {
# @ref creates a field in the current table (MovieActor) that holds the primary key of the referenced type
# In this case, @ref(fields: "id") is implied
movie: Movie! @ref
# movieId: UUID! <- this is created by the above @ref, see: implicit.gql
movie: Movie!
# movieId: UUID! <- this is created by the implied @ref, see: implicit.gql

actor: Actor! @ref
# actorId: UUID! <- this is created by the above @ref, see: implicit.gql
actor: Actor!
# actorId: UUID! <- this is created by the implied @ref, see: implicit.gql

role: String! @col(name: "role") # "main" or "supporting"
role: String! # "main" or "supporting"
# TODO: optional other fields
}

# Users
# Suppose a user can leave reviews for movies
# user:reviews is a one to many relationship, movie:reviews is a one to many relationship, movie:user is a many to many relationship
type User
@table(name: "Users", singular: "user", plural: "users", key: ["id"]) {
# id: UUID! @col(name: "user_id") @default(expr: "uuidV4()")
@table {
id: String! @col(name: "user_auth")
username: String! @col(name: "username", dataType: "varchar(50)")
# The following are generated from the @ref in the Review table
Expand All @@ -69,36 +71,31 @@ type User
# Join table for many-to-many relationship for users and favorite movies
type FavoriteMovie
@table(name: "FavoriteMovies", key: ["user", "movie"]) {
user: User! @ref
movie: Movie! @ref
# @ref is implicit
user: User!
movie: Movie!
}

# Join table for many-to-many relationship for users and favorite actors
type FavoriteActor
@table(name: "FavoriteActors", key: ["user", "actor"]) {
user: User! @ref
actor: Actor! @ref
user: User!
actor: Actor!
}

# Join table for many-to-many relationship for users and watched movies
type WatchedMovie
@table(name: "WatchedMovies", key: ["user", "movie"]) {
user: User! @ref
movie: Movie! @ref
user: User!
movie: Movie!
}

# Reviews
type Review @table(name: "Reviews", key: ["movie", "user"]) {
id: UUID! @col(name: "review_id") @default(expr: "uuidV4()")
user: User! @ref
movie: Movie! @ref
id: UUID! @default(expr: "uuidV4()")
user: User!
movie: Movie!
rating: Int
reviewText: String
reviewDate: Date! @default(expr: "request.time")
}

# Self Joins
extend type Movie {
sequelTo: Movie
}

4 changes: 2 additions & 2 deletions dataconnect/movie/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { getAuth, signInWithRedirect, GoogleAuthProvider, signOut, User } from 'firebase/auth';
import { getAuth, signInWithPopup, GoogleAuthProvider, signOut, User } from 'firebase/auth';
import { firebaseapp, onAuthStateChanged } from '@/lib/firebase';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
Expand Down Expand Up @@ -28,7 +28,7 @@ const Navbar = () => {

const handleSignIn = async () => {
const provider = new GoogleAuthProvider();
await signInWithRedirect(auth, provider);
await signInWithPopup(auth, provider);
};

const handleSignOut = async () => {
Expand Down

0 comments on commit 0823b91

Please sign in to comment.