add medreport schema
This commit is contained in:
@@ -17,6 +17,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getTeamAccount(slug: string) {
|
||||
const { data, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.select('*')
|
||||
.eq('slug', slug)
|
||||
@@ -36,6 +37,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getTeamAccountById(accountId: string) {
|
||||
const { data, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.select('*')
|
||||
.eq('id', accountId)
|
||||
@@ -55,6 +57,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getSubscription(accountId: string) {
|
||||
const { data, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('subscriptions')
|
||||
.select('*, items: subscription_items !inner (*)')
|
||||
.eq('account_id', accountId)
|
||||
@@ -73,6 +76,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getOrder(accountId: string) {
|
||||
const response = await this.client
|
||||
.schema('medreport')
|
||||
.from('orders')
|
||||
.select('*, items: order_items !inner (*)')
|
||||
.eq('account_id', accountId)
|
||||
@@ -91,13 +95,17 @@ export class TeamAccountsApi {
|
||||
* @param slug
|
||||
*/
|
||||
async getAccountWorkspace(slug: string, userId: string) {
|
||||
const accountPromise = this.client.rpc('team_account_workspace', {
|
||||
account_slug: slug,
|
||||
});
|
||||
const accountPromise = this.client
|
||||
.schema('medreport')
|
||||
.rpc('team_account_workspace', {
|
||||
account_slug: slug,
|
||||
});
|
||||
|
||||
const accountsPromise = this.client
|
||||
.schema('medreport')
|
||||
.from('accounts_memberships')
|
||||
.select(`
|
||||
.select(
|
||||
`
|
||||
account_id,
|
||||
user_accounts (
|
||||
id,
|
||||
@@ -106,7 +114,8 @@ export class TeamAccountsApi {
|
||||
slug,
|
||||
picture_url
|
||||
)
|
||||
`)
|
||||
`,
|
||||
)
|
||||
.eq('user_id', userId)
|
||||
.eq('account_role', 'owner');
|
||||
|
||||
@@ -114,7 +123,7 @@ export class TeamAccountsApi {
|
||||
accountPromise,
|
||||
accountsPromise,
|
||||
]);
|
||||
|
||||
|
||||
if (accountResult.error) {
|
||||
return {
|
||||
error: accountResult.error,
|
||||
@@ -154,7 +163,7 @@ export class TeamAccountsApi {
|
||||
async hasPermission(params: {
|
||||
accountId: string;
|
||||
userId: string;
|
||||
permission: Database['public']['Enums']['app_permissions'];
|
||||
permission: Database['medreport']['Enums']['app_permissions'];
|
||||
}) {
|
||||
const { data, error } = await this.client.rpc('has_permission', {
|
||||
account_id: params.accountId,
|
||||
@@ -176,6 +185,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getMembersCount(accountId: string) {
|
||||
const { count, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts_memberships')
|
||||
.select('*', {
|
||||
head: true,
|
||||
@@ -197,6 +207,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getCustomerId(accountId: string) {
|
||||
const { data, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('billing_customers')
|
||||
.select('customer_id')
|
||||
.eq('account_id', accountId)
|
||||
@@ -217,6 +228,7 @@ export class TeamAccountsApi {
|
||||
*/
|
||||
async getInvitation(adminClient: SupabaseClient<Database>, token: string) {
|
||||
const { data: invitation, error } = await adminClient
|
||||
.schema('medreport')
|
||||
.from('invitations')
|
||||
.select<
|
||||
string,
|
||||
|
||||
Reference in New Issue
Block a user