-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cce7e6d
commit b10ff15
Showing
3 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { supabase } from "./index.ts"; | ||
|
||
export async function sendPaymentInfo(user_id: string, level: string): Promise<any> { | ||
const { data, error } = await supabase | ||
.from('payments') | ||
.insert([ | ||
{ user_id: user_id, level: level } | ||
]); | ||
|
||
if (error) { | ||
console.error('Error sending payment info:', error); | ||
} else { | ||
console.log('Payment info sent successfully:', data); | ||
return data | ||
} | ||
} | ||
|
||
export async function getPaymentsInfoByUsername(username: string): Promise<any> { | ||
// Получаем user_id по username из таблицы users | ||
const { data: userData, error: userError } = await supabase | ||
.from('users') | ||
.select('user_id') | ||
.eq('username', username) | ||
.single(); | ||
|
||
if (userError) { | ||
console.error('Error fetching user ID:', userError); | ||
return null; | ||
} | ||
|
||
const user_id = userData.user_id; | ||
|
||
// Получаем все строчки с данным user_id из таблицы payments | ||
const { data: paymentsData, error: paymentsError } = await supabase | ||
.from('payments') | ||
.select('*') | ||
.eq('user_id', user_id); | ||
|
||
if (paymentsError) { | ||
console.error('Error fetching payments info:', paymentsError); | ||
return null; | ||
} | ||
|
||
return paymentsData; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters