content.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
  2. import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
  3. const ContentFile = ({ projectKeys }: StepContentProps) => {
  4. const files = [
  5. {
  6. name: '.env',
  7. language: 'bash',
  8. code: `
  9. VITE_BRIVEN_URL=${projectKeys.apiUrl ?? 'your-project-url'}
  10. VITE_BRIVEN_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
  11. `,
  12. },
  13. {
  14. name: 'src/utils/briven.ts',
  15. language: 'ts',
  16. code: `
  17. import { createClient } from "@supabase/supabase-js";
  18. export const briven = createClient(
  19. import.meta.env.VITE_BRIVEN_URL,
  20. import.meta.env.VITE_BRIVEN_KEY
  21. );
  22. `,
  23. },
  24. {
  25. name: 'src/routes/index.tsx',
  26. language: 'tsx',
  27. code: `
  28. import { createFileRoute } from '@tanstack/react-router'
  29. import { briven } from '../utils/briven'
  30. export const Route = createFileRoute('/')({
  31. loader: async () => {
  32. const { data: todos } = await briven.from('todos').select()
  33. return { todos }
  34. },
  35. component: Home,
  36. })
  37. function Home() {
  38. const { todos } = Route.useLoaderData()
  39. return (
  40. <ul>
  41. {todos?.map((todo) => (
  42. <li key={todo.id}>{todo.name}</li>
  43. ))}
  44. </ul>
  45. )
  46. }
  47. `,
  48. },
  49. ]
  50. return <MultipleCodeBlock files={files} />
  51. }
  52. export default ContentFile