fix: remove supabase-js related @ts-ignores

This commit is contained in:
Alaister Young committed 2022-09-30 22:32:06 +10:00
1 parent 5b3be53f55
commit e20b7dc3cf
7 files changed
+129 -50

No files matched your search

@@ -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<boolean>(false)
const handleFormSubmit = async (values: any) => {
// @ts-ignore
const { error } = await supabase.from<PartnerContact>('partner_contacts').insert([
const { error } = await supabase.from('partner_contacts').insert([
{
type: values.type,
first: values.first,
+112
View File
@@ -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'
}
}
}
+4 -1
View File
@@ -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<Database>(SUPABASE_URL, SUPABASE_ANON_KEY)
export type SupabaseClient = typeof supabase
export default supabase
+2 -4
View File
@@ -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<Partner>('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<Partner>('partners')
.from('partners')
.select('*')
.eq('slug', params!.slug as string)
.single()
+1 -2
View File
@@ -10,8 +10,7 @@ import TileGrid from '../../../components/Partners/TileGrid'
export async function getStaticProps() {
const { data: partners } = await supabase
// @ts-ignore
.from<Partner>('partners')
.from('partners')
.select('*')
.eq('approved', true)
.eq('type', 'expert')
+6 -10
View File
@@ -13,8 +13,7 @@ import TileGrid from '../../../components/Partners/TileGrid'
export async function getStaticProps() {
const { data: partners } = await supabase
// @ts-ignore
.from<Partner>('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<Partner>('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
+2 -29
View File
@@ -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']