diff --git a/apps/www/components/Partners/BecomeAPartners.tsx b/apps/www/components/Partners/BecomeAPartners.tsx index 7334256bc5b..eaa1f60764c 100644 --- a/apps/www/components/Partners/BecomeAPartners.tsx +++ b/apps/www/components/Partners/BecomeAPartners.tsx @@ -1,8 +1,7 @@ -import { SupabaseClient } from '@supabase/supabase-js' import { Button, Form, Input, InputNumber, Select } from '@supabase/ui' import { useState } from 'react' import countries from '~/data/Countries.json' -import { PartnerContact } from '~/types/partners' +import { SupabaseClient } from '~/lib/supabase' const INITIAL_VALUES = { type: 'expert', @@ -41,8 +40,7 @@ export default function BecomeAPartner({ supabase }: { supabase: SupabaseClient const [formSubmitted, setFormSubmitted] = useState(false) const handleFormSubmit = async (values: any) => { - // @ts-ignore - const { error } = await supabase.from('partner_contacts').insert([ + const { error } = await supabase.from('partner_contacts').insert([ { type: values.type, first: values.first, diff --git a/apps/www/lib/database.types.ts b/apps/www/lib/database.types.ts new file mode 100644 index 00000000000..2e536759c2f --- /dev/null +++ b/apps/www/lib/database.types.ts @@ -0,0 +1,112 @@ +export type Json = string | number | boolean | null | { [key: string]: Json } | Json[] + +export interface Database { + public: { + Tables: { + partners: { + Row: { + id: number + slug: string + type: Database['public']['Enums']['partner_type'] + category: string + developer: string + title: string + description: string + logo: string + images: string[] + video: string + overview: string + website: string + docs: string + approved: boolean + } + Insert: { + id?: number + slug?: string + type?: Database['public']['Enums']['partner_type'] + category?: string + developer?: string + title?: string + description?: string + logo?: string + images?: string[] + video?: string + overview?: string + website?: string + docs?: string + approved?: boolean + } + Update: { + id?: number + slug?: string + type?: Database['public']['Enums']['partner_type'] + category?: string + developer?: string + title?: string + description?: string + logo?: string + images?: string[] + video?: string + overview?: string + website?: string + docs?: string + approved?: boolean + } + } + partner_contacts: { + Row: { + id: number + type: Database['public']['Enums']['partner_type'] + company: string + country: string + details?: string + email: string + first: string + last: string + phone?: string + size?: number + title?: string + website: string + } + Insert: { + id?: number + type?: Database['public']['Enums']['partner_type'] + company?: string + country?: string + details?: string + email?: string + first?: string + last?: string + phone?: string + size?: number + title?: string + website?: string + } + Update: { + id?: number + type?: Database['public']['Enums']['partner_type'] + company?: string + country?: string + details?: string + email?: string + first?: string + last?: string + phone?: string + size?: number + title?: string + website?: string + } + } + } + Views: {} + Functions: { + derive_label_sort_from_label: { + Args: { label: string } + Returns: string + } + } + Enums: { + partner_type: 'technology' | 'expert' + } + } +} diff --git a/apps/www/lib/supabase.ts b/apps/www/lib/supabase.ts index 304c3890488..e2572c7016c 100644 --- a/apps/www/lib/supabase.ts +++ b/apps/www/lib/supabase.ts @@ -1,9 +1,12 @@ import { createClient } from '@supabase/supabase-js' +import { Database } from './database.types' const SUPABASE_URL = 'https://obuldanrptloktxcffvn.supabase.co' const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzNzY1NjAxNSwiZXhwIjoxOTUzMjMyMDE1fQ.0sfp_Njf7l4g-nOCF5a1TQE11rPqtz8Y10uctIetkBA' -const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY) +const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY) + +export type SupabaseClient = typeof supabase export default supabase diff --git a/apps/www/pages/partners/[slug].tsx b/apps/www/pages/partners/[slug].tsx index d17ce9ee915..3cea05b2960 100644 --- a/apps/www/pages/partners/[slug].tsx +++ b/apps/www/pages/partners/[slug].tsx @@ -201,8 +201,7 @@ function Partner({ partner }: { partner: Partner }) { // This function gets called at build time export const getStaticPaths: GetStaticPaths = async () => { - // @ts-ignore - const { data: slugs } = await supabase.from('partners').select('slug') + const { data: slugs } = await supabase.from('partners').select('slug') const paths: { params: { slug: string } @@ -223,8 +222,7 @@ export const getStaticPaths: GetStaticPaths = async () => { // This also gets called at build time export const getStaticProps: GetStaticProps = async ({ params }) => { let { data: partner } = await supabase - // @ts-ignore - .from('partners') + .from('partners') .select('*') .eq('slug', params!.slug as string) .single() diff --git a/apps/www/pages/partners/experts/index.tsx b/apps/www/pages/partners/experts/index.tsx index 22076a1dcb9..7c3f1c15844 100644 --- a/apps/www/pages/partners/experts/index.tsx +++ b/apps/www/pages/partners/experts/index.tsx @@ -10,8 +10,7 @@ import TileGrid from '../../../components/Partners/TileGrid' export async function getStaticProps() { const { data: partners } = await supabase - // @ts-ignore - .from('partners') + .from('partners') .select('*') .eq('approved', true) .eq('type', 'expert') diff --git a/apps/www/pages/partners/integrations/index.tsx b/apps/www/pages/partners/integrations/index.tsx index 0a642471240..85c32ee35ca 100644 --- a/apps/www/pages/partners/integrations/index.tsx +++ b/apps/www/pages/partners/integrations/index.tsx @@ -13,8 +13,7 @@ import TileGrid from '../../../components/Partners/TileGrid' export async function getStaticProps() { const { data: partners } = await supabase - // @ts-ignore - .from('partners') + .from('partners') .select('*') .eq('approved', true) .eq('type', 'technology') @@ -58,20 +57,17 @@ function IntegrationPartnersPage(props: Props) { setIsSearching(true) let query = supabase - // @ts-ignore - .from('partners') + .from('partners') .select('*') .eq('approved', true) .order('category') .order('title') if (search.trim()) { - query = query - // @ts-ignore - .textSearch('tsv', `${search.trim()}`, { - type: 'websearch', - config: 'english', - }) + query = query.textSearch('tsv', `${search.trim()}`, { + type: 'websearch', + config: 'english', + }) } const { data: partners } = await query diff --git a/apps/www/types/partners.ts b/apps/www/types/partners.ts index 871735ac166..4dba09c82e2 100644 --- a/apps/www/types/partners.ts +++ b/apps/www/types/partners.ts @@ -1,30 +1,3 @@ -export interface Partner { - id: number - slug: string - type: 'technology' | 'expert' - category: string - developer: string - title: string - description: string - logo: string - images: string[] - video: string - overview: string - website: string - docs: string - approved: boolean -} +import { Database } from '../lib/database.types' -export interface PartnerContact { - type: 'technology' | 'expert' - company: string - country: string - details?: string - email: string - first: string - last: string - phone?: string - size?: number - title?: string - website: string -} +export type Partner = Database['public']['Tables']['partners']['Row']