diff --git a/.gitignore b/.gitignore index 86db642..0f5a99c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ api_docs.md telemetry-id public/qrafty.otf public/JetBrainsMono-Regular.ttf -export-resources.yml \ No newline at end of file +export-resources.yml +opencode.json \ No newline at end of file diff --git a/opencode.json b/opencode.json new file mode 100644 index 0000000..32e975a --- /dev/null +++ b/opencode.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "supabase": { + "type": "remote", + "url": "https://mcp.supabase.com/mcp?project_ref=bmywdrwjdqmrkafhiuwn&features=docs%2Cdatabase%2Cdebugging%2Cdevelopment%2Cfunctions%2Cbranching", + "enabled": true + } + } +} \ No newline at end of file diff --git a/src/components/Hero.tsx b/src/components/Hero.tsx index d5f9c0e..f7e5d80 100644 --- a/src/components/Hero.tsx +++ b/src/components/Hero.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from "react" import { Link } from "react-router-dom" -import { IconArrowRight, IconExternalLink, IconFolderOpen, IconMusic } from "@tabler/icons-react" +import { IconArrowRight, IconExternalLink, IconFolderOpen, IconMusic, IconPackage } from "@tabler/icons-react" import { useIsMobile } from "@/hooks/use-mobile" import * as motion from "motion/react-client" @@ -143,13 +143,14 @@ const Hero = () => { - - - Open Music Packs + + + Creator Packs - - Browse All Resources + + + Music Packs diff --git a/src/hooks/useCreatorPacks.ts b/src/hooks/useCreatorPacks.ts index 4ec2caf..697fb0c 100644 --- a/src/hooks/useCreatorPacks.ts +++ b/src/hooks/useCreatorPacks.ts @@ -116,10 +116,21 @@ export const useCreatorPacks = () => { .eq('status', 'approved') .order('created_at', { ascending: false }); - if (error) throw error; + if (error) { + console.error('Supabase error details:', { + message: error.message, + details: error.details, + hint: error.hint, + code: error.code + }); + throw error; + } setPacks((data as CreatorPackWithProfiles[])?.map(mapToCreatorPack) || []); } catch (error: unknown) { - console.error('Error fetching creator packs:', getErrorMessage(error)); + console.error('Error fetching creator packs:', error); + if (error && typeof error === 'object' && 'message' in error) { + console.error('Error details:', (error as { message: unknown }).message); + } } finally { setIsLoading(false); } diff --git a/src/integrations/supabase/client.ts b/src/integrations/supabase/client.ts index e8996c8..d709120 100644 --- a/src/integrations/supabase/client.ts +++ b/src/integrations/supabase/client.ts @@ -3,7 +3,7 @@ import { createClient } from '@supabase/supabase-js'; import type { Database } from './types'; const SUPABASE_URL = import.meta.env.VITE_SUPABASE_URL as string; -const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_ANON_KEY as string; +const SUPABASE_PUBLISHABLE_KEY = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY as string; // Import the supabase client like this: // import { supabase } from "@/integrations/supabase/client"; diff --git a/supabase/migrations/20260420000000_creator_packs_rls_policy.sql b/supabase/migrations/20260420000000_creator_packs_rls_policy.sql new file mode 100644 index 0000000..7bcf15c --- /dev/null +++ b/supabase/migrations/20260420000000_creator_packs_rls_policy.sql @@ -0,0 +1,20 @@ +-- Drop existing policies if they exist to avoid conflicts +DROP POLICY IF EXISTS "Creator packs are publicly readable if approved" ON creator_packs; +DROP POLICY IF EXISTS "Users can manage their own creator packs" ON creator_packs; + +-- Allow anyone to read approved creator packs +CREATE POLICY "Creator packs are publicly readable if approved" ON creator_packs +FOR SELECT +USING (status = 'approved'); + +-- Allow users to insert, update, and delete their own creator packs +CREATE POLICY "Users can manage their own creator packs" ON creator_packs +FOR ALL +USING (auth.uid() = user_id) +WITH CHECK (auth.uid() = user_id); + +-- Allow admins to review creator packs +CREATE POLICY "Admins can review creator packs" ON creator_packs +FOR UPDATE +USING (auth.jwt() ->> 'email' = 'yamura@duck.com') +WITH CHECK (auth.jwt() ->> 'email' = 'yamura@duck.com'); \ No newline at end of file