From 2c0eeb96c34f472461ae6678d65dd72f4a272475 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 7 May 2025 23:04:16 -0500 Subject: [PATCH] - Implemented discord authentication - Added script to fetch typescript definitions for the supabase database --- components/app/nav-bar.vue | 98 ++++++- components/player.vue | 7 - nuxt.config.ts | 5 +- package-lock.json | 116 ++++++++ package.json | 7 +- pages/confirm.vue | 34 ++- pages/login.vue | 35 --- pages/login/auto/index.vue | 33 +++ pages/login/index.vue | 22 ++ pages/players/[id].vue | 6 +- pages/players/random.vue | 6 +- types/supabase.d.ts | 577 +++++++++++++++++++++++++++++++++++++ 12 files changed, 892 insertions(+), 54 deletions(-) delete mode 100644 pages/login.vue create mode 100644 pages/login/auto/index.vue create mode 100644 pages/login/index.vue create mode 100644 types/supabase.d.ts diff --git a/components/app/nav-bar.vue b/components/app/nav-bar.vue index 0b78093..d930708 100644 --- a/components/app/nav-bar.vue +++ b/components/app/nav-bar.vue @@ -1,3 +1,23 @@ + + \ No newline at end of file + + + \ No newline at end of file diff --git a/components/player.vue b/components/player.vue index d1f58ee..a3b231a 100644 --- a/components/player.vue +++ b/components/player.vue @@ -24,13 +24,6 @@ import type { Player } from '~/types/Player'; const props = defineProps<{ player: Player }>() - -// defineProps({ -// player: { -// type: Player, -// required: true -// } -// }) \ No newline at end of file diff --git a/pages/login/index.vue b/pages/login/index.vue new file mode 100644 index 0000000..a781892 --- /dev/null +++ b/pages/login/index.vue @@ -0,0 +1,22 @@ + + diff --git a/pages/players/[id].vue b/pages/players/[id].vue index c7a6adc..59ed528 100644 --- a/pages/players/[id].vue +++ b/pages/players/[id].vue @@ -4,8 +4,11 @@ const route = useRoute() const playerId = route.params.id + const user = useSupabaseUser() const client = useSupabaseClient() + console.log('current user:', user) + const { data: player, pending, error } = await useAsyncData( 'players', async () => { @@ -14,8 +17,7 @@ .eq('id', playerId) .single() - console.log(`player:`) - console.log(data) + console.log(`player:`, data) return data }, { diff --git a/pages/players/random.vue b/pages/players/random.vue index e9459ee..66d16c7 100644 --- a/pages/players/random.vue +++ b/pages/players/random.vue @@ -2,8 +2,11 @@ import type { Player } from '~/types/Player' // const config = useRuntimeConfig() + const user = useSupabaseUser() const client = useSupabaseClient() + console.log('current user:', user) + const { data: playerList, pending, error } = await useAsyncData( 'random_player', async () => { @@ -13,8 +16,7 @@ .eq('mlb_player.offense_col', 1) .limit(3) - console.log('players from supabase: ') - console.log(data) + console.log('players from supabase: ', data) return data }, { diff --git a/types/supabase.d.ts b/types/supabase.d.ts new file mode 100644 index 0000000..dccb843 --- /dev/null +++ b/types/supabase.d.ts @@ -0,0 +1,577 @@ +export type Json = + | string + | number + | boolean + | null + | { [key: string]: Json | undefined } + | Json[]; + +export type Database = { + public: { + Tables: { + cardsets: { + Row: { + created_at: string; + description: string | null; + for_purchase: boolean; + id: number; + in_packs: boolean; + name: string; + ranked_legal: boolean; + total_cards: number | null; + }; + Insert: { + created_at?: string; + description?: string | null; + for_purchase?: boolean; + id?: number; + in_packs?: boolean; + name: string; + ranked_legal?: boolean; + total_cards?: number | null; + }; + Update: { + created_at?: string; + description?: string | null; + for_purchase?: boolean; + id?: number; + in_packs?: boolean; + name?: string; + ranked_legal?: boolean; + total_cards?: number | null; + }; + Relationships: []; + }; + mlb_player: { + Row: { + first_name: string | null; + id: number; + key_bbref: string | null; + key_fangraphs: number | null; + key_mlbam: number | null; + key_retro: string | null; + last_name: string | null; + offense_col: number | null; + }; + Insert: { + first_name?: string | null; + id?: number; + key_bbref?: string | null; + key_fangraphs?: number | null; + key_mlbam?: number | null; + key_retro?: string | null; + last_name?: string | null; + offense_col?: number | null; + }; + Update: { + first_name?: string | null; + id?: number; + key_bbref?: string | null; + key_fangraphs?: number | null; + key_mlbam?: number | null; + key_retro?: string | null; + last_name?: string | null; + offense_col?: number | null; + }; + Relationships: []; + }; + players: { + Row: { + bbref_id: string | null; + cardset_id: number; + cost: number; + created_at: string; + description: string; + fangr_id: string | null; + franchise: Database["public"]["Enums"]["franchise"] | null; + headshot: string | null; + id: number; + image: string; + image2: string | null; + mlbclub: Database["public"]["Enums"]["franchise"] | null; + mlbplayer_id: number | null; + name: string; + positions: string[] | null; + quantity: number; + rarity_id: number; + set_num: number | null; + strat_code: string | null; + vanity_card: string | null; + }; + Insert: { + bbref_id?: string | null; + cardset_id: number; + cost: number; + created_at?: string; + description: string; + fangr_id?: string | null; + franchise?: Database["public"]["Enums"]["franchise"] | null; + headshot?: string | null; + id?: number; + image: string; + image2?: string | null; + mlbclub?: Database["public"]["Enums"]["franchise"] | null; + mlbplayer_id?: number | null; + name: string; + positions?: string[] | null; + quantity?: number; + rarity_id: number; + set_num?: number | null; + strat_code?: string | null; + vanity_card?: string | null; + }; + Update: { + bbref_id?: string | null; + cardset_id?: number; + cost?: number; + created_at?: string; + description?: string; + fangr_id?: string | null; + franchise?: Database["public"]["Enums"]["franchise"] | null; + headshot?: string | null; + id?: number; + image?: string; + image2?: string | null; + mlbclub?: Database["public"]["Enums"]["franchise"] | null; + mlbplayer_id?: number | null; + name?: string; + positions?: string[] | null; + quantity?: number; + rarity_id?: number; + set_num?: number | null; + strat_code?: string | null; + vanity_card?: string | null; + }; + Relationships: [ + { + foreignKeyName: "players_cardset_id_fkey"; + columns: ["cardset_id"]; + isOneToOne: false; + referencedRelation: "cardsets"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "players_mlbplayer_id_fkey"; + columns: ["mlbplayer_id"]; + isOneToOne: false; + referencedRelation: "mlb_player"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "players_rarity_id_fkey"; + columns: ["rarity_id"]; + isOneToOne: false; + referencedRelation: "rarity"; + referencedColumns: ["id"]; + }, + ]; + }; + profiles: { + Row: { + avatar_url: string | null; + created_at: string | null; + discord_id: string | null; + discord_username: string | null; + email: string | null; + id: string; + }; + Insert: { + avatar_url?: string | null; + created_at?: string | null; + discord_id?: string | null; + discord_username?: string | null; + email?: string | null; + id: string; + }; + Update: { + avatar_url?: string | null; + created_at?: string | null; + discord_id?: string | null; + discord_username?: string | null; + email?: string | null; + id?: string; + }; + Relationships: []; + }; + rarity: { + Row: { + color: string; + created_at: string; + id: number; + name: string; + value: number; + }; + Insert: { + color: string; + created_at?: string; + id?: number; + name: string; + value: number; + }; + Update: { + color?: string; + created_at?: string; + id?: number; + name?: string; + value?: number; + }; + Relationships: []; + }; + teams: { + Row: { + abbrev: string | null; + career: string | null; + collection_value: string | null; + color: string | null; + event_id: string | null; + gmid: number | null; + gmname: string | null; + gsheet: string | null; + has_guide: string | null; + id: number; + is_ai: number | null; + lname: string | null; + logo: string | null; + ranking: number | null; + season: number | null; + sname: string | null; + team_value: string | null; + wallet: number | null; + }; + Insert: { + abbrev?: string | null; + career?: string | null; + collection_value?: string | null; + color?: string | null; + event_id?: string | null; + gmid?: number | null; + gmname?: string | null; + gsheet?: string | null; + has_guide?: string | null; + id: number; + is_ai?: number | null; + lname?: string | null; + logo?: string | null; + ranking?: number | null; + season?: number | null; + sname?: string | null; + team_value?: string | null; + wallet?: number | null; + }; + Update: { + abbrev?: string | null; + career?: string | null; + collection_value?: string | null; + color?: string | null; + event_id?: string | null; + gmid?: number | null; + gmname?: string | null; + gsheet?: string | null; + has_guide?: string | null; + id?: number; + is_ai?: number | null; + lname?: string | null; + logo?: string | null; + ranking?: number | null; + season?: number | null; + sname?: string | null; + team_value?: string | null; + wallet?: number | null; + }; + Relationships: []; + }; + }; + Views: { + random_player: { + Row: { + bbref_id: string | null; + cardset_id: number | null; + cost: number | null; + created_at: string | null; + description: string | null; + fangr_id: string | null; + franchise: Database["public"]["Enums"]["franchise"] | null; + headshot: string | null; + id: number | null; + image: string | null; + image2: string | null; + mlbclub: Database["public"]["Enums"]["franchise"] | null; + mlbplayer_id: number | null; + name: string | null; + positions: string[] | null; + quantity: number | null; + rarity_id: number | null; + set_num: number | null; + strat_code: string | null; + vanity_card: string | null; + }; + Insert: { + bbref_id?: string | null; + cardset_id?: number | null; + cost?: number | null; + created_at?: string | null; + description?: string | null; + fangr_id?: string | null; + franchise?: Database["public"]["Enums"]["franchise"] | null; + headshot?: string | null; + id?: number | null; + image?: string | null; + image2?: string | null; + mlbclub?: Database["public"]["Enums"]["franchise"] | null; + mlbplayer_id?: number | null; + name?: string | null; + positions?: string[] | null; + quantity?: number | null; + rarity_id?: number | null; + set_num?: number | null; + strat_code?: string | null; + vanity_card?: string | null; + }; + Update: { + bbref_id?: string | null; + cardset_id?: number | null; + cost?: number | null; + created_at?: string | null; + description?: string | null; + fangr_id?: string | null; + franchise?: Database["public"]["Enums"]["franchise"] | null; + headshot?: string | null; + id?: number | null; + image?: string | null; + image2?: string | null; + mlbclub?: Database["public"]["Enums"]["franchise"] | null; + mlbplayer_id?: number | null; + name?: string | null; + positions?: string[] | null; + quantity?: number | null; + rarity_id?: number | null; + set_num?: number | null; + strat_code?: string | null; + vanity_card?: string | null; + }; + Relationships: [ + { + foreignKeyName: "players_cardset_id_fkey"; + columns: ["cardset_id"]; + isOneToOne: false; + referencedRelation: "cardsets"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "players_mlbplayer_id_fkey"; + columns: ["mlbplayer_id"]; + isOneToOne: false; + referencedRelation: "mlb_player"; + referencedColumns: ["id"]; + }, + { + foreignKeyName: "players_rarity_id_fkey"; + columns: ["rarity_id"]; + isOneToOne: false; + referencedRelation: "rarity"; + referencedColumns: ["id"]; + }, + ]; + }; + }; + Functions: { + [_ in never]: never; + }; + Enums: { + franchise: + | "Arizona Diamondbacks" + | "Atlanta Braves" + | "Baltimore Orioles" + | "Boston Red Sox" + | "Chicago Cubs" + | "Chicago White Sox" + | "Cincinnati Reds" + | "Cleveland Guardians" + | "Colorado Rockies" + | "Detroit Tigers" + | "Houston Astros" + | "Kansas City Royals" + | "Los Angeles Angels" + | "Los Angeles Dodgers" + | "Miami Marlins" + | "Milwaukee Brewers" + | "Minnesota Twins" + | "New York Mets" + | "New York Yankees" + | "Oakland Athletics" + | "Philadelphia Phillies" + | "Pittsburgh Pirates" + | "San Diego Padres" + | "San Francisco Giants" + | "Seattle Mariners" + | "St Louis Cardinals" + | "Tampa Bay Rays" + | "Texas Rangers" + | "Toronto Blue Jays" + | "Washington Nationals" + | "Anaheim Angels" + | "Brilliant Stars" + | "Cleveland Indians" + | "Custom Ballplayers" + | "Junior All Stars" + | "Mario Super Sluggers" + | "Montreal Expos" + | "Tampa Bay Devil Rays"; + }; + CompositeTypes: { + [_ in never]: never; + }; + }; +}; + +type DefaultSchema = Database[Extract]; + +export type Tables< + DefaultSchemaTableNameOrOptions extends + | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) + | { schema: keyof Database }, + TableName extends DefaultSchemaTableNameOrOptions extends { + schema: keyof Database; + } + ? keyof (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & + Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) + : never = never, +> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } + ? (Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & + Database[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Row: infer R; + } + ? R + : never + : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & + DefaultSchema["Views"]) + ? (DefaultSchema["Tables"] & + DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { + Row: infer R; + } + ? R + : never + : never; + +export type TablesInsert< + DefaultSchemaTableNameOrOptions extends + | keyof DefaultSchema["Tables"] + | { schema: keyof Database }, + TableName extends DefaultSchemaTableNameOrOptions extends { + schema: keyof Database; + } + ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] + : never = never, +> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } + ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Insert: infer I; + } + ? I + : never + : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Insert: infer I; + } + ? I + : never + : never; + +export type TablesUpdate< + DefaultSchemaTableNameOrOptions extends + | keyof DefaultSchema["Tables"] + | { schema: keyof Database }, + TableName extends DefaultSchemaTableNameOrOptions extends { + schema: keyof Database; + } + ? keyof Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] + : never = never, +> = DefaultSchemaTableNameOrOptions extends { schema: keyof Database } + ? Database[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Update: infer U; + } + ? U + : never + : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Update: infer U; + } + ? U + : never + : never; + +export type Enums< + DefaultSchemaEnumNameOrOptions extends + | keyof DefaultSchema["Enums"] + | { schema: keyof Database }, + EnumName extends DefaultSchemaEnumNameOrOptions extends { + schema: keyof Database; + } + ? keyof Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] + : never = never, +> = DefaultSchemaEnumNameOrOptions extends { schema: keyof Database } + ? Database[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] + : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] + ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] + : never; + +export type CompositeTypes< + PublicCompositeTypeNameOrOptions extends + | keyof DefaultSchema["CompositeTypes"] + | { schema: keyof Database }, + CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { + schema: keyof Database; + } + ? keyof Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] + : never = never, +> = PublicCompositeTypeNameOrOptions extends { schema: keyof Database } + ? Database[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] + : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] + ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] + : never; + +export const Constants = { + public: { + Enums: { + franchise: [ + "Arizona Diamondbacks", + "Atlanta Braves", + "Baltimore Orioles", + "Boston Red Sox", + "Chicago Cubs", + "Chicago White Sox", + "Cincinnati Reds", + "Cleveland Guardians", + "Colorado Rockies", + "Detroit Tigers", + "Houston Astros", + "Kansas City Royals", + "Los Angeles Angels", + "Los Angeles Dodgers", + "Miami Marlins", + "Milwaukee Brewers", + "Minnesota Twins", + "New York Mets", + "New York Yankees", + "Oakland Athletics", + "Philadelphia Phillies", + "Pittsburgh Pirates", + "San Diego Padres", + "San Francisco Giants", + "Seattle Mariners", + "St Louis Cardinals", + "Tampa Bay Rays", + "Texas Rangers", + "Toronto Blue Jays", + "Washington Nationals", + "Anaheim Angels", + "Brilliant Stars", + "Cleveland Indians", + "Custom Ballplayers", + "Junior All Stars", + "Mario Super Sluggers", + "Montreal Expos", + "Tampa Bay Devil Rays", + ], + }, + }, +} as const;