From d88e8e1cd80a8ed91f24c4e7fc7e74be6f593dff Mon Sep 17 00:00:00 2001 From: Gabo Esquivel Date: Fri, 19 Jul 2024 14:43:24 -0600 Subject: [PATCH] chore: update orm db queries --- apps/indexer/src/lib/supabase-client.ts | 4 ++-- apps/webapp/actions.ts | 6 +++--- .../components/routes/project/register-address-form.tsx | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/indexer/src/lib/supabase-client.ts b/apps/indexer/src/lib/supabase-client.ts index 2ed6ad64..a409be95 100644 --- a/apps/indexer/src/lib/supabase-client.ts +++ b/apps/indexer/src/lib/supabase-client.ts @@ -5,8 +5,8 @@ import { appenv } from '~/config' // Initialize Supabase client const supabase = createClient(appenv.supabase.url, appenv.supabase.anonKey) -export async function upsertAuctionDetail(data: TablesInsert<'auction_details'>) { - const { data: result, error } = await supabase.from('auction_details').upsert( +export async function upsertAuctionDetail(data: TablesInsert<'auctions'>) { + const { data: result, error } = await supabase.from('auctions').upsert( [ { ...data, diff --git a/apps/webapp/actions.ts b/apps/webapp/actions.ts index 91e56776..0aabf54b 100644 --- a/apps/webapp/actions.ts +++ b/apps/webapp/actions.ts @@ -7,7 +7,7 @@ import axios from 'axios' import { Resend } from 'resend' import { z } from 'zod' import { createSupabaseServerClient } from '@/services/supabase' -import { preSaleInsertSchema } from '@repo/supabase' +import { presaleInsertSchema } from '@repo/supabase' // get session object by id export async function getSesssion(formData: FormData) { @@ -36,14 +36,14 @@ export async function registerAddress(formData: FormData) { try { const o = fromEntries(formData) console.log('register address input', o) - const data = preSaleInsertSchema.parse({ + const data = presaleInsertSchema.parse({ ...o, project_id: parseInt(o.project_id), created_at: new Date().toDateString() }) const supabase = await createSupabaseServerClient() const { data: createdEntry, error } = await supabase - .from('pre_sale') + .from('presale') .insert([data]) .select('*') diff --git a/apps/webapp/components/routes/project/register-address-form.tsx b/apps/webapp/components/routes/project/register-address-form.tsx index db65d940..58c40278 100644 --- a/apps/webapp/components/routes/project/register-address-form.tsx +++ b/apps/webapp/components/routes/project/register-address-form.tsx @@ -9,7 +9,7 @@ import { useQuery } from '@tanstack/react-query' import { useSession } from '@/hooks/use-session' import { Button, ButtonProps, buttonVariants } from '@/components/ui/button' import { cn } from '@/lib/utils' -import { preSaleInsertSchema } from '@repo/supabase' +import { presaleInsertSchema } from '@repo/supabase' import { useSupabaseClient } from '@/services/supabase' export const RegisterAddressForm: FunctionComponent<{ projectId: number }> = ({ @@ -25,7 +25,7 @@ export const RegisterAddressForm: FunctionComponent<{ projectId: number }> = ({ enabled: Boolean(session), // only fetch if logged in queryFn: async () => { const { data, error } = await supabase - .from('pre_sale') + .from('presale') .select() .eq('project_id', projectId) .eq('account', session!.account!) // we know for sure @@ -43,7 +43,7 @@ export const RegisterAddressForm: FunctionComponent<{ projectId: number }> = ({ project_id: parseInt(o.project_id, 10) } // validate input - preSaleInsertSchema.safeParse(data) + presaleInsertSchema.safeParse(data) return registerAddress(formData) })