feat: update API and database structure for membership confirmation and wallet integration

- Refactor API calls to use 'medreport' schema for membership confirmation and account updates
- Enhance success notification component to include wallet balance and expiration details
- Modify database types to reflect new 'medreport' schema and add product-related tables
- Update localization files to support new wallet messages
- Adjust SQL migration scripts for proper schema references and function definitions
This commit is contained in:
Danel Kungla
2025-07-09 10:01:12 +03:00
parent 4f36f9c037
commit 9371ff7710
6 changed files with 234 additions and 452 deletions

View File

@@ -25,12 +25,11 @@ class AuthApi {
throw new Error('User not authenticated'); throw new Error('User not authenticated');
} }
const { data, error } = await this.client.rpc( const { data, error } = await this.client
'has_unseen_membership_confirmation', .schema('medreport')
{ .rpc('has_unseen_membership_confirmation', {
p_user_id: user.id, p_user_id: user.id,
}, });
);
if (error) { if (error) {
throw error; throw error;
@@ -53,7 +52,9 @@ class AuthApi {
throw new Error('User not authenticated'); throw new Error('User not authenticated');
} }
const { error } = await this.client.rpc('update_account', { const { error } = await this.client
.schema('medreport')
.rpc('update_account', {
p_name: data.firstName, p_name: data.firstName,
p_last_name: data.lastName, p_last_name: data.lastName,
p_personal_code: data.personalCode, p_personal_code: data.personalCode,
@@ -86,7 +87,10 @@ class AuthApi {
throw new Error('User not authenticated'); throw new Error('User not authenticated');
} }
console.log('test', user, data); console.log('test', user, data);
const response = await this.client.from('account_params').insert({ const response = await this.client
.schema('medreport')
.from('account_params')
.insert({
account_id: user.id, account_id: user.id,
height: data.height, height: data.height,
weight: data.weight, weight: data.weight,

View File

@@ -11,12 +11,17 @@ export const SuccessNotification = ({
title, title,
titleKey, titleKey,
descriptionKey, descriptionKey,
walletProps,
buttonProps, buttonProps,
}: { }: {
showLogo?: boolean; showLogo?: boolean;
title?: string; title?: string;
titleKey?: string; titleKey?: string;
descriptionKey?: string; descriptionKey?: string;
walletProps?: {
amount: string;
expiredAt: string;
};
buttonProps?: { buttonProps?: {
buttonTitleKey: string; buttonTitleKey: string;
href: string; href: string;
@@ -38,6 +43,16 @@ export const SuccessNotification = ({
<Trans i18nKey={descriptionKey} /> <Trans i18nKey={descriptionKey} />
</p> </p>
</div> </div>
{walletProps && (
<div>
<Trans i18nKey="common.wallet.balance" />
<p></p>
<Trans
i18nKey="common.wallet.expiredAt"
values={{ expiredAt: '12.12.2025' }}
/>
</div>
)}
{buttonProps && ( {buttonProps && (
<Button className="mt-8 w-full"> <Button className="mt-8 w-full">
<Link href={buttonProps.href}> <Link href={buttonProps.href}>

View File

@@ -157,7 +157,7 @@ export type Database = {
[_ in never]: never [_ in never]: never
} }
} }
public: { medreport: {
Tables: { Tables: {
account_params: { account_params: {
Row: { Row: {
@@ -189,7 +189,6 @@ export type Database = {
created_at: string | null created_at: string | null
created_by: string | null created_by: string | null
email: string | null email: string | null
has_consent_anonymized_company_statistics: boolean | null
has_consent_personal_data: boolean | null has_consent_personal_data: boolean | null
id: string id: string
is_personal_account: boolean is_personal_account: boolean
@@ -209,7 +208,6 @@ export type Database = {
created_at?: string | null created_at?: string | null
created_by?: string | null created_by?: string | null
email?: string | null email?: string | null
has_consent_anonymized_company_statistics?: boolean | null
has_consent_personal_data?: boolean | null has_consent_personal_data?: boolean | null
id?: string id?: string
is_personal_account?: boolean is_personal_account?: boolean
@@ -229,7 +227,6 @@ export type Database = {
created_at?: string | null created_at?: string | null
created_by?: string | null created_by?: string | null
email?: string | null email?: string | null
has_consent_anonymized_company_statistics?: boolean | null
has_consent_personal_data?: boolean | null has_consent_personal_data?: boolean | null
id?: string id?: string
is_personal_account?: boolean is_personal_account?: boolean
@@ -438,7 +435,7 @@ export type Database = {
analysis_ids: number[] | null analysis_ids: number[] | null
created_at: string created_at: string
id: number id: number
status: Database["public"]["Enums"]["analysis_order_status"] status: Database["medreport"]["Enums"]["analysis_order_status"]
user_id: string user_id: string
} }
Insert: { Insert: {
@@ -446,7 +443,7 @@ export type Database = {
analysis_ids?: number[] | null analysis_ids?: number[] | null
created_at?: string created_at?: string
id?: number id?: number
status: Database["public"]["Enums"]["analysis_order_status"] status: Database["medreport"]["Enums"]["analysis_order_status"]
user_id: string user_id: string
} }
Update: { Update: {
@@ -454,7 +451,7 @@ export type Database = {
analysis_ids?: number[] | null analysis_ids?: number[] | null
created_at?: string created_at?: string
id?: number id?: number
status?: Database["public"]["Enums"]["analysis_order_status"] status?: Database["medreport"]["Enums"]["analysis_order_status"]
user_id?: string user_id?: string
} }
Relationships: [] Relationships: []
@@ -524,7 +521,7 @@ export type Database = {
created_at: string created_at: string
id: number id: number
order_number: string order_number: string
order_status: Database["public"]["Enums"]["analysis_order_status"] order_status: Database["medreport"]["Enums"]["analysis_order_status"]
updated_at: string | null updated_at: string | null
user_id: string user_id: string
} }
@@ -533,7 +530,7 @@ export type Database = {
created_at?: string created_at?: string
id?: number id?: number
order_number: string order_number: string
order_status: Database["public"]["Enums"]["analysis_order_status"] order_status: Database["medreport"]["Enums"]["analysis_order_status"]
updated_at?: string | null updated_at?: string | null
user_id: string user_id: string
} }
@@ -542,7 +539,7 @@ export type Database = {
created_at?: string created_at?: string
id?: number id?: number
order_number?: string order_number?: string
order_status?: Database["public"]["Enums"]["analysis_order_status"] order_status?: Database["medreport"]["Enums"]["analysis_order_status"]
updated_at?: string | null updated_at?: string | null
user_id?: string user_id?: string
} }
@@ -562,21 +559,21 @@ export type Database = {
customer_id: string customer_id: string
email: string | null email: string | null
id: number id: number
provider: Database["public"]["Enums"]["billing_provider"] provider: Database["medreport"]["Enums"]["billing_provider"]
} }
Insert: { Insert: {
account_id: string account_id: string
customer_id: string customer_id: string
email?: string | null email?: string | null
id?: number id?: number
provider: Database["public"]["Enums"]["billing_provider"] provider: Database["medreport"]["Enums"]["billing_provider"]
} }
Update: { Update: {
account_id?: string account_id?: string
customer_id?: string customer_id?: string
email?: string | null email?: string | null
id?: number id?: number
provider?: Database["public"]["Enums"]["billing_provider"] provider?: Database["medreport"]["Enums"]["billing_provider"]
} }
Relationships: [ Relationships: [
{ {
@@ -665,19 +662,19 @@ export type Database = {
} }
config: { config: {
Row: { Row: {
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
enable_account_billing: boolean enable_account_billing: boolean
enable_team_account_billing: boolean enable_team_account_billing: boolean
enable_team_accounts: boolean enable_team_accounts: boolean
} }
Insert: { Insert: {
billing_provider?: Database["public"]["Enums"]["billing_provider"] billing_provider?: Database["medreport"]["Enums"]["billing_provider"]
enable_account_billing?: boolean enable_account_billing?: boolean
enable_team_account_billing?: boolean enable_team_account_billing?: boolean
enable_team_accounts?: boolean enable_team_accounts?: boolean
} }
Update: { Update: {
billing_provider?: Database["public"]["Enums"]["billing_provider"] billing_provider?: Database["medreport"]["Enums"]["billing_provider"]
enable_account_billing?: boolean enable_account_billing?: boolean
enable_team_account_billing?: boolean enable_team_account_billing?: boolean
enable_team_accounts?: boolean enable_team_accounts?: boolean
@@ -845,7 +842,6 @@ export type Database = {
id: number id: number
invite_token: string invite_token: string
invited_by: string invited_by: string
personal_code: string | null
role: string role: string
updated_at: string updated_at: string
} }
@@ -857,7 +853,6 @@ export type Database = {
id?: number id?: number
invite_token: string invite_token: string
invited_by: string invited_by: string
personal_code?: string | null
role: string role: string
updated_at?: string updated_at?: string
} }
@@ -869,7 +864,6 @@ export type Database = {
id?: number id?: number
invite_token?: string invite_token?: string
invited_by?: string invited_by?: string
personal_code?: string | null
role?: string role?: string
updated_at?: string updated_at?: string
} }
@@ -904,21 +898,74 @@ export type Database = {
}, },
] ]
} }
medusa_products_analyses_relations: { medreport_product_groups: {
Row: {
created_at: string
id: number
name: string
updated_at: string | null
}
Insert: {
created_at?: string
id?: number
name: string
updated_at?: string | null
}
Update: {
created_at?: string
id?: number
name?: string
updated_at?: string | null
}
Relationships: []
}
medreport_products: {
Row: {
created_at: string
id: number
name: string
product_group_id: number | null
updated_at: string | null
}
Insert: {
created_at?: string
id?: number
name: string
product_group_id?: number | null
updated_at?: string | null
}
Update: {
created_at?: string
id?: number
name?: string
product_group_id?: number | null
updated_at?: string | null
}
Relationships: [
{
foreignKeyName: "medreport_products_product_groups_id_fkey"
columns: ["product_group_id"]
isOneToOne: false
referencedRelation: "medreport_product_groups"
referencedColumns: ["id"]
},
]
}
medreport_products_analyses_relations: {
Row: { Row: {
analysis_element_id: number | null analysis_element_id: number | null
analysis_id: number | null analysis_id: number | null
medusa_product_id: number product_id: number
} }
Insert: { Insert: {
analysis_element_id?: number | null analysis_element_id?: number | null
analysis_id?: number | null analysis_id?: number | null
medusa_product_id: number product_id: number
} }
Update: { Update: {
analysis_element_id?: number | null analysis_element_id?: number | null
analysis_id?: number | null analysis_id?: number | null
medusa_product_id?: number product_id?: number
} }
Relationships: [ Relationships: [
{ {
@@ -935,20 +982,27 @@ export type Database = {
referencedRelation: "analyses" referencedRelation: "analyses"
referencedColumns: ["id"] referencedColumns: ["id"]
}, },
{
foreignKeyName: "medreport_products_analyses_product_id_fkey"
columns: ["product_id"]
isOneToOne: true
referencedRelation: "medreport_products"
referencedColumns: ["id"]
},
] ]
} }
medusa_products_external_services_relations: { medreport_products_external_services_relations: {
Row: { Row: {
connected_online_service_id: number connected_online_service_id: number
medusa_product_id: number product_id: number
} }
Insert: { Insert: {
connected_online_service_id: number connected_online_service_id: number
medusa_product_id: number product_id: number
} }
Update: { Update: {
connected_online_service_id?: number connected_online_service_id?: number
medusa_product_id?: number product_id?: number
} }
Relationships: [ Relationships: [
{ {
@@ -958,6 +1012,13 @@ export type Database = {
referencedRelation: "connected_online_services" referencedRelation: "connected_online_services"
referencedColumns: ["id"] referencedColumns: ["id"]
}, },
{
foreignKeyName: "medreport_products_connected_online_services_product_id_fkey"
columns: ["product_id"]
isOneToOne: false
referencedRelation: "medreport_products"
referencedColumns: ["id"]
},
] ]
} }
nonces: { nonces: {
@@ -1021,35 +1082,35 @@ export type Database = {
Row: { Row: {
account_id: string account_id: string
body: string body: string
channel: Database["public"]["Enums"]["notification_channel"] channel: Database["medreport"]["Enums"]["notification_channel"]
created_at: string created_at: string
dismissed: boolean dismissed: boolean
expires_at: string | null expires_at: string | null
id: number id: number
link: string | null link: string | null
type: Database["public"]["Enums"]["notification_type"] type: Database["medreport"]["Enums"]["notification_type"]
} }
Insert: { Insert: {
account_id: string account_id: string
body: string body: string
channel?: Database["public"]["Enums"]["notification_channel"] channel?: Database["medreport"]["Enums"]["notification_channel"]
created_at?: string created_at?: string
dismissed?: boolean dismissed?: boolean
expires_at?: string | null expires_at?: string | null
id?: never id?: never
link?: string | null link?: string | null
type?: Database["public"]["Enums"]["notification_type"] type?: Database["medreport"]["Enums"]["notification_type"]
} }
Update: { Update: {
account_id?: string account_id?: string
body?: string body?: string
channel?: Database["public"]["Enums"]["notification_channel"] channel?: Database["medreport"]["Enums"]["notification_channel"]
created_at?: string created_at?: string
dismissed?: boolean dismissed?: boolean
expires_at?: string | null expires_at?: string | null
id?: never id?: never
link?: string | null link?: string | null
type?: Database["public"]["Enums"]["notification_type"] type?: Database["medreport"]["Enums"]["notification_type"]
} }
Relationships: [ Relationships: [
{ {
@@ -1120,33 +1181,33 @@ export type Database = {
Row: { Row: {
account_id: string account_id: string
billing_customer_id: number billing_customer_id: number
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
created_at: string created_at: string
currency: string currency: string
id: string id: string
status: Database["public"]["Enums"]["payment_status"] status: Database["medreport"]["Enums"]["payment_status"]
total_amount: number total_amount: number
updated_at: string updated_at: string
} }
Insert: { Insert: {
account_id: string account_id: string
billing_customer_id: number billing_customer_id: number
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
created_at?: string created_at?: string
currency: string currency: string
id: string id: string
status: Database["public"]["Enums"]["payment_status"] status: Database["medreport"]["Enums"]["payment_status"]
total_amount: number total_amount: number
updated_at?: string updated_at?: string
} }
Update: { Update: {
account_id?: string account_id?: string
billing_customer_id?: number billing_customer_id?: number
billing_provider?: Database["public"]["Enums"]["billing_provider"] billing_provider?: Database["medreport"]["Enums"]["billing_provider"]
created_at?: string created_at?: string
currency?: string currency?: string
id?: string id?: string
status?: Database["public"]["Enums"]["payment_status"] status?: Database["medreport"]["Enums"]["payment_status"]
total_amount?: number total_amount?: number
updated_at?: string updated_at?: string
} }
@@ -1184,17 +1245,17 @@ export type Database = {
role_permissions: { role_permissions: {
Row: { Row: {
id: number id: number
permission: Database["public"]["Enums"]["app_permissions"] permission: Database["medreport"]["Enums"]["app_permissions"]
role: string role: string
} }
Insert: { Insert: {
id?: number id?: number
permission: Database["public"]["Enums"]["app_permissions"] permission: Database["medreport"]["Enums"]["app_permissions"]
role: string role: string
} }
Update: { Update: {
id?: number id?: number
permission?: Database["public"]["Enums"]["app_permissions"] permission?: Database["medreport"]["Enums"]["app_permissions"]
role?: string role?: string
} }
Relationships: [ Relationships: [
@@ -1232,7 +1293,7 @@ export type Database = {
product_id: string product_id: string
quantity: number quantity: number
subscription_id: string subscription_id: string
type: Database["public"]["Enums"]["subscription_item_type"] type: Database["medreport"]["Enums"]["subscription_item_type"]
updated_at: string updated_at: string
variant_id: string variant_id: string
} }
@@ -1245,7 +1306,7 @@ export type Database = {
product_id: string product_id: string
quantity?: number quantity?: number
subscription_id: string subscription_id: string
type: Database["public"]["Enums"]["subscription_item_type"] type: Database["medreport"]["Enums"]["subscription_item_type"]
updated_at?: string updated_at?: string
variant_id: string variant_id: string
} }
@@ -1258,7 +1319,7 @@ export type Database = {
product_id?: string product_id?: string
quantity?: number quantity?: number
subscription_id?: string subscription_id?: string
type?: Database["public"]["Enums"]["subscription_item_type"] type?: Database["medreport"]["Enums"]["subscription_item_type"]
updated_at?: string updated_at?: string
variant_id?: string variant_id?: string
} }
@@ -1277,14 +1338,14 @@ export type Database = {
account_id: string account_id: string
active: boolean active: boolean
billing_customer_id: number billing_customer_id: number
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
cancel_at_period_end: boolean cancel_at_period_end: boolean
created_at: string created_at: string
currency: string currency: string
id: string id: string
period_ends_at: string period_ends_at: string
period_starts_at: string period_starts_at: string
status: Database["public"]["Enums"]["subscription_status"] status: Database["medreport"]["Enums"]["subscription_status"]
trial_ends_at: string | null trial_ends_at: string | null
trial_starts_at: string | null trial_starts_at: string | null
updated_at: string updated_at: string
@@ -1293,14 +1354,14 @@ export type Database = {
account_id: string account_id: string
active: boolean active: boolean
billing_customer_id: number billing_customer_id: number
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
cancel_at_period_end: boolean cancel_at_period_end: boolean
created_at?: string created_at?: string
currency: string currency: string
id: string id: string
period_ends_at: string period_ends_at: string
period_starts_at: string period_starts_at: string
status: Database["public"]["Enums"]["subscription_status"] status: Database["medreport"]["Enums"]["subscription_status"]
trial_ends_at?: string | null trial_ends_at?: string | null
trial_starts_at?: string | null trial_starts_at?: string | null
updated_at?: string updated_at?: string
@@ -1309,14 +1370,14 @@ export type Database = {
account_id?: string account_id?: string
active?: boolean active?: boolean
billing_customer_id?: number billing_customer_id?: number
billing_provider?: Database["public"]["Enums"]["billing_provider"] billing_provider?: Database["medreport"]["Enums"]["billing_provider"]
cancel_at_period_end?: boolean cancel_at_period_end?: boolean
created_at?: string created_at?: string
currency?: string currency?: string
id?: string id?: string
period_ends_at?: string period_ends_at?: string
period_starts_at?: string period_starts_at?: string
status?: Database["public"]["Enums"]["subscription_status"] status?: Database["medreport"]["Enums"]["subscription_status"]
trial_ends_at?: string | null trial_ends_at?: string | null
trial_starts_at?: string | null trial_starts_at?: string | null
updated_at?: string updated_at?: string
@@ -1360,7 +1421,7 @@ export type Database = {
name: string | null name: string | null
picture_url: string | null picture_url: string | null
subscription_status: subscription_status:
| Database["public"]["Enums"]["subscription_status"] | Database["medreport"]["Enums"]["subscription_status"]
| null | null
} }
Relationships: [] Relationships: []
@@ -1394,7 +1455,7 @@ export type Database = {
account_slug: string account_slug: string
invitations: Database["public"]["CompositeTypes"]["invitation"][] invitations: Database["public"]["CompositeTypes"]["invitation"][]
} }
Returns: Database["public"]["Tables"]["invitations"]["Row"][] Returns: Database["medreport"]["Tables"]["invitations"]["Row"][]
} }
can_action_account_member: { can_action_account_member: {
Args: { target_team_account_id: string; target_user_id: string } Args: { target_team_account_id: string; target_user_id: string }
@@ -1410,7 +1471,6 @@ export type Database = {
id: number id: number
invite_token: string invite_token: string
invited_by: string invited_by: string
personal_code: string | null
role: string role: string
updated_at: string updated_at: string
} }
@@ -1433,7 +1493,6 @@ export type Database = {
created_at: string | null created_at: string | null
created_by: string | null created_by: string | null
email: string | null email: string | null
has_consent_anonymized_company_statistics: boolean | null
has_consent_personal_data: boolean | null has_consent_personal_data: boolean | null
id: string id: string
is_personal_account: boolean is_personal_account: boolean
@@ -1460,7 +1519,6 @@ export type Database = {
created_at: string created_at: string
updated_at: string updated_at: string
expires_at: string expires_at: string
personal_code: string
inviter_name: string inviter_name: string
inviter_email: string inviter_email: string
}[] }[]
@@ -1476,7 +1534,6 @@ export type Database = {
primary_owner_user_id: string primary_owner_user_id: string
name: string name: string
email: string email: string
personal_code: string
picture_url: string picture_url: string
created_at: string created_at: string
updated_at: string updated_at: string
@@ -1486,14 +1543,6 @@ export type Database = {
Args: Record<PropertyKey, never> Args: Record<PropertyKey, never>
Returns: Json Returns: Json
} }
get_invitations_with_account_ids: {
Args: { company_id: string; personal_codes: string[] }
Returns: {
invite_token: string
personal_code: string
account_id: string
}[]
}
get_nonce_status: { get_nonce_status: {
Args: { p_id: string } Args: { p_id: string }
Returns: Json Returns: Json
@@ -1522,7 +1571,7 @@ export type Database = {
Args: { Args: {
user_id: string user_id: string
account_id: string account_id: string
permission_name: Database["public"]["Enums"]["app_permissions"] permission_name: Database["medreport"]["Enums"]["app_permissions"]
} }
Returns: boolean Returns: boolean
} }
@@ -1554,10 +1603,6 @@ export type Database = {
Args: { target_account_id: string } Args: { target_account_id: string }
Returns: boolean Returns: boolean
} }
is_company_admin: {
Args: { account_slug: string }
Returns: boolean
}
is_mfa_compliant: { is_mfa_compliant: {
Args: Record<PropertyKey, never> Args: Record<PropertyKey, never>
Returns: boolean Returns: boolean
@@ -1588,8 +1633,8 @@ export type Database = {
role: string role: string
role_hierarchy_level: number role_hierarchy_level: number
primary_owner_user_id: string primary_owner_user_id: string
subscription_status: Database["public"]["Enums"]["subscription_status"] subscription_status: Database["medreport"]["Enums"]["subscription_status"]
permissions: Database["public"]["Enums"]["app_permissions"][] permissions: Database["medreport"]["Enums"]["app_permissions"][]
}[] }[]
} }
transfer_team_account_ownership: { transfer_team_account_ownership: {
@@ -1613,8 +1658,8 @@ export type Database = {
target_account_id: string target_account_id: string
target_customer_id: string target_customer_id: string
target_order_id: string target_order_id: string
status: Database["public"]["Enums"]["payment_status"] status: Database["medreport"]["Enums"]["payment_status"]
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
total_amount: number total_amount: number
currency: string currency: string
line_items: Json line_items: Json
@@ -1622,11 +1667,11 @@ export type Database = {
Returns: { Returns: {
account_id: string account_id: string
billing_customer_id: number billing_customer_id: number
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
created_at: string created_at: string
currency: string currency: string
id: string id: string
status: Database["public"]["Enums"]["payment_status"] status: Database["medreport"]["Enums"]["payment_status"]
total_amount: number total_amount: number
updated_at: string updated_at: string
} }
@@ -1637,8 +1682,8 @@ export type Database = {
target_customer_id: string target_customer_id: string
target_subscription_id: string target_subscription_id: string
active: boolean active: boolean
status: Database["public"]["Enums"]["subscription_status"] status: Database["medreport"]["Enums"]["subscription_status"]
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
cancel_at_period_end: boolean cancel_at_period_end: boolean
currency: string currency: string
period_starts_at: string period_starts_at: string
@@ -1651,14 +1696,14 @@ export type Database = {
account_id: string account_id: string
active: boolean active: boolean
billing_customer_id: number billing_customer_id: number
billing_provider: Database["public"]["Enums"]["billing_provider"] billing_provider: Database["medreport"]["Enums"]["billing_provider"]
cancel_at_period_end: boolean cancel_at_period_end: boolean
created_at: string created_at: string
currency: string currency: string
id: string id: string
period_ends_at: string period_ends_at: string
period_starts_at: string period_starts_at: string
status: Database["public"]["Enums"]["subscription_status"] status: Database["medreport"]["Enums"]["subscription_status"]
trial_ends_at: string | null trial_ends_at: string | null
trial_starts_at: string | null trial_starts_at: string | null
updated_at: string updated_at: string
@@ -1706,6 +1751,51 @@ export type Database = {
| "incomplete_expired" | "incomplete_expired"
| "paused" | "paused"
} }
CompositeTypes: {
[_ in never]: never
}
}
public: {
Tables: {
[_ in never]: never
}
Views: {
[_ in never]: never
}
Functions: {
get_invitations_with_account_ids: {
Args: { company_id: string; personal_codes: string[] }
Returns: {
invite_token: string
personal_code: string
account_id: string
}[]
}
has_permission: {
Args: {
user_id: string
account_id: string
permission_name: Database["public"]["Enums"]["app_permissions"]
}
Returns: boolean
}
has_role_on_account: {
Args: { account_id: string; account_role?: string }
Returns: boolean
}
is_company_admin: {
Args: { account_slug: string }
Returns: boolean
}
}
Enums: {
app_permissions:
| "roles.manage"
| "billing.manage"
| "settings.manage"
| "members.manage"
| "invites.manage"
}
CompositeTypes: { CompositeTypes: {
invitation: { invitation: {
email: string | null email: string | null
@@ -1831,7 +1921,7 @@ export const Constants = {
graphql_public: { graphql_public: {
Enums: {}, Enums: {},
}, },
public: { medreport: {
Enums: { Enums: {
analysis_order_status: [ analysis_order_status: [
"QUEUED", "QUEUED",
@@ -1865,5 +1955,16 @@ export const Constants = {
], ],
}, },
}, },
public: {
Enums: {
app_permissions: [
"roles.manage",
"billing.manage",
"settings.manage",
"members.manage",
"invites.manage",
],
},
},
} as const } as const

View File

@@ -120,5 +120,9 @@
"city": "Linn", "city": "Linn",
"weight": "Kaal", "weight": "Kaal",
"height": "Pikkus" "height": "Pikkus"
},
"wallet": {
"balance": "Sinu MedReporti konto seis",
"expiredAt": "Kehtiv kuni {{expiredAt}}"
} }
} }

View File

@@ -1,342 +0,0 @@
drop trigger if exists "check_not_already_tied_to_connected_online" on "public"."medreport_products_analyses_relations";
drop trigger if exists "check_not_already_tied_to_analysis" on "public"."medreport_products_external_services_relations";
drop policy "read_all" on "public"."medreport_product_groups";
drop policy "Enable read access for all users" on "public"."medreport_products_analyses_relations";
revoke delete on table "public"."medreport_product_groups" from "anon";
revoke insert on table "public"."medreport_product_groups" from "anon";
revoke references on table "public"."medreport_product_groups" from "anon";
revoke select on table "public"."medreport_product_groups" from "anon";
revoke trigger on table "public"."medreport_product_groups" from "anon";
revoke truncate on table "public"."medreport_product_groups" from "anon";
revoke update on table "public"."medreport_product_groups" from "anon";
revoke delete on table "public"."medreport_product_groups" from "authenticated";
revoke insert on table "public"."medreport_product_groups" from "authenticated";
revoke references on table "public"."medreport_product_groups" from "authenticated";
revoke select on table "public"."medreport_product_groups" from "authenticated";
revoke trigger on table "public"."medreport_product_groups" from "authenticated";
revoke truncate on table "public"."medreport_product_groups" from "authenticated";
revoke update on table "public"."medreport_product_groups" from "authenticated";
revoke delete on table "public"."medreport_product_groups" from "service_role";
revoke insert on table "public"."medreport_product_groups" from "service_role";
revoke references on table "public"."medreport_product_groups" from "service_role";
revoke select on table "public"."medreport_product_groups" from "service_role";
revoke trigger on table "public"."medreport_product_groups" from "service_role";
revoke truncate on table "public"."medreport_product_groups" from "service_role";
revoke update on table "public"."medreport_product_groups" from "service_role";
revoke delete on table "public"."medreport_products_analyses_relations" from "anon";
revoke insert on table "public"."medreport_products_analyses_relations" from "anon";
revoke references on table "public"."medreport_products_analyses_relations" from "anon";
revoke select on table "public"."medreport_products_analyses_relations" from "anon";
revoke trigger on table "public"."medreport_products_analyses_relations" from "anon";
revoke truncate on table "public"."medreport_products_analyses_relations" from "anon";
revoke update on table "public"."medreport_products_analyses_relations" from "anon";
revoke delete on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke insert on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke references on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke select on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke trigger on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke truncate on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke update on table "public"."medreport_products_analyses_relations" from "authenticated";
revoke delete on table "public"."medreport_products_analyses_relations" from "service_role";
revoke insert on table "public"."medreport_products_analyses_relations" from "service_role";
revoke references on table "public"."medreport_products_analyses_relations" from "service_role";
revoke select on table "public"."medreport_products_analyses_relations" from "service_role";
revoke trigger on table "public"."medreport_products_analyses_relations" from "service_role";
revoke truncate on table "public"."medreport_products_analyses_relations" from "service_role";
revoke update on table "public"."medreport_products_analyses_relations" from "service_role";
revoke delete on table "public"."medreport_products_external_services_relations" from "anon";
revoke insert on table "public"."medreport_products_external_services_relations" from "anon";
revoke references on table "public"."medreport_products_external_services_relations" from "anon";
revoke select on table "public"."medreport_products_external_services_relations" from "anon";
revoke trigger on table "public"."medreport_products_external_services_relations" from "anon";
revoke truncate on table "public"."medreport_products_external_services_relations" from "anon";
revoke update on table "public"."medreport_products_external_services_relations" from "anon";
revoke delete on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke insert on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke references on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke select on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke trigger on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke truncate on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke update on table "public"."medreport_products_external_services_relations" from "authenticated";
revoke delete on table "public"."medreport_products_external_services_relations" from "service_role";
revoke insert on table "public"."medreport_products_external_services_relations" from "service_role";
revoke references on table "public"."medreport_products_external_services_relations" from "service_role";
revoke select on table "public"."medreport_products_external_services_relations" from "service_role";
revoke trigger on table "public"."medreport_products_external_services_relations" from "service_role";
revoke truncate on table "public"."medreport_products_external_services_relations" from "service_role";
revoke update on table "public"."medreport_products_external_services_relations" from "service_role";
alter table "public"."medreport_product_groups" drop constraint "medreport_product_groups_name_key";
alter table "public"."medreport_products" drop constraint "medreport_products_product_groups_id_fkey";
alter table "public"."medreport_products_analyses_relations" drop constraint "medreport_products_analyses_analysis_element_id_fkey";
alter table "public"."medreport_products_analyses_relations" drop constraint "medreport_products_analyses_analysis_element_id_key";
alter table "public"."medreport_products_analyses_relations" drop constraint "medreport_products_analyses_analysis_id_fkey";
alter table "public"."medreport_products_analyses_relations" drop constraint "medreport_products_analyses_analysis_id_key";
alter table "public"."medreport_products_analyses_relations" drop constraint "medreport_products_analyses_product_id_fkey";
alter table "public"."medreport_products_analyses_relations" drop constraint "product_can_be_tied_to_only_one_analysis_item";
alter table "public"."medreport_products_analyses_relations" drop constraint "product_can_be_tied_to_only_one_external_item";
alter table "public"."medreport_products_external_services_relations" drop constraint "medreport_products_connected_online_services_id_fkey";
alter table "public"."medreport_products_external_services_relations" drop constraint "medreport_products_connected_online_services_id_key";
alter table "public"."medreport_products_external_services_relations" drop constraint "medreport_products_connected_online_services_product_id_fkey";
alter table "public"."medreport_product_groups" drop constraint "medreport_product_groups_pkey";
alter table "public"."medreport_products_analyses_relations" drop constraint "medreport_products_analyses_pkey";
alter table "public"."medreport_products_external_services_relations" drop constraint "medreport_products_connected_online_services_pkey";
drop index if exists "public"."medreport_product_groups_name_key";
drop index if exists "public"."medreport_product_groups_pkey";
drop index if exists "public"."medreport_products_analyses_pkey";
drop index if exists "public"."medreport_products_analyses_analysis_element_id_key";
drop index if exists "public"."medreport_products_analyses_analysis_id_key";
drop index if exists "public"."medreport_products_connected_online_services_id_key";
drop index if exists "public"."medreport_products_connected_online_services_pkey";
drop table "public"."medreport_product_groups";
drop table "public"."medreport_products_analyses_relations";
drop table "public"."medreport_products_external_services_relations";
create table "public"."medusa_products_analyses_relations" (
"medusa_product_id" bigint not null,
"analysis_element_id" bigint,
"analysis_id" bigint
);
alter table "public"."medusa_products_analyses_relations" enable row level security;
create table "public"."medusa_products_external_services_relations" (
"medusa_product_id" bigint not null,
"connected_online_service_id" bigint not null
);
alter table "public"."medusa_products_external_services_relations" enable row level security;
CREATE UNIQUE INDEX medusa_products_analyses_relations_pkey ON public.medusa_products_analyses_relations USING btree (medusa_product_id);
CREATE UNIQUE INDEX medusa_products_external_services_relations_product_id_key ON public.medusa_products_external_services_relations USING btree (medusa_product_id);
CREATE UNIQUE INDEX medreport_products_analyses_analysis_element_id_key ON public.medusa_products_analyses_relations USING btree (analysis_element_id);
CREATE UNIQUE INDEX medreport_products_analyses_analysis_id_key ON public.medusa_products_analyses_relations USING btree (analysis_id);
CREATE UNIQUE INDEX medreport_products_connected_online_services_id_key ON public.medusa_products_external_services_relations USING btree (connected_online_service_id);
CREATE UNIQUE INDEX medreport_products_connected_online_services_pkey ON public.medusa_products_external_services_relations USING btree (connected_online_service_id);
alter table "public"."medusa_products_analyses_relations" add constraint "medusa_products_analyses_relations_pkey" PRIMARY KEY using index "medusa_products_analyses_relations_pkey";
alter table "public"."medusa_products_external_services_relations" add constraint "medreport_products_connected_online_services_pkey" PRIMARY KEY using index "medreport_products_connected_online_services_pkey";
alter table "public"."medusa_products_analyses_relations" add constraint "medreport_products_analyses_analysis_element_id_fkey" FOREIGN KEY (analysis_element_id) REFERENCES analysis_elements(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."medusa_products_analyses_relations" validate constraint "medreport_products_analyses_analysis_element_id_fkey";
alter table "public"."medusa_products_analyses_relations" add constraint "medreport_products_analyses_analysis_element_id_key" UNIQUE using index "medreport_products_analyses_analysis_element_id_key";
alter table "public"."medusa_products_analyses_relations" add constraint "medreport_products_analyses_analysis_id_fkey" FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."medusa_products_analyses_relations" validate constraint "medreport_products_analyses_analysis_id_fkey";
alter table "public"."medusa_products_analyses_relations" add constraint "medreport_products_analyses_analysis_id_key" UNIQUE using index "medreport_products_analyses_analysis_id_key";
alter table "public"."medusa_products_analyses_relations" add constraint "medreport_products_analyses_product_id_fkey" FOREIGN KEY (medusa_product_id) REFERENCES medreport_products(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."medusa_products_analyses_relations" validate constraint "medreport_products_analyses_product_id_fkey";
alter table "public"."medusa_products_analyses_relations" add constraint "product_can_be_tied_to_only_one_analysis_item" CHECK (((analysis_id IS NULL) OR (analysis_element_id IS NULL))) not valid;
alter table "public"."medusa_products_analyses_relations" validate constraint "product_can_be_tied_to_only_one_analysis_item";
alter table "public"."medusa_products_analyses_relations" add constraint "product_can_be_tied_to_only_one_external_item" CHECK (((analysis_id IS NULL) OR (analysis_element_id IS NULL))) not valid;
alter table "public"."medusa_products_analyses_relations" validate constraint "product_can_be_tied_to_only_one_external_item";
alter table "public"."medusa_products_external_services_relations" add constraint "medreport_products_connected_online_services_id_fkey" FOREIGN KEY (connected_online_service_id) REFERENCES connected_online_services(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."medusa_products_external_services_relations" validate constraint "medreport_products_connected_online_services_id_fkey";
alter table "public"."medusa_products_external_services_relations" add constraint "medreport_products_connected_online_services_id_key" UNIQUE using index "medreport_products_connected_online_services_id_key";
alter table "public"."medusa_products_external_services_relations" add constraint "medreport_products_connected_online_services_product_id_fkey" FOREIGN KEY (medusa_product_id) REFERENCES medreport_products(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."medusa_products_external_services_relations" validate constraint "medreport_products_connected_online_services_product_id_fkey";
alter table "public"."medusa_products_external_services_relations" add constraint "medusa_products_external_services_relations_product_id_key" UNIQUE using index "medusa_products_external_services_relations_product_id_key";
grant delete on table "public"."medusa_products_analyses_relations" to "service_role";
grant insert on table "public"."medusa_products_analyses_relations" to "service_role";
grant references on table "public"."medusa_products_analyses_relations" to "service_role";
grant select on table "public"."medusa_products_analyses_relations" to "service_role";
grant trigger on table "public"."medusa_products_analyses_relations" to "service_role";
grant truncate on table "public"."medusa_products_analyses_relations" to "service_role";
grant update on table "public"."medusa_products_analyses_relations" to "service_role";
grant delete on table "public"."medusa_products_external_services_relations" to "service_role";
grant insert on table "public"."medusa_products_external_services_relations" to "service_role";
grant references on table "public"."medusa_products_external_services_relations" to "service_role";
grant select on table "public"."medusa_products_external_services_relations" to "service_role";
grant trigger on table "public"."medusa_products_external_services_relations" to "service_role";
grant truncate on table "public"."medusa_products_external_services_relations" to "service_role";
grant update on table "public"."medusa_products_external_services_relations" to "service_role";
CREATE TRIGGER check_not_already_tied_to_connected_online BEFORE INSERT OR UPDATE ON public.medusa_products_analyses_relations FOR EACH ROW EXECUTE FUNCTION check_tied_to_connected_online();
CREATE TRIGGER check_not_already_tied_to_analysis BEFORE INSERT OR UPDATE ON public.medusa_products_external_services_relations FOR EACH ROW EXECUTE FUNCTION check_tied_to_analysis_item();
revoke delete on table "public"."medreport_products" from "anon";
revoke insert on table "public"."medreport_products" from "anon";
revoke references on table "public"."medreport_products" from "anon";
revoke select on table "public"."medreport_products" from "anon";
revoke trigger on table "public"."medreport_products" from "anon";
revoke truncate on table "public"."medreport_products" from "anon";
revoke update on table "public"."medreport_products" from "anon";
revoke delete on table "public"."medreport_products" from "authenticated";
revoke insert on table "public"."medreport_products" from "authenticated";
revoke references on table "public"."medreport_products" from "authenticated";
revoke select on table "public"."medreport_products" from "authenticated";
revoke trigger on table "public"."medreport_products" from "authenticated";
revoke truncate on table "public"."medreport_products" from "authenticated";
revoke update on table "public"."medreport_products" from "authenticated";
revoke delete on table "public"."medreport_products" from "service_role";
revoke insert on table "public"."medreport_products" from "service_role";
revoke references on table "public"."medreport_products" from "service_role";
revoke select on table "public"."medreport_products" from "service_role";
revoke trigger on table "public"."medreport_products" from "service_role";
revoke truncate on table "public"."medreport_products" from "service_role";
revoke update on table "public"."medreport_products" from "service_role";
alter table "public"."medreport_products" drop constraint "medreport_products_name_key";
alter table "public"."medusa_products_analyses_relations" drop constraint "medreport_products_analyses_product_id_fkey";
alter table "public"."medusa_products_external_services_relations" drop constraint "medreport_products_connected_online_services_product_id_fkey";
alter table "public"."medreport_products" drop constraint "medreport_products_pkey";
drop index if exists "public"."medreport_products_name_key";
drop index if exists "public"."medreport_products_pkey";
drop table "public"."medreport_products";

View File

@@ -1,28 +1,28 @@
alter table "public"."accounts_memberships" add column "has_seen_confirmation" boolean not null default false; alter table "medreport"."accounts_memberships" add column "has_seen_confirmation" boolean not null default false;
set check_function_bodies = off; set check_function_bodies = off;
CREATE OR REPLACE FUNCTION public.has_unseen_membership_confirmation(p_user_id uuid DEFAULT auth.uid()) CREATE OR REPLACE FUNCTION medreport.has_unseen_membership_confirmation(p_user_id uuid DEFAULT auth.uid())
RETURNS boolean RETURNS boolean
LANGUAGE sql LANGUAGE sql
SECURITY DEFINER SECURITY DEFINER
SET search_path TO 'public', 'extensions' SET search_path TO 'medreport', 'extensions'
AS $function$ AS $function$
select exists ( select exists (
select 1 select 1
from public.accounts_memberships am from medreport.accounts_memberships am
where am.user_id = p_user_id where am.user_id = p_user_id
and am.has_seen_confirmation = false and am.has_seen_confirmation = false
); );
$function$ $function$
; ;
grant execute on function public.has_unseen_membership_confirmation(uuid) grant execute on function medreport.has_unseen_membership_confirmation(uuid)
to authenticated, anon; to authenticated, anon;
drop function if exists "public"."has_personal_code"(account_id uuid); drop function if exists "medreport"."has_personal_code"(account_id uuid);
CREATE OR REPLACE FUNCTION public.has_consent_personal_data(account_id uuid) CREATE OR REPLACE FUNCTION medreport.has_consent_personal_data(account_id uuid)
RETURNS boolean RETURNS boolean
LANGUAGE plpgsql LANGUAGE plpgsql
SECURITY DEFINER SECURITY DEFINER
@@ -30,12 +30,12 @@ CREATE OR REPLACE FUNCTION public.has_consent_personal_data(account_id uuid)
AS $function$BEGIN AS $function$BEGIN
RETURN EXISTS ( RETURN EXISTS (
SELECT 1 SELECT 1
FROM public.accounts FROM medreport.accounts
WHERE id = account_id WHERE id = account_id
AND has_consent_personal_data IS TRUE AND has_consent_personal_data IS TRUE
); );
END;$function$ END;$function$
; ;
grant execute on function public.has_consent_personal_data(uuid) grant execute on function medreport.has_consent_personal_data(uuid)
to authenticated, anon; to authenticated, anon;