add medreport schema
This commit is contained in:
@@ -44,7 +44,6 @@
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"react-hook-form": "^7.56.3",
|
||||
"react-i18next": "^15.5.1",
|
||||
"sonner": "^2.0.3"
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
|
||||
@@ -19,7 +19,8 @@ import { Trans } from '@kit/ui/trans';
|
||||
import { useUpdateAccountData } from '../../hooks/use-update-account';
|
||||
import { AccountDetailsSchema } from '../../schema/account-details.schema';
|
||||
|
||||
type UpdateUserDataParams = Database['public']['Tables']['accounts']['Update'];
|
||||
type UpdateUserDataParams =
|
||||
Database['medreport']['Tables']['accounts']['Update'];
|
||||
|
||||
export function UpdateAccountDetailsForm({
|
||||
displayName,
|
||||
|
||||
@@ -72,6 +72,7 @@ function UploadProfileAvatarForm(props: {
|
||||
uploadUserProfilePhoto(client, file, props.userId)
|
||||
.then((pictureUrl) => {
|
||||
return client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.update({
|
||||
picture_url: pictureUrl,
|
||||
@@ -90,6 +91,7 @@ function UploadProfileAvatarForm(props: {
|
||||
removeExistingStorageFile()
|
||||
.then(() => {
|
||||
return client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.update({
|
||||
picture_url: null,
|
||||
|
||||
@@ -17,7 +17,9 @@ interface UserWorkspace {
|
||||
id: string | null;
|
||||
name: string | null;
|
||||
picture_url: string | null;
|
||||
subscription_status: Tables<'subscriptions'>['status'] | null;
|
||||
subscription_status:
|
||||
| Tables<{ schema: 'medreport' }, 'subscriptions'>['status']
|
||||
| null;
|
||||
};
|
||||
|
||||
user: User;
|
||||
|
||||
@@ -21,6 +21,7 @@ export function usePersonalAccountData(
|
||||
}
|
||||
|
||||
const response = await client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.select()
|
||||
.eq('primary_owner_user_id', userId)
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useMutation } from '@tanstack/react-query';
|
||||
import { Database } from '@kit/supabase/database';
|
||||
import { useSupabase } from '@kit/supabase/hooks/use-supabase';
|
||||
|
||||
type UpdateData = Database['public']['Tables']['accounts']['Update'];
|
||||
type UpdateData = Database['medreport']['Tables']['accounts']['Update'];
|
||||
|
||||
export function useUpdateAccountData(accountId: string) {
|
||||
const client = useSupabase();
|
||||
@@ -11,9 +11,13 @@ export function useUpdateAccountData(accountId: string) {
|
||||
const mutationKey = ['account:data', accountId];
|
||||
|
||||
const mutationFn = async (data: UpdateData) => {
|
||||
const response = await client.from('accounts').update(data).match({
|
||||
id: accountId,
|
||||
});
|
||||
const response = await client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.update(data)
|
||||
.match({
|
||||
id: accountId,
|
||||
});
|
||||
|
||||
if (response.error) {
|
||||
throw response.error;
|
||||
|
||||
@@ -17,6 +17,7 @@ class AccountsApi {
|
||||
*/
|
||||
async getAccount(id: string) {
|
||||
const { data, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.select('*')
|
||||
.eq('id', id)
|
||||
@@ -35,6 +36,7 @@ class AccountsApi {
|
||||
*/
|
||||
async getAccountWorkspace() {
|
||||
const { data, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('user_account_workspace')
|
||||
.select(`*`)
|
||||
.single();
|
||||
@@ -63,6 +65,7 @@ class AccountsApi {
|
||||
const { user } = data;
|
||||
|
||||
const { data: accounts, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('accounts_memberships')
|
||||
.select(
|
||||
`
|
||||
@@ -91,6 +94,7 @@ class AccountsApi {
|
||||
|
||||
async loadTempUserAccounts() {
|
||||
const { data: accounts, error } = await this.client
|
||||
.schema('medreport')
|
||||
.from('user_accounts')
|
||||
.select(`name, slug`);
|
||||
|
||||
@@ -131,6 +135,7 @@ class AccountsApi {
|
||||
*/
|
||||
async getOrder(accountId: string) {
|
||||
const response = await this.client
|
||||
.schema('medreport')
|
||||
.from('orders')
|
||||
.select('*, items: order_items !inner (*)')
|
||||
.eq('account_id', accountId)
|
||||
@@ -151,6 +156,7 @@ class AccountsApi {
|
||||
*/
|
||||
async getCustomerId(accountId: string) {
|
||||
const response = await this.client
|
||||
.schema('medreport')
|
||||
.from('billing_customers')
|
||||
.select('customer_id')
|
||||
.eq('account_id', accountId)
|
||||
|
||||
Reference in New Issue
Block a user