Skip to content

Commit

Permalink
chore: update orm db queries
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Jul 19, 2024
1 parent f621d0c commit d88e8e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/indexer/src/lib/supabase-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { appenv } from '~/config'
// Initialize Supabase client
const supabase = createClient<Database>(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,
Expand Down
6 changes: 3 additions & 3 deletions apps/webapp/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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('*')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }> = ({
Expand All @@ -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
Expand All @@ -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)
})
Expand Down

0 comments on commit d88e8e1

Please sign in to comment.